/* Ledger — warm-ink terminal. Gold echoes the Providus alert table header. */
:root {
  --bg: #0f0d0a;
  --panel: #16130e;
  --panel-2: #1b1711;
  --line: #2b2419;
  --line-soft: #211c14;
  --text: #ece4d3;
  --muted: #9a8f7a;
  --gold: #d4a72c;
  --gold-soft: rgba(212, 167, 44, 0.14);
  --debit: #e07a6b;
  --credit: #82b87c;
  --radius: 4px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 500px at 50% -12%, rgba(212, 167, 44, 0.07), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

:where(a, button, select, input, textarea, summary):focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px 72px; }

/* ---------------------------------------------------------------- masthead */
.masthead {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 22px 0 14px;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  font-family: var(--mono);
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.34em; text-transform: uppercase;
  color: var(--gold);
}
.wordmark span { color: var(--muted); letter-spacing: 0.18em; }
.masthead nav { display: flex; gap: 18px; font-size: 13px; }
.masthead nav a { color: var(--muted); }
.masthead nav a:hover { color: var(--gold); }

/* ------------------------------------------------------------------- hero */
.hero {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 24px; flex-wrap: wrap;
  padding: 34px 0 26px;
  border-bottom: 1px solid var(--line);
}
.hero-label {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 10px;
}
.hero-balance {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: clamp(2.1rem, 6vw, 3.4rem); font-weight: 600;
  letter-spacing: -0.02em; line-height: 1;
}
.hero-balance .cur { color: var(--gold); font-size: 0.42em; letter-spacing: 0.1em; margin-right: 0.5em; vertical-align: 0.42em; }
.hero-sub { color: var(--muted); font-size: 13px; margin-top: 10px; }

.sync { text-align: right; font-size: 12.5px; color: var(--muted); }
.sync-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; background: var(--muted); vertical-align: 1px; }
.sync-ok .sync-dot { background: var(--credit); }
.sync-error .sync-dot { background: var(--debit); }
.sync-skipped .sync-dot { background: var(--gold); }
.sync form { margin-top: 10px; }

/* ------------------------------------------------------------------ cards */
.cards {
  display: grid; gap: 1px; background: var(--line-soft);
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line); border-radius: var(--radius);
  margin: 26px 0; overflow: hidden;
}
.card { background: var(--panel); padding: 18px 20px; }
.card-label {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--muted);
}
.card-value {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 1.5rem; margin-top: 8px; letter-spacing: -0.01em;
}
.card-value.out { color: var(--debit); }
.card-value.in { color: var(--credit); }

/* ------------------------------------------------------------------ panels */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
}
.panel h2, .panel h3 {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--muted);
  margin: 0 0 16px; font-weight: 500;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 26px; }
.chart-box { position: relative; height: 260px; }

.cat-list { list-style: none; margin: 16px 0 0; padding: 0; font-size: 13px; }
.cat-list li { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-top: 1px solid var(--line-soft); }
.swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.cat-list .name { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-list .amt { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------------- filters */
.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 18px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted);
}
select, input[type="text"], input[type="password"], input[type="search"], textarea {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px; font-family: var(--sans); font-size: 13.5px;
  min-height: 36px;
}
textarea { font-family: var(--mono); font-size: 12.5px; width: 100%; resize: vertical; }
.btn {
  background: var(--gold-soft); color: var(--gold);
  border: 1px solid rgba(212, 167, 44, 0.42); border-radius: var(--radius);
  padding: 8px 15px; font-size: 13px; font-weight: 500; cursor: pointer;
  min-height: 36px; font-family: var(--sans);
}
.btn:hover { background: rgba(212, 167, 44, 0.24); }
.btn-quiet {
  background: transparent; color: var(--muted); border-color: var(--line);
}
.btn-quiet:hover { color: var(--text); border-color: var(--gold); background: transparent; }

/* ------------------------------------------------------------------ ledger */
.ledger { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ledger-head, .row-main {
  display: grid;
  grid-template-columns: 96px minmax(140px, 1fr) minmax(0, 1.5fr) 190px 150px;
  gap: 14px; align-items: center;
}
.ledger-head {
  padding: 10px 16px; background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted);
}
.ledger-head .amt-col, .row .amount { text-align: right; }
.row { border-top: 1px solid var(--line-soft); background: var(--panel); }
.row:first-child { border-top: none; }
.row:hover { background: var(--panel-2); }
.row-main { padding: 12px 16px; }
.row .date { font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row .payee { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.row .narrative { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amount {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 14.5px; white-space: nowrap;
}
.row .amount.debit { color: var(--debit); }
.row .amount.credit { color: var(--credit); }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 100px;
  padding: 3px 11px; font-size: 11.5px; color: var(--muted);
  cursor: pointer; list-style: none; max-width: 100%;
}
.pill::-webkit-details-marker { display: none; }
.pill:hover { border-color: var(--gold); color: var(--text); }
.pill .tick { color: var(--gold); font-size: 9px; }
.pill .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details[open] > .pill { border-color: var(--gold); color: var(--text); }
.pill.business { border-color: rgba(212, 167, 44, 0.45); }

.edit {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 0 16px 14px 112px; font-size: 13px;
}
.edit label.check { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; }
.edit select { min-height: 34px; padding: 6px 8px; }

.empty { padding: 44px 16px; text-align: center; color: var(--muted); background: var(--panel); }

/* ------------------------------------------------------------------- misc */
.flash {
  margin: 16px 0 0; padding: 10px 14px;
  border: 1px solid rgba(212, 167, 44, 0.4); border-left-width: 3px;
  background: var(--gold-soft); border-radius: var(--radius); font-size: 13px;
}
.note { color: var(--muted); font-size: 12.5px; }
.section-title {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 16px; margin: 30px 0 14px; flex-wrap: wrap;
}
.section-title h2 {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--muted); margin: 0; font-weight: 500;
}
details.tool { margin-top: 26px; }
details.tool > summary {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted); cursor: pointer; padding: 8px 0;
}
details.tool > summary:hover { color: var(--gold); }

/* ------------------------------------------------------------------ login */
.login-shell { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 350px; }
.login-card .wordmark { display: block; text-align: center; margin-bottom: 26px; font-size: 15px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input { width: 100%; }
.login-error { color: var(--debit); font-size: 13px; text-align: center; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .ledger-head { display: none; }
  .row-main {
    grid-template-columns: 1fr auto;
    grid-template-areas: "date amount" "payee amount" "narr narr" "cat cat";
    gap: 6px 12px;
  }
  .row .date { grid-area: date; }
  .row .payee { grid-area: payee; }
  .row .narrative { grid-area: narr; white-space: normal; }
  .row .cat-cell { grid-area: cat; margin-top: 4px; }
  .row .amount { grid-area: amount; align-self: center; font-size: 15px; }
  .edit { padding: 0 16px 14px; }
  .edit select, .edit .btn { flex: 1 1 140px; }
}

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

/* the whole row is the disclosure control for its edit form */
summary.row-main { cursor: pointer; list-style: none; }
summary.row-main::-webkit-details-marker { display: none; }
.row details[open] { background: var(--panel-2); }
.row details[open] summary.row-main { border-bottom: 1px solid var(--line-soft); }
