/*
 * KuuniFinance — theme.css
 *
 * Design tokens, reset, and the components shared by both pages. Page-specific
 * rules live in dashboard.css and tools.css.
 *
 * Palette, type and button shapes match the Kuuni Partners site (theme.css at
 * the site root) so the two read as one brand. Fraunces/Inter load from Google
 * Fonts with full system fallbacks, so the app still works offline.
 *
 * Money figures are always monospace with tabular numerals so columns of
 * dollars line up like a ledger.
 */

:root {
  /* Kuuni Partners palette. Navy is the brand primary, gold the single accent. */
  --navy: #0f2440;
  --navy-800: #16345c;
  --navy-600: #1e4a80;
  --gold: #c8a45c;
  --gold-600: #b28c42;

  /* Neutrals, matched to the main site. */
  --paper: #f5f7fa;
  --surface: #ffffff;
  --surface-sunk: #eef2f7;
  --ink: #14202e;
  --ink-soft: #3a4757;
  --ink-faint: #6b7787;
  --rule: #e3e8ee;
  --rule-soft: #eef2f6;

  /* The accent the app paints with is the brand navy; gold is reserved for
     emphasis and highlights, exactly as on the marketing site. */
  --accent: #1e4a80;
  --accent-hover: #16345c;
  --accent-wash: #e7eef7;
  --on-accent: #ffffff;

  /* Semantic state, deliberately distinct from both brand hues. */
  --good: #1e7a57;
  --good-wash: #e2f0e9;
  --warn: #b28c42;
  --warn-wash: #f7efe0;
  --risk: #b3402c;
  --risk-wash: #f8e7e3;

  --focus: #c8a45c;
  --shadow-card: 0 1px 2px rgba(15, 36, 64, 0.05), 0 10px 30px rgba(15, 36, 64, 0.08);
  --shadow-pop: 0 4px 14px rgba(15, 36, 64, 0.06), 0 18px 44px -20px rgba(15, 36, 64, 0.35);

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --gap: 1.25rem;
}

@media (prefers-color-scheme: dark) {
  /* Dark mode derived from the brand navy rather than a neutral grey, so the
     app still reads as Kuuni in either theme. */
  :root:not([data-theme="light"]) {
    --navy: #0f2440;
    --navy-800: #16345c;
    --navy-600: #1e4a80;
    --gold: #d8b36a;
    --gold-600: #c8a45c;

    --paper: #0a1626;
    --surface: #102138;
    --surface-sunk: #0c1a2c;
    --ink: #e8eef6;
    --ink-soft: #a9bace;
    --ink-faint: #7e91a8;
    --rule: #22395a;
    --rule-soft: #1a2e4a;

    --accent: #7fa8d8;
    --accent-hover: #9bbce4;
    --accent-wash: #15294a;
    --on-accent: #08121f;

    --good: #5bbf96;
    --good-wash: #102b22;
    --warn: #d8b36a;
    --warn-wash: #2e2512;
    --risk: #e0836f;
    --risk-wash: #331c17;

    --focus: #c8a45c;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.5), 0 12px 30px -20px rgba(0, 0, 0, 0.9);
    --shadow-pop: 0 2px 8px rgba(0, 0, 0, 0.55), 0 20px 44px -24px rgba(0, 0, 0, 0.95);
  }
}

:root[data-theme="dark"] {
  --navy: #0f2440;
  --navy-800: #16345c;
  --navy-600: #1e4a80;
  --gold: #d8b36a;
  --gold-600: #c8a45c;

  --paper: #0a1626;
  --surface: #102138;
  --surface-sunk: #0c1a2c;
  --ink: #e8eef6;
  --ink-soft: #a9bace;
  --ink-faint: #7e91a8;
  --rule: #22395a;
  --rule-soft: #1a2e4a;

  --accent: #7fa8d8;
  --accent-hover: #9bbce4;
  --accent-wash: #15294a;
  --on-accent: #08121f;

  --good: #5bbf96;
  --good-wash: #102b22;
  --warn: #d8b36a;
  --warn-wash: #2e2512;
  --risk: #e0836f;
  --risk-wash: #331c17;

  --focus: #c8a45c;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.5), 0 12px 30px -20px rgba(0, 0, 0, 0.9);
  --shadow-pop: 0 2px 8px rgba(0, 0, 0, 0.55), 0 20px 44px -24px rgba(0, 0, 0, 0.95);
}

/* ------------------------------- reset -------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

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

h1,
h2,
h3,
h4,
p,
figure {
  margin: 0;
}

/* Headings in Fraunces, as on the marketing site. */
h1,
h2,
h3,
h4 {
  font-family: var(--serif);
  color: var(--ink);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold-600);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

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

/* ------------------------------- layout ------------------------------- */

.shell {
  max-width: 74rem;
  margin: 0 auto;
  padding: 0 1.25rem 5rem;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--on-accent);
  padding: 0.6rem 1rem;
  z-index: 50;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* ------------------------------- header ------------------------------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
}

.masthead-inner {
  max-width: 74rem;
  margin: 0 auto;
  padding: 0.7rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 72px;
}

/* Brand lockup mirrors the Kuuni site header: crest, then stacked wordmark
   over a small attribution line. */
.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}

.wordmark-crest {
  height: 44px;
  width: auto;
  object-fit: contain;
  flex: 0 0 auto;
}

.wordmark-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}

.wordmark-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.32rem;
  letter-spacing: -0.01em;
  color: var(--navy);
}

.wordmark-name em {
  font-style: normal;
  color: var(--gold-600);
}

.wordmark-tag {
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.mainnav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
}

.mainnav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
}

.mainnav a:hover {
  background: var(--surface-sunk);
  color: var(--ink);
}

.mainnav a[aria-current="page"] {
  background: var(--accent-wash);
  color: var(--navy-600);
  font-weight: 600;
}

@media (max-width: 34rem) {
  .masthead-inner { gap: 0.6rem; padding-inline: 1rem; }
  .wordmark { gap: 9px; }
  .wordmark-crest { height: 36px; }
  .wordmark-name { font-size: 1.12rem; }
  .wordmark-tag { font-size: 0.6rem; letter-spacing: 0.1em; }
  .mainnav a { padding: 0.4rem 0.6rem; font-size: 0.86rem; }
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.25rem;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.card-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.card-question {
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* ------------------------------ figures ------------------------------- */

/* Every dollar amount on screen uses .fig, so columns always align. */
.fig {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.fig-xl {
  font-size: 2.4rem;
  font-weight: 600;
  line-height: 1.05;
}

.fig-lg {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.15;
}

.fig-sm {
  font-size: 0.9rem;
  font-weight: 550;
}

.is-good {
  color: var(--good);
}

.is-warn {
  color: var(--warn);
}

.is-risk {
  color: var(--risk);
}

.muted {
  color: var(--ink-soft);
}

.faint {
  color: var(--ink-faint);
}

/* ------------------------------- pills -------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.pill-good {
  background: var(--good-wash);
  color: var(--good);
}

.pill-warn {
  background: var(--warn-wash);
  color: var(--warn);
}

.pill-risk {
  background: var(--risk-wash);
  color: var(--risk);
}

.pill-neutral {
  background: var(--surface-sunk);
  color: var(--ink-soft);
}

/* ------------------------------- meters ------------------------------- */

.meter {
  height: 8px;
  background: var(--surface-sunk);
  border-radius: 999px;
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.meter.good > span {
  background: var(--good);
}

.meter.warn > span {
  background: var(--warn);
}

.meter.risk > span {
  background: var(--risk);
}

/* ------------------------------ controls ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.6rem 1.4rem;
  /* Pill shape, as on the Kuuni marketing site. */
  border-radius: 999px;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #fff;
  font-size: 0.93rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }

.btn:hover {
  background: var(--navy-800);
}

.btn-ghost {
  background: transparent;
  color: var(--navy);
  border-color: rgba(15, 36, 64, 0.25);
}

.btn-ghost:hover {
  background: rgba(15, 36, 64, 0.05);
}

.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
}

.btn-quiet:hover {
  background: var(--accent-wash);
}

/*
 * Remove control. Sized to the 44px minimum touch target on coarse pointers —
 * these sit close to the inputs beside them and a mis-tap deletes a row.
 */
.btn-danger {
  background: transparent;
  border-color: transparent;
  color: var(--risk);
  padding: 0.3rem 0.45rem;
  font-size: 1.05rem;
  line-height: 1;
  min-width: 1.9rem;
  min-height: 1.9rem;
}

@media (pointer: coarse) {
  .btn-danger {
    min-width: 44px;
    min-height: 44px;
    font-size: 1.25rem;
  }
}

.btn-danger:hover {
  background: var(--risk-wash);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field > label,
.field-label {
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--ink-soft);
}

.field-hint {
  font-size: 0.76rem;
  color: var(--ink-faint);
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}

input[type="number"] {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

input:hover,
select:hover {
  border-color: var(--ink-faint);
}

/* ------------------------------- tables ------------------------------- */

.tablewrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--rule-soft);
}

thead th {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--rule);
}

td.num,
th.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

tbody tr:last-child td {
  border-bottom: 0;
}

/* ------------------------------ utilities ----------------------------- */

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.spread {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.empty {
  color: var(--ink-faint);
  font-size: 0.9rem;
  padding: 0.75rem 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------- footer ------------------------------- */

.pagefoot {
  border-top: 1px solid var(--rule);
  margin-top: 3rem;
  padding-top: 1.25rem;
  font-size: 0.83rem;
  color: var(--ink-faint);
  display: flex;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.pagefoot a {
  color: var(--accent);
}
