:root {
  --blue: #1668dc;
  --blue-dark: #0f55bb;
  --blue-soft: #e8f1fe;
  --ink: #2b3445;
  --muted: #8a93a5;
  --line: #e6e9f0;
  --bg: #f4f6fa;
  --green: #22a06b;
  --red: #e5484d;
  --orange: #f2922e;
  --radius: 8px;
  --sidebar: 232px;
  --topbar: 52px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar);
  background: var(--blue);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  z-index: 40;
  color: #fff;
}
.brand { display: flex; flex-direction: column; line-height: 1; width: calc(var(--sidebar) - 32px); }
.brand b { font-size: 17px; letter-spacing: .5px; }
.brand span { font-size: 9px; letter-spacing: 3px; opacity: .85; margin-top: 2px; }
.burger {
  background: none; border: 0; color: #fff; font-size: 20px; cursor: pointer;
  padding: 4px 8px; border-radius: 4px; line-height: 1;
}
.burger:hover { background: rgba(255,255,255,.15); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #d9e8ff; color: var(--blue-dark);
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
.topbar-right form { margin: 0; }
.logout-btn {
  background: rgba(255,255,255,.15); border: 0; color: #fff; padding: 5px 12px;
  border-radius: 4px; cursor: pointer; font-size: 13px;
}
.logout-btn:hover { background: rgba(255,255,255,.28); }

/* ---------- sidebar ---------- */
.sidebar {
  position: fixed;
  top: var(--topbar); bottom: 0; left: 0;
  width: var(--sidebar);
  background: #fff;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  z-index: 30;
  padding-bottom: 24px;
}
.who { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.who .dot { width: 30px; height: 30px; border-radius: 50%; background: #eaf7d9; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #4c7c1f; }
.who b { display: block; font-size: 13px; }
.who small { color: var(--muted); font-size: 11px; text-transform: capitalize; }

.nav { list-style: none; margin: 8px 0 0; padding: 0; }
.nav > li > a, .nav-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; color: #4a5568; font-size: 13.5px;
  background: none; border: 0; width: 100%; text-align: left; cursor: pointer;
  font-family: inherit;
}
.nav > li > a:hover, .nav-toggle:hover { background: #f7f9fc; text-decoration: none; }
.nav .ico { width: 18px; text-align: center; opacity: .75; flex: none; }
.nav .caret { margin-left: auto; font-size: 10px; opacity: .5; transition: transform .15s; }
.nav li.open .caret { transform: rotate(180deg); }
.nav > li.active > a, .nav > li.active > .nav-toggle { background: var(--blue); color: #fff; }
.nav > li.active .ico, .nav > li.active .caret { opacity: 1; }
.subnav { list-style: none; margin: 0; padding: 2px 0 6px; display: none; }
.nav li.open .subnav { display: block; }
.subnav a { display: block; padding: 7px 16px 7px 44px; color: #5a6478; font-size: 13px; }
.subnav a:hover { background: #f7f9fc; text-decoration: none; }
.subnav a.on { color: var(--blue); font-weight: 600; }
.subnav a.on::before { content: "\2022"; margin-right: 6px; }
.nav .tag { margin-left: auto; background: var(--red); color: #fff; font-size: 9px; padding: 2px 6px; border-radius: 3px; letter-spacing: .5px; }

/* ---------- layout ---------- */
.main { margin: var(--topbar) 0 0 var(--sidebar); padding: 18px 22px 40px; }
.page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 20px; margin: 0; font-weight: 600; }
.crumbs { color: var(--muted); font-size: 12.5px; }
.crumbs a { color: var(--muted); }

.card { background: #fff; border-radius: var(--radius); box-shadow: 0 1px 3px rgba(16,24,40,.06); margin-bottom: 18px; }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 16px 18px; }
.card-body.tight { padding: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 5px; border: 1px solid var(--blue);
  background: #fff; color: var(--blue); font-size: 13px; cursor: pointer;
  font-family: inherit; line-height: 1.4; white-space: nowrap;
}
.btn:hover { background: var(--blue-soft); text-decoration: none; }
.btn-solid { background: var(--blue); color: #fff; }
.btn-solid:hover { background: var(--blue-dark); color: #fff; }
.btn-grey { border-color: var(--line); color: #5a6478; }
.btn-grey:hover { background: #f4f6fa; }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: #fdeced; }
.btn-purple { border-color: #7b5cd6; color: #7b5cd6; }
.btn-purple:hover { background: #f1ecfd; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 4px; padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.stat .value { font-size: 20px; font-weight: 500; }
.stat .value .cur, .stat .value .unit { font-size: 11px; color: var(--muted); margin-left: 3px; }
.stat .value.red { color: var(--red); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 18px; }
.tile { background: #fff; border-radius: var(--radius); box-shadow: 0 1px 3px rgba(16,24,40,.06); padding: 18px; display: flex; align-items: center; gap: 14px; }
.tile .glyph { width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center; font-size: 19px; flex: none; }
.tile .label { color: var(--muted); font-size: 12.5px; }
.tile .value { font-size: 22px; font-weight: 600; }
.g-blue { background: #e8f1fe; color: var(--blue); }
.g-green { background: #e3f6ed; color: var(--green); }
.g-orange { background: #fdf0e0; color: var(--orange); }
.g-red { background: #fdeced; color: var(--red); }

/* ---------- tables ---------- */
.table-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 18px; }
.table-tools .spacer { margin-left: auto; }
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid th { background: #fafbfd; color: #5a6478; font-weight: 600; font-size: 12px; white-space: nowrap; }
table.grid tbody tr:nth-child(even) { background: #fcfdff; }
table.grid tbody tr:hover { background: var(--blue-soft); }
table.grid td.num, table.grid th.num { text-align: right; white-space: nowrap; }
table.grid .cur { font-size: 10px; color: var(--muted); margin-left: 2px; }
.sort { color: #5a6478; display: inline-flex; gap: 4px; align-items: center; }
.sort:hover { color: var(--blue); text-decoration: none; }
.sort .arrow { font-size: 9px; opacity: .55; }
.empty { padding: 40px 18px; text-align: center; color: var(--muted); }

.pill { display: inline-block; padding: 3px 10px; border-radius: 11px; font-size: 11px; font-weight: 600; }
.badge-paid { background: #e3f6ed; color: var(--green); }
.badge-unpaid { background: #fdeced; color: var(--red); }
.badge-partial { background: #fdf0e0; color: #c87a1a; }
.badge-void { background: #eef0f4; color: var(--muted); }
.txt-red { color: var(--red); }
.txt-green { color: var(--green); }
.txt-muted { color: var(--muted); }

.pager { display: flex; align-items: center; gap: 6px; padding: 12px 18px; flex-wrap: wrap; }
.pager .count { color: var(--muted); font-size: 12.5px; margin-right: auto; }
.pager a, .pager span.cur {
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 4px; font-size: 12.5px; color: #5a6478;
}
.pager a:hover { background: #f4f6fa; text-decoration: none; }
.pager span.cur { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ---------- forms ---------- */
.form-control, .form-select {
  width: 100%; padding: 8px 11px; border: 1px solid #d5dae3; border-radius: 5px;
  font: inherit; font-size: 13.5px; background: #fff; color: var(--ink);
}
.form-control:focus, .form-select:focus { outline: 0; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22,104,220,.12); }
.form-check-input { width: 16px; height: 16px; accent-color: var(--blue); }
label { font-size: 12.5px; color: #5a6478; display: block; margin-bottom: 5px; font-weight: 500; }
.field { margin-bottom: 14px; }
.field .help { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.field .err { font-size: 12px; color: var(--red); margin-top: 4px; }
.field-check { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.field-check label { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 16px; }
.inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }
.w-sm { max-width: 150px; }

/* ---------- messages ---------- */
.flash { padding: 11px 16px; border-radius: 6px; margin-bottom: 12px; font-size: 13.5px; border: 1px solid transparent; }
.flash-success { background: #e8f8f0; border-color: #b7e4cd; color: #166b48; }
.flash-error { background: #fdeced; border-color: #f6c4c6; color: #a32329; }
.flash-warning { background: #fdf4e3; border-color: #f3dcae; color: #8a5a10; }
.flash-info { background: var(--blue-soft); border-color: #bcd8fb; color: #10448f; }

/* ---------- progress ---------- */
.prog { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.prog .who-dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; background: var(--blue); flex: none; }
.prog .bar { height: 7px; background: #eef0f4; border-radius: 4px; overflow: hidden; }
.prog .bar > i { display: block; height: 100%; background: var(--blue); }
.prog .meta { flex: 1; min-width: 0; }
.prog .meta .top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }

/* Chart beside the collectors panel. The minmax(0,…) tracks let both cards
   shrink past their content width instead of widening the page. */
.dash-split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 1100px) { .dash-split { grid-template-columns: minmax(0, 1fr); } }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: #eef0f3; padding: 20px; }
.login-box { background: #fff; width: 100%; max-width: 330px; padding: 28px; border-radius: 4px; box-shadow: 0 1px 4px rgba(16,24,40,.1); }
.login-box .logo { text-align: center; margin-bottom: 20px; }
.login-box .logo b { font-size: 24px; color: var(--blue); letter-spacing: .5px; }
.login-box .logo span { display: block; font-size: 10px; letter-spacing: 5px; color: #6b7280; margin-top: 2px; }
.login-box h1 { font-size: 16px; text-align: center; font-weight: 600; margin: 0 0 18px; }
.login-box .btn { width: 100%; justify-content: center; }

/* ---------- print ---------- */
.sheet { background: #fff; max-width: 760px; margin: 0 auto; padding: 36px; }
.sheet h1 { font-size: 22px; margin: 0 0 4px; }
.sheet .meta { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin: 24px 0; font-size: 13px; }
.sheet table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 13px; }
.sheet th, .sheet td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.sheet th { background: #fafbfd; }
.sheet tfoot td { font-weight: 600; border-bottom: 0; }

@media print {
  .topbar, .sidebar, .no-print { display: none !important; }
  .main { margin: 0; padding: 0; }
  body { background: #fff; }
  .sheet { box-shadow: none; padding: 0; max-width: none; }
}

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 24px rgba(16,24,40,.18); }
  body.nav-open .sidebar { transform: none; }
  .main { margin-left: 0; padding: 14px; }
  .brand { width: auto; }
  .brand span { display: none; }
  .scrim { position: fixed; inset: var(--topbar) 0 0; background: rgba(16,24,40,.35); z-index: 25; display: none; }
  body.nav-open .scrim { display: block; }
  .page-head h1 { font-size: 18px; }
  .stat .value { font-size: 17px; }
  .table-tools { padding: 10px 12px; }
  table.grid th, table.grid td { padding: 9px 10px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tile { padding: 14px; gap: 10px; }
  .tile .glyph { width: 34px; height: 34px; font-size: 16px; }
  .tile .value { font-size: 19px; }
}

/* Columns a collector does not need while standing at a client's door. */
@media (max-width: 760px) {
  table.grid .hide-sm { display: none; }
}
