:root {
  --bg: #f4f6f9; --card: #fff; --ink: #1c2733; --muted: #67788a;
  --line: #e2e8f0; --accent: #0e7490; --accent2: #0891b2;
  --good: #16a34a; --bad: #dc2626; --warn: #d97706;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--bad); min-height: 1em; }

.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #0e7490, #164e63); }
.login-card { background: #fff; padding: 32px 36px; border-radius: 12px; width: 320px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card h1 { margin: 0; }
.login-card p { margin: 0 0 8px; }
.login-card input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.login-card button { padding: 10px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-size: 14px; cursor: pointer; }

header { display: flex; align-items: center; gap: 14px; padding: 10px 18px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; }
nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; }
nav a.active { color: #fff; background: var(--accent); }
.spacer { flex: 1; }
select, .filters input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 13px; }
button.ghost { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; color: var(--muted); }

main { padding: 18px; max-width: 1200px; margin: 0 auto; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.card h3 { margin: 0 0 8px; font-size: 14px; }
.kpis { display: flex; gap: 16px; flex-wrap: wrap; }
.kpi .v { font-size: 18px; font-weight: 700; }
.kpi .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pos { color: var(--good); } .neg { color: var(--bad); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; overflow-x: auto; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filters input[type=search] { min-width: 220px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.wrap { white-space: normal; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr.click { cursor: pointer; }
tr.click:hover { background: #f0f7fa; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; background: #e2e8f0; }
.tag.completed, .tag.paid { background: #dcfce7; color: #166534; }
.tag.new { background: #fef3c7; color: #92400e; }
.bar-chart { width: 100%; height: 150px; }
.legend { font-size: 11px; color: var(--muted); }
a.ext { color: var(--accent); text-decoration: none; }
a.ext:hover { text-decoration: underline; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .detail-grid { grid-template-columns: 1fr; } }
.back { margin-bottom: 10px; display: inline-block; color: var(--accent); text-decoration: none; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
h2 { margin: 4px 0 12px; font-size: 18px; }
pre.desc { margin: 0; font: inherit; white-space: pre-wrap; }

/* --- create forms --- */
nav a.cta { background: var(--good); color: #fff; }
nav a.cta.active { background: #15803d; }
.frow { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.frow > label { width: 110px; flex: none; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.frow > input, .frow > select { flex: 1; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; background: #fff; }
.frow > div { flex: 1; }
#lineBody input { padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; font-size: 13px; }
.quickadd { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: #ecfeff; border: 1px solid #a5f3fc; border-radius: 8px; padding: 10px; margin-bottom: 12px; }
.quickadd select, .quickadd input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
table.totals { width: auto; margin-left: auto; margin-top: 8px; }
table.totals td { border: 0; padding: 3px 10px; }
button:not(.ghost) { background: var(--accent); color: #fff; border: 0; border-radius: 7px; padding: 9px 16px; font-size: 14px; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
p.pos, #payMsg.pos, #actMsg.pos, #convMsg.pos { color: var(--good); }
