/* Billet Finance — the shell.
   Self-hosted only: no CDN, no icon font, no third-party CSS. The Content
   Security Policy forbids external origins entirely, so anything added here
   must ship from this repo. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #16191d;
  --ink-soft: #5b6470;
  --line: #dfe3e8;
  --accent: #1f4b8f;
  --accent-soft: #eaf0f9;
  --good: #1c7c4a;
  --bad: #a32b2b;
  --sidebar-w: 232px;
  --topbar-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --surface: #1c2026;
    --ink: #e8eaed;
    --ink-soft: #9aa4b2;
    --line: #2c323a;
    --accent: #6ea3f0;
    --accent-soft: #1f2937;
    --good: #4caf7d;
    --bad: #e2716b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.4rem; margin: 0 0 1rem; }
a { color: var(--accent); }
.muted { color: var(--ink-soft); }

/* --- top bar ------------------------------------------------------------ */

.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h);
  display: flex; align-items: center; gap: .75rem; padding: 0 1rem;
  background: var(--surface); border-bottom: 1px solid var(--line); z-index: 20;
}
.brand { font-weight: 600; color: var(--ink); text-decoration: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.who { color: var(--ink-soft); font-size: .9rem; }
.inline { display: inline; margin: 0; }
.linkish {
  background: none; border: 0; padding: 0; color: var(--accent);
  cursor: pointer; font: inherit; text-decoration: underline;
}

/* Hamburger is a pure-CSS checkbox toggle — no JavaScript for navigation. */
.hamburger { display: none; flex-direction: column; gap: 4px; cursor: pointer; padding: 6px; }
.hamburger span { display: block; width: 20px; height: 2px; background: var(--ink); }

/* --- sidebar ------------------------------------------------------------ */

.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 1rem .5rem; overflow-y: auto; z-index: 10;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .7rem; margin-bottom: .15rem;
  border-radius: 6px; color: var(--ink); text-decoration: none; font-size: .93rem;
}
.sidebar a:hover { background: var(--accent-soft); }
.sidebar a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.sidebar-note {
  margin: 1rem .7rem; font-size: .8rem; color: var(--ink-soft);
  border-top: 1px solid var(--line); padding-top: .75rem;
}

/* --- content ------------------------------------------------------------ */

.content { padding: calc(var(--topbar-h) + 1.5rem) 1.5rem 3rem calc(var(--sidebar-w) + 1.5rem); }
.bare { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 1.25rem; margin-bottom: 1rem;
}
.auth-card { width: min(380px, 100%); }
.auth-card h1 { text-align: center; }

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

label { display: block; margin: .8rem 0 .3rem; font-size: .85rem; color: var(--ink-soft); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: .55rem .65rem; font: inherit;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
button[type=submit]:not(.linkish):not(.btn-small) {
  margin-top: 1.1rem; width: 100%; padding: .6rem;
  background: var(--accent); color: #fff; border: 0; border-radius: 6px;
  font: inherit; font-weight: 600; cursor: pointer;
}
button[type=submit]:not(.linkish):not(.btn-small):hover { filter: brightness(1.08); }

/* --- flashes ------------------------------------------------------------ */

.flashes { list-style: none; margin: 0 0 1rem; padding: 0; }
.flash {
  padding: .6rem .8rem; border-radius: 6px; margin-bottom: .5rem;
  border: 1px solid var(--line); background: var(--surface); font-size: .9rem;
}
.flash-error { border-color: var(--bad); color: var(--bad); }

/* --- numbers ------------------------------------------------------------ */
/* Money lines up in a column or it is not readable. */
.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  text-align: right; white-space: nowrap;
}
.negative { color: var(--bad); }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); text-align: left; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); }
.table-scroll { overflow-x: auto; }

/* --- small screens ------------------------------------------------------ */

@media (max-width: 780px) {
  .hamburger { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform .18s ease; }
  .nav-toggle:checked ~ .sidebar { transform: translateX(0); }
  .content { padding-left: 1.25rem; padding-right: 1.25rem; }
  .who { display: none; }
}

/* --- settings / dense tables -------------------------------------------- */

h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.small { font-size: .8rem; }
.mt { margin-top: 1.25rem; }
.center { text-align: center; }
.btn-small {
  padding: .3rem .6rem; font: inherit; font-size: .85rem;
  background: var(--accent); color: #fff; border: 0; border-radius: 5px; cursor: pointer;
}
.btn-small:hover { filter: brightness(1.08); }
/* The dense mapping table needs compact controls or it will not fit. */
.accounts select, .accounts input[type=text] {
  padding: .25rem .35rem; font-size: .85rem; width: auto; min-width: 5.5rem;
}
.accounts td { vertical-align: top; }
details summary { cursor: pointer; font-weight: 600; }

/* --- monthly module ------------------------------------------------------ */

.month-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 1rem; margin-bottom: 1rem; }
.month-head h1 { margin: 0; }
.month-nav { display: flex; flex-wrap: wrap; gap: .3rem; }
.month-nav a {
  padding: .2rem .5rem; border-radius: 5px; font-size: .8rem;
  text-decoration: none; color: var(--ink-soft); border: 1px solid var(--line);
}
.month-nav a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* The refill number is the reason the page exists; it should be readable
   from across the room. */
.headline { display: flex; flex-wrap: wrap; gap: 2rem; align-items: flex-start; }
.headline-main { display: flex; flex-direction: column; }
.headline-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.headline-figure {
  font-size: 2.6rem; font-weight: 700; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.headline-split { display: flex; gap: 2rem; margin-left: auto; }
.headline-split > div { display: flex; flex-direction: column; }
.big { font-size: 1.35rem; font-weight: 600; }

.walk-summary { display: flex; flex-wrap: wrap; gap: 2rem; margin-bottom: 1rem; }
.walk-summary > div { display: flex; flex-direction: column; }
.walk-summary .num { font-size: 1.15rem; font-weight: 600; }
tr.low-point td { background: var(--accent-soft); }
tr.trust-row { opacity: .75; }
.tag {
  font-size: .7rem; padding: .1rem .35rem; border-radius: 4px;
  border: 1px solid var(--line); color: var(--ink-soft); margin-left: .35rem;
}
input.num { text-align: right; }
.inline-form { display: flex; align-items: flex-end; gap: .5rem; margin-top: 1rem; }
.inline-form label { margin: 0; }
.inline-form input { width: auto; }
.row-fields { display: flex; flex-wrap: wrap; gap: 1rem; }
.row-fields > div { flex: 1 1 8rem; }
.checkline { display: flex; align-items: center; gap: .4rem; margin-top: .8rem; }
.checkline input { width: auto; }
.btn-small.danger { background: var(--bad); }

@media (max-width: 780px) {
  .headline-split { margin-left: 0; }
  .headline-figure { font-size: 2rem; }
}

/* --- statement ----------------------------------------------------------- */

.statement-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.statement { margin-bottom: 1.25rem; }
.statement thead th { font-size: .78rem; border-bottom: 2px solid var(--line); padding-bottom: .3rem; }
.statement thead th.num { font-size: .95rem; color: var(--ink); font-weight: 700; }
.statement td { border-bottom: 1px dotted var(--line); }
.statement.contingent { border-top: 2px solid var(--line); }
.footnotes { font-size: .85rem; color: var(--ink-soft); padding-left: 1.2rem; }
.stake-list { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.stake {
  font-size: .82rem; padding: .2rem .5rem; border-radius: 5px;
  border: 1px solid var(--line); background: var(--bg);
}
.stake.total { border-color: var(--accent); color: var(--accent); }

@media (max-width: 980px) { .statement-cols { grid-template-columns: 1fr; } }

/* --- net worth chart ----------------------------------------------------- */

.networth-chart { display: block; margin: .5rem 0 1rem; overflow: visible; }
.networth-chart .grid { stroke: var(--line); stroke-width: 1; }
.networth-chart .grid-label {
  fill: var(--ink-soft); font-size: 9px; text-anchor: end;
  font-variant-numeric: tabular-nums;
}
.networth-chart .series {
  fill: none; stroke: var(--accent); stroke-width: 2;
  stroke-linejoin: round; stroke-linecap: round;
}
.networth-chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
/* A filled point is a statement that went to a lender. */
.networth-chart .dot.issued { fill: var(--accent); }
