:root {
  --bg: #0f1623;
  --panel: #18212f;
  --panel-2: #1f2a3a;
  --line: #2a3648;
  --text: #e8eef6;
  --muted: #8ea0b8;
  --brand: #4f8cff;
  --in: #2ecc71;
  --out: #ff6b6b;
  --transfer: #c084fc;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
  background: var(--panel); position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #8b5cf6); font-weight: 800; letter-spacing: .5px;
}
.brand h1 { margin: 0; font-size: 17px; }
.brand p { margin: 0; color: var(--muted); font-size: 12px; }
.range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.range label { color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; }

main { max-width: 1180px; margin: 0 auto; padding: 24px; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.card .bank { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.card .name { font-size: 16px; font-weight: 700; margin: 2px 0 10px; }
.card .balance { font-size: 26px; font-weight: 800; }
.card .flows { display: flex; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.card .flows .in { color: var(--in); }
.card .flows .out { color: var(--out); }
.card .unrec { margin-top: 10px; font-size: 12px; padding: 5px 9px; border-radius: 8px; display: inline-block; }
.card .unrec.pending { background: rgba(255,107,107,.12); color: var(--out); }
.card .unrec.clear { background: rgba(46,204,113,.12); color: var(--in); }
.card .editob { position: absolute; top: 14px; right: 14px; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 12px; }
.card .editob:hover { color: var(--text); }

/* totals */
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
.total { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.total span { color: var(--muted); font-size: 12px; display: block; }
.total strong { font-size: 22px; }
.total.in strong { color: var(--in); }
.total.out strong { color: var(--out); }
.total.net strong { color: var(--brand); }

.grid { display: grid; grid-template-columns: 360px 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } .totals { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-top: 16px; box-shadow: var(--shadow);
}
.grid .panel { margin-top: 0; }
.panel h2 { margin: 0 0 14px; font-size: 15px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }

/* form */
.type-toggle { display: flex; gap: 6px; margin-bottom: 14px; background: var(--bg); padding: 4px; border-radius: 10px; }
.type-toggle label {
  flex: 1; text-align: center; padding: 7px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 13px;
}
.type-toggle label:has(input:checked) { background: var(--brand); color: #fff; font-weight: 600; }
.type-toggle input { display: none; }

.field { margin-bottom: 12px; }
.field label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
input, select {
  width: 100%; padding: 9px 11px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 9px; color: var(--text); font-size: 14px;
}
input:focus, select:focus { outline: none; border-color: var(--brand); }

button { cursor: pointer; font-family: inherit; }
.primary { width: 100%; padding: 11px; background: var(--brand); border: 0; border-radius: 10px; color: #fff; font-weight: 600; font-size: 14px; }
.primary:hover { filter: brightness(1.08); }
.ghost { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); padding: 7px 12px; border-radius: 8px; font-size: 12px; }
.ghost:hover { border-color: var(--brand); }
.err { color: var(--out); font-size: 12px; min-height: 16px; margin: 8px 0 0; }

/* breakdown */
.breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 560px) { .breakdown { grid-template-columns: 1fr; } }
.breakdown h3 { font-size: 13px; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { margin-bottom: 9px; }
.bars .row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 3px; }
.bars .track { height: 6px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.bars .fill { height: 100%; border-radius: 6px; }
.bars.income .fill { background: var(--in); }
.bars.expense .fill { background: var(--out); }
.empty { color: var(--muted); font-size: 13px; font-style: italic; }

/* table */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters select, .filters input { width: auto; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
td.right, th.right { text-align: right; }
.pill { padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.pill.income { background: rgba(46,204,113,.15); color: var(--in); }
.pill.expense { background: rgba(255,107,107,.15); color: var(--out); }
.pill.transfer { background: rgba(192,132,252,.15); color: var(--transfer); }
.amt.income { color: var(--in); }
.amt.expense { color: var(--out); }
.amt.transfer { color: var(--transfer); }
.del { background: none; border: 0; color: var(--muted); font-size: 15px; }
.del:hover { color: var(--out); }
.edit { background: none; border: 0; color: var(--muted); font-size: 13px; }
.edit:hover { color: var(--brand); }
td .rowbtns { display: flex; gap: 6px; justify-content: flex-end; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; width: 320px; box-shadow: var(--shadow); }
.brand.center { flex-direction: column; text-align: center; margin-bottom: 20px; }
.brand.center .logo { width: 52px; height: 52px; font-size: 20px; }

/* header user area */
.userbox { display: flex; align-items: center; gap: 10px; }
.userbox .who { font-size: 13px; color: var(--muted); }
.userbox .who strong { color: var(--text); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; width: 460px; max-width: calc(100vw - 32px); max-height: calc(100vh - 64px); overflow:auto; box-shadow: var(--shadow); }
.modal h2 { margin: 0 0 14px; font-size: 16px; }
.modal .close { float: right; background: none; border: 0; color: var(--muted); font-size: 18px; }
.modal .close:hover { color: var(--text); }
.modal .userlist { list-style: none; padding: 0; margin: 0 0 18px; }
.modal .userlist li { display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.modal .userlist .role { font-size: 11px; color: var(--muted); margin-left: 8px; }
.modal .inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.modal .inline .field { margin: 0; flex: 1; min-width: 110px; }
.editing-banner { background: rgba(79,140,255,.12); border: 1px solid var(--brand); color: var(--text);
  padding: 7px 10px; border-radius: 8px; font-size: 12px; margin-bottom: 12px; display: none; justify-content: space-between; align-items: center; }
.editing-banner button { background: none; border: 0; color: var(--muted); font-size: 12px; }
.muted-note { color: var(--muted); font-size: 12px; margin: -6px 0 14px; }
.amt-pos { color: var(--in); }
.amt-neg { color: var(--out); }
.minibar { height: 7px; border-radius: 5px; background: var(--bg); position: relative; min-width: 80px; overflow: hidden; }
.minibar .pos { position: absolute; left: 50%; top: 0; height: 100%; background: var(--in); }
.minibar .neg { position: absolute; right: 50%; top: 0; height: 100%; background: var(--out); }
#reportTable tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.pill.create { background: rgba(46,204,113,.15); color: var(--in); }
.pill.update { background: rgba(79,140,255,.15); color: var(--brand); }
.pill.delete { background: rgba(255,107,107,.15); color: var(--out); }

.card .cardbtns { position: absolute; top: 12px; right: 12px; display: flex; gap: 10px; }
.card .cardbtns button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 12px; }
.card .cardbtns button:hover { color: var(--text); }

#recPreview th, #recPreview td { font-size: 12px; padding: 5px 8px; }
#recPreview .hdr { color: var(--brand); font-weight: 700; }

.rec-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 10px; margin-bottom: 14px; }
.rec-summary .box { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.rec-summary .box span { display: block; color: var(--muted); font-size: 11px; }
.rec-summary .box strong { font-size: 18px; }
.rec-summary .box.ok strong { color: var(--in); }
.rec-summary .box.warn strong { color: var(--out); }

.rec-results details { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; padding: 4px 12px; }
.rec-results summary { cursor: pointer; padding: 8px 0; font-weight: 600; font-size: 13px; }
.rec-results .minirow { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; align-items: center; }
.rec-results .minirow .left { color: var(--muted); }
.rec-results .minirow button { font-size: 12px; }
.rec-results .minirow .meta { color: var(--muted); font-size: 11px; }
.rec-results .minirow.col { display: block; }
.rec-results .minirow.col .r1 { display: flex; justify-content: space-between; gap: 10px; }
.rec-results .minirow.col .r2 { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.rec-results .minirow.col .r2 .or { color: var(--muted); font-size: 12px; }
.rec-results .minirow.col .r2 select { width: auto; padding: 5px 8px; font-size: 12px; }
.rec-results .minirow.col .r2 .xfer { background: var(--transfer); border: 0; color: #2a0a44; padding: 4px 9px; border-radius: 7px; font-weight: 600; font-size: 12px; }
.rec-results .hint { background: rgba(192,132,252,.12); border: 1px solid var(--transfer); color: var(--text);
  font-size: 12px; padding: 6px 9px; border-radius: 8px; margin-top: 7px; }
.rec-results .add { background: var(--in); border: 0; color: #06301a; padding: 4px 9px; border-radius: 7px; font-weight: 600; }

.rtick { color: var(--in); font-weight: 700; margin-left: 2px; }
.imports { margin-top: 16px; }
.imports h3 { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.imports .irow { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.imports .irow .meta { color: var(--muted); font-size: 12px; }
.imports .undo { background: none; border: 1px solid var(--line); color: var(--muted); padding: 3px 9px; border-radius: 7px; font-size: 12px; }
.imports .undo:hover { border-color: var(--out); color: var(--out); }
