:root {
  --bg: #0b0f14; --panel: #121821; --panel2: #182130; --line: #223047;
  --text: #e6edf3; --dim: #8b98a9; --accent: #4f8ff7; --accent2: #7c5cff;
  --green: #2ecc8f; --red: #ff5d6c; --amber: #ffb84d;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; }

.app { display: flex; min-height: 100vh; }
.side { width: 210px; background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; flex-shrink: 0; }
.side .logo { font-size: 17px; font-weight: 700; letter-spacing: .4px; padding: 6px 10px 14px; }
.side .logo span { color: var(--accent); }
.side nav a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--dim); margin-bottom: 2px; font-weight: 500; }
.side nav a.active, .side nav a:hover { background: var(--panel2); color: var(--text); }
.side .user { margin-top: 18px; padding: 10px 12px; color: var(--dim); font-size: 12px; border-top: 1px solid var(--line); }
.main { flex: 1; padding: 20px 24px; min-width: 0; }

h1 { font-size: 20px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 20px 0 8px; }
.sub { color: var(--dim); margin-bottom: 16px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card .k { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.card .v { font-size: 22px; font-weight: 700; margin-top: 4px; }
.card .v small { font-size: 13px; color: var(--dim); font-weight: 500; }
.card.green .v { color: var(--green); } .card.red .v { color: var(--red); } .card.amber .v { color: var(--amber); }

table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.grid th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--dim); padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--panel2); }
table.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
table.grid tr:last-child td { border-bottom: none; }
table.grid tr.click { cursor: pointer; } table.grid tr.click:hover td { background: var(--panel2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.neg { color: var(--red); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.pill.paid { background: rgba(46,204,143,.15); color: var(--green); }
.pill.unpaid { background: rgba(255,93,108,.14); color: var(--red); }
.pill.open { background: rgba(255,184,77,.15); color: var(--amber); }
.pill.fixed { background: rgba(79,143,247,.15); color: var(--accent); }
.pill.verified { background: rgba(46,204,143,.15); color: var(--green); }
.pill.new { background: var(--accent2); color: white; }
.pill.stale { background: rgba(255,184,77,.2); color: var(--amber); }
.pill.flag { background: rgba(255,93,108,.14); color: var(--red); }

.btn { background: var(--accent); border: none; color: white; padding: 8px 14px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn.danger { background: var(--red); } .btn.green { background: var(--green); color: #04140d; }
.btn:disabled { opacity: .45; cursor: default; }

select, input[type=text], input[type=number], input[type=date], input[type=password] {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 34px; width: 340px; }
.login h1 { text-align: center; margin-bottom: 4px; }
.login .sub { text-align: center; }
.login input { width: 100%; margin-bottom: 10px; }
.login .btn { width: 100%; margin-top: 6px; }
.err { color: var(--red); font-size: 13px; margin-top: 8px; }

.stubview { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.stubview .head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 12px; }
.total-line { font-size: 18px; font-weight: 800; }
.section-t { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--dim); margin: 16px 0 6px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: 440px; max-width: 94vw; max-height: 90vh; overflow: auto; }
.modal h2 { margin-top: 0; }
.modal label { display: block; color: var(--dim); font-size: 12px; margin: 10px 0 4px; }
.modal input, .modal select { width: 100%; }

.toast { position: fixed; bottom: 18px; right: 18px; background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--green); padding: 12px 16px; border-radius: 8px; z-index: 60; }
.toast.error { border-left-color: var(--red); }

.fab { position: fixed; bottom: 20px; right: 20px; width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent2); border: none; font-size: 22px; cursor: pointer; z-index: 40;
  box-shadow: 0 4px 18px rgba(0,0,0,.4); }
.fab:hover { filter: brightness(1.15); }
.fab-panel { position: fixed; bottom: 84px; right: 20px; width: 340px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 16px; z-index: 41; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.fab-panel textarea { background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font: inherit; resize: vertical; }

@media (max-width: 820px) {
  .app { flex-direction: column; }
  .side { width: 100%; display: flex; align-items: center; overflow-x: auto; padding: 8px; }
  .side .logo { padding: 6px 12px; white-space: nowrap; }
  .side nav { display: flex; } .side nav a { white-space: nowrap; }
  .side .user { display: none; }
  .main { padding: 14px; }
}
