/* ============================================================
   LifeLedger
   Direction: a ledger, not a dashboard. Money is set in tabular
   mono and ruled off with hairlines, the way a bound account book
   does it. One accent — oxidised copper, borrowed from the
   coppersmiths' row in Baščaršija — carries every positive figure.
   Debt answers in plum. Nothing else is allowed to shout.

   To use the intended display face, drop Bricolage Grotesque woff2
   files into /assets/fonts and uncomment the @font-face below.
   The fallback stack is deliberate, not an afterthought.
   ============================================================ */

/*
@font-face {
  font-family: 'Bricolage';
  src: url('/assets/fonts/bricolage-grotesque.woff2') format('woff2');
  font-weight: 200 800; font-display: swap;
}
*/

:root {
  --ink:        #0D1317;
  --panel:      #131C22;
  --panel-2:    #18232A;
  --line:       #24343D;
  --line-soft:  #1B282F;

  --copper:     #4FA894;   /* the accent. income, positive, primary action */
  --copper-dim: #2F6B5E;
  --plum:       #A45D80;   /* debt, outflow */
  --amber:      #D2A24C;   /* attention */
  --rust:       #C25B4E;   /* danger, destructive */

  --paper:      #E9E7DF;
  --paper-dim:  #A9B4BB;
  --mute:       #6F818C;

  --display: 'Bricolage', 'Archivo', 'Helvetica Neue', -apple-system, sans-serif;
  --body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:    'JetBrains Mono', 'SF Mono', ui-monospace, 'Cascadia Mono', Menlo, monospace;

  --r: 4px;              /* restrained radius. this is paperwork. */
  --gut: 22px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background: var(--ink);
  color: var(--paper);
  font: 15px/1.55 var(--body);
  font-feature-settings: 'kern' 1, 'liga' 1;
  -webkit-font-smoothing: antialiased;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  background: var(--copper); color: var(--ink); padding: 10px 16px;
}
.skip:focus { left: 8px; top: 8px; }

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

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

.rail {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 20px 0;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.rail__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 22px;
  font-family: var(--display);
  font-size: 17px; font-weight: 600; letter-spacing: -0.02em;
}
.rail__mark {
  display: grid; place-items: center;
  width: 28px; height: 28px;
  background: var(--copper); color: var(--ink);
  border-radius: var(--r);
  font-weight: 700; font-size: 15px;
}

.rail__nav { display: flex; flex-direction: column; padding: 0 10px; gap: 1px; }

.rail__link {
  color: var(--paper-dim);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--r);
  font-size: 14px;
  border-left: 2px solid transparent;
  transition: background .12s, color .12s;
}
.rail__link:hover { background: var(--panel-2); color: var(--paper); }
.rail__link.is-on {
  background: var(--panel-2);
  color: var(--paper);
  border-left-color: var(--copper);
}
.rail__link--small { font-size: 13px; padding: 6px 12px; }

.rail__foot {
  margin-top: auto; padding: 16px 10px 0;
  border-top: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 1px;
}
.rail__out { padding: 6px 12px; }
.rail__who {
  padding: 6px 12px; font-size: 11px; color: var(--mute);
  text-transform: uppercase; letter-spacing: .08em;
}

.main { padding: 32px var(--gut) 64px; max-width: 1180px; }

.navtoggle-input, .navtoggle-btn { display: none; }

/* ---------------------------------------------------------- type */

h1 {
  font-family: var(--display);
  font-size: 26px; font-weight: 600; letter-spacing: -0.025em;
  margin-bottom: 4px;
}
h2 {
  font-family: var(--display);
  font-size: 16px; font-weight: 600; letter-spacing: -0.01em;
  margin-bottom: 12px;
}
h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }

.blurb { color: var(--mute); font-size: 14px; margin-bottom: 24px; }

.eyebrow {
  font: 500 10px/1 var(--mono);
  text-transform: uppercase; letter-spacing: .14em;
  color: var(--mute);
  margin-bottom: 10px;
}

.pagehead {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 24px;
}

/* Every figure in the app. Tabular so columns line up like a ledger. */
.fig {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.fig--in  { color: var(--copper); }
.fig--out { color: var(--plum); }

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

.grid { display: grid; gap: 12px; }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
}
.card--pad { padding: 22px; }

/* Signature: the stat rule. A hairline in the accent sits under each
   headline figure, its width set from the data itself. */
.stat__label {
  font: 500 10px/1 var(--mono);
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--mute); margin-bottom: 10px;
}
.stat__value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 25px; font-weight: 500; letter-spacing: -0.04em;
  line-height: 1.1;
}
.stat__unit { font-size: 13px; color: var(--mute); margin-left: 4px; }
.stat__rule {
  height: 2px; margin-top: 12px;
  background: var(--line);
  position: relative; overflow: hidden;
}
.stat__rule i {
  position: absolute; inset: 0 auto 0 0;
  background: var(--copper);
  display: block;
}
.stat__rule--out i { background: var(--plum); }
.stat__foot { margin-top: 8px; font-size: 12px; color: var(--mute); }

.up   { color: var(--copper); }
.down { color: var(--rust); }

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

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

thead th {
  background: var(--panel);
  text-align: left;
  font: 500 10px/1 var(--mono);
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--mute);
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panel); }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.rowlink { color: var(--paper); text-decoration: none; font-weight: 500; }
.rowlink:hover { color: var(--copper); text-decoration: underline; text-underline-offset: 3px; }

.empty {
  padding: 48px 24px; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--r);
  color: var(--mute);
}
.empty strong { display: block; color: var(--paper); margin-bottom: 6px; font-size: 15px; }

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

.pill {
  display: inline-block;
  font: 500 11px/1 var(--mono);
  letter-spacing: .04em;
  padding: 4px 7px; border-radius: 3px;
  background: var(--panel-2); color: var(--paper-dim);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.pill--good { color: var(--copper); border-color: var(--copper-dim); }
.pill--bad  { color: var(--rust); border-color: #5A2E29; }
.pill--warn { color: var(--amber); border-color: #5C4620; }
.pill--neutral { color: var(--paper-dim); }

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

.form { display: grid; gap: 18px; max-width: 720px; }
.form__grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.field--wide { grid-column: 1 / -1; }

label.lab {
  display: block;
  font: 500 11px/1 var(--mono);
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--paper-dim); margin-bottom: 6px;
}

input[type=text], input[type=email], input[type=password], input[type=url],
input[type=date], input[type=month], input[type=number], input[type=file],
select, textarea {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--paper);
  padding: 9px 11px;
  font: 14px var(--body);
  transition: border-color .12s, box-shadow .12s;
}
input[inputmode=decimal], input.mono, select[name=currency] {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.55; }

input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: none;
  border-color: var(--copper);
  box-shadow: 0 0 0 3px rgba(79, 168, 148, .18);
}
a:focus-visible, button:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }

.help { font-size: 12px; color: var(--mute); margin-top: 5px; }
.err  { font-size: 12px; color: var(--rust); margin-top: 5px; }
.field--bad input, .field--bad select, .field--bad textarea { border-color: var(--rust); }

.check { display: flex; align-items: center; gap: 9px; }
.check input { width: 16px; height: 16px; accent-color: var(--copper); }
.check label { font-size: 14px; color: var(--paper-dim); margin: 0; text-transform: none; letter-spacing: 0; font-family: var(--body); }

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

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--copper); color: #08110E;
  border: 1px solid var(--copper);
  border-radius: var(--r);
  padding: 9px 16px;
  font: 600 13px/1 var(--body);
  cursor: pointer; text-decoration: none;
  transition: filter .12s;
}
.btn:hover { filter: brightness(1.1); }
.btn--ghost { background: transparent; color: var(--paper-dim); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--copper); color: var(--paper); filter: none; }
.btn--danger { background: transparent; color: var(--rust); border-color: #5A2E29; }
.btn--danger:hover { background: var(--rust); color: var(--ink); filter: none; }
.btn--small { padding: 6px 11px; font-size: 12px; }

.linkbtn {
  background: none; border: 0; padding: 0;
  color: var(--paper-dim); font: 13px var(--body);
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.linkbtn:hover { color: var(--rust); }

.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions--end { justify-content: flex-end; }

/* ---------------------------------------------------------- flash */

.flash {
  border: 1px solid var(--line);
  border-left: 2px solid var(--copper);
  background: var(--panel);
  padding: 12px 16px; border-radius: var(--r);
  margin-bottom: 20px; font-size: 14px;
}
.flash--error { border-left-color: var(--rust); }

/* ---------------------------------------------------------- gate */

.gate-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.gate { width: 100%; max-width: 380px; }
.gate__card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 2px solid var(--copper);
  border-radius: var(--r);
  padding: 30px;
}
.gate__brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--display); font-size: 17px; font-weight: 600;
  margin-bottom: 24px;
}
.gate__note { text-align: center; margin-top: 18px; font-size: 12px; color: var(--mute); }
.gate .form { gap: 14px; }

.codebox {
  font-family: var(--mono);
  font-size: 26px; letter-spacing: .38em; text-align: center;
  padding: 12px;
}

.secretbox {
  font-family: var(--mono); font-size: 13px;
  background: var(--ink); border: 1px solid var(--line);
  padding: 12px; border-radius: var(--r);
  word-break: break-all; color: var(--copper);
}

.codes { columns: 2; gap: 12px; margin: 16px 0; }
.codes li {
  font-family: var(--mono); font-size: 14px;
  list-style: none; padding: 5px 0;
  border-bottom: 1px solid var(--line-soft);
  break-inside: avoid;
}

#qr { display: grid; place-items: center; padding: 14px; background: #fff; border-radius: var(--r); }

/* ---------------------------------------------------------- charts */

.chartbox { position: relative; height: 260px; }
.chartbox--short { height: 200px; }

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

.split { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; align-items: start; }

.deflist { display: grid; gap: 0; }
.deflist div {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 9px 0; border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.deflist div:last-child { border-bottom: 0; }
.deflist dt { color: var(--mute); }
.deflist dd { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }

.searchbar { display: flex; gap: 8px; margin-bottom: 16px; max-width: 420px; }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 20px; }
.pager a, .pager span {
  padding: 6px 11px; border: 1px solid var(--line); border-radius: var(--r);
  font-family: var(--mono); font-size: 12px;
  color: var(--paper-dim); text-decoration: none;
}
.pager .is-on { background: var(--copper); color: var(--ink); border-color: var(--copper); }

.bar { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--copper); }
.bar--out i { background: var(--plum); }

.warn {
  border: 1px solid #5C4620; background: rgba(210,162,76,.07);
  color: var(--amber); padding: 12px 14px; border-radius: var(--r);
  font-size: 13px;
}

/* ---------------------------------------------------------- print CV */

@media print {
  body { background: #fff; color: #111; }
  .noprint { display: none !important; }
}

/* ---------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: 0 auto 0 0; z-index: 30;
    width: 232px; transform: translateX(-100%);
    transition: transform .18s ease;
  }
  .navtoggle-input:checked ~ .shell .rail { transform: none; }
  .navtoggle-btn {
    display: inline-grid; place-items: center;
    width: 38px; height: 38px; margin-bottom: 16px;
    border: 1px solid var(--line); border-radius: var(--r);
    color: var(--paper-dim); cursor: pointer; font-size: 18px;
  }
  .main { padding: 18px 16px 56px; }
  .grid--4, .grid--2, .form__grid { grid-template-columns: 1fr; }
  h1 { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
