/* ═══════════════════════════════════════════════
   My Work — list + card layout
   ═══════════════════════════════════════════════ */

/* ── Root container ── */
.tw { min-width: 0; overflow-x: hidden; max-width: 100%; }

/* ── Stat tiles ── */
.tw-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 900px) { .tw-metrics { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .tw-metrics { grid-template-columns: 1fr; } }

.tw-metric {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.tw-metric__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.tw-metric__label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.tw-metric__icon-wrap {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.tw-metric__icon-wrap--amber   { background: #fffbeb; color: #d97706; }
.tw-metric__icon-wrap--blue    { background: #eff6ff; color: #2563eb; }
.tw-metric__icon-wrap--green   { background: #ecfdf5; color: #059669; }
.tw-metric__icon-wrap--slate   { background: rgba(100,116,139,.07); color: #64748b; }
[data-theme="dark"] .tw-metric__icon-wrap--amber { background: rgba(217,119,6,.1); color: #fbbf24; }
[data-theme="dark"] .tw-metric__icon-wrap--blue  { background: rgba(37,99,235,.1); color: #60a5fa; }
[data-theme="dark"] .tw-metric__icon-wrap--green { background: rgba(16,185,129,.1); color: #34d399; }
[data-theme="dark"] .tw-metric__icon-wrap--slate { background: rgba(100,116,139,.1); color: #94a3b8; }
.tw-metric__icon { width: 16px; height: 16px; }
.tw-metric__val {
  font-size: 24px; font-weight: 700; color: var(--text-primary);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.tw-metric__sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.tw-metric--highlight { background: var(--bg-base); border-color: rgba(16,185,129,.3); }
[data-theme="dark"] .tw-metric--highlight { border-color: rgba(16,185,129,.15); }

/* ── Layout: list left, card right ── */
.tw-layout { display: grid; grid-template-columns: 1fr 420px; gap: 20px; min-height: calc(100vh - 80px); align-items: stretch; }
@media (max-width: 1024px) { .tw-layout { grid-template-columns: 1fr; } }

/* ── Header row ── */
.tw-header {
  display: flex; flex-wrap: wrap; justify-content: space-between;
  align-items: center; gap: 12px; margin-bottom: 12px;
}
.tw-header__left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tw-header__title { margin: 0; font-size: 22px; font-weight: 700; color: var(--text-primary); }
.tw-header__count { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* Filter tabs */
.tw-filter-tabs {
  display: flex; min-width: 0; overflow-x: auto; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.tw-filter-tab {
  padding: 5px 12px; border: none; background: none; border-radius: 7px;
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; white-space: nowrap; transition: background .15s, color .15s;
}
.tw-filter-tab:hover { color: var(--text-primary); }
.tw-filter-tab--active { background: var(--bg-hover); color: var(--text-primary); }

/* ── Left: List panel ── */
.tw-list-panel {
  background: transparent; border: none;
  border-radius: 0; overflow: visible;
  display: flex; flex-direction: column;
}
#twList {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
}
.tw-list-panel__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.tw-list-panel__label {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px;
}

/* ── Time + Line row wrapper ── */
.tw-line-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 6px;
}
.tw-line-time {
  width: 52px; flex-shrink: 0; text-align: right;
  display: flex; flex-direction: column; align-items: flex-end; gap: 0;
  font-family: 'IBM Plex Mono', monospace;
}
.tw-line-time__hour {
  font-size: 13px; font-weight: 700; color: var(--text-primary); line-height: 1.2;
}
.tw-line-time__ampm {
  font-size: 8px; font-weight: 600; color: var(--text-muted); letter-spacing: 1px;
}
.tw-line-time__date {
  font-size: 8px; font-weight: 600; color: var(--text-muted); opacity: .7; margin-top: 1px;
}

/* ── Themed line rows ── */
.tw-line {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; transition: all .15s;
  flex: 1; min-width: 0;
}
.tw-line:hover { transform: translateY(-1px); }
.tw-line--selected { box-shadow: inset 3px 0 0 var(--active-text, #3b82f6); }
.tw-line--done { opacity: .5; }

/* Type badge */
.tw-line-badge {
  font-size: 9px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase;
  padding: 3px 8px; border-radius: 4px; flex-shrink: 0; border: 1px solid;
  font-family: 'IBM Plex Mono', monospace;
}

/* Action buttons */
.tw-line-action {
  width: 24px; height: 24px; border-radius: 4px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; transition: all .15s; background: rgba(0,0,0,.03);
  border: none; cursor: pointer;
}
.tw-line-action:hover { background: rgba(0,0,0,.08); }
.tw-line-action--edit { color: #64748b; }
.tw-line-action--edit:hover { color: #3b82f6; }
.tw-line-action--del { color: #cbd5e1; }
.tw-line-action--del:hover { color: #ef4444; background: rgba(239,68,68,.06); }

/* Clock buttons */
.tw-line__btn {
  border: none; padding: 5px 10px; font-size: 9px; font-weight: 700;
  letter-spacing: .5px; text-transform: uppercase; cursor: pointer;
  transition: all .15s; font-family: 'IBM Plex Mono', monospace;
}
.tw-line__btn--start { background: #f59e0b; color: #fff; }
.tw-line__btn--pause { background: #3b82f6; color: #fff; }
.tw-line__btn--done  { background: rgba(22,163,74,.12); color: #4ade80; }
.tw-line__btn--completed { background: #16a34a; color: #fff; }

/* Pull line — Blueprint */
.tw-line--pull {
  background: linear-gradient(rgba(200,215,235,.15) 1px,transparent 1px),
              linear-gradient(90deg,rgba(200,215,235,.15) 1px,transparent 1px), #f8fafd;
  background-size: 20px 20px; border: 2px solid #c5d3e8; border-radius: 4px;
  padding: 10px 16px; font-family: 'IBM Plex Mono', monospace;
}
/* Repair line — Green sidebar */
.tw-line--repair {
  background: #fff; border-radius: 14px; overflow: hidden; padding: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 0 0 1px rgba(0,0,0,.03);
}
.tw-line--repair-bar {
  width: 5px; align-self: stretch; background: linear-gradient(180deg,#16a34a,#22c55e); flex-shrink: 0;
}
/* Listing line — manifest purple */
.tw-line--listing {
  background: repeating-linear-gradient(135deg,transparent,transparent 14px,rgba(139,92,246,.04) 14px,rgba(139,92,246,.04) 15px),
              repeating-linear-gradient(45deg,transparent,transparent 14px,rgba(139,92,246,.02) 14px,rgba(139,92,246,.02) 15px),
              #faf9fd;
  border: 2px solid #c4b5d8; border-radius: 6px;
  border-left: 4px solid #7c3aed; overflow: hidden;
  font-family: 'IBM Plex Mono', monospace; padding: 10px 16px;
  box-shadow: 2px 2px 0 #e0d4f0;
}
/* Message line — Teal */
.tw-line--msg {
  background: #f8fffe; border: 1px solid #a7f3d0; border-radius: 10px;
  border-left: 4px solid #0d9488; padding: 10px 16px;
  font-family: 'Manrope', sans-serif;
}
/* Other line — Notepad */
.tw-line--other {
  background: #fffef9; border: 1px solid #e8e2d0; border-radius: 12px;
  padding: 10px 16px;
}

/* Dark mode overrides */
[data-theme="dark"] .tw-line--pull { background: linear-gradient(rgba(59,130,246,.05) 1px,transparent 1px),linear-gradient(90deg,rgba(59,130,246,.05) 1px,transparent 1px),#1a2030; border-color: #3a4a60; }
[data-theme="dark"] .tw-line--repair { background: #1e1e22; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
[data-theme="dark"] .tw-line--listing {
  background: repeating-linear-gradient(135deg,transparent,transparent 14px,rgba(139,92,246,.08) 14px,rgba(139,92,246,.08) 15px),
              repeating-linear-gradient(45deg,transparent,transparent 14px,rgba(139,92,246,.04) 14px,rgba(139,92,246,.04) 15px),
              #1a1726;
  border-color: #4c3b6e; border-left-color: #7c3aed; box-shadow: 2px 2px 0 #3a2d54;
}
[data-theme="dark"] .tw-line--msg { background: #162220; border-color: #2a4a40; }
[data-theme="dark"] .tw-line--other { background: #1c1b16; border-color: #3a3828; }
[data-theme="dark"] .tw-line-action { background: rgba(255,255,255,.05); }
[data-theme="dark"] .tw-line-action:hover { background: rgba(255,255,255,.1); }

/* Empty list */
.tw-list-empty {
  padding: 40px 20px; text-align: center;
  font-size: 13px; color: var(--text-muted);
}

/* ── Right: Card panel ── */
.tw-card-panel {
  position: sticky; top: 0; overflow-y: auto; max-height: calc(100vh - 80px);
}
.tw-card-panel__empty {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 40px 20px; text-align: center;
  color: var(--text-muted); font-size: 13px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* Card wrap */
.tw-card-wrap { cursor: default; min-width: 0; max-width: 100%; }
.tw-card-wrap:hover { transform: none; }

/* ── Task card (generic) ── */
.tw-task-card {
  background: var(--bg-card); border: 2px solid var(--border); border-radius: 14px;
  overflow: hidden; transition: all .3s; font-family: 'Manrope', sans-serif;
}
.tw-task-card.selected { border-color: var(--active-text); box-shadow: 0 4px 20px rgba(0,0,0,.08); }
.tw-task-card__header { padding: 16px 18px 0; }
.tw-task-card__badge {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 100px; padding: 3px 10px 3px 7px;
  font-size: 10px; font-weight: 700; font-family: 'IBM Plex Mono', monospace;
}
.tw-task-card__top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.tw-task-card__title { margin: 0 0 2px; font-size: 18px; font-weight: 800; color: var(--text-primary); }
.tw-task-card__sub { margin: 0 0 12px; font-size: 11px; color: var(--text-muted); }
.tw-task-card__body { padding: 0 18px 22px; }

/* Clock bar */
.tw-clock-bar { display: flex; gap: 6px; margin-bottom: 14px; }
.tw-clock-bar button {
  border: none; padding: 10px 0; font-size: 11px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase; cursor: pointer;
  transition: all .2s; font-family: 'IBM Plex Mono', monospace;
  border-radius: 8px;
}
.tw-clock-start { flex: 1; background: #f59e0b; color: #fff; }
.tw-clock-start.running { background: #3b82f6; color: #fff; }
.tw-clock-done { padding: 10px 18px; background: rgba(22,163,74,.1); color: #4ade80; }
.tw-clock-done.complete { background: #16a34a; color: #fff; }

/* View button (legacy, kept for backward compat) */
.tw-view-btn {
  width: 100%; padding: 11px 0; background: transparent;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase; cursor: pointer; transition: all .2s;
  font-family: 'IBM Plex Mono', monospace;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--text-secondary); margin-bottom: 12px;
}
.tw-view-btn:hover { background: rgba(0,0,0,.02); }

/* Summary row */
.tw-summary { display: flex; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); margin-bottom: 8px; }
.tw-summary__cell { flex: 1; text-align: center; padding: 10px 0; }
.tw-summary__cell + .tw-summary__cell { border-left: 1px solid var(--border); }
.tw-summary__val { font-size: 14px; font-weight: 800; color: var(--text-primary); }
.tw-summary__label {
  font-size: 8px; letter-spacing: 1.5px; color: var(--text-muted);
  margin-top: 1px; text-transform: uppercase; font-weight: 600;
}

/* Pull parts table */
.tw-parts-header { display: flex; padding: 0 0 4px; border-bottom: 1px solid var(--border); margin-bottom: 2px; }
.tw-parts-header span { font-size: 8px; letter-spacing: 2px; color: var(--text-muted); font-weight: 700; }
.tw-part-row { display: flex; align-items: center; padding: 5px 0; cursor: pointer; transition: opacity .15s; }
.tw-part-row.done { opacity: .5; }
.tw-part-chk {
  width: 14px; height: 14px; border-radius: 2px; margin-right: 8px;
  border: 2px solid #b5c6dc; display: flex; align-items: center;
  justify-content: center; transition: all .15s; flex-shrink: 0;
}
.tw-part-row.done .tw-part-chk { background: #3b82f6; border-color: #3b82f6; }

/* ── Card type variations ── */

/* 1. Pull Session — blueprint grid */
.tw-card--pull {
  background: linear-gradient(rgba(200,215,235,.25) 1px, transparent 1px),
              linear-gradient(90deg, rgba(200,215,235,.25) 1px, transparent 1px),
              #f8fafd;
  background-size: 20px 20px; border: 2px solid #c5d3e8;
  border-radius: 4px; font-family: 'IBM Plex Mono', monospace;
}
.tw-card--pull .tw-clock-start, .tw-card--pull .tw-clock-done { border-radius: 4px; }
.tw-card--pull .tw-view-btn { border-color: #c5d3e8; color: #3b82f6; border-radius: 4px; }

/* 2. Repair — green accent bar */
.tw-card--repair {
  background: var(--bg-card); border-radius: 20px;
  display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--border);
}
.tw-card--repair .tw-clock-start, .tw-card--repair .tw-clock-done { border-radius: 12px; }

/* 3. Listing — manifest purple */
.tw-card--listing {
  background: repeating-linear-gradient(135deg,transparent,transparent 14px,rgba(139,92,246,.04) 14px,rgba(139,92,246,.04) 15px),
              repeating-linear-gradient(45deg,transparent,transparent 14px,rgba(139,92,246,.02) 14px,rgba(139,92,246,.02) 15px),
              #faf9fd;
  border: 2px solid #c4b5d8; border-radius: 6px;
  font-family: 'IBM Plex Mono', monospace; box-shadow: 3px 3px 0 #e0d4f0;
  overflow: hidden; position: relative;
}
.tw-card--listing .tw-clock-start, .tw-card--listing .tw-clock-done { border-radius: 4px; }

/* 4. Other — warm parchment */
.tw-card--other {
  background: #fffef9; border: 1px solid #e8e2d0; border-radius: 12px;
  overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.tw-card--other .tw-clock-start, .tw-card--other .tw-clock-done { border-radius: 8px; }

/* 5. Customer/Sale (Message) — teal header */
.tw-card--message {
  background: #f8fffe; border: 1px solid #a7f3d0; border-radius: 16px;
  font-family: 'Manrope', sans-serif; overflow: hidden;
}
.tw-card--message .tw-clock-start, .tw-card--message .tw-clock-done { border-radius: 10px; }

/* ── View / Edit / Delete button row ── */
.tw-btn-row { margin-bottom: 8px; }
.tw-btn-row button {
  transition: background .15s, color .15s;
}
.tw-btn-row button:hover { background: rgba(0,0,0,.03) !important; }

/* ── Blink animation for live indicator ── */
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Task Popup Overlay ── */
.tw-popup-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.5); display: flex;
  align-items: center; justify-content: center;
  padding: 24px; overflow-y: auto;
  animation: twFadeIn .2s ease;
}
.tw-popup-box {
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  animation: twSlideIn .25s ease;
}
.tw-popup-close {
  position: absolute; top: 12px; right: 12px;
  width: 28px; height: 28px; border-radius: 8px; border: none;
  background: rgba(0,0,0,.06); cursor: pointer; font-size: 16px;
  color: var(--text-muted); display: flex; align-items: center;
  justify-content: center; z-index: 1;
}
.tw-popup-close:hover { background: rgba(0,0,0,.12); }
@keyframes twFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Edit Modal ── */
.tw-edit-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.5); display: flex;
  align-items: center; justify-content: center;
  padding: 24px; overflow-y: auto;
  animation: twFadeIn .2s ease;
}
.tw-edit-box {
  width: 100%; max-width: 520px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  max-height: 90vh; display: flex; flex-direction: column;
  animation: twSlideIn .25s ease; overflow: hidden;
}
.tw-edit-box__inner { padding: 20px 24px 12px; overflow-y: auto; flex: 1; min-height: 0; }
.tw-edit-footer {
  flex-shrink: 0; padding: 12px 24px 20px;
  border-top: 1px solid var(--border); background: var(--bg-card);
}
.tw-edit-field { margin-bottom: 14px; }
.tw-edit-label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px;
}
.tw-edit-input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; font-family: inherit;
  color: var(--text-primary); background: var(--bg-input, var(--bg-base));
  outline: none; transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
}
.tw-edit-input:focus { border-color: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,0.15); }
.tw-edit-textarea { resize: vertical; min-height: 72px; font-family: inherit; font-size: 14px; }
.tw-edit-actions { display: flex; gap: 8px; margin-top: 4px; }
.tw-edit-cancel {
  flex: 1; padding: 11px 0; background: var(--bg-hover); border: none;
  border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--text-primary); font-family: inherit;
}
.tw-edit-save {
  flex: 2; padding: 11px 0; border: none; color: #fff;
  background: #059669; border-radius: 10px; font-size: 13px;
  font-weight: 600; cursor: pointer; transition: background .15s;
  font-family: inherit;
}
.tw-edit-save:hover { background: #10b981; }

/* ── Tech toggle buttons ── */
.tw-tech-toggle {
  padding: 6px 14px; border-radius: 100px; border: 1px solid var(--border);
  background: var(--bg-base); cursor: pointer; transition: all .15s;
  display: inline-flex; align-items: center; gap: 4px; font-family: inherit;
}
.tw-tech-toggle:hover { border-color: #3b82f6; background: rgba(59,130,246,.04); }
.tw-tech-toggle--selected {
  border-color: #3b82f6; background: rgba(59,130,246,.08);
  box-shadow: 0 0 0 1px rgba(59,130,246,.2);
}
.tw-tech-toggle--selected span { color: #3b82f6 !important; font-weight: 600 !important; }

/* ── Checklist items ── */
.tw-modal-checklist {
  max-height: 240px; overflow-y: auto; border: 1px solid var(--border);
  border-radius: 10px; padding: 4px;
}
.tw-modal-check-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-radius: 6px; cursor: pointer; transition: background .1s;
}
.tw-modal-check-item:hover { background: var(--bg-hover); }
.tw-modal-check-item input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: #3b82f6; cursor: pointer; flex-shrink: 0;
}

/* ── Select All button ── */
.tw-select-all-btn {
  padding: 4px 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg-base); font-size: 11px; font-weight: 600; cursor: pointer;
  color: #3b82f6; font-family: 'IBM Plex Mono', monospace; letter-spacing: .5px;
  transition: all .15s;
}
.tw-select-all-btn:hover { background: rgba(59,130,246,.06); border-color: #3b82f6; }

/* ── Empty state ── */
.tw-empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.tw-empty__icon { font-size: 40px; margin-bottom: 12px; opacity: .4; }
.tw-empty__text { font-size: 14px; font-weight: 500; }
.tw-empty__sub { font-size: 12px; margin-top: 4px; }

/* ── Animations ── */
@keyframes twPulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
@keyframes twSlideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.tw-line { animation: twSlideIn .35s cubic-bezier(.16,1,.3,1) backwards; }
.tw-line:nth-child(1) { animation-delay: .04s; }
.tw-line:nth-child(2) { animation-delay: .08s; }
.tw-line:nth-child(3) { animation-delay: .12s; }
.tw-line:nth-child(4) { animation-delay: .16s; }
.tw-line:nth-child(5) { animation-delay: .20s; }
.tw-line:nth-child(6) { animation-delay: .24s; }
.tw-line:nth-child(7) { animation-delay: .28s; }
.tw-line:nth-child(8) { animation-delay: .32s; }

/* ── View Toggle ── */
.tw-view-toggle {
  display: flex; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 2px; gap: 2px;
}
.tw-view-toggle__btn {
  padding: 5px 8px; border: none; background: none; border-radius: 6px;
  cursor: pointer; color: var(--text-muted); display: flex; align-items: center;
  justify-content: center; transition: all .15s;
}
.tw-view-toggle__btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.tw-view-toggle__btn--active { background: var(--bg-hover); color: var(--text-primary); }

/* ── Timeline View ── */
.tw-timeline-wrap { min-height: calc(100vh - 280px); }

.tw-tl-toolbar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
  flex-wrap: wrap;
}
.tw-tl-range-tabs {
  display: flex; min-width: 0; overflow-x: auto; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.tw-tl-range-tab {
  padding: 5px 12px; border: none; background: none; border-radius: 7px;
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; white-space: nowrap; transition: background .15s, color .15s;
}
.tw-tl-range-tab:hover { color: var(--text-primary); }
.tw-tl-range-tab--active { background: var(--bg-hover); color: var(--text-primary); }

.tw-tl-nav {
  display: flex; align-items: center; gap: 6px; margin-left: auto;
}
.tw-tl-nav-btn {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: transparent; cursor: pointer; color: var(--text-muted);
  font-size: 14px; transition: all .15s;
}
.tw-tl-nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tw-tl-date-label {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  min-width: 120px; text-align: center;
}
.tw-tl-custom-range {
  display: flex; align-items: center; gap: 6px;
}
.tw-tl-custom-range input[type="date"] {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; background: var(--bg-card); color: var(--text-primary);
  font-family: inherit;
}

/* Multi-day columns */
.tw-tl-columns {
  display: flex; gap: 0; border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; background: var(--bg-card);
}
.tw-tl-column {
  flex: 1; min-width: 0; border-right: 1px solid var(--border);
}
.tw-tl-column:last-child { border-right: none; }
.tw-tl-column-header {
  padding: 10px 12px; font-size: 12px; font-weight: 700; color: var(--text-primary);
  border-bottom: 1px solid var(--border); background: var(--bg-base);
  text-align: center; letter-spacing: .3px;
}
.tw-tl-column-header--today {
  background: rgba(59,130,246,.06); color: #3b82f6;
}
[data-theme="dark"] .tw-tl-column-header--today {
  background: rgba(59,130,246,.1); color: #60a5fa;
}

/* Hour grid — pixel-positioned */
.tw-tl-grid {
  position: relative; overflow: visible;
}
.tw-tl-grid--dragover {
  background: rgba(59,130,246,.03);
}

/* Hour line markers */
.tw-tl-hour-line {
  pointer-events: none;
}
.tw-tl-label {
  width: 70px; padding: 4px 8px 0 12px;
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace; text-align: right;
  line-height: 1;
}

/* Timeline card — base */
.tw-tl-card {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border-radius: 8px; margin-bottom: 3px; cursor: pointer;
  transition: box-shadow .15s, transform .15s;
  background: var(--bg-base); border-left: 4px solid var(--border);
}
.tw-tl-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }

/* Absolutely positioned card (scheduled, on grid) */
.tw-tl-card--abs {
  position: absolute; left: 78px; right: 8px;
  margin: 0; overflow: hidden; z-index: 2;
  cursor: grab; border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  display: flex; flex-direction: column; justify-content: flex-start;
}
.tw-tl-card--abs:hover {
  z-index: 5; box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.tw-tl-card__inner {
  padding: 6px 10px; flex: 1; min-height: 0; overflow: hidden;
}
.tw-tl-card__title {
  font-size: 12px; font-weight: 700; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block;
}
.tw-tl-card__meta {
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  flex-shrink: 0; font-family: 'IBM Plex Mono', monospace;
}
.tw-tl-card__time {
  font-size: 10px; font-weight: 600; flex-shrink: 0;
  font-family: 'IBM Plex Mono', monospace; display: block;
  margin-top: 2px;
}

/* Resize handle */
.tw-tl-card__resize {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 8px; cursor: ns-resize; z-index: 3;
  background: transparent; transition: background .15s;
  border-radius: 0 0 8px 8px;
}
.tw-tl-card__resize::after {
  content: '';
  position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px; border-radius: 2px;
  background: rgba(0,0,0,.12); transition: background .15s;
}
.tw-tl-card:hover .tw-tl-card__resize::after,
.tw-tl-card--resizing .tw-tl-card__resize::after {
  background: rgba(0,0,0,.3);
}
[data-theme="dark"] .tw-tl-card__resize::after { background: rgba(255,255,255,.1); }
[data-theme="dark"] .tw-tl-card:hover .tw-tl-card__resize::after { background: rgba(255,255,255,.3); }

/* Drag & resize states */
.tw-tl-card--dragging {
  opacity: .7; cursor: grabbing !important;
  box-shadow: 0 8px 24px rgba(0,0,0,.15) !important;
  z-index: 10 !important;
}
.tw-tl-card--resizing {
  z-index: 10 !important;
  box-shadow: 0 8px 24px rgba(0,0,0,.15) !important;
}

/* Unscheduled card (flat, draggable into grid) */
.tw-tl-card--unsched {
  cursor: grab; padding: 8px 12px; margin: 4px 12px;
}
.tw-tl-card--unsched:active { cursor: grabbing; }

/* Unscheduled section */
.tw-tl-unsched {
  border-top: 2px dashed var(--border); padding: 8px 0 8px; margin-top: 4px;
}
.tw-tl-unsched-label {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  padding: 6px 12px; font-family: 'IBM Plex Mono', monospace;
}

/* Single day wrapper */
.tw-tl-single {
  border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; background: var(--bg-card);
}
.tw-tl-single-header {
  padding: 10px 16px; font-size: 13px; font-weight: 700;
  color: var(--text-primary); border-bottom: 1px solid var(--border);
  background: var(--bg-base);
}

/* ── Bottom bar (filter tabs + view toggle) ── */
.tw-mobile-bottom {
  display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 12px;
  position: sticky; bottom: 0; z-index: 50;
  padding: 10px 16px; background: var(--bg-base);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0,0,0,.06);
}
.tw-mobile-bottom .tw-filter-tabs--mobile {
  display: flex; overflow-x: auto; gap: 0;
}
.tw-mobile-toggle {
  display: flex; gap: 0; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px;
}
.tw-mobile-toggle__btn {
  padding: 8px 16px; border: none; background: none; border-radius: 7px;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, color .15s; white-space: nowrap;
}
.tw-mobile-toggle__btn--active { background: var(--bg-hover); color: var(--text-primary); }
/* Hide desktop header filter tabs — they're in the bottom bar now */
.tw-filter-tabs--desktop { display: none; }

/* ── Mobile card swipe view ── */
.tw-mobile-cards__nav {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 14px 0 20px;
}
.tw-mobile-cards__arrow {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg-card); display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary); transition: all .15s;
}
.tw-mobile-cards__arrow:hover { background: var(--bg-hover); color: var(--text-primary); }
.tw-mobile-cards__arrow:disabled { opacity: .3; cursor: default; }
.tw-mobile-cards__counter {
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  font-family: 'IBM Plex Mono', monospace; min-width: 60px; text-align: center;
}
.tw-mobile-cards__track {
  overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  display: flex; gap: 0; scrollbar-width: none;
}
.tw-mobile-cards__track::-webkit-scrollbar { display: none; }
.tw-mobile-cards__slide {
  flex: 0 0 100%; width: 100%; scroll-snap-align: start; scroll-snap-stop: always;
  padding: 0 4px; box-sizing: border-box;
}

/* In card mode, hide the list layout and show swipe view */
.tw[data-tw-mobile-mode="cards"] .tw-layout { display: none; }
.tw[data-tw-mobile-mode="cards"] .tw-mobile-cards { display: block !important; }
/* In list mode, hide the swipe view */
.tw[data-tw-mobile-mode="list"] .tw-mobile-cards { display: none !important; }

/* ── Mobile ── */
@media (max-width: 1024px) {
  .tw-mobile-bottom {
    flex-direction: column; box-shadow: none;
    position: fixed; bottom: 0; left: 0; right: 0;
    padding: 8px 12px;
  }
  .tw { padding-bottom: 90px; }
  .tw-card-panel { display: none !important; }
  .tw-task-card { max-width: 100%; }
  .tw-tl-columns { flex-direction: column; }
  .tw-tl-column { border-right: none; border-bottom: 1px solid var(--border); }
  .tw-tl-column:last-child { border-bottom: none; }
}
@media (max-width: 640px) {
  .tw-metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tw-metric { padding: 10px; }
  .tw-metric__val { font-size: 18px; }
  .tw-metric__label { font-size: 11px; }
  .tw-metric__icon-wrap { display: none; }
  .tw-header { gap: 8px; }
  .tw-header__title { font-size: 18px; }
  .tw-filter-tabs { width: 100%; }
  .tw-filter-tab { padding: 5px 10px; font-size: 12px; }
  .tw-line { gap: 8px; flex-wrap: wrap; }
  .tw-line-badge { display: none; }
  .tw-line-row { min-width: 0; flex-wrap: wrap; }
  .tw-line span, .tw-line div { white-space: normal !important; word-break: break-word; overflow-wrap: break-word; }
  .tw-line-time { width: auto; }
  .tw-tl-label { width: 50px; font-size: 10px; padding: 6px 4px; }
  .tw-tl-card--abs { left: 58px; }
  .tw-summary { flex-wrap: wrap; }
  .tw-summary__cell { flex: 1 1 auto; min-width: 33%; }
  .tw-edit-box { padding: 16px; }
  .tw-task-card__title, .tw-task-card h2 { word-break: break-word; overflow-wrap: break-word; }
  .tw-btn-row { flex-wrap: wrap; }
}
@media (max-width: 400px) {
  .tw-metrics { grid-template-columns: 1fr; }
  .tw-filter-tab { padding: 4px 6px; font-size: 10px; }
}

/* ── Day headers (week view) ── */
.tw-day-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary, #64748b);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 14px 8px 6px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  margin-bottom: 2px;
  font-family: 'IBM Plex Mono', monospace;
}
.tw-day-header:first-child { padding-top: 0; }
[data-theme="dark"] .tw-day-header { border-color: rgba(255,255,255,.08); }

/* ── Completed tasks section ── */
.tw-completed-section { margin-top: auto; padding-top: 24px; }
.tw-completed-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 8px 8px; cursor: pointer; user-select: none;
  border-top: 1px solid var(--border, #e2e8f0);
  font-size: 12px; font-weight: 700; color: var(--text-secondary, #64748b);
  text-transform: uppercase; letter-spacing: 1px;
  font-family: 'IBM Plex Mono', monospace;
}
.tw-completed-header:hover { color: var(--text-primary, #334155); }
[data-theme="dark"] .tw-completed-header { border-color: rgba(255,255,255,.08); }
[data-theme="dark"] .tw-completed-header:hover { color: #e2e8f0; }
.tw-completed-chevron {
  transition: transform .15s ease;
  transform: rotate(90deg);
  flex-shrink: 0;
}
.tw-completed-section--collapsed .tw-completed-chevron { transform: rotate(0deg); }
.tw-completed-count {
  font-size: 11px; font-weight: 600;
  background: var(--bg-secondary, #f1f5f9); color: var(--text-secondary, #64748b);
  padding: 1px 7px; border-radius: 10px;
}
[data-theme="dark"] .tw-completed-count { background: rgba(255,255,255,.08); }
.tw-completed-list { opacity: .65; }
.tw-completed-section--collapsed .tw-completed-list { display: none; }

/* ═══ Blocked task state ═══ */
.wb-card--blocked { opacity: 0.55; position: relative; }
.wb-card--blocked::after {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0,0,0,.03) 10px, rgba(0,0,0,.03) 20px);
  border-radius: inherit; pointer-events: none;
}
.wb-blocked-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; color: #b45309;
  background: #fef3c7; padding: 2px 8px; border-radius: 10px; margin-top: 4px;
  white-space: nowrap;
}
[data-theme="dark"] .wb-blocked-badge { color: #fbbf24; background: rgba(251,191,36,.15); }

/* ── Alert banners (over time / past due) ── */
.tw-alert-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; font-size: 13px; font-weight: 700;
  font-family: 'IBM Plex Mono', monospace; letter-spacing: 0.5px;
}
.tw-alert-banner--overtime {
  background: #fef2f2; border-bottom: 2px solid #fecaca; color: #dc2626;
}
.tw-alert-banner--pastdue {
  background: #fff7ed; border-bottom: 2px solid #fed7aa; color: #ea580c;
}
[data-theme="dark"] .tw-alert-banner--overtime {
  background: rgba(220,38,38,.12); border-bottom-color: rgba(220,38,38,.3); color: #fca5a5;
}
[data-theme="dark"] .tw-alert-banner--pastdue {
  background: rgba(234,88,12,.12); border-bottom-color: rgba(234,88,12,.3); color: #fdba74;
}

/* ═══ Blocker picker (dispatch modal) ═══ */
.wbv2-blocker-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500; color: var(--text-primary);
  background: var(--bg-secondary, #f1f5f9); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 8px; cursor: pointer;
}
.wbv2-blocker-pill:hover { background: var(--bg-hover, #e2e8f0); }
.wbv2-blocker-dropdown {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 50;
  max-height: 200px; overflow-y: auto;
  background: var(--bg-card, #fff); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); margin-top: 4px;
}
.wbv2-blocker-option {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; cursor: pointer; font-size: 13px;
  color: var(--text-primary);
}
.wbv2-blocker-option:hover { background: var(--bg-hover, #f1f5f9); }

/* ─── Check-In Card ─── */
.tw-card--checkin { border: 2px solid #d4d4d4; border-top: 4px solid #dc2626; border-radius: 3px; background: #fafafa; }
.ci-hdr { background: #292524; padding: 18px 20px 14px; border-radius: 1px 1px 0 0; }
.ci-steps { display: flex; align-items: center; gap: 0; justify-content: center; }
.ci-step-dot { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; transition: all .2s; }
.ci-step-dot--active { background: #dc2626; color: #fff; box-shadow: 0 0 0 3px rgba(220,38,38,.3); }
.ci-step-dot--done { background: #292524; color: #fff; border: 2px solid #78716c; }
.ci-step-dot--pending { background: #57534e; color: #a8a29e; border: 2px solid #57534e; }
.ci-step-line { width: 28px; height: 2px; background: #57534e; }
.ci-step-line--done { background: #78716c; }
.ci-info-grid { background: #fff; border: 2px solid #e7e5e4; border-radius: 3px; overflow: hidden; }
.ci-info-row { display: flex; border-bottom: 1px solid #e7e5e4; }
.ci-info-row:last-child { border-bottom: none; }
.ci-info-cell { flex: 1; padding: 10px 12px; border-right: 1px solid #e7e5e4; }
.ci-info-cell:last-child { border-right: none; }
.ci-main-preview { width: 100%; aspect-ratio: 16/10; border-radius: 6px; overflow: hidden; background: #292524; display: flex; align-items: center; justify-content: center; }
.ci-thumb-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.ci-thumb { width: 56px; height: 56px; border-radius: 5px; overflow: hidden; cursor: pointer; border: 2px solid transparent; flex-shrink: 0; }
.ci-thumb.is-main { border-color: #dc2626; }

/* Check-in dispatch card */
.wbv2-card--checkin { border: 2px solid #d4d4d4; border-top: 4px solid #dc2626; border-radius: 3px; background: #fafafa; }

/* Check-in line */
.tw-line--checkin { border-left: none; padding: 0; }
.tw-line--checkin-bar { width: 5px; background: linear-gradient(180deg, #dc2626 0%, #991b1b 100%); border-radius: 3px 0 0 3px; flex-shrink: 0; align-self: stretch; }
.wbv2-line--checkin { border-left: 3px solid #dc2626; }

/* Dark mode */
[data-theme="dark"] .tw-card--checkin { background: #1c1917; border-color: #44403c; border-top-color: #dc2626; }
[data-theme="dark"] .ci-hdr { background: #0c0a09; }
[data-theme="dark"] .ci-info-grid { background: #1c1917; border-color: #44403c; }
[data-theme="dark"] .ci-info-row { border-color: #44403c; }
[data-theme="dark"] .ci-info-cell { border-color: #44403c; }
[data-theme="dark"] .ci-main-preview { background: #0c0a09; }
[data-theme="dark"] .wbv2-card--checkin { background: #1c1917; border-color: #44403c; border-top-color: #dc2626; }
[data-theme="dark"] .tw-line--checkin { background: #1c1917; }
[data-theme="dark"] .tw-line--checkin span[style*="color:#292524"] { color: #e7e5e4 !important; }

/* ═══ Listing Mode Tabs ═══ */
.tw-listing-tabs { display: flex; gap: 0; margin: 12px 0 4px; border: 1px solid #d6d3d1; border-radius: 8px; overflow: hidden; }
.tw-listing-tab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 8px 0; font-size: 11px; font-weight: 600; font-family: 'Manrope', sans-serif; border: none; cursor: pointer; background: #fff; color: #78716c; transition: all .15s; }
.tw-listing-tab:first-child { border-right: 1px solid #d6d3d1; }
.tw-listing-tab--active.tw-listing-tab--parts { background: #f0fdf4; color: #16a34a; font-weight: 800; }
.tw-listing-tab--active.tw-listing-tab--plat { background: #f5f3ff; color: #7c3aed; font-weight: 800; }

/* ═══ Parts List Mode ═══ */
.tw-card--parts-list { background: #f0fdf4 !important; }

.tw-pl-header { display: flex; align-items: center; gap: 8px; padding: 4px 0 6px; border-bottom: 1px solid #bbf7d0; margin-bottom: 4px; }
.tw-pl-header__name { flex: 1; font-size: 9px; font-weight: 700; letter-spacing: 1px; color: #16a34a; font-family: 'IBM Plex Mono', monospace; text-transform: uppercase; }
.tw-pl-header__price { width: 72px; font-size: 9px; font-weight: 700; letter-spacing: 1px; color: #16a34a; font-family: 'IBM Plex Mono', monospace; text-align: right; text-transform: uppercase; }

.tw-pl-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #ecfdf5; }
.tw-pl-row:last-of-type { border-bottom: none; }
.tw-pl-row__name { flex: 1; font-size: 13px; font-weight: 600; color: #14532d; font-family: 'Manrope', sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tw-pl-price-input { width: 72px; padding: 5px 8px; font-size: 12px; font-weight: 600; font-family: 'IBM Plex Mono', monospace; text-align: right; border: 1px solid #bbf7d0; border-radius: 6px; background: #fff; color: #15803d; outline: none; transition: border-color .15s; -moz-appearance: textfield; }
.tw-pl-price-input::-webkit-inner-spin-button,
.tw-pl-price-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.tw-pl-price-input:focus { border-color: #16a34a; box-shadow: 0 0 0 2px #bbf7d044; }

.tw-pl-add-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed #bbf7d0; }
.tw-pl-add-name { flex: 1; padding: 7px 10px; font-size: 12px; border: 1px solid #bbf7d0; border-radius: 6px; background: #fff; color: #14532d; outline: none; font-family: 'IBM Plex Mono', monospace; }
.tw-pl-add-name:focus { border-color: #16a34a; }
.tw-pl-add-price { width: 64px; padding: 7px 6px; font-size: 11px; font-family: 'IBM Plex Mono', monospace; text-align: right; border: 1px solid #bbf7d0; border-radius: 6px; background: #fff; color: #15803d; outline: none; -moz-appearance: textfield; }
.tw-pl-add-price::-webkit-inner-spin-button,
.tw-pl-add-price::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.tw-pl-add-price:focus { border-color: #16a34a; }
.tw-pl-add-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; border: none; border-radius: 6px; background: #16a34a; color: #fff; cursor: pointer; flex-shrink: 0; }
.tw-pl-add-btn:hover { background: #15803d; }

/* ═══ Dark mode: Listing tabs & parts list ═══ */
[data-theme="dark"] .tw-listing-tabs { border-color: #44403c; }
[data-theme="dark"] .tw-listing-tab { background: #1c1917; color: #a8a29e; border-color: #44403c; }
[data-theme="dark"] .tw-listing-tab--active.tw-listing-tab--parts { background: #052e16; color: #4ade80; }
[data-theme="dark"] .tw-listing-tab--active.tw-listing-tab--plat { background: #2e1065; color: #a78bfa; }
[data-theme="dark"] .tw-card--parts-list { background: #0a1f0f !important; border-color: #166534 !important; }
[data-theme="dark"] .tw-pl-header { border-color: #166534; }
[data-theme="dark"] .tw-pl-header__name,
[data-theme="dark"] .tw-pl-header__price { color: #4ade80; }
[data-theme="dark"] .tw-pl-row { border-color: #14532d; }
[data-theme="dark"] .tw-pl-row__name { color: #bbf7d0; }
[data-theme="dark"] .tw-pl-price-input { background: #1c1917; border-color: #166534; color: #4ade80; }
[data-theme="dark"] .tw-pl-price-input:focus { border-color: #4ade80; }
[data-theme="dark"] .tw-pl-add-row { border-color: #166534; }
[data-theme="dark"] .tw-pl-add-name { background: #1c1917; border-color: #166534; color: #bbf7d0; }
[data-theme="dark"] .tw-pl-add-price { background: #1c1917; border-color: #166534; color: #4ade80; }
