:root {
  --bg: #f5f6f8; --card: #fff; --ink: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --brand: #e4572e; --brand-ink: #fff; --ok: #138a4b; --ok-bg: #e6f6ed; --warn: #a15c00; --warn-bg: #fff3dc;
  --bad: #c62828; --bad-bg: #fdecec; --info: #2754c5; --info-bg: #e9efff;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; padding: 40px 16px; }
small { color: var(--muted); }

/* top bar */
.top { background: #1d2330; color: #fff; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 10px 16px; position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 17px; }
.brand span { color: var(--brand); }
.top nav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; }
.top nav a { color: #cfd5df; padding: 6px 10px; border-radius: 6px; }
.top nav a.on, .top nav a:hover { background: #313a4d; color: #fff; text-decoration: none; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.who .muted { color: #aab2c0; }
.who select { background: #313a4d; color: #fff; border: 0; padding: 5px 8px; border-radius: 6px; }
.pill { background: #313a4d; padding: 3px 9px; border-radius: 99px; }
button.link { background: none; border: 0; color: #ffb59f; cursor: pointer; padding: 0; font: inherit; }

main { max-width: 1150px; margin: 0 auto; padding: 18px 16px 60px; }
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.card.bad { border-color: var(--bad); color: var(--bad); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.row-between { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: flex-start; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.tile .k { font-size: 13px; color: var(--muted); }
.tile .v { font-size: 24px; font-weight: 700; margin: 2px 0; }
.tile.hl { border-color: var(--brand); }
.tile.hl .v { color: var(--brand); }
.tile.red .v { color: var(--bad); }

/* forms */
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid #cdd2da; border-radius: 7px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #ffc9b8; border-color: var(--brand); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--ink); }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 14px; }
.form .full { grid-column: 1 / -1; }
.btn { display: inline-block; background: var(--brand); color: var(--brand-ink); border: 0; padding: 9px 16px; border-radius: 7px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid #cdd2da; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { background: #fff; color: var(--bad); border: 1px solid #efb4b4; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters input, .filters select { width: auto; flex: 1 1 180px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tabs a { padding: 6px 12px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--ink); }
.tabs a.on { background: var(--ink); color: #fff; border-color: var(--ink); text-decoration: none; }
.hint { font-size: 13px; padding: 8px 10px; border-radius: 7px; background: var(--info-bg); color: var(--info); margin-bottom: 10px; }
.hint.warn { background: var(--warn-bg); color: var(--warn); }

/* tables */
.tw { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 8px; white-space: nowrap; }
td { border-bottom: 1px solid #f0f1f4; padding: 8px; vertical-align: middle; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.void td { color: #a0a6b0; text-decoration: line-through; }
td input, td select { padding: 5px 7px; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #eef0f3; color: #4b5563; white-space: nowrap; }
.badge.paid, .badge.active { background: var(--ok-bg); color: var(--ok); }
.badge.partial, .badge.on_hold { background: var(--warn-bg); color: var(--warn); }
.badge.overdue, .badge.dropped, .badge.cancelled { background: var(--bad-bg); color: var(--bad); }
.badge.due { background: var(--info-bg); color: var(--info); }

.money3 { display: flex; gap: 18px; text-align: right; }
.money3 b { display: block; font-size: 17px; }
.wa { color: #128c4a; font-weight: 600; font-size: 13px; }

/* trend */
.trend { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.trend .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.trend .bar-v { width: 100%; max-width: 38px; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; }
.trend .col.cur .bar-v { background: #1d2330; }
.trend .lbl { font-size: 11px; color: var(--muted); margin-top: 4px; }
.trend .amt { font-size: 10px; color: var(--muted); margin-bottom: 2px; white-space: nowrap; }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 20, 30, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; z-index: 20; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; }
.modal .mh { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal .mh h2 { margin: 0; }
.modal .mb { padding: 16px; }
.modal .x { background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1d2330; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 30; max-width: 92vw; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); }

/* login */
.login { max-width: 380px; margin: 8vh auto; }
.login .brand { font-size: 24px; text-align: center; margin-bottom: 16px; }

/* receipt */
.receipt { max-width: 640px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 26px; position: relative; }
.receipt .rh { display: flex; justify-content: space-between; border-bottom: 2px solid var(--ink); padding-bottom: 10px; margin-bottom: 14px; gap: 10px; }
.receipt .rh h1 { font-size: 24px; }
.receipt table td { border: 0; padding: 5px 0; }
.receipt table td:first-child { color: var(--muted); width: 42%; }
.receipt .amount { font-size: 26px; font-weight: 700; }
.receipt .stamp { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg); font-size: 64px; font-weight: 800; color: rgba(198, 40, 40, .25); border: 6px solid rgba(198, 40, 40, .25); padding: 4px 22px; }
.receipt .foot { margin-top: 26px; display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); gap: 10px; }

@media print {
  .top, .noprint { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .receipt { border: 1px solid #000; }
}
@media (max-width: 600px) {
  .top nav { order: 3; width: 100%; }
  .money3 { gap: 12px; }
  .tile .v { font-size: 20px; }
}
