:root {
  --bg: #f4f6f8; --panel: #fff; --text: #1d2733; --muted: #667085; --line: #dfe4ea;
  --brand: #17624f; --brand-dark: #104a3b; --side: #14342d; --side-text: #d8e7e2;
  --ok: #17803d; --warn: #b45309; --bad: #b42318; --pend: #9a6700;
  --radius: 8px; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: .2rem 0 1rem; }
h1 .sub { font-weight: 400; color: var(--muted); font-size: 1.1rem; margin-left: .4rem; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
code { background: #eef1f4; padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { text-align: right; white-space: nowrap; }
.hint { color: var(--muted); font-size: .85rem; margin: .2rem 0 .8rem; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex: 0 0 240px; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 1rem 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { font-weight: 700; font-size: 1.05rem; padding: 0 1.1rem 1rem; color: #fff; }
.sidebar nav { flex: 1; }
.sidebar nav a { display: block; padding: .5rem 1.1rem; color: var(--side-text); text-decoration: none; border-left: 3px solid transparent; }
.sidebar nav a.sub { padding-left: 1.9rem; font-size: .93rem; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .07); }
.sidebar nav a.active { background: rgba(255, 255, 255, .13); border-left-color: #6ee7b7; color: #fff; font-weight: 600; }
.nav-heading { text-transform: uppercase; font-size: .7rem; letter-spacing: .07em; color: #8fb3a8; padding: 1rem 1.1rem .3rem; }
.userbox { border-top: 1px solid rgba(255, 255, 255, .12); padding: .8rem 1.1rem 0; font-size: .9rem; }
.userbox .who { color: #fff; }
.userbox .role { display: block; color: #8fb3a8; font-size: .78rem; }
.userbox a, .userbox .link { color: var(--side-text); display: block; margin-top: .35rem; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }
.content { flex: 1; min-width: 0; padding: 1.4rem 1.8rem 3rem; max-width: 1280px; }
.menu-toggle { display: none; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin: 1rem 0; box-shadow: var(--shadow); }
.card h2:first-child { margin-top: 0; }
.narrow-form { max-width: 520px; }
body.plain { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.card.narrow { width: 100%; max-width: 440px; }
.card.narrow h1 { font-size: 1.3rem; }

label { display: block; font-weight: 600; font-size: .88rem; margin: 0 0 .8rem; }
label small { display: block; font-weight: 400; color: var(--muted); margin-top: .2rem; }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=month], input[type=date], input[type=file], select, textarea {
  display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem; font: inherit; font-weight: 400; color: var(--text);
  background: #fff; border: 1px solid #c5ccd5; border-radius: 6px;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid #2f8f77; outline-offset: 1px; }
.wide-input { width: 100%; }
label.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; }
label.check input { margin-top: .25rem; }

.btn, button.btn { display: inline-block; padding: .45rem .9rem; font: inherit; font-weight: 600; font-size: .9rem; border-radius: 6px; border: 1px solid #c5ccd5; background: #fff; color: var(--text); text-decoration: none; cursor: pointer; line-height: 1.3; }
.btn:hover { background: #f0f3f6; }
.btn.small { padding: .25rem .6rem; font-size: .8rem; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); border-color: #e5b4ae; }
.btn.wa { background: #e8f8ee; border-color: #8fd3a8; color: #0f5f2e; }
.btn.wa-missing { background: #fff7e6; border-color: #e6c27a; color: #7a4b00; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.filters, .inline-form, .grid-form { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.filters label, .inline-form label, .grid-form label { margin: 0; flex: 1 1 170px; }
.filters .btn, .inline-form .btn, .grid-form .btn { margin-bottom: 0; }
.grid-form .wide { flex: 1 1 100%; }
.inline { display: inline; }
form.inline-form input { margin-top: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .6rem; }

.flash { padding: .6rem .9rem; border-radius: 6px; margin: 0 0 .8rem; border: 1px solid; }
.flash.ok { background: #e8f6ed; border-color: #a6d9b8; color: #14532d; }
.flash.error { background: #fdecea; border-color: #f1b3ac; color: #7a1b12; }
.flash.warn { background: #fff4e0; border-color: #f0cf93; color: #6b3d00; }

.tabs { display: flex; gap: .3rem; margin: 1rem 0 .6rem; flex-wrap: wrap; }
.tabs a { padding: .35rem .9rem; border-radius: 999px; background: #e7ebef; color: var(--text); text-decoration: none; font-weight: 600; font-size: .9rem; }
.tabs a.active { background: var(--brand); color: #fff; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; margin: .8rem 0 1.2rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: var(--shadow); }
.stat span { display: block; font-size: .8rem; color: var(--muted); }
.stat strong { font-size: 1.35rem; }
.stat.warn strong { color: var(--bad); }
.stat.ok strong { color: var(--ok); }

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: .55rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { background: #f7f9fb; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
table.data th.num { text-align: right; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.actions { white-space: nowrap; }
table.data tr.archived td, table.data tr.voided td { color: var(--muted); }
table.data tr.voided td:not(:last-child) { text-decoration: line-through; }
tr.row-error { background: #fff3f1; }
tr.row-dupe { background: #fffaf0; }
ul.msgs { margin: .3rem 0 0; padding-left: 1.1rem; font-size: .85rem; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge.paid { background: #dcf3e4; color: #14532d; }
.badge.pending { background: #fdf0c8; color: #6b4a00; }
.badge.defaulter { background: #fbdcd8; color: #7a1b12; }

.empty { background: var(--panel); border: 1px dashed #c5ccd5; border-radius: var(--radius); padding: 1.2rem; text-align: center; }
.pager { display: flex; gap: .8rem; align-items: center; margin: .8rem 0; }
.toolbar { display: flex; gap: 1rem; align-items: center; margin-bottom: .6rem; }
.toolbar input { max-width: 320px; margin: 0; }
.checklist { max-height: 460px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
.check-row { display: flex; align-items: center; gap: .6rem; margin: 0; padding: .45rem .7rem; font-weight: 400; border-bottom: 1px solid #eef1f4; cursor: pointer; }
.check-row:hover { background: #f6faf8; }
.check-row input[type=checkbox] { width: 1.1rem; height: 1.1rem; margin: 0; }
.check-row .nm { font-weight: 600; }
.check-row .note { margin-left: auto; }
.save-bar { margin-top: 1rem; }
details summary { cursor: pointer; }
details.inline-details { display: inline-block; vertical-align: top; }
details .inline-form, details .grid-form { margin-top: .5rem; }
pre.preview { background: #f0f7f3; border: 1px solid #cfe5da; padding: .8rem; border-radius: 6px; white-space: pre-wrap; font: inherit; }

@media (max-width: 800px) {
  .layout { display: block; }
  .sidebar { position: static; width: auto; height: auto; display: none; }
  .sidebar.open { display: flex; }
  .menu-toggle { display: inline-block; margin-bottom: 1rem; padding: .45rem .9rem; font: inherit; font-weight: 600; border: 1px solid #c5ccd5; background: #fff; border-radius: 6px; }
  .content { padding: 1rem 1rem 3rem; }
}
@media print { .sidebar, .menu-toggle, .filters, .tabs, .btn { display: none !important; } .content { padding: 0; } }
