:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #16191f;
  --text-2: #5b6270;
  --text-3: #8a909c;
  --accent: #1f4e79;
  --accent-hover: #173d60;
  --accent-soft: #e8eff7;
  --ok: #1a7f4b; --ok-soft: #e6f4ec;
  --warn: #9a5b00; --warn-soft: #fdf1dc;
  --bad: #b42318; --bad-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --border: #2a2f39;
    --text: #e8eaee; --text-2: #a4abb8; --text-3: #737b89;
    --accent: #7fb0e0; --accent-hover: #a2c6ea; --accent-soft: #1b2a3a;
    --ok: #5cc98d; --ok-soft: #13291d; --warn: #e8b04b; --warn-soft: #2d2413;
    --bad: #f07a6e; --bad-soft: #2f1715;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* layout */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; font-weight: 650; }
.brand img { width: 30px; height: 30px; }
.brand small { display: block; font-weight: 400; color: var(--text-3); font-size: 11.5px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--text-2); font-weight: 500; margin-bottom: 2px;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .count {
  margin-left: auto; font-size: 11.5px; background: var(--warn-soft); color: var(--warn);
  padding: 1px 7px; border-radius: 99px; font-weight: 600;
}
.side-foot { margin-top: auto; padding: 0 8px; }
.main { padding: 28px 36px 60px; max-width: 1240px; width: 100%; }
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.head .spacer { flex: 1; }

/* cards & grids */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat .label { color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 24px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
a.stat { color: inherit; display: block; }
a.stat:hover { text-decoration: none; border-color: var(--accent); }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -20px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 20px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; }
.empty { color: var(--text-3); padding: 28px 0; text-align: center; }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

/* forms */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
input[type=text], input[type=password], input[type=date], input[type=email], input[type=number], input[type=month],
select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 70px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1; min-width: 140px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg label { margin: 0; padding: 7px 14px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.seg input { display: none; }
.seg input:checked + span { color: var(--accent); }
.seg label:has(input:checked) { background: var(--accent-soft); color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #0f1115; } }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn svg { width: 16px; height: 16px; }
form.inline { display: inline; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 18px; font-weight: 500; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.error { background: var(--bad-soft); color: var(--bad); }

.drop {
  border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 26px; text-align: center;
  color: var(--text-2); cursor: pointer; transition: .15s; background: var(--surface);
}
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drop strong { color: var(--text); }
.drop input { display: none; }

.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.viewer { position: sticky; top: 20px; height: calc(100vh - 60px); padding: 0; overflow: hidden; }
.viewer iframe, .viewer img { width: 100%; height: 100%; border: 0; object-fit: contain; background: var(--surface-2); }
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--text-2); font-size: 13px; }
dl.kv dd { margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; padding: 28px; }
.login img { width: 64px; display: block; margin: 0 auto 12px; }

.mobilebar { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; position: fixed; inset: 0; z-index: 20; height: auto; }
  .side.open { display: flex; }
  .mobilebar {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--surface);
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; font-weight: 650;
  }
  .mobilebar img { width: 26px; }
  .mobilebar button { margin-left: auto; }
  .main { padding: 18px 16px 50px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g2, .g3, .split { grid-template-columns: 1fr; }
  .viewer { position: static; height: 60vh; }
  th, td { padding: 9px 12px; }
  .table-wrap { margin: 0 -20px; }
  .hide-m { display: none; }
}
.grid > .card + .card { margin-top: 0; }
h2 svg { width: 17px; height: 17px; vertical-align: -3px; color: var(--warn); }
.badge svg { width: 12px; height: 12px; }
.drop svg { width: 26px; height: 26px; margin-bottom: 6px; }
.btn svg, .nav svg { flex: none; }
.shell { grid-template-columns: 228px minmax(0, 1fr); }
.main, .grid > *, .split > * { min-width: 0; }
.drop { font-weight: 400; font-size: 13.5px; margin: 0; display: block; }
.drop .small { color: var(--text-3); }
@media (max-width: 900px) { .shell { grid-template-columns: minmax(0, 1fr); } }
input[type=search] {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; outline: none;
}
input[type=search]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stat .value { white-space: nowrap; }
@media (max-width: 900px) {
  .stat .value { font-size: 20px; }
  /* bank transactions as cards on phones */
  #txtable thead { display: none; }
  #txtable, #txtable tbody { display: block; }
  #txtable tr { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 12px 20px;
                border-bottom: 1px solid var(--border); }
  #txtable tr:last-child { border-bottom: 0; }
  #txtable td { padding: 0; border: 0; }
  #txtable td.c-sel { grid-column: 1 / -1; grid-row: 1; }
  #txtable td.c-sel:empty { display: none; }
  #txtable td.c-date { grid-column: 1; grid-row: 2; color: var(--text-2); font-size: 12.5px; }
  #txtable td.c-amt { grid-column: 2; grid-row: 2 / span 2; align-self: center; font-weight: 600; }
  #txtable td.c-pay { grid-column: 1; grid-row: 3; }
  #txtable td.c-status { grid-column: 1 / -1; grid-row: 4; }
  #txtable td.c-act { grid-column: 1 / -1; grid-row: 5; text-align: left; }
  #txtable thead { display: none; }
  #txtable td.empty { grid-column: 1 / -1; }
}
