:root {
  --bg: #050b1a; --panel: #0b1630; --line: #1a2b52; --text: #e6eefc; --muted: #8798bb;
  --blue: #00aaff; --gold: #ffc531; --red: #ff5470; --ok: #2ee59d;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 15px/1.5 Inter, system-ui, sans-serif; color: var(--text);
  background: var(--bg);
  background-image: linear-gradient(rgba(0,170,255,.05) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(0,170,255,.05) 1px, transparent 1px);
  background-size: 32px 32px;
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
h1, h2 { font-family: Orbitron, sans-serif; letter-spacing: .03em; }
h2 { font-size: 15px; margin: 0 0 14px; color: var(--blue); text-transform: uppercase; }

.top {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: rgba(5,11,26,.9);
  position: sticky; top: 0; z-index: 5; backdrop-filter: blur(6px);
}
.brand { font-family: Orbitron, sans-serif; font-weight: 800; color: var(--text); font-size: 17px; }
.brand span { color: var(--blue); text-shadow: 0 0 12px rgba(0,170,255,.6); }
.brand.big { font-size: 26px; text-align: center; margin: 0 0 20px; }
nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
nav a { color: var(--muted); font-weight: 500; }
nav a.on { color: var(--gold); }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; margin-bottom: 16px;
}
.login { max-width: 380px; margin: 12vh auto 0; }
pre { background: #000; padding: 10px; border-radius: 8px; overflow-x: auto; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select {
  font: inherit; color: var(--text); background: #06102a; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; width: 100%; min-width: 0;
}
input:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,170,255,.2); }
input[type=date], input[type=month] { color-scheme: dark; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.grid .wide { grid-column: 1 / -1; }

.btn {
  font: 600 14px Inter, sans-serif; cursor: pointer; border: 1px solid var(--blue);
  background: var(--blue); color: #001528; padding: 10px 18px; border-radius: 8px;
  display: inline-block; text-align: center; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.1); }
.btn.ghost { background: transparent; color: var(--blue); padding: 8px 12px; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
button.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }
.login .btn { width: 100%; margin-top: 14px; }

.row { display: flex; gap: 10px; align-items: center; }
.row.grow { flex: 1; }
.inline { display: inline; margin: 0; }
.danger-zone { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }

.daybar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.daybar input { width: auto; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: 12px; padding: 14px; }
.stat.gold { border-left-color: var(--gold); }
.stat small { color: var(--muted); display: block; }
.stat b { font-family: Orbitron, sans-serif; font-size: 22px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list li > div:first-child { flex: 1; min-width: 0; }
.list small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.list li.off { opacity: .5; }
.amt { font-weight: 600; white-space: nowrap; }

table { width: 100%; border-collapse: collapse; }
td { padding: 8px 4px; border-top: 1px solid var(--line); vertical-align: middle; }
tr:first-child td { border-top: 0; }
.num { text-align: right; white-space: nowrap; }
.barcell { width: 30%; }
.bar { display: block; height: 8px; border-radius: 4px; background: var(--blue); min-width: 2px; }
.bar.gold { background: var(--gold); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid; }
.flash.ok { border-color: var(--ok); color: var(--ok); background: rgba(46,229,157,.08); }
.flash.error { border-color: var(--red); color: var(--red); background: rgba(255,84,112,.08); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

@media (max-width: 560px) {
  .grid, .stats { grid-template-columns: 1fr; }
  .barcell { display: none; }
  .stat b { font-size: 20px; }
  .list li { flex-wrap: wrap; }
}

/* ---- ledger additions ---- */
.in { color: var(--ok); }
.out { color: var(--red); }
.amt.income { color: var(--ok); }
.amt.expense { color: var(--red); }
.num.income { color: var(--ok); }
.num.expense { color: var(--red); }
.stats.four { grid-template-columns: repeat(4, 1fr); }
.stat.in { border-left-color: var(--ok); }
.stat.out { border-left-color: var(--red); }
.stat.in b, .stat.out b { color: inherit; }
.stat b.sm { font-size: 15px; }
.stat small.out { color: var(--red); }
h2.split { display: flex; justify-content: space-between; gap: 10px; }
.nowrap { white-space: nowrap; }
.row.wrap { flex-wrap: wrap; }
.editlist { display: flex; flex-direction: column; gap: 8px; }
.editrow { display: grid; grid-template-columns: 2fr 1fr 1fr 1.2fr auto auto; gap: 8px; align-items: center; margin: 0; }
.editrow.pay { grid-template-columns: auto 1fr 2fr auto; margin-top: 12px; }
.editrow.add { padding-top: 8px; border-top: 1px dashed var(--line); }
.btn.ghost.danger { border-color: var(--red); color: var(--red); background: transparent; }
.yeartable .barcell { width: 35%; }
.bar.inb { background: var(--ok); margin-bottom: 3px; }
.bar.outb { background: var(--red); }
.legend .key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; }
.legend .key.in { background: var(--ok); margin-left: 0; }
.legend .key.out { background: var(--red); }
@media (max-width: 760px) {
  .stats.four { grid-template-columns: 1fr 1fr; }
  .editrow { grid-template-columns: 1fr 1fr 1fr; }
  .editrow .num { grid-column: 1 / 2; }
  .editrow.pay { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .stats.four { grid-template-columns: 1fr; }
  .yeartable .barcell { display: none; }
}
/* ---- sheet page ---- */
.steps { padding-left: 20px; margin: 0 0 14px; }
.steps li { margin-bottom: 6px; }
pre#script { max-height: 260px; overflow: auto; white-space: pre; }
details summary { cursor: pointer; color: var(--blue); }
code { background: #000; padding: 1px 5px; border-radius: 4px; }
