/* ==========================================================================
   Probate Plan - shared visual system
   Palette intent: quiet, warm, and dignified. Brand navy for structure,
   brand gold for accent, clay instead of alarm-red for urgency, all on warm
   cream. Nothing here should feel like a bank dashboard or a hospital form.
   ========================================================================== */

/* Palette derived from the ProbatePlan.store mark: brand navy #002454 and
   brand gold #CC9C3C, set on warm cream so the whole thing reads dignified
   rather than cold or clinical. */
:root {
  --paper:        #FBF9F5;
  --surface:      #FFFFFF;
  --surface-alt:  #F4F1EB;
  --surface-sunk: #EDE8DF;

  --ink:    #1F2937;
  --ink-2:  #55606F;
  --ink-3:  #8A939F;

  --line:      #E3DED4;
  --line-soft: #EEEAE2;

  --navy:         #002454;  /* exact brand navy */
  --primary:      #1B3E68;
  --primary-2:    #002454;
  --primary-soft: #E8EDF4;

  --sage:      #5E7A9B;     /* soft slate blue, drawn from the mark's mid tone */
  --sage-soft: #EAEFF5;

  --gold:      #B0862F;     /* brand gold, darkened for text contrast */
  --gold-bright: #CC9C3C;   /* exact brand gold, for fills and seals */
  --gold-soft: #FAF2E1;

  --clay:      #A85843;
  --clay-soft: #F8E9E4;

  --success:      #4F7A5C;
  --success-soft: #E8F1EA;

  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 1px 2px rgba(38,51,47,.05), 0 4px 16px rgba(38,51,47,.06);
  --shadow-lg: 0 2px 6px rgba(38,51,47,.07), 0 12px 32px rgba(38,51,47,.10);

  --serif: Georgia, "Liberation Serif", "DejaVu Serif", "Times New Roman", serif;
  --sans:  system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:  ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  --paper:        #131820;
  --surface:      #1A212B;
  --surface-alt:  #171E27;
  --surface-sunk: #111721;

  --ink:    #E7EAEF;
  --ink-2:  #A6B0BE;
  --ink-3:  #75808E;

  --line:      #2C3644;
  --line-soft: #232C38;

  --navy:         #7FA3D0;
  --primary:      #7FA3D0;
  --primary-2:    #A3C0E4;
  --primary-soft: #1B2735;

  --sage:      #8AA4C4;
  --sage-soft: #1B2530;

  --gold:      #D8B368;
  --gold-bright: #E0BC74;
  --gold-soft: #2B2519;

  --clay:      #CE8570;
  --clay-soft: #34241F;

  --success:      #7FA98A;
  --success-soft: #1F2C23;

  --shadow:    0 1px 2px rgba(0,0,0,.30), 0 4px 16px rgba(0,0,0,.28);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.35), 0 12px 32px rgba(0,0,0,.40);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.25; color: var(--ink); }
h1 { font-size: 1.85rem; margin: 0 0 .35em; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; margin: 1.8em 0 .6em; }
h3 { font-size: 1.1rem;  margin: 1.5em 0 .5em; }
a { color: var(--primary); text-decoration-color: color-mix(in srgb, var(--primary) 35%, transparent); text-underline-offset: 2px; }
a:hover { color: var(--primary-2); }

/* ------------------------------------------------------------------ shell */

.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { padding: 0 20px 16px; border-bottom: 1px solid var(--line-soft); margin-bottom: 14px; }
.brand a { display: block; text-decoration: none; }
.brand-logo { width: 100%; max-width: 200px; height: auto; display: block; }

/* Two real assets rather than a CSS filter: the inverse artwork keeps the gold
   and blue of the mark instead of flattening it to a single hue. Both are
   ~13 KB, so loading the pair costs less than the single oversized PNG did. */
.logo-dark  { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark  { display: block; }
.brand-sub {
  font-size: .7rem; color: var(--ink-3); margin-top: 7px;
  letter-spacing: .09em; text-transform: uppercase; font-weight: 600;
}
/* Fallback wordmark, used only if the logo file is missing. */
.brand-mark {
  font-family: var(--serif); font-size: 1.15rem; font-weight: 600;
  color: var(--primary-2); display: flex; align-items: center; gap: 9px; letter-spacing: -.01em;
}

.nav { padding: 0 12px; }
.nav-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-3); padding: 14px 10px 6px; font-weight: 600;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-size: .9rem;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-alt); color: var(--ink); }
.nav a.active { background: var(--primary-soft); color: var(--primary-2); font-weight: 600; }
.nav a .count {
  margin-left: auto; font-size: .74rem; color: var(--ink-3);
  background: var(--surface-alt); padding: 1px 7px; border-radius: 20px;
}
.nav a.active .count { background: var(--surface); color: var(--primary); }
.nav a .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--clay); margin-left: auto; }

/* min-width:0 lets this grid column shrink below its content width, so the wide
   table scrolls inside .grid-wrap instead of forcing the whole page sideways. */
.main { padding: 30px 38px 70px; max-width: 1500px; min-width: 0; overflow-x: hidden; }
.page-head { margin-bottom: 26px; }
.page-head .eyebrow {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--gold); font-weight: 700; margin-bottom: 7px;
}
.page-head p.lede { color: var(--ink-2); max-width: 70ch; margin: .4em 0 0; font-size: .96rem; }

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 12px;
}
.card-head h2, .card-head h3 { margin: 0; font-size: 1.05rem; }
.card-head .sub { color: var(--ink-3); font-size: .85rem; margin-left: auto; }
.card-body { padding: 20px; }
.card-body > p:first-child { margin-top: 0; }

/* ------------------------------------------------------------------ stats */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-3); font-weight: 600; margin-bottom: 7px;
}
.stat .value { font-family: var(--serif); font-size: 1.62rem; line-height: 1.1; color: var(--ink); }
.stat .value.muted { color: var(--ink-3); font-style: italic; font-size: 1.05rem; }
.stat .foot { font-size: .78rem; color: var(--ink-3); margin-top: 6px; }
.stat.accent-gold  { border-left: 3px solid var(--gold); }
.stat.accent-clay  { border-left: 3px solid var(--clay); }
.stat.accent-sage  { border-left: 3px solid var(--sage); }
.stat.accent-primary { border-left: 3px solid var(--primary); }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .72rem; font-weight: 600; padding: 2px 9px;
  border-radius: 20px; border: 1px solid transparent; white-space: nowrap;
}
.badge-urgent  { background: var(--clay-soft);    color: var(--clay);    border-color: color-mix(in srgb, var(--clay) 22%, transparent); }
.badge-high    { background: var(--gold-soft);    color: var(--gold);    border-color: color-mix(in srgb, var(--gold) 22%, transparent); }
.badge-medium  { background: var(--surface-alt);  color: var(--ink-2);   border-color: var(--line); }
.badge-low     { background: var(--surface-alt);  color: var(--ink-3);   border-color: var(--line); }
.badge-ok      { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.badge-info    { background: var(--primary-soft); color: var(--primary-2); border-color: color-mix(in srgb, var(--primary) 20%, transparent); }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  font: inherit; font-size: .88rem; font-weight: 600;
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none; transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-alt); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-gold:hover { filter: brightness(.94); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-alt); color: var(--ink); }
.btn-sm { padding: 5px 11px; font-size: .8rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ----------------------------------------------------------------- forms */

.field { margin-bottom: 20px; }
.field-label {
  display: flex; align-items: baseline; gap: 8px;
  font-weight: 600; font-size: .9rem; margin-bottom: 5px; color: var(--ink);
}
.field-label .req { color: var(--clay); font-size: .7rem; font-weight: 700; letter-spacing: .05em; }
.help {
  font-size: .84rem; color: var(--ink-2); line-height: 1.55;
  margin: 0 0 8px; max-width: 68ch;
  border-left: 2px solid var(--line); padding-left: 11px;
}
.help a { font-weight: 600; }

input[type=text], input[type=date], input[type=number], input[type=email],
input[type=password], select, textarea {
  width: 100%; max-width: 520px; font: inherit; font-size: .92rem;
  padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 78px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}
input.money { max-width: 200px; text-align: right; font-variant-numeric: tabular-nums; }
.saved-flash { color: var(--success); font-size: .78rem; opacity: 0; transition: opacity .3s; }
.saved-flash.show { opacity: 1; }

/* -------------------------------------------------------------- progress */

.progress { height: 7px; background: var(--surface-sunk); border-radius: 20px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--sage); border-radius: 20px; transition: width .4s; }

/* ------------------------------------------------------------ wizard nav */

.steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 26px; }
.step {
  display: flex; align-items: center; gap: 8px; text-decoration: none;
  padding: 9px 15px; border-radius: 30px; font-size: .87rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  transition: all .14s;
}
.step:hover { border-color: var(--sage); color: var(--ink); }
.step.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.step .n {
  width: 21px; height: 21px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: .72rem;
  background: var(--surface-alt); color: var(--ink-2);
}
.step.active .n { background: rgba(255,255,255,.22); color: #fff; }
.step.done .n { background: var(--success-soft); color: var(--success); }
.step.done { border-color: color-mix(in srgb, var(--success) 30%, transparent); }

/* ------------------------------------------------------------------ grid */

.grid-wrap {
  overflow-x: auto; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .86rem; }
table.grid th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-alt); color: var(--ink-2);
  font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.grid th .hint {
  display: inline-grid; place-items: center; width: 14px; height: 14px; margin-left: 5px;
  border-radius: 50%; background: var(--line); color: var(--ink-2);
  font-size: .62rem; cursor: help; vertical-align: middle; font-weight: 700;
}
table.grid td { padding: 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.grid tbody tr:hover td { background: color-mix(in srgb, var(--sage-soft) 55%, transparent); }
table.grid tbody tr.is-done td { opacity: .55; }
table.grid tbody tr.row-urgent { box-shadow: inset 3px 0 0 var(--clay); }

.cell-input {
  width: 100%; border: 1px solid transparent; background: transparent;
  font: inherit; font-size: .86rem; color: var(--ink);
  padding: 8px 10px; border-radius: 0; min-height: 36px;
}
.cell-input:hover { background: var(--surface-alt); }
.cell-input:focus {
  outline: none; background: var(--surface);
  border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary);
}
.cell-input.money { text-align: right; font-variant-numeric: tabular-nums; }
.cell-input.dirty { background: var(--gold-soft); }
textarea.cell-input { min-height: 36px; resize: vertical; line-height: 1.4; }
select.cell-input { appearance: none; cursor: pointer; }

.grid-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.grid-toolbar .spacer { margin-left: auto; }
.search-box {
  display: flex; align-items: center; gap: 7px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 10px; max-width: 300px;
}
.search-box input { border: none; box-shadow: none !important; padding: 7px 0; max-width: none; }
.search-box svg { color: var(--ink-3); flex: none; }

.row-actions { display: flex; gap: 3px; padding: 4px 6px; }
.icon-btn {
  border: none; background: transparent; color: var(--ink-3); cursor: pointer;
  padding: 4px; border-radius: 4px; line-height: 0;
}
.icon-btn:hover { background: var(--surface-alt); color: var(--clay); }

.subtotal-row td {
  background: var(--surface-alt) !important; font-weight: 700;
  border-top: 2px solid var(--line); font-size: .84rem;
}

/* --------------------------------------------------------------- tooltip */

/* Fixed positioning keeps the tooltip clear of .grid-wrap's overflow clipping.
   grid.js moves and clamps it to the viewport. */
.tip-float {
  position: fixed; z-index: 200; max-width: 330px;
  background: var(--ink); color: #F3F1EC;
  padding: 11px 13px; border-radius: var(--radius-sm); font-size: .8rem;
  line-height: 1.5; font-weight: 400; text-transform: none; letter-spacing: 0;
  box-shadow: var(--shadow-lg); pointer-events: none;
  opacity: 0; visibility: hidden; transition: opacity .12s, visibility .12s;
}
.tip-float.show { opacity: 1; visibility: visible; }
:root[data-theme="dark"] .tip-float { background: #0C1219; color: #E7EAEF; }

/* --------------------------------------------------------------- notices */

.notice {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface-alt);
  font-size: .89rem; line-height: 1.55; margin-bottom: 18px;
}
.notice svg { flex: none; margin-top: 2px; }
.notice > div > strong:first-child { display: block; margin-bottom: 2px; }
.notice-urgent { background: var(--clay-soft); border-color: color-mix(in srgb, var(--clay) 25%, transparent); color: var(--ink); }
.notice-urgent svg { color: var(--clay); }
.notice-info { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 20%, transparent); }
.notice-info svg { color: var(--primary); }
.notice-gold { background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 25%, transparent); }
.notice-gold svg { color: var(--gold); }
.notice-ok { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.notice-ok svg { color: var(--success); }

/* --------------------------------------------------------------- signoff */

.signer {
  display: flex; align-items: center; gap: 13px; padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
}
.signer:last-child { border-bottom: none; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-2);
  font-weight: 700; font-size: .88rem; font-family: var(--serif);
}
.avatar.signed { background: var(--success-soft); color: var(--success); }
.signer .who { font-weight: 600; }
.signer .when { font-size: .8rem; color: var(--ink-3); }
.signer .state { margin-left: auto; }

.seal {
  text-align: center; padding: 26px; border: 2px solid var(--gold);
  border-radius: var(--radius); background: var(--gold-soft);
}
.seal .seal-mark { font-family: var(--serif); font-size: 1.3rem; color: var(--gold); margin-bottom: 5px; }
.seal .hash { font-family: var(--mono); font-size: .76rem; color: var(--ink-2); }

/* ----------------------------------------------------------------- guide */

.guide-layout { display: grid; grid-template-columns: 1fr 250px; gap: 34px; align-items: start; }
.guide-toc { position: sticky; top: 26px; font-size: .85rem; }
.guide-toc a {
  display: block; padding: 4px 9px; color: var(--ink-2);
  text-decoration: none; border-left: 2px solid var(--line); line-height: 1.4;
}
.guide-toc a:hover { color: var(--primary); border-left-color: var(--sage); background: var(--surface-alt); }

.prose { max-width: 76ch; }
.prose h2 { padding-top: 14px; border-top: 1px solid var(--line-soft); }
.prose table { width: 100%; border-collapse: collapse; margin: 1.2em 0; font-size: .88rem; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 11px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-alt); font-family: var(--sans); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; }
.prose td[align=right], .prose th[align=right] { text-align: right; }
.prose code { background: var(--surface-alt); padding: 1px 5px; border-radius: 4px; font-size: .88em; }
.prose blockquote { border-left: 3px solid var(--sage); margin: 1em 0; padding: 2px 0 2px 15px; color: var(--ink-2); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .3em 0; }
.prose hr { border: none; border-top: 1px solid var(--line); margin: 2em 0; }

/* ---------------------------------------------------------------- misc */

.muted { color: var(--ink-3); }
.small { font-size: .84rem; }
.mono { font-family: var(--mono); font-size: .84em; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt0 { margin-top: 0; }
.stack > * + * { margin-top: 16px; }
.divider { height: 1px; background: var(--line); margin: 24px 0; }

.legal-note {
  font-size: .8rem; color: var(--ink-3); line-height: 1.55;
  border-top: 1px solid var(--line); padding-top: 14px; margin-top: 30px; max-width: 76ch;
}

.empty {
  text-align: center; padding: 44px 20px; color: var(--ink-3);
}
.empty svg { color: var(--line); margin-bottom: 10px; }

/* ----------------------------------------------------------------- auth */

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .card-body { padding: 30px; }
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head .leaf { width: 38px; height: 38px; color: var(--sage); }

/* --------------------------------------------------------------- topbar */

.topbar {
  display: flex; align-items: center; gap: 14px; margin-bottom: 22px;
  padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.topbar .spacer { margin-left: auto; }
.user-chip {
  display: flex; align-items: center; gap: 8px; font-size: .86rem; color: var(--ink-2);
}

@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .main { padding: 22px 18px 60px; }
  .guide-layout { grid-template-columns: 1fr; }
  .guide-toc { position: static; }
}
