:root {
  --bg: #0f1115; --panel: #181c24; --panel2: #1f2430; --border: #2a3140;
  --text: #e8ebf0; --muted: #9aa3b2; --accent: #4f8cff; --green: #3ecf8e;
  --red: #ff6b6b; --amber: #ffb454; --radius: 12px;
}
* { box-sizing: border-box; margin: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

header { display: flex; align-items: center; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 5; flex-wrap: wrap; }
header h1 { font-size: 18px; margin-right: auto; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav button { background: none; border: none; color: var(--muted); padding: 8px 12px; border-radius: 8px; }
nav button.active { background: var(--panel2); color: var(--text); }
#save-status { font-size: 12px; color: var(--muted); min-width: 60px; }
main { max-width: 1000px; margin: 0 auto; padding: 20px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h2 { font-size: 15px; margin-bottom: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.stat { font-size: 28px; font-weight: 700; }
.stat.green { color: var(--green); } .stat.red { color: var(--red); } .stat.amber { color: var(--amber); }
.sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.paid td { color: var(--muted); }
tr.paid .name { text-decoration: line-through; }
.table-wrap { overflow-x: auto; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; background: var(--panel2); color: var(--muted); }
.pill.warn { background: rgba(255,180,84,.15); color: var(--amber); }

.btn { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 9px 14px; font-weight: 600; }
.btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--border); padding: 5px 10px; }
.btn.small { padding: 5px 10px; font-size: 13px; }

.bar { height: 8px; border-radius: 4px; background: var(--panel2); overflow: hidden; margin-top: 6px; }
.bar > div { height: 100%; background: var(--green); }
.bar > div.over { background: var(--red); }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; text-transform: uppercase; }
.cal-cell { min-height: 76px; min-width: 0; background: var(--panel2); border-radius: 8px; padding: 6px; font-size: 11px; border: 1px solid transparent; }
.cal-cell.other { opacity: .35; }
.cal-cell.weekend { background: #171b23; }
.cal-cell.today { border-color: var(--accent); }
.cal-cell .d { font-weight: 700; font-size: 12px; margin-bottom: 3px; }
.cal-ev { border-radius: 4px; padding: 1px 4px; margin-bottom: 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; background: rgba(255,107,107,.18); color: #ffb3b3; }
.cal-ev.pay { background: rgba(62,207,142,.2); color: var(--green); font-weight: 700; }

/* Login */
#login { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 50; }
#login .card { width: 320px; }
#login h1 { font-size: 20px; margin-bottom: 14px; }
#login input { width: 100%; margin-bottom: 10px; }
#login .btn { width: 100%; }
#login .err { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 18px; }

textarea { width: 100%; min-height: 140px; background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-family: ui-monospace, monospace; font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.hidden { display: none !important; }
@media (max-width: 640px) { .cal-cell { min-height: 54px; } main { padding: 12px; } }
