/* Tallymail Counsel — Dashboard styles
 *
 * Palette aligned with the task-pane and the legal docs:
 *   Brand primary = #5C3CFB (deep indigo-purple). Same hex used in legal/index.html
 *   and taskpane.css to keep the product visually one product across all surfaces.
 *
 * The dashboard uses a dark theme because (a) lawyers stare at email all day in
 * white Outlook, so a dark dashboard provides eye-relief, and (b) numbers and
 * money values read more clearly against dark surfaces.
 */
:root {
  --bg:        #0b0e15;   /* near-black background, very subtle blue tint */
  --panel:     #141926;   /* card background */
  --panel-2:   #1c2333;   /* hover/active variant */
  --line:      #2a3346;   /* subtle borders */
  --text:      #ecf0f7;   /* primary text — high contrast */
  --muted:     #8993a8;   /* secondary text */
  --accent:    #7c5fff;   /* brand purple, brightened for dark bg contrast */
  --accent-2:  #b18cff;   /* lighter accent for trims and highlights */
  --brand-deep:#5C3CFB;   /* canonical brand purple (matches task-pane + legal) */
  --success:   #34d399;
  --warn:      #fbbf24;
  --danger:    #f87171;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px; line-height: 1.4; }

.topbar { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand-block { position: relative; }
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 4px 10px 4px 4px; border-radius: 8px; transition: background .15s ease; user-select: none; }
.brand:hover { background: var(--panel-2); }
.brand .logo { width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(124,95,255,0.35); }
.brand .logo svg { width: 28px; height: 28px; display: block; }
.brand .name { font-size: 17px; font-weight: 600; }
.brand .name em { font-style: normal; color: var(--accent-2); margin-left: 4px; }
.brand-caret { color: var(--accent-2); font-size: 16px; font-weight: 700; margin-left: 6px;
  line-height: 1; transition: transform .15s ease; }
.brand:hover .brand-caret { transform: translateY(1px); }

/* Module switcher dropdown menu */
.module-menu { position: absolute; top: calc(100% + 6px); left: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 6px; min-width: 320px; z-index: 100;
  box-shadow: 0 12px 32px rgba(0,0,0,.55); }
.module-menu[hidden] { display: none; }
.module-menu .mod { display: block; padding: 10px 12px; border-radius: 6px;
  color: var(--text); text-decoration: none; cursor: pointer; }
.module-menu .mod:hover { background: var(--panel-2); }
.module-menu .mod.active { background: rgba(124,95,255,.12); border: 1px solid rgba(124,95,255,.35); }
.module-menu .mod.disabled { color: var(--muted); cursor: not-allowed; }
.module-menu .mod.disabled:hover { background: transparent; }
.module-menu .mod-title { display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 14px; }
.module-menu .mod-pill { font-size: 10px; padding: 2px 8px; border-radius: 99px;
  background: var(--panel-2); color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px; }
.module-menu .mod-pill.live { background: rgba(52,211,153,.18); color: var(--success); }
.module-menu .mod-pill.soon { background: rgba(124,95,255,.15); color: var(--accent-2); }
.module-menu .mod-desc { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--muted); text-decoration: none; padding: 8px 14px; border-radius: 6px; font-weight: 500; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--panel-2); color: var(--text); }
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.user-chip strong { color: var(--text); }

.main { max-width: 1400px; margin: 0 auto; padding: 28px; }
.tab { animation: fadeIn 0.18s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 16px; flex-wrap: wrap; }
.row h1 { font-size: 22px; font-weight: 600; margin: 0; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.input { background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 8px 12px; border-radius: 6px; font-size: 14px; min-width: 180px; }
.input.wide { min-width: 320px; }
textarea.input { min-height: 72px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); }

.btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 6px; font-size: 14px; cursor: pointer; font-weight: 500; }
.btn:hover { background: var(--line); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.primary:hover { filter: brightness(1.1); }
.btn-small { padding: 5px 10px; font-size: 12px; text-decoration: none; color: var(--muted);
  border: 1px solid transparent; border-radius: 6px; transition: all .15s ease; }
.btn-small:hover { color: var(--text); border-color: var(--line); background: var(--panel-2); }
.operator-link { color: var(--accent-2) !important; border-color: rgba(177,140,255,0.35) !important;
  background: rgba(124,95,255,0.10); font-weight: 600; }
.operator-link:hover { background: rgba(124,95,255,0.20) !important; color: #fff !important; }

/* Compact pill buttons used inside cards (Team members card etc.) — purple
 * by default, with a .btn-danger variant for destructive actions. Replaces
 * the bare coral-pink text links. */
.btn-mini { display: inline-block; padding: 4px 11px; font-size: 12px; font-weight: 600;
  border-radius: 99px; border: 1px solid rgba(124,95,255,0.40);
  background: rgba(124,95,255,0.14); color: var(--accent-2);
  cursor: pointer; text-decoration: none; transition: all .15s ease; }
.btn-mini:hover { background: rgba(124,95,255,0.28); color: #fff; transform: translateY(-1px); }
.btn-mini + .btn-mini { margin-left: 6px; }
.btn-mini.btn-danger { background: rgba(248,113,113,0.10); border-color: rgba(248,113,113,0.40); color: var(--danger); }
.btn-mini.btn-danger:hover { background: rgba(248,113,113,0.25); color: #fff; }

/* Floating Feedback FAB — bottom-right, always visible, opens the suggestion modal */
.feedback-fab { position: fixed; right: 24px; bottom: 24px; z-index: 50;
  padding: 12px 18px; border: 0; border-radius: 99px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 600; font-size: 13px; cursor: pointer;
  box-shadow: 0 6px 24px rgba(124,95,255,0.45); transition: all .15s ease; }
.feedback-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 32px rgba(124,95,255,0.55); }
.feedback-fab:active { transform: translateY(0); }

/* Court-ready chronology banner shown at the top of the Timeline tab.
 * Calls out the highest-value use case for the Timeline (trial bundles,
 * witness statements, costs). Dismissible via the × button; preference
 * is kept in localStorage so it doesn't keep nagging. */
.timeline-court-banner { display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 18px; margin: 0 0 18px;
  background: linear-gradient(135deg, rgba(124,95,255,0.12), rgba(177,140,255,0.06));
  border: 1px solid rgba(124,95,255,0.40); border-radius: 10px; position: relative; }
.timeline-court-banner .tcb-icon { font-size: 26px; line-height: 1; flex-shrink: 0;
  color: var(--accent-2); padding-top: 2px; }
.timeline-court-banner .tcb-body { flex: 1; }
.timeline-court-banner .tcb-title { font-weight: 700; font-size: 15px; margin-bottom: 4px;
  color: var(--text); }
.timeline-court-banner .tcb-text { color: var(--muted); font-size: 13px; line-height: 1.5; }
.timeline-court-banner .tcb-text strong { color: var(--text); font-weight: 600; }
.timeline-court-banner .tcb-close { position: absolute; top: 8px; right: 12px;
  background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer;
  padding: 0; line-height: 1; }
.timeline-court-banner .tcb-close:hover { color: var(--text); }
.timeline-court-banner[hidden] { display: none; }
.btn-danger { color: var(--danger); }

.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.card-stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.card-stat.highlight { background: linear-gradient(135deg, rgba(124,95,255,0.10), rgba(177,140,255,0.06)); border-color: rgba(124,95,255,0.35); }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Matter colour dot */
.matter-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; flex-shrink: 0; }

/* Sortable column headers */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sortable .sort-icon { opacity: 0.4; margin-left: 4px; font-size: 10px; }
th.sortable.sorted-asc .sort-icon, th.sortable.sorted-desc .sort-icon { opacity: 1; color: var(--accent-2); }

/* Onboarding wizard */
.modal-card.wizard { max-width: 520px; }
.wizard-progress { display: flex; gap: 8px; justify-content: center; margin: -10px 0 22px; }
.wizard-progress .dot { width: 28px; height: 6px; border-radius: 3px; background: var(--line); transition: background 0.2s; }
.wizard-progress .dot.active { background: var(--accent); }
.wizard-step h3 { margin: 0 0 8px; }
.wizard-step > p.muted { margin-bottom: 18px; }

/* Shortcut help */
.shortcut-table { width: 100%; font-size: 13px; color: var(--muted); margin: 8px 0 16px; }
.shortcut-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.shortcut-table td:first-child { width: 110px; }
kbd { background: var(--panel-2); border: 1px solid var(--line); padding: 2px 6px; border-radius: 4px; font-size: 11px; font-family: monospace; color: var(--text); }

/* Recent captures sidebar */
.recent-toggle { position: fixed; right: 22px; bottom: 22px; width: 44px; height: 44px; border-radius: 50%; background: var(--accent); border: 0; color: white; font-size: 16px; cursor: pointer; z-index: 30; box-shadow: 0 6px 20px rgba(0,0,0,0.4); }
.recent-toggle:hover { filter: brightness(1.1); }
.recent-pane { position: fixed; right: 0; top: 60px; bottom: 0; width: 340px; background: var(--panel); border-left: 1px solid var(--line); z-index: 25; display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(0,0,0,0.3); }
.recent-pane[hidden] { display: none !important; }

/* Green tick for already-captured scan rows (no disabled checkbox) */
.tick-ok { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: rgba(46,204,113,0.18); color: var(--success); font-weight: 800; font-size: 12px; }
tr.is-captured td { opacity: 0.65; }
tr.is-captured:hover td { opacity: 0.85; }
tr.is-new td { font-weight: 500; }

/* Scan headline — one clear summary instead of 5 stat cards */
.scan-headline {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 24px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.scan-headline .hl-main { flex: 1; }
.scan-headline .hl-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); font-weight: 600; }
.scan-headline h2 { margin: 4px 0 12px; font-size: 24px; font-weight: 700; color: var(--text); }
.scan-headline .hl-detail { display: flex; gap: 14px; flex-wrap: wrap; }
.scan-headline .hl-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px; border-radius: 99px; font-size: 13px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.scan-headline .hl-pill strong { font-size: 15px; font-weight: 700; color: var(--text); }
.scan-headline .hl-pill.hl-new { background: rgba(124,95,255,0.14); border-color: rgba(124,95,255,0.35); color: var(--accent); }
.scan-headline .hl-pill.hl-new strong { color: var(--accent); }
.scan-headline .hl-pill.hl-saved { background: rgba(46,204,113,0.10); border-color: rgba(46,204,113,0.30); color: var(--success); }
.scan-headline .hl-pill.hl-saved strong { color: var(--success); }
.scan-headline .hl-pill a.link { margin-left: 6px; font-size: 11px; color: var(--accent-2); text-decoration: underline; }
.scan-headline .hl-actions { flex-shrink: 0; }
.scan-headline .hl-actions .btn.primary { font-size: 14px; padding: 12px 20px; font-weight: 600; }

/* Big success banner shown when every email in the scan is already captured */
.scan-success-banner {
  background: linear-gradient(135deg, rgba(46,204,113,0.14), rgba(124,95,255,0.10));
  border: 1px solid rgba(46,204,113,0.35);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.scan-success-banner .icon-circle {
  width: 44px; height: 44px; border-radius: 50%; background: var(--success);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 22px; flex-shrink: 0;
}
.scan-success-banner h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; color: var(--text); }
.scan-success-banner p { margin: 0; font-size: 13px; color: var(--muted); }
.scan-success-banner .actions { margin-left: auto; }

/* Save toolbar — sits at top of scan results, always visible during a scan */
.save-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.save-toolbar[hidden] { display: none !important; }

/* Sign-in gate: full-screen overlay when user is not authenticated */
.signin-gate {
  position: fixed;
  inset: 60px 0 0 0;     /* below the top nav */
  background: var(--bg);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  z-index: 40;
}
.signin-gate[hidden] { display: none !important; }
.signin-card {
  max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 40px 36px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.signin-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 24px; }
.signin-logo {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; color: white;
}
.signin-name { font-size: 18px; font-weight: 600; color: var(--text); }
.signin-name em { font-style: normal; color: var(--accent-2); margin-left: 4px; }
.signin-card h1 { font-size: 22px; font-weight: 600; margin: 0 0 12px; }
.signin-card p  { margin: 0 0 24px; color: var(--muted); line-height: 1.55; }
.signin-card .btn.primary { font-size: 15px; padding: 12px 28px; font-weight: 600; }

/* Direction chip — bigger and clearer than tiny arrows */
.dir-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; margin-right: 8px;
  border-radius: 99px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  vertical-align: middle;
}
.dir-chip-sent     { background: rgba(124,95,255,0.18); color: var(--accent); }
.dir-chip-received { background: rgba(177,140,255,0.18); color: var(--accent-2); }
.dir-arrow { font-size: 14px; font-weight: 800; line-height: 1; }
.dir-label { font-size: 10px; }

/* Selection badge shown in the top nav whenever scan rows are ticked.
 * It IS a link (clicks to Matters tab) — style it as an interactive pill so
 * users know to use it, not just read it. */
.selection-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  margin-left: 12px;
  border-radius: 99px;
  background: var(--accent);
  color: #fff !important;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: filter .15s ease, transform .15s ease;
  box-shadow: 0 2px 8px rgba(124,95,255,.25);
}
.selection-badge:hover { filter: brightness(1.08); transform: translateY(-1px); }
.selection-badge:active { transform: translateY(0); }
.selection-badge[hidden] { display: none !important; }
.selection-badge strong { font-size: 14px; font-weight: 700; }

/* Per-matter "Add selected" button — only when there's a scan selection */
.add-selected-link {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.add-selected-link:hover { text-decoration: underline; }

/* Assign banner on Matters page (one place to allocate selection) */
.assign-banner {
  background: linear-gradient(135deg, rgba(124,95,255,0.18), rgba(177,140,255,0.10));
  border: 1px solid rgba(124,95,255,0.45);
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.assign-banner[hidden] { display: none !important; }
.assign-banner .ab-text { font-size: 14px; color: var(--text); }
.assign-banner .ab-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.save-toolbar-summary { font-size: 13px; color: var(--muted); }
.save-toolbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Sticky save bar at bottom (appears only when items are selected) */
.sticky-save-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--panel); border-top: 1px solid var(--line);
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  z-index: 20;
  box-shadow: 0 -6px 20px rgba(0,0,0,0.35);
  transform: translateY(0);
  transition: transform 0.2s;
}
.sticky-save-bar[hidden] { display: none !important; }
.sticky-save-bar .summary { font-size: 14px; color: var(--text); }
.sticky-save-bar .summary strong { font-size: 18px; margin-right: 4px; }
.sticky-save-bar .actions { display: flex; gap: 10px; align-items: center; }
.sticky-save-bar select { min-width: 220px; }
.recent-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.recent-list { overflow-y: auto; flex: 1; padding: 8px 0; }
.recent-item { padding: 10px 18px; border-bottom: 1px solid var(--line); }
.recent-item:hover { background: var(--panel-2); }
.recent-item .subj { font-weight: 600; color: var(--text); font-size: 13px; margin-bottom: 2px; }
.recent-item .meta { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }
.recent-item .meta .cost { color: var(--success); font-weight: 600; }

/* Highlighted row (for j/k navigation) */
tr.kbd-active td { background: rgba(177,140,255,0.12) !important; }

.data-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.data-table th, .data-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.data-table th { background: var(--panel-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 600; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .empty { text-align: center; color: var(--muted); padding: 28px; }
.data-table .link { color: var(--accent-2); cursor: pointer; }
.data-table .link:hover { text-decoration: underline; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.badge.open { background: rgba(46,204,113,0.15); color: var(--success); }
.badge.closed { background: rgba(241,196,15,0.15); color: var(--warn); }
.badge.archived { background: rgba(139,151,167,0.2); color: var(--muted); }

.totals-bar { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px;
  display: flex; gap: 28px; margin-bottom: 16px; flex-wrap: wrap; }
.totals-bar .item { font-size: 13px; color: var(--muted); }
.totals-bar .item strong { color: var(--text); font-size: 17px; margin-left: 6px; font-weight: 700; }

.timeline { display: flex; flex-direction: column; gap: 10px; }
.t-entry { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.t-entry-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.t-entry-head .who { font-weight: 600; }
.t-entry-head .when { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.t-entry-subject { margin: 4px 0 6px; font-size: 14px; color: var(--text); }
.t-entry-snippet { color: var(--muted); font-size: 13px; line-height: 1.5; }
.t-entry-meta { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--muted); align-items: center; flex-wrap: wrap; }
.t-entry-meta strong { color: var(--text); }
.t-entry-meta .cost { color: var(--success); font-weight: 700; font-size: 15px; }
.t-entry-actions { margin-left: auto; display: flex; gap: 6px; }
.dir-pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
.dir-pill.sent { background: rgba(124,95,255,0.15); color: var(--accent); }
.dir-pill.received { background: rgba(177,140,255,0.15); color: var(--accent-2); }

.form-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px; max-width: 540px; margin-bottom: 16px; }
.form-card h3 { margin: 0 0 14px; font-size: 16px; font-weight: 600; }
.form-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.form-card label .input { display: block; width: 100%; margin-top: 4px; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: none; }
.saved { color: var(--success); font-size: 12px; margin-top: 8px; }
.muted { color: var(--muted); font-size: 12px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal[hidden] { display: none !important; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: 92%; max-width: 480px; }
.modal-card h3 { margin: 0 0 14px; font-size: 18px; font-weight: 600; }
.modal-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.modal-card label .input { display: block; width: 100%; margin-top: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.toast { position: fixed; bottom: 28px; right: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 18px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 100; animation: slideIn 0.2s ease-out; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.group-row td { background: var(--panel-2); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 14px; }
.group-row td strong { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 14px; }

/* Toggle group (e.g. List / Timeline view switcher) */
.toggle-group { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 2px; }
.toggle-btn { background: transparent; border: 0; padding: 6px 12px; color: var(--muted); font-weight: 500; cursor: pointer; border-radius: 4px; }
.toggle-btn.active { background: var(--panel-2); color: var(--text); }
.toggle-btn:hover { color: var(--text); }
.checkbox-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--muted); font-size: 13px; cursor: pointer; }
.checkbox-pill input { margin: 0; }

/* Spine timeline visualization */
.spine { position: relative; padding: 12px 0 12px 0; }
.spine::before {
  content: "";
  position: absolute;
  left: 110px;
  top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--line) 0%, var(--accent) 50%, var(--line) 100%);
  border-radius: 1px;
}
.spine-day {
  position: relative;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  font-weight: 700;
  margin: 20px 0 10px;
  padding-left: 140px;
}
.spine-day::before {
  content: "";
  position: absolute;
  left: 100px;
  top: 4px;
  width: 22px;
  height: 22px;
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 50%;
}
.spine-node {
  position: relative;
  padding: 10px 0 14px 140px;
  margin: 0;
  min-height: 56px;
}
.spine-node::before {
  /* The bullet dot on the spine */
  content: "";
  position: absolute;
  left: 104px;
  top: 16px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-2);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent-2);
}
.spine-node.dir-sent::before    { background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.spine-node.dir-received::before{ background: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2); }
.spine-node .when {
  position: absolute;
  left: 0;
  top: 14px;
  width: 90px;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.spine-node .who {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}
.spine-node .who strong { color: var(--text); font-weight: 600; }
.spine-node .subject {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.spine-node .narrative {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
  line-height: 1.4;
}
.spine-node .meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.spine-node .meta .cost { color: var(--success); font-weight: 700; margin-left: 8px; }
.spine-node .meta .rate { font-variant-numeric: tabular-nums; }
.spine-node:hover { background: rgba(255,255,255,0.02); border-radius: 8px; }

.filter-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 14px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 18px; }
.filter-grid label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.filter-grid label .input { display: block; width: 100%; margin-top: 4px; min-width: 0; font-size: 13px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text); }
.filter-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.filter-actions .muted { font-size: 12px; }

/* Editable minutes inline in scan table */
.mins-input { width: 60px; padding: 4px 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 4px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.mins-input:focus { outline: none; border-color: var(--accent); background: var(--panel); }
.row-cost-edited { color: var(--warn); }
.row-cost-edited::before { content: "✎ "; font-size: 10px; }

/* 0-min non-billable rows: muted, italic, no ✎ pencil */
.row-cost-nonbillable {
  color: var(--muted, #6b7280) !important;
  font-style: italic;
  font-weight: 400;
}
.row-cost-nonbillable::before { content: none !important; }

/* Click-to-open email link on subject */
.subject-link { color: inherit; text-decoration: none; border-bottom: 1px dashed transparent; }
.subject-link:hover { color: var(--accent-2); border-bottom-color: var(--accent-2); }
.open-icon { font-size: 11px; opacity: 0.55; margin-left: 4px; }
.subject-link:hover .open-icon { opacity: 1; }

/* Printable header — visible only when printing */
.print-only { display: none; }

/* ========== Print styles ========== */
@media print {
  /* Reset to white background, dark text */
  html, body { background: #ffffff !important; color: #111111 !important; font-size: 11pt; }
  .topbar, .nav, .user-chip, .row-actions, .toast, .modal, .summary-cards,
  .data-table, .filter-panel, .form-card, #scanIntro, #scanProgress, #scanResults,
  .main > .tab:not(#tab-timeline) { display: none !important; }
  /* Show only the timeline tab content during print */
  #tab-timeline { display: block !important; }
  #tab-timeline .row { display: none; }
  .totals-bar { display: none; }
  .timeline { padding: 0; }

  /* Print header */
  .print-only { display: block; padding: 0 0 18px; border-bottom: 2px solid #111; margin: 0 0 20px; }
  .ph-brand { font-size: 12pt; color: #555; letter-spacing: 0.5px; }
  .ph-brand em { font-style: normal; color: #2563eb; }
  .ph-title { font-size: 22pt; margin: 6pt 0 4pt; font-weight: 700; }
  .ph-ref { font-size: 11pt; color: #333; margin: 2pt 0; }
  .ph-totals { font-size: 13pt; margin: 8pt 0 4pt; font-weight: 600; }
  .ph-meta { font-size: 9pt; color: #777; margin-top: 6pt; }

  /* Spine: keep the vertical layout but in monochrome */
  .spine::before { background: #222 !important; width: 1.5px; }
  .spine-day { color: #333 !important; font-weight: 700; margin-top: 22pt; }
  .spine-day::before { background: #fff !important; border-color: #222 !important; }
  .spine-node { color: #111 !important; page-break-inside: avoid; break-inside: avoid; }
  .spine-node::before { box-shadow: 0 0 0 1px #222 !important; }
  .spine-node.dir-sent::before    { background: #2563eb !important; }
  .spine-node.dir-received::before{ background: #444 !important; }
  .spine-node .when { color: #555 !important; }
  .spine-node .who { color: #555 !important; }
  .spine-node .who strong { color: #000 !important; }
  .spine-node .subject { color: #000 !important; font-size: 12pt; }
  .spine-node .narrative { color: #333 !important; }
  .spine-node .meta { color: #555 !important; }
  .spine-node .meta .cost { color: #047857 !important; }
  .subject-link { color: #000 !important; border-bottom: none !important; }
  .open-icon { display: none !important; }
  .dir-pill { background: #eee !important; color: #444 !important; padding: 1px 6px; }
  .main { padding: 0; max-width: 100%; }

  @page { margin: 18mm 16mm; }
}

.search-section { margin-top: 18px; }
.search-section h3 { font-size: 13px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.6px; margin: 0 0 10px; }

/* -------------------------------------------------------------------- */
/* Scan-row narrative cell — inline editable + AI-suggest button        */
/* -------------------------------------------------------------------- */
.narrative-cell {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.narrative-input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.35;
  padding: 4px 6px;
  border: 1px solid var(--line, #d0d0d8);
  border-radius: 4px;
  resize: vertical;
  min-height: 34px;
  max-height: 96px;
  background: var(--bg, #fff);
  color: var(--text, #111);
}
.narrative-input:focus {
  outline: 2px solid var(--accent, #5648D3);
  outline-offset: 0;
  border-color: transparent;
}
.narrative-input::placeholder {
  color: var(--muted, #999);
  font-style: italic;
}
.narrative-ai-btn {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line, #d0d0d8);
  border-radius: 4px;
  background: var(--bg-alt, #f6f5ff);
  color: var(--accent, #5648D3);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background 0.12s ease, transform 0.12s ease;
}
.narrative-ai-btn:hover:not(:disabled) {
  background: var(--accent, #5648D3);
  color: #fff;
  transform: scale(1.05);
}
.narrative-ai-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

/* -------------------------------------------------------------------- */
/* Save toolbar — visual attention when items are ticked (Feature C)     */
/* Existing #saveToolbar becomes more prominent when count > 0 by        */
/* attaching class "save-toolbar-active" via JS (in updateCommitButton). */
/* -------------------------------------------------------------------- */
.save-toolbar.save-toolbar-active {
  background: linear-gradient(90deg, rgba(86,72,211,0.08), rgba(86,72,211,0.14));
  border: 1px solid rgba(86,72,211,0.35);
  animation: save-toolbar-pulse 1.6s ease-in-out 0s 2;
}
@keyframes save-toolbar-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(86,72,211,0.35); }
  50%  { box-shadow: 0 0 0 6px rgba(86,72,211,0.00); }
  100% { box-shadow: 0 0 0 0 rgba(86,72,211,0.00); }
}
.save-toolbar.save-toolbar-active #goToMattersBtn {
  font-weight: 600;
}
