@font-face{font-family:Fira;font-weight:500;font-display:swap;src:url(/fonts/fira-500-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:Fira;font-weight:500;font-display:swap;src:url(/fonts/fira-500-cyrillic.woff2) format('woff2');unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}
@font-face{font-family:Fira;font-weight:600;font-display:swap;src:url(/fonts/fira-600-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:Fira;font-weight:600;font-display:swap;src:url(/fonts/fira-600-cyrillic.woff2) format('woff2');unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}
@font-face{font-family:Mono;font-weight:400 500;font-display:swap;src:url(/fonts/jbmono-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:Mono;font-weight:400 500;font-display:swap;src:url(/fonts/jbmono-cyrillic.woff2) format('woff2');unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}

:root {
  color-scheme: dark;
  --bg: #0b0c11;
  --panel: #12141b;
  --inset: #0d0f15;
  --raised: #181b24;
  --line: #262a38;
  --line-hi: #3a4052;
  --text: #e6e8f0;
  --muted: #8f94a8;
  --dim: #5d6274;
  --mint: #9fd8cb;
  --lavender: #b7a8e0;
  --pink: #e3b3c8;
  --sage: #b8cfa0;
  --peach: #e8b89a;
  --accent: var(--mint);
  --income: var(--sage);
  --expense: var(--pink);
  /* Category palette. */
  --c0: #9fd8cb;
  --c1: #b7a8e0;
  --c2: #e3b3c8;
  --c3: #e8b89a;
  --c4: #b8cfa0;
  --c5: #9cc4e4;
  --c6: #d8cba4;
  --c7: #a9b0c6;
  --sans: Fira, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: Mono, ui-monospace, "SFMono-Regular", Menlo, monospace;
  --cut: 12px;
  --nav-width: 200px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg);
  /* Faint static grid: painted once with the page, never animated. */
  background-image:
    linear-gradient(rgb(230 232 240 / .022) 1px, transparent 1px),
    linear-gradient(90deg, rgb(230 232 240 / .022) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--text);
  font: 500 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 12% -12%, rgb(183 168 224 / .09), transparent 70%),
    radial-gradient(760px 480px at 100% 0%, rgb(159 216 203 / .06), transparent 70%);
}

h1, h2, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }

.num, .code, .label { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { white-space: nowrap; }
.cur { font-style: normal; margin-left: .28em; color: var(--muted); font-size: .82em; }
.label { font-size: 10.5px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.code { font-size: 10px; letter-spacing: .1em; color: var(--dim); }
.muted { color: var(--muted); }
.pos { color: var(--sage); }
.neg { color: var(--pink); }
.num.income { color: var(--income); }
.num.expense { color: var(--text); }

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

.app { display: grid; grid-template-columns: var(--nav-width) minmax(0, 1fr); min-height: 100dvh; }

.nav {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 18px 12px;
  border-right: 1px solid var(--line);
  background: rgb(11 12 17 / .72);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; font: 500 15px var(--mono); letter-spacing: .06em; }
.hex {
  width: 18px;
  height: 20px;
  background: linear-gradient(160deg, var(--mint), var(--lavender));
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}

.nav-item {
  position: relative;
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  color: var(--muted);
  font-size: 13.5px;
  transition: color .15s, background-color .15s;
}
.nav-item svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.3; }
.nav-item:hover { color: var(--text); background: rgb(230 232 240 / .04); }
.nav-item.active { color: var(--accent); background: rgb(159 216 203 / .07); text-shadow: 0 0 14px rgb(159 216 203 / .35); }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px rgb(159 216 203 / .7);
}
.nav-item.active .code { color: var(--accent); }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: rgb(11 12 17 / .94);
}
.month-picker { display: flex; align-items: center; gap: 4px; margin-right: auto; }
.month-title { min-width: 168px; padding: 6px 8px; text-align: center; font: 500 15px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.month-title.other { color: var(--lavender); }
.month-title:hover { color: var(--accent); }

.screen-host { padding: 22px 28px 48px; overflow-x: clip; }
.screen { display: grid; gap: 16px; max-width: 1180px; margin: 0 auto; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .stack { align-content: start; }
.grid-2.flat { gap: 28px; }
.stack { display: grid; gap: 16px; }

/* ---- motion ---- */

@keyframes slide-right { from { opacity: 0; transform: translateX(28px); } }
@keyframes slide-left { from { opacity: 0; transform: translateX(-28px); } }
@keyframes reveal { from { opacity: 0; transform: translateY(10px); } }
@keyframes grow { from { transform: scaleY(0); } }
@keyframes pulse { 50% { opacity: .25; } }
@keyframes scan { from { transform: translateY(-100%); } to { transform: translateY(100vh); } }
@keyframes glitch {
  0% { transform: translateX(-3px); text-shadow: 2px 0 var(--lavender); }
  50% { transform: translateX(3px); text-shadow: -2px 0 var(--mint); }
  100% { transform: none; text-shadow: none; }
}

.slide-from-right { animation: slide-right .2s var(--ease); }
.slide-from-left { animation: slide-left .2s var(--ease); }

/* Boot reveal runs once: the class is removed right after the first paint settles. */
.boot .screen > * { animation: reveal .42s var(--ease) backwards; }
.boot .screen > :nth-child(2) { animation-delay: .06s; }
.boot .screen > :nth-child(3) { animation-delay: .12s; }
.boot .screen > :nth-child(4) { animation-delay: .18s; }
.boot .main::after {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 90px;
  pointer-events: none;
  background: linear-gradient(transparent, rgb(159 216 203 / .08), transparent);
  animation: scan .7s linear forwards;
}
.boot .daybar i, .slide-from-right .daybar i, .slide-from-left .daybar i,
.boot .monthbar i, .slide-from-right .monthbar i, .slide-from-left .monthbar i {
  transform-origin: bottom;
  animation: grow .45s var(--ease) backwards;
}

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

/* ---- phone ---- */

@media (max-width: 860px) {
  .app { display: block; padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  .nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 6;
    height: auto;
    flex-direction: row;
    gap: 0;
    padding: 0 4px env(safe-area-inset-bottom);
    border-right: 0;
    border-top: 1px solid var(--line);
    background: rgb(11 12 17 / .97);
  }
  .nav .brand, .nav-item .code { display: none; }
  .nav-item { flex: 1; grid-template-columns: 1fr; justify-items: center; gap: 3px; padding: 9px 0 8px; font-size: 10px; }
  .nav-item.active::before { left: 22%; right: 22%; top: 0; bottom: auto; width: auto; height: 2px; }
  .topbar { padding: 10px 14px; gap: 8px; }
  .month-title { min-width: 0; font-size: 13px; padding: 6px 2px; }
  /* Bottom room so the floating add button never covers the last row. */
  .screen-host { padding: 14px 12px 88px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .topbar .add {
    position: fixed;
    right: 14px;
    bottom: calc(74px + env(safe-area-inset-bottom));
    z-index: 6;
    padding: 13px 18px;
  }
  .sync span { display: none; }
}

/* ---- paper ---- */

#print { display: none; }

@media print {
  body { background: #fff; color: #000; font: 11pt/1.35 Georgia, serif; }
  body::before, .app, .scrim, .toast, .tip { display: none !important; }
  #print { display: block; }
  #print h1 { font-size: 18pt; margin-bottom: 4pt; }
  #print h2 { font-size: 12pt; margin: 14pt 0 4pt; }
  #print p { margin: 4pt 0 8pt; color: #333; }
  #print table { width: 100%; border-collapse: collapse; }
  #print th, #print td { padding: 3pt 6pt; border-bottom: .5pt solid #999; text-align: left; vertical-align: top; }
  #print .num { text-align: right; white-space: nowrap; font-family: "Courier New", monospace; }
  #print thead { display: table-header-group; }
  #print tr { break-inside: avoid; }
}
