/* style.css */

/* ---------- Tokens ---------- */
:root {
  /* Surfaces — deep ink with cool undertone, not pure black */
  --bg:        #0e1018;
  --bg-2:      #11141d;
  --surface:   #161a25;
  --surface-2: #1c2030;
  --surface-3: #232838;
  --surface-4: #2c3145;

  /* Borders */
  --border:        #262b3a;
  --border-strong: #343a4d;
  --border-subtle: #1d2230;

  /* Text */
  --text:         #e8e9ee;
  --text-2:       #b6bac6;
  --text-muted:   #7a7f8e;
  --text-faint:   #545968;

  /* Brand — refined warm bronze, not casino gold */
  --brand:         #c89968;
  --brand-hover:   #dab088;
  --brand-soft:    rgba(200, 153, 104, 0.12);
  --brand-border:  rgba(200, 153, 104, 0.35);
  --brand-ink:     #1a1208;

  /* Status */
  --ok:        #5fb87f;
  --ok-soft:   rgba(95, 184, 127, 0.14);
  --warn:      #e8a857;
  --warn-soft: rgba(232, 168, 87, 0.14);
  --danger:    #e76b6b;
  --danger-soft: rgba(231, 107, 107, 0.14);

  /* Section accents — each top-level area has an identity */
  --c-about:         #f5b942;
  --c-gifts:         #d8a0b1;
  --c-export:        #94d3b3;
  --c-heir:          #9cb4e0;
  --c-letters:       #ec8a64;
  --c-instructions:  #5cc8d8;
  --c-funeral:       #b3a6d4;
  --c-legal:         #8a92db;
  --c-insurance:     #5fc798;
  --c-tax:           #d6b366;
  --c-accounts:      #d8b461;
  --c-property:      #d8946b;
  --c-safe:          #7d9bbd;
  --c-subscriptions: #6aa9dd;
  --c-contacts:      #b394d8;
  --c-medical:       #e87a7a;
  --c-financial:     #6cc28e;

  /* Layout */
  --sidebar-w: 248px;
  --content-pad-x: 48px;
  --content-pad-y: 18px;
  --max-content: 1240px;

  /* Type */
  --font-body: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --font-display: "New York", "Iowan Old Style", "Hoefler Text", Georgia, "Times New Roman", serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, monospace;

  /* Radius / shadow */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow-1:  0 1px 0 rgba(255,255,255,0.02), 0 1px 2px rgba(0,0,0,0.4);
  --shadow-2:  0 4px 12px rgba(0,0,0,0.35), 0 1px 0 rgba(255,255,255,0.02) inset;
  --shadow-3:  0 18px 40px rgba(0,0,0,0.5), 0 2px 0 rgba(255,255,255,0.02) inset;
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(200,153,104,0.05), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(108,168,194,0.05), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0.005em;
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--brand-hover); }

button { font-family: inherit; }

::selection { background: var(--brand-soft); color: var(--brand-hover); }

/* ---------- Typography ---------- */
.display {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ---------- Layout shell ---------- */
.layout { display: flex; min-height: 100vh; }

.content {
  margin-left: var(--sidebar-w);
  padding: var(--content-pad-y) var(--content-pad-x) 64px;
  flex: 1;
  max-width: calc(var(--max-content) + var(--sidebar-w));
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
  border-right: 1px solid var(--border);
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  overflow-y: auto;
  z-index: 5;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.sidebar-header {
  padding: 16px 22px 10px;
  border-bottom: 1px solid var(--border-subtle);
}
.brand-lockup { display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: linear-gradient(160deg, var(--brand) 0%, #8e6a44 100%);
  color: var(--brand-ink);
  box-shadow: 0 2px 8px rgba(200,153,104,0.25), 0 0 0 1px rgba(255,255,255,0.06) inset;
}
.brand-mark svg { width: 16px; height: 16px; }
.brand-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--text);
}
.brand-version {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-left: 4px;
  align-self: flex-end;
  padding-bottom: 3px;
}
.brand-name:hover { color: var(--brand-hover); }
.brand-tag {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.04em;
}

.nav { flex: 1; padding: 10px 12px 24px; }
.nav-group { margin-top: 18px; }
.nav-group:first-child { margin-top: 4px; }
.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 12px 8px;
}
.nav-list { list-style: none; display: flex; flex-direction: column; gap: 1px; }

.nav-item {
  --section: var(--text-muted);
  display: flex; align-items: center; gap: 12px;
  padding: 5px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
  position: relative;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item .nav-icon {
  width: 24px; height: 24px;
  flex: 0 0 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--section);
  opacity: 0.85;
  transition: opacity .15s ease, transform .15s ease;
}
.nav-item .nav-icon svg { width: 24px; height: 24px; display: block; }
.nav-item:hover .nav-icon { opacity: 1; }
.nav-item.is-active {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.is-active .nav-icon { opacity: 1; }
.nav-item.is-active::before {
  content: "";
  position: absolute; left: -4px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--section);
}
.nav-item .nav-arrow {
  margin-left: auto;
  width: 12px; height: 12px;
  color: var(--text-faint);
}

/* Section color hooks */
.nav-item.s-about         { --section: var(--c-about); }
.nav-item.s-gifts         { --section: var(--c-gifts); }
.nav-item.s-export        { --section: var(--c-export); }
.nav-item.s-heir          { --section: var(--c-heir); }
.nav-item.s-letters       { --section: var(--c-letters); }
.nav-item.s-instructions  { --section: var(--c-instructions); }
.nav-item.s-funeral       { --section: var(--c-funeral); }
.nav-item.s-legal         { --section: var(--c-legal); }
.nav-item.s-insurance     { --section: var(--c-insurance); }
.nav-item.s-tax           { --section: var(--c-tax); }
.nav-item.s-accounts      { --section: var(--c-accounts); }
.nav-item.s-property      { --section: var(--c-property); }
.nav-item.s-safe          { --section: var(--c-safe); }
.nav-item.s-subscriptions { --section: var(--c-subscriptions); }
.nav-item.s-contacts      { --section: var(--c-contacts); }
.nav-item.s-medical       { --section: var(--c-medical); }
.nav-item.s-financial     { --section: var(--c-financial); }
.nav-item.s-dashboard     { --section: var(--brand); }

.sidebar-footer {
  padding: 14px 22px 22px;
  border-top: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; gap: 8px;
}
.signed-in {
  font-size: 12px;
  color: var(--text-muted);
}
.signed-in strong { color: var(--text-2); font-weight: 600; }
.logout-link {
  font-size: 12px;
  color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 6px;
  width: max-content;
}
.logout-link:hover { color: var(--danger); }
.logout-link svg { width: 13px; height: 13px; }

/* ---------- Page header ---------- */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}
.page-header-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.page-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--section, var(--text-muted));
}
.page-eyebrow svg { width: 14px; height: 14px; }
.page-header h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
}
.page-sub {
  color: var(--text-muted);
  font-size: 13px;
}
.page-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Section color on page header eyebrow */
.section-about         { --section: var(--c-about); }
.section-gifts         { --section: var(--c-gifts); }
.section-letters       { --section: var(--c-letters); }
.section-instructions  { --section: var(--c-instructions); }
.section-funeral       { --section: var(--c-funeral); }
.section-legal         { --section: var(--c-legal); }
.section-insurance     { --section: var(--c-insurance); }
.section-tax           { --section: var(--c-tax); }
.section-accounts      { --section: var(--c-accounts); }
.section-property      { --section: var(--c-property); }
.section-safe          { --section: var(--c-safe); }
.section-subscriptions { --section: var(--c-subscriptions); }
.section-contacts      { --section: var(--c-contacts); }
.section-medical       { --section: var(--c-medical); }
.section-financial     { --section: var(--c-financial); }
.section-vault         { --section: var(--brand); }

/* ---------- Flash (toast — no layout shift) ---------- */
.flash-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 100;
  pointer-events: none;
}
.flash {
  background: var(--surface-3);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow-2);
  pointer-events: auto;
  max-width: 360px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .05s ease;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn:hover { background: var(--surface-3); border-color: var(--text-faint); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(180deg, var(--brand-hover) 0%, var(--brand) 100%);
  border-color: var(--brand);
  color: var(--brand-ink);
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 4px 14px rgba(200,153,104,0.18);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #ecbf8e 0%, var(--brand-hover) 100%);
  border-color: var(--brand-hover);
  color: var(--brand-ink);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger {
  border-color: rgba(231,107,107,0.4);
  color: var(--danger);
  background: transparent;
}
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-xs { padding: 4px 9px; font-size: 11px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; }
.btn-icon svg { width: 14px; height: 14px; }

/* ---------- Tags / pills ---------- */
.tag {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 3px 9px;
  min-width: 92px;
  background: var(--surface-3);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  border: 1px solid var(--border-subtle);
}
.tag-gold  { background: var(--brand-soft); color: var(--brand-hover); border-color: var(--brand-border); }
.tag-green { background: var(--ok-soft); color: var(--ok); border-color: rgba(95,184,127,0.3); }
.tag-red   { background: var(--danger-soft); color: var(--danger); border-color: rgba(231,107,107,0.3); }
.tag-warn  { background: var(--warn-soft); color: var(--warn); border-color: rgba(232,168,87,0.3); }

.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.status::before {
  content: "";
  width: 6px; height: 6px; border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
}
.status-empty    { color: var(--text-faint); }
.status-started  { color: var(--section, var(--brand)); }
.status-complete { color: var(--ok); }

/* ---------- Tables ---------- */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  table-layout: fixed;
  box-shadow: var(--shadow-1);
}
.data-table th {
  text-align: left;
  padding: 8px 14px;
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--section, var(--text-muted));
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.th-sort {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px dotted currentColor;
  padding-bottom: 1px;
}
.th-sort:hover { color: var(--text); border-bottom-style: solid; }
.th-sort .sort-arrow { font-size: 9px; opacity: 0.55; }
.th-sort.is-active { color: var(--text); border-bottom: 1px solid currentColor; }
.th-sort.is-active .sort-arrow { opacity: 1; color: var(--section, var(--brand)); }

/* Account category colors */
.cat-bank        { --cat: #6cc28e; }
.cat-investment  { --cat: #d8b461; }
.cat-retirement  { --cat: #b3a6d4; }
.cat-business    { --cat: #ec8a64; }
.cat-credit_card { --cat: #e76b6b; }
.cat-debt        { --cat: #c97089; }
.cat-digital     { --cat: #6aa9dd; }
.cat-crypto      { --cat: #e8a857; }
.cat-other       { --cat: #7a7f8e; }

.data-table tr.cat-header td {
  background: var(--surface-2);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  font-weight: 700;
  padding: 8px 14px;
  color: var(--c-accounts);
  border-top: 2px solid var(--c-accounts);
  border-bottom: 1px solid var(--border);
  cursor: default;
}
.data-table tr.cat-header:hover td { background: var(--surface-2); }
.data-table tbody > tr[data-href]:has(+ tr.cat-header) td { padding-bottom: 10px; }

/* Per-row category tags use the Accounts theme color uniformly.
   Only the group HEADERS are colored per category (above). */
.tag.cat-bank,
.tag.cat-investment,
.tag.cat-retirement,
.tag.cat-business,
.tag.cat-credit_card,
.tag.cat-debt,
.tag.cat-digital,
.tag.cat-crypto,
.tag.cat-other {
  color: var(--c-accounts);
  border-color: color-mix(in srgb, var(--c-accounts) 35%, transparent);
  background: color-mix(in srgb, var(--c-accounts) 12%, transparent);
}
/* Red override when key info is missing — must come after the gold rules */
.tag.cat-warn {
  color: var(--danger);
  border-color: rgba(231,107,107,0.5);
  background: rgba(231,107,107,0.15);
}
.data-table td {
  padding: 3px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-size: 13.5px;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .12s ease; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table tr[data-href] { cursor: pointer; }
.data-table tr[data-href]:hover td:first-child { box-shadow: inset 3px 0 0 var(--section, var(--brand)); }

.data-table td.actions { white-space: nowrap; width: 1%; text-align: right; overflow: visible; text-overflow: clip; }
.actions .btn { margin-left: 6px; }
.inline-form { display: inline; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 12px; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }

/* ---------- Dashboard ---------- */
.hero {
  background:
    linear-gradient(135deg, rgba(200,153,104,0.08) 0%, rgba(108,168,194,0.05) 60%, transparent 100%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute; right: -120px; top: -80px;
  width: 360px; height: 360px;
  background: radial-gradient(circle, var(--brand-soft) 0%, transparent 65%);
  pointer-events: none;
}
.hero-eyebrow {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 4px;
}
.hero-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 2px;
  max-width: 720px;
  position: relative; z-index: 1;
}
.hero-sub {
  color: var(--text-2);
  font-size: 12.5px;
  max-width: 720px;
  position: relative; z-index: 1;
}
.hero-meter {
  margin-top: 10px;
  display: flex; flex-direction: column; gap: 6px;
  max-width: 720px;
  position: relative; z-index: 1;
}
.hero-meter-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}
.encryption-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, #6ee7b7 16%, transparent);
  color: #6ee7b7;
  border: 1px solid color-mix(in srgb, #6ee7b7 28%, transparent);
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.02em;
}
.encryption-badge svg { width: 12px; height: 12px; }
.form-card { position: relative; }
.form-card-lock {
  position: absolute;
  top: 14px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: help;
}
.form-card-lock-text {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 500;
}
.form-card-lock-icon { font-size: 16px; }
.hero-meter-row strong {
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}
.hero-meter-row .pct {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--brand);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.meter {
  height: 8px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}
.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-hover) 100%);
  border-radius: 999px;
  transition: width .6s cubic-bezier(.2,.7,.2,1);
}

.section-eyebrow {
  display: flex; align-items: center; justify-content: space-between;
  margin: 28px 0 14px;
}
.section-eyebrow .eyebrow { color: var(--text-muted); }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.dash-card {
  --section: var(--text-muted);
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px 10px;
  text-decoration: none;
  color: var(--text);
  display: flex; flex-direction: column; gap: 6px;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
  overflow: hidden;
}
.dash-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--section);
  opacity: 0.55;
  transition: opacity .15s ease;
}
.dash-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.dash-card:hover::before { opacity: 1; }
.dash-card.is-empty::before { opacity: 0.18; }
.dash-card.is-empty { color: var(--text-2); }
.dash-card.is-empty:hover::before { opacity: 0.5; }

.dash-card-head { display: flex; align-items: center; justify-content: space-between; }
.dash-icon {
  width: 26px; height: 26px;
  border-radius: 7px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--section) 14%, transparent);
  color: var(--section);
  border: 1px solid color-mix(in srgb, var(--section) 24%, transparent);
}
.dash-icon svg { width: 14px; height: 14px; }
.dash-card.is-empty .dash-icon {
  background: var(--surface-2);
  color: var(--text-faint);
  border-color: var(--border);
}
.dash-card-body { display: flex; flex-direction: column; gap: 4px; }
.dash-label {
  font-size: 14px; font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.dash-count { font-size: 12px; color: var(--text-muted); }
.dash-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: auto;
  padding-top: 2px;
}
.dash-arrow {
  color: var(--text-faint);
  transition: color .15s ease, transform .15s ease;
}
.dash-card:hover .dash-arrow { color: var(--section); transform: translateX(2px); }
.dash-arrow svg { width: 16px; height: 16px; }

/* Dashboard section color hooks */
.dash-card.s-letters       { --section: var(--c-letters); }
.dash-card.s-instructions  { --section: var(--c-instructions); }
.dash-card.s-funeral       { --section: var(--c-funeral); }
.dash-card.s-legal         { --section: var(--c-legal); }
.dash-card.s-insurance     { --section: var(--c-insurance); }
.dash-card.s-tax           { --section: var(--c-tax); }
.dash-card.s-accounts      { --section: var(--c-accounts); }
.dash-card.s-property      { --section: var(--c-property); }
.dash-card.s-safe          { --section: var(--c-safe); }
.dash-card.s-subscriptions { --section: var(--c-subscriptions); }
.dash-card.s-contacts      { --section: var(--c-contacts); }
.dash-card.s-medical       { --section: var(--c-medical); }
.dash-card.s-financial     { --section: var(--c-financial); }

/* ---------- Forms ---------- */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 920px;
  box-shadow: var(--shadow-1);
}
.form-row { display: flex; gap: 18px; }
.field {
  display: flex; flex-direction: column;
  margin-bottom: 18px;
  flex: 1;
  min-width: 0;
}
.field.flex2 { flex: 2; }
.field.flex3 { flex: 3; }
.field label {
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 7px;
  text-transform: uppercase; letter-spacing: 0.12em;
}
.field input,
.field select,
.field textarea {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 13px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.field input::placeholder,
.field textarea::placeholder { color: var(--text-faint); }
.field input:hover,
.field select:hover,
.field textarea:hover { border-color: var(--text-faint); }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--surface-3);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.field textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.field input[type="file"] { padding: 7px; }
.letter-body {
  min-height: 360px;
  font-size: 15.5px;
  line-height: 1.85;
  font-family: var(--font-display);
}

.checkbox-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  cursor: pointer;
  flex-direction: row !important;
  margin-bottom: 18px;
  color: var(--text);
}
.checkbox-label input { width: auto; margin: 0; }

.req { color: var(--danger); margin-left: 2px; }
.enc-badge { font-size: 11px; }
.enc-note {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 18px;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  width: max-content;
}
.enc-note svg { width: 12px; height: 12px; color: var(--ok); }

.form-actions {
  display: flex; gap: 12px; align-items: center;
  padding-top: 18px; margin-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.current-file {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: 6px;
  margin-bottom: 10px;
}
.current-file svg { width: 14px; height: 14px; color: var(--brand); }

/* ---------- Detail cards ---------- */
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-1);
}
.detail-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.detail-actions { display: flex; gap: 8px; flex-shrink: 0; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px 28px;
  margin-bottom: 8px;
}
.detail-grid > div { min-width: 0; }
.detail-grid label {
  font-size: 10.5px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  display: block;
  margin-bottom: 4px;
}
.detail-grid p {
  font-size: 14px;
  color: var(--text);
  word-wrap: break-word;
}
.detail-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}
.detail-section label {
  font-size: 10.5px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  display: block;
  margin-bottom: 10px;
}
.detail-body {
  line-height: 1.75;
  white-space: pre-wrap;
  font-size: 14.5px;
  color: var(--text);
}
.detail-card .muted.small {
  margin-top: 14px;
  display: block;
}

/* ---------- File / link helpers ---------- */
.file-link {
  color: var(--brand);
  font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
}
.file-link svg { width: 14px; height: 14px; }
.url-link { font-size: 16px; }

/* ---------- Empty state ---------- */
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 56px 32px;
  text-align: center;
  color: var(--text-2);
  font-size: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.empty-state .empty-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--section, var(--brand));
}
.empty-state .empty-icon svg { width: 22px; height: 22px; }
.empty-state .empty-title {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--text);
}
.empty-state p { max-width: 440px; }
.empty-state .btn { margin-top: 4px; }

/* ---------- Vault password reveal ---------- */
.pw-mask { font-family: var(--font-mono); }
.pw-value { font-family: var(--font-mono); font-size: 13px; }
.hidden { display: none; }
.reveal-hint { color: var(--text-muted); font-size: 12px; margin-top: 8px; }
.reveal-btn { margin-left: 8px; }

/* ---------- Auth pages ---------- */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(800px 480px at 50% -10%, rgba(200,153,104,0.10), transparent 60%),
    radial-gradient(700px 400px at 50% 120%, rgba(108,168,194,0.08), transparent 60%),
    var(--bg);
}
.auth-shell { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; }
.auth-shell-wide { max-width: 480px; }

.auth-mark {
  width: 60px; height: 60px;
  border-radius: 16px;
  background: linear-gradient(160deg, var(--brand) 0%, #8e6a44 100%);
  display: grid; place-items: center;
  margin-bottom: 18px;
  box-shadow:
    0 16px 40px rgba(200,153,104,0.25),
    0 0 0 1px rgba(255,255,255,0.06) inset,
    0 -1px 0 rgba(0,0,0,0.25) inset;
  color: var(--brand-ink);
}
.auth-mark svg { width: 28px; height: 28px; }

.auth-card {
  width: 100%;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 34px 36px 30px;
  box-shadow: var(--shadow-3);
}
.auth-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text);
  text-align: center;
  margin-bottom: 8px;
}
.auth-sub {
  color: var(--text-2);
  font-size: 13.5px;
  text-align: center;
  margin-bottom: 24px;
  line-height: 1.6;
}
.auth-sub strong { color: var(--text); }

.auth-foot {
  margin-top: 22px;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

/* ---------- Modal (custom confirm) ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(8, 10, 16, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  z-index: 100;
}
.modal-backdrop.is-open { display: block; }
.modal {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 48px);
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  padding: 24px 26px 22px;
  z-index: 101;
  display: none;
}
.modal.is-open { display: block; }
.modal-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  display: grid; place-items: center;
  margin-bottom: 14px;
  border: 1px solid rgba(231,107,107,0.3);
}
.modal-icon svg { width: 20px; height: 20px; }
.modal-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.modal-body {
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.55;
  margin-bottom: 20px;
}
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ---------- Utilities ---------- */
.ml-1 { margin-left: 6px; }
.mt-2 { margin-top: 14px; }
.flex { display: flex; }
.gap-2 { gap: 12px; }

/* ---------- Insurance table: many columns, let content size them ---------- */
.data-table.section-insurance { table-layout: auto; }
.data-table.section-insurance td:nth-child(7) { max-width: 220px; }  /* Beneficiaries */
.data-table.section-insurance td:nth-child(4),
.data-table.section-insurance td:nth-child(5) { max-width: 140px; }   /* Coverage, Premium */

/* ---------- Tighter accounts list ---------- */
.data-table.section-accounts td { padding-top: 1px; padding-bottom: 1px; }
.data-table.section-accounts tr.cat-header td { padding-top: 5px; padding-bottom: 5px; }
.data-table.section-accounts tbody > tr[data-href]:has(+ tr.cat-header) td { padding-bottom: 7px; }
.data-table.section-accounts .tag { font-size: 10px; min-width: 78px; padding: 2px 7px; }
.data-table.section-accounts .actions .btn-sm { padding: 3px 7px; font-size: 11px; }
.data-table.section-accounts .actions .btn { margin-left: 3px; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
