/* ==========================================================================
   What's in my docs? — design system
   Cool slate + indigo brand, soft cards, tabular financial numerals.
   UI/UX guidelines: clear hierarchy, consistent shape/depth/motion, WCAG AA
   contrast, visible focus rings, reduced-motion support.
   ========================================================================== */

:root {
  /* Surfaces */
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e3e8f0;
  --line-strong: #d3dae6;

  /* Ink */
  --ink: #0f172a;
  --muted: #55637a;
  --faint: #64748b;

  /* Brand */
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eef2ff;
  --accent-ink: #ffffff;

  /* Semantics */
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --bad: #be123c;
  --bad-bg: #fff1f2;
  --none: #475569;
  /* Interactive */
  --hover: #f8fafc;
  --ink-muted: #55637a;
  --border: #e3e8f0;


  /* Shape + depth */
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / .05), 0 1px 3px rgb(15 23 42 / .04);
  --shadow-md: 0 4px 14px rgb(15 23 42 / .08), 0 1px 3px rgb(15 23 42 / .05);
  --shadow-lg: 0 16px 40px rgb(15 23 42 / .16);
  --ring: 0 0 0 3px rgb(79 70 229 / .28);

  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1100px 480px at 50% -260px, rgb(99 102 241 / .10), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Slim, quiet scrollbars on scrollable panels */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
*::-webkit-scrollbar-track { background: transparent; }

/* Account sidebar (signed-in users) */
.sidebar {
  flex: 0 0 250px;
  width: 250px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: rgb(255 255 255 / .8);
  backdrop-filter: blur(8px);
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.sidebar[hidden] { display: none; }
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.brand-mark {
  width: 22px;
  height: 22px;
  flex: none;
  filter: drop-shadow(0 1px 2px rgb(79 70 229 / .35));
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  color: var(--ink);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.sidebar-btn:hover {
  background: var(--accent-soft);
  border-color: #dde3ff;
}
.sidebar-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
/* Sidebar links (Upload / Dashboard) reuse the button look */
a.sidebar-btn {
  text-decoration: none;
  justify-content: flex-start;
}
.sidebar-btn[aria-current='page'] {
  background: var(--accent-soft);
  border-color: #dde3ff;
}

/* Organization switcher container */
.org-switcher-mount {
  margin-bottom: 6px;
}
/* Clerk's org switcher overrides */
.org-switcher-mount .cl-organizationSwitcherTrigger {
  width: 100%;
  justify-content: flex-start;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: none;
}
.org-switcher-mount .cl-organizationSwitcherTrigger:hover {
  background: var(--accent-soft);
  border-color: #dde3ff;
}

/* Sidebar client list */
.sidebar-clients {
  margin: 8px 0 4px;
  padding: 0;
}
.sidebar-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ink-muted);
  padding: 0 12px;
  margin-bottom: 4px;
}
.sidebar-icon-btn {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: background .15s, border-color .15s;
}
.sidebar-icon-btn:hover {
  background: var(--accent-soft);
  border-color: #dde3ff;
  color: var(--ink);
}
.client-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sidebar-client-btn {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 13px;
  text-align: left;
  color: var(--ink-muted);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.sidebar-client-btn:hover,
.sidebar-client-btn.active {
  background: var(--accent-soft);
  color: var(--ink);
  border-color: #dde3ff;
}
.sidebar-subtle-btn {
  width: 100%;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  color: var(--ink-muted);
  background: none;
  border: none;
  padding: 4px 12px;
  cursor: pointer;
  margin-top: 2px;
}
.sidebar-subtle-btn:hover { color: var(--ink); }
.sidebar-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgb(79 70 229 / .35);
}

/* Plan badge variants — Free is subdued, Pro is the brand accent. */
.sidebar-badge.free { background: var(--none-bg); color: var(--none); box-shadow: none; }
.sidebar-badge.pro  { /* default brand accent — no override needed */ }

/* Admin badge — warm amber to signal elevated privileges. */
.admin-badge { background: #fef3c7; color: #92400e; box-shadow: 0 1px 2px rgb(146 64 14 / .25); }
.header-admin-badge { margin-left: 6px; vertical-align: middle; }

/* Owner badge — gold/crown to signal the single highest-privilege user. */
.owner-badge { background: #fef3c7; color: #92400e; box-shadow: 0 1px 2px rgb(146 64 14 / .30); }

.main-wrap {
  flex: 1;
  min-width: 0;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 20px 32px;
}

header { text-align: center; margin-bottom: 30px; }
h1 {
  margin: 0 0 8px;
  font-size: 31px;
  font-weight: 800;
  letter-spacing: -0.025em;
}
.subtitle {
  margin: 0 auto;
  max-width: 560px;
  color: var(--muted);
  font-size: 15px;
}

/* Document dashboard ("My documents") */
.documents { margin-top: 4px; }
.documents-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}
.documents-head h2 { margin: 0; font-size: 19px; letter-spacing: -0.015em; }
.documents-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
  letter-spacing: .02em;
}
.documents-status {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--bad);
}
.document-list {
  list-style: none;
  margin: 0 0 26px;
  padding: 0;
  display: grid;
  gap: 10px;
}
.document-item {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.document-item:hover {
  border-color: #c7d2fe;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.document-item:active { transform: translateY(0); }
.document-item:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.document-icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: linear-gradient(180deg, var(--accent-soft), #e0e7ff);
  border: 1px solid #dde3ff;
}
.document-icon svg { width: 20px; height: 20px; }
.document-item:has(.badge.plain) .document-icon {
  color: var(--none);
  background: var(--none-bg);
  border-color: var(--line);
}
.document-main { flex: 1; min-width: 0; }
.document-name {
  font-weight: 650;
  font-size: 14px;
  word-break: break-all;
}
.document-preview {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.document-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.document-item .chevron {
  flex: none;
  font-size: 11px;
  color: var(--faint);
  transition: transform .15s ease, color .15s ease;
}
.document-item:hover .chevron {
  color: var(--accent);
  transform: translateX(2px);
}

.documents-search {
  flex: 1;
  max-width: 280px;
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.documents-search::placeholder { color: var(--faint); }
.documents-search:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.document-delete {
  flex: none;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s ease, color .15s ease;
}
.document-delete:hover {
  background: var(--bad-bg);
  color: var(--bad);
}
.trend-stat-card {
  text-align: center;
  padding: 20px 16px;
}
.networth-value {
  font-size: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin: 8px 0 2px;
  color: var(--ink);
}
.networth-sub {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}
#documents-empty {
  text-align: center;
  background: var(--card);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 26px 20px;
  margin: 0 0 26px;
  font-style: normal;
  font-size: 13px;
  color: var(--muted);
}

/* Document detail (saved analysis) */
#document-detail { margin-top: 26px; }
.detail-title { min-width: 0; }
/* The detail card header is informational, not collapsible */
#document-detail .page-head { cursor: default; }
#document-detail .page-head:hover { background: none; }

/* Dropzone */
#dropzone {
  border: 2px dashed #c9d2f5;
  border-radius: var(--radius);
  background: var(--card);
  padding: 46px 20px 40px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, transform .15s ease;
}
#dropzone:hover, #dropzone.dragover {
  border-color: var(--accent);
  background: linear-gradient(180deg, #f8f9ff, var(--card));
  box-shadow: var(--shadow-md);
}
#dropzone:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.dz-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #dde3ff;
  transition: transform .15s ease, box-shadow .15s ease;
}
.dz-icon svg { width: 26px; height: 26px; }
#dropzone:hover .dz-icon {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgb(79 70 229 / .18);
}
.dz-title { margin: 0 0 4px; font-weight: 650; font-size: 16.5px; }
.dz-hint { margin: 0; color: var(--muted); font-size: 13px; }

/* Progress */
#progress { margin-top: 20px; }
.progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-strong), #818cf8);
  transition: width .2s ease;
}

/* Bulk upload — file list & job progress */
.file-list { margin-bottom: 12px; }
.file-list-heading {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}
.file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-size { color: var(--muted); white-space: nowrap; font-size: 12px; }

#bulk-progress { margin-top: 20px; }
.bulk-head { margin-bottom: 8px; }
.bulk-head h3 { font-size: 16px; font-weight: 600; margin: 0; }

.job-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.job-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  transition: background .15s ease;
}
.job-row.job-done { border-color: #34d399; }
.job-row.job-failed { border-color: #f87171; }
.job-row.job-processing { border-color: #fbbf24; }
.job-row[role="button"]:hover { background: var(--hover); }
.job-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-status { font-size: 14px; white-space: nowrap; }
.job-ok { color: #34d399; }
.job-err { color: #f87171; }
.job-busy { color: #fbbf24; }

/* Mask panel */
.mask-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.mask-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.mask-head label {
  font-weight: 650;
  font-size: 14px;
}
.mask-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
#mask-input {
  width: 100%;
  font: inherit;
  font-size: 13px;
  font-family: var(--mono);
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  resize: vertical;
  background: #f8fafc;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
#mask-input:hover { border-color: var(--line-strong); }
#mask-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
  background: #fff;
}
.mask-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.mask-summary {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 650;
  color: var(--warn);
}
.mask-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.mask-chip {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--mono);
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid #fde68a;
  padding: 2px 9px;
  border-radius: 999px;
}

/* Results */
#results { margin-top: 28px; }
.results-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.results-head h2 { margin: 0 0 4px; font-size: 18px; word-break: break-all; letter-spacing: -0.01em; }
.meta { margin: 0; color: var(--muted); font-size: 13px; }

/* Buttons */
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease, background .15s ease;
}
.btn:hover {
  border-color: #c7d2fe;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.btn:disabled {
  opacity: .55;
  cursor: default;
  box-shadow: none;
  transform: none;
}
.btn-primary {
  background: linear-gradient(180deg, #6366f1, var(--accent));
  border-color: transparent;
  color: var(--accent-ink);
  box-shadow: 0 1px 2px rgb(79 70 229 / .35), inset 0 1px 0 rgb(255 255 255 / .18);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #5457e8, var(--accent-strong));
  border-color: transparent;
  box-shadow: 0 6px 16px rgb(79 70 229 / .35), inset 0 1px 0 rgb(255 255 255 / .18);
}

/* Terms to Redact drawer */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  /* Animate visibility instead of display:none so the backdrop fades and
     the panel slides. The hidden attribute toggles opacity + visibility. */
  transition: visibility .2s, opacity .2s ease;
}
.drawer-overlay[hidden] {
  display: block;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}
.drawer-overlay:not([hidden]) {
  visibility: visible;
  opacity: 1;
}
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(15 23 42 / .5);
  backdrop-filter: blur(3px);
}
.drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(400px, 94vw);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  overflow-y: auto;
  transform: translateX(24px);
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
}
.drawer-overlay:not([hidden]) .drawer {
  transform: translateX(0);
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.drawer-head h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.drawer-sub {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 12.5px;
}
.drawer-add {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
#drawer-term-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 13px;
  font-family: var(--mono);
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
#drawer-term-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
  background: #fff;
}
.drawer-hint {
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--muted);
}
.drawer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.drawer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--mono);
  word-break: break-all;
  background: #fbfcfe;
}
.drawer-remove {
  border: 0;
  background: none;
  color: var(--faint);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color .15s ease, background .15s ease;
}
.drawer-remove:hover {
  color: var(--bad);
  background: var(--bad-bg);
}
.drawer-empty {
  color: var(--muted);
  font-size: 13px;
}

/* Billing drawer */
.billing-current {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: var(--accent-soft);
  border: 1px solid #dde3ff;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 0 0 18px;
}
.billing-current strong { font-size: 14px; }
.billing-note { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.billing-section-title {
  font-size: 13.5px;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
.billing-hint {
  font-weight: 400;
  font-size: 11.5px;
  color: var(--faint);
  margin-left: 6px;
}
.billing-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin: 0 0 18px;
}
.billing-option {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.billing-option:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.billing-option:disabled { opacity: .6; cursor: wait; }
.billing-option strong { font-size: 18px; letter-spacing: -0.02em; }
.billing-option strong small { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.billing-option span { font-size: 11.5px; color: var(--muted); line-height: 1.35; }

/* Bank accounts drawer */
.drawer-wide { width: min(430px, 94vw); }
.bank-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.bank-form input,
.bank-form select,
.bank-form textarea {
  font: inherit;
  font-size: 13px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.bank-form input:focus,
.bank-form select:focus,
.bank-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
  background: #fff;
}
.bank-form textarea { resize: vertical; min-height: 46px; }
.bank-form-row { display: flex; gap: 8px; }
.bank-form-row select { flex: 1.2; min-width: 0; }
.bank-form-row input { flex: 1; min-width: 0; }
.bank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fbfcfe;
}
.bank-item-main { min-width: 0; }
.bank-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.bank-item-name {
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.bank-item-last4 {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--muted);
}
.bank-item-meta {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  word-break: break-word;
}
.bank-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.bank-edit {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color .15s ease, background .15s ease;
}
.bank-edit:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

/* Setup (pre-extraction mask panel) */
#setup { margin-top: 20px; }
.setup-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

/* Collapsible pages */
.page {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  cursor: pointer;
  user-select: none;
  transition: background .15s ease;
}
.page-head:hover { background: #f8fafc; }
.page-body { display: none; padding: 0 18px 18px; transition: none; }
.page.open .page-body {
  display: block;
  animation: pageExpand .2s ease forwards;
}
@keyframes pageExpand {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.badge {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
}
.badge.text { color: var(--ok); background: var(--ok-bg); }
.badge.ocr  { color: var(--warn); background: var(--warn-bg); }
.badge.none, .badge.error { color: var(--bad); background: var(--bad-bg); }
.badge.ai { color: var(--accent); background: var(--accent-soft); border: 1px solid #dde3ff; }
.badge.plain { color: var(--none); background: var(--none-bg); }
.page-count { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chevron { color: var(--faint); font-size: 11px; transition: transform .15s ease; }
.page.open .chevron { transform: rotate(90deg); }

.page-body pre {
  margin: 0 0 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow: auto;
}
.page-note { color: var(--bad); font-size: 13px; margin: 0 0 12px; }
.email-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.email-wrap input[type="email"] {
  width: 160px;
  font-size: 12.5px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.email-wrap input[type="email"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.summary-note { margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.summary-warn {
  margin: 0 0 12px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid #fde68a;
}

/* Rendered AI summary (markdown) */
.markdown {
  font-size: 14px;
  line-height: 1.65;
  max-height: 420px;
  overflow: auto;
  margin-bottom: 12px;
}
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
  margin: 16px 0 6px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.markdown h1 { font-size: 19px; }
.markdown h2 { font-size: 17px; }
.markdown h3 { font-size: 15px; }
.markdown h4, .markdown h5, .markdown h6 { font-size: 14px; }
.markdown p { margin: 8px 0; }
.markdown ul, .markdown ol { margin: 8px 0; padding-left: 24px; }
.markdown li { margin: 3px 0; }
.markdown li > ul, .markdown li > ol { margin: 3px 0; }
.markdown strong { font-weight: 700; }
.markdown a { color: var(--accent); }
.markdown hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.markdown code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}
.markdown pre {
  margin: 10px 0;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow: auto;
}
.markdown pre code { background: none; border: none; padding: 0; }
.markdown blockquote {
  margin: 10px 0;
  padding: 2px 14px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}
.markdown table {
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}
.markdown th, .markdown td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
}
.markdown th { background: #f8fafc; font-weight: 700; }

/* Visual dashboard (accounts, tickers, key facts) */
.dash-section { margin-bottom: 20px; }
.dash-section:last-child { margin-bottom: 12px; }
.dash-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--faint);
}

.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 12px;
}
.account-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: linear-gradient(180deg, #fbfcff 0%, var(--card) 65%);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease, border-color .15s ease, transform .15s ease;
}
.account-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #c7d2fe;
  transform: translateY(-1px);
}
.account-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.account-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-status {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
  border-radius: 999px;
  padding: 2px 8px;
}
.account-status.managed-status { color: var(--ok); background: var(--ok-bg); }
.account-status.unmanaged-status { color: var(--warn); background: var(--warn-bg); }

.account-card.managed { border-left: 3px solid var(--ok); }
.account-card.unmanaged { border-left: 3px solid var(--warn); }
.account-card.managed:hover { border-left-color: var(--ok); }
.account-card.unmanaged:hover { border-left-color: var(--warn); }
.account-balance {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.account-delta {
  display: inline-block;
  margin-top: 8px;
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 3px 10px;
  border-radius: 999px;
}
.account-delta.up { color: var(--ok); background: var(--ok-bg); }
.account-delta.down { color: var(--bad); background: var(--bad-bg); }
.account-delta.flat { color: var(--none); background: var(--none-bg); }

.account-movements {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 9px;
}
.mv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 12.5px;
}
.mv-label {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mv-amount {
  font-family: var(--mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.mv-amount.up { color: var(--ok); }
.mv-amount.down { color: var(--bad); }
.mv-amount.flat { color: var(--none); }
.mv-track {
  height: 5px;
  border-radius: 3px;
  background: var(--none-bg);
  overflow: hidden;
}
.mv-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width .3s ease;
}
.mv-fill.up { background: var(--ok); }
.mv-fill.down { background: var(--bad); }
.mv-fill.flat { background: var(--none); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
}
.tickers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tickers-table th,
.tickers-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tickers-table tr:last-child td { border-bottom: none; }
.tickers-table th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faint);
  background: #f8fafc;
}
.tickers-table td.num { text-align: right; }
.tickers-table th.num { text-align: right; }
.tickers-table td {
  font-variant-numeric: tabular-nums;
}
.ticker {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #dde3ff;
  border-radius: 7px;
  padding: 2px 8px;
}
.ticker-name {
  color: var(--muted);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.delta-pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 2px 9px;
  border-radius: 999px;
}
.delta-pill.up { color: var(--ok); background: var(--ok-bg); }
.delta-pill.down { color: var(--bad); background: var(--bad-bg); }
.delta-pill.flat { color: var(--none); background: var(--none-bg); }

.facts-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.fact-chip {
  font-size: 12.5px;
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 13px;
  color: #334155;
  transition: border-color .15s ease, background .15s ease;
}
.fact-chip:hover {
  border-color: #c7d2fe;
  background: #f8faff;
}
.fact-chip::before {
  content: "•";
  color: var(--accent);
  font-weight: 700;
  margin-right: 6px;
}

.page-actions { display: flex; gap: 8px; }

.empty-state { color: var(--muted); font-style: italic; margin: 0 0 12px; font-size: 13px; }
.empty-state a { color: var(--accent); }

/* Error */
.error {
  margin-top: 20px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--bad-bg);
  border: 1px solid #fecdd3;
  color: var(--bad);
  font-size: 14px;
  font-weight: 600;
}

footer {
  text-align: center;
  color: var(--faint);
  font-size: 12px;
  padding: 28px 20px 44px;
}
footer p { margin: 0; }

/* Narrow screens: sidebar becomes a top bar above the content */
@media (max-width: 900px) {
  body { flex-direction: column; }
  .sidebar {
    flex: none;
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 10px 16px;
    gap: 12px;
  }
  .sidebar-nav { flex-direction: row; }
  .sidebar-btn { width: auto; }
}

@media (max-width: 560px) {
  main { padding: 32px 14px 24px; }
  .header-row { flex-direction: column; align-items: stretch; gap: 12px; text-align: center; }
  .auth { justify-content: center; }
  .document-item { padding: 12px 12px; }
  .drawer { padding: 18px; }
  .signed-out-actions { flex-direction: column; align-items: stretch; }
}

/* Phone-width passability: dropzone, drawers, charts, and document list
   must be usable at 390 px wide (iPhone 14 width). */
@media (max-width: 480px) {
  .dropzone { padding: 30px 18px; }
  .dz-title { font-size: 15px; }
  .dz-hint { font-size: 12px; }
  .documents-head { flex-wrap: wrap; }
  .documents-search { max-width: 100%; width: 100%; }
  .document-item { padding: 10px 10px; gap: 10px; }
  .document-icon { width: 34px; height: 34px; }
  .document-name { font-size: 13px; }
  .document-meta { font-size: 11px; }
  .document-preview { font-size: 11px; }
  .document-delete { width: 28px; height: 28px; border-radius: 6px; }
  .trend-chart { height: 200px; }
  .trend-wide .trend-chart { height: 220px; }
  .trend-donut-card { flex-direction: column; }
  .donut-legend { font-size: 10px; }
  .networth-value { font-size: 26px; }
  .drawer { padding: 14px; }
  .drawer-body { gap: 12px; }
}

/* Auth */
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  text-align: left;
}
.auth {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.auth-user {
  font-size: 13px;
  color: var(--muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.signed-out {
  max-width: 860px;
  margin: 0 auto 16px;
}
.landing-hero { text-align: center; padding: 28px 12px 8px; }
.landing-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #dde3ff;
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 16px;
}
.landing-hero h2 {
  margin: 0 0 12px;
  font-size: 34px;
  letter-spacing: -0.025em;
  line-height: 1.15;
}
.landing-sub {
  margin: 0 auto 24px;
  max-width: 620px;
  color: var(--muted);
  font-size: 15.5px;
}
.signed-out-actions { display: flex; justify-content: center; gap: 10px; }
.btn-lg { padding: 12px 24px; font-size: 14.5px; }
.landing-micro { margin: 14px 0 0; color: var(--faint); font-size: 12.5px; }

.landing-guarantees {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 40px 0;
}
.guarantee {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--muted);
}
.guarantee strong { color: var(--ink); font-size: 13px; }
.guarantee-icon { font-size: 18px; }

.landing-section { margin: 40px 0; }
.landing-section h3 {
  text-align: center;
  font-size: 20px;
  letter-spacing: -0.015em;
  margin: 0 0 20px;
}
.landing-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.landing-steps li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.landing-steps strong { color: var(--ink); font-size: 14px; }
.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 700;
}

.landing-pricing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.price-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--muted);
}
.price-card.featured { border: 2px solid var(--accent); }
.price-card > strong { color: var(--ink); font-size: 15px; }
.price-amount { font-size: 26px; font-weight: 800; color: var(--ink); letter-spacing: -0.02em; }
.price-amount small { font-size: 13px; font-weight: 500; color: var(--muted); }
.price-card .btn { margin-top: 10px; }

.landing-footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--faint);
  font-size: 12.5px;
}
.landing-links a { color: var(--muted); text-decoration: none; margin-left: 16px; }
.landing-testimonials {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.testimonial {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0;
  text-align: left;
}
.testimonial p {
  margin: 0 0 8px;
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.5;
  font-style: italic;
}
.testimonial cite {
  font-size: 12px;
  color: var(--muted);
  font-style: normal;
}
/* Trends (dashboard charts across saved documents) */
.trends {
  margin: 0 0 26px;
}
.trends-sub {
  font-size: 12.5px;
  color: var(--muted);
}
.trends-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.trend-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  box-shadow: var(--shadow-sm);
}
.trend-wide {
  grid-column: 1 / -1;
}
.trend-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.trend-chart {
  position: relative;
  height: 240px;
}
.trend-wide .trend-chart {
  height: 280px;
}
.donut-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10.5px;
  line-height: 1.35;
  color: var(--muted);
}
.donut-legend li {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
/* Donut cards lay the chart and its HTML legend side by side so long account
   names wrap in a dedicated column instead of overflowing the canvas. */
.trend-donut-card {
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  align-items: stretch;
  gap: 14px;
}
.trend-donut-card .trend-title {
  flex: 1 1 100%;
}
.trend-donut-card .trend-chart {
  flex: 0 0 46%;
  min-width: 0;
}
.trend-donut-card .donut-legend {
  flex: 1 1 0%;
  min-width: 0;
}
.donut-legend-swatch {
  flex: 0 0 9px;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-top: 3px;
}
@media (max-width: 720px) {
  .trends-grid {
    grid-template-columns: 1fr;
  }
  .trend-wide .trend-chart {
    height: 240px;
  }
}

/* Dashboard route (/dashboard): aggregate charts lead, documents follow. */
#app.dashboard-mode {
  display: flex;
  flex-direction: column;
}
#app.dashboard-mode[hidden] { display: none; }
#app.dashboard-mode #document-detail { order: 0; }
#app.dashboard-mode #trends-empty { order: 1; }
#app.dashboard-mode #trends { order: 2; margin-bottom: 0; }
#app.dashboard-mode #documents { order: 3; margin-top: 26px; }
#app.dashboard-mode #error { order: 4; }

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ==========================================================================
   Admin UI: audit log, org settings, API keys, webhooks
   ========================================================================== */

/* Audit table */
.audit-table-wrap { max-height: 420px; overflow-y: auto; margin-top: 12px; }
.audit-table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.audit-table th { text-align: left; padding: 8px 10px; font-weight: 600; color: var(--muted); border-bottom: 2px solid var(--line); white-space: nowrap; }
.audit-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--ink); vertical-align: top; }
.audit-table tr:hover td { background: var(--accent-soft); }
.audit-table .audit-action { font-weight: 500; white-space: nowrap; }
.audit-table .audit-details { color: var(--muted); font-size: .75rem; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-table .audit-time { white-space: nowrap; color: var(--muted); font-size: .75rem; }
.audit-filters { margin-top: 12px; }
.audit-filters select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: .8125rem; background: var(--card); color: var(--ink); }

/* Settings fields (retention, etc.) */
.settings-field { margin-bottom: 16px; }
.settings-field label { display: block; font-weight: 600; font-size: .8125rem; margin-bottom: 4px; color: var(--ink); }
.settings-input-row { display: flex; gap: 8px; align-items: center; }
.settings-input-row input { flex: 1; }
.settings-unit { font-size: .8125rem; color: var(--muted); }
.settings-hint { font-size: .75rem; color: var(--muted); margin-top: 4px; }
.settings-ok { color: var(--ok); font-size: .8125rem; font-weight: 500; margin-top: 8px; }

/* Drawer section titles and dividers */
.drawer-section-title { font-size: .875rem; font-weight: 600; margin: 20px 0 8px; color: var(--ink); }
.drawer-section-danger .drawer-section-title { color: var(--bad); }

/* Admin panel stats grid */
.admin-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 12px; margin: 12px 0; }
.admin-stat { background: var(--accent-soft); border-radius: 8px; padding: 12px; text-align: center; }
.admin-stat-val { display: block; font-size: 1.25rem; font-weight: 700; color: var(--ink); }
.admin-stat-label { display: block; font-size: .6875rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }
.settings-err { color: var(--bad); font-size: .8125rem; margin-top: 8px; }

/* Danger button */
.btn-danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-danger:hover { background: #9f102f; }

/* API key created display */
.api-key-created { background: var(--ok-bg); border: 1px solid var(--ok); border-radius: 8px; padding: 12px; margin: 12px 0; }
.api-key-label { font-size: .8125rem; font-weight: 600; color: var(--ok); margin: 0 0 8px; }
.api-key-value-wrap { display: flex; gap: 8px; align-items: center; }
.api-key-value-wrap code { flex: 1; padding: 8px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; font-size: .75rem; word-break: break-all; }

/* Checkbox group */
.checkbox-group { display: flex; flex-direction: column; gap: 6px; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: .8125rem; color: var(--ink); cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: auto; margin: 0; }

/* Drawer list item actions */
.drawer-list-item-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; flex-shrink: 0; }
.drawer-list-item-actions .btn { padding: 3px 10px; font-size: .75rem; }

/* Client inbound email */
.client-email-in { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.client-email-in code { font-size: .75rem; background: var(--accent-soft); padding: 1px 5px; border-radius: 3px; }

/* ==========================================================================
   Insights page: forecasting, fees, drift alerts
   ========================================================================== */

.insights { margin: 18px 0; }
.insights[hidden] { display: none; }

.insights-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 12px;
}
@media (max-width: 720px) {
  .insights-grid { grid-template-columns: 1fr; }
}

#insights-fees-breakdown { margin-top: 14px; text-align: left; }
#insights-fees-breakdown .donut-legend { margin-top: 8px; }

/* Drift alerts */
.drift-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  text-align: left;
}
.drift-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.drift-item:last-child { border-bottom: none; }
.drift-icon {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
}
.drift-icon.up { background: #fef2f2; color: #dc2626; }
.drift-icon.down { background: #ecfdf5; color: #059669; }
.drift-body { flex: 1; min-width: 0; }
.drift-body strong { display: block; font-size: .8125rem; }
.drift-detail {
  display: block;
  font-size: .75rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Cash-flow projection chart */
#insights-projection-card .trend-chart { height: 280px; }
@media (max-width: 720px) {
  #insights-projection-card .trend-chart { height: 220px; }
}

/* ==========================================================================
   Language selector (sidebar)
   ========================================================================== */

.sidebar-lang {
  margin-top: 18px;
  padding: 0 10px;
}
.lang-select {
  width: 100%;
  padding: 6px 30px 6px 10px;
  font-size: .75rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.lang-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* ==========================================================================
   Compliance static pages (PI Canada, APPI Japan)
   ========================================================================== */

.static-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 60px;
  font-family: var(--font);
  color: var(--ink);
  line-height: 1.7;
}
.static-wrap { }
.static-page h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 4px; }
.static-page h2 { font-size: 1.2rem; font-weight: 600; margin: 28px 0 8px; }
.static-page h3 { font-size: 1.05rem; font-weight: 600; margin: 18px 0 6px; }
.static-page p, .static-page li { margin: 0 0 10px; font-size: .9375rem; }
.static-page ul { padding-left: 20px; margin: 8px 0 14px; }
.static-page table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: .875rem; }
.static-page th, .static-page td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.static-page th { background: var(--accent-soft); font-weight: 600; }
.static-page code { font-size: .8125rem; background: var(--accent-soft); padding: 1px 5px; border-radius: 3px; }
.static-page hr { border: none; border-top: 1px solid var(--line); margin: 28px 0; }
.static-back { display: inline-block; margin-bottom: 20px; color: var(--accent); text-decoration: none; font-size: .875rem; }
.static-back:hover { text-decoration: underline; }
.static-date { font-size: .8125rem; color: var(--muted); }
.static-footer { font-size: .8125rem; color: var(--muted); font-style: italic; }
