:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --ink: #17211d;
  --muted: #66736d;
  --line: #e2e8e5;
  --primary: #0f5132;
  --primary-ink: #ffffff;
  --primary-soft: #e6f2ec;
  --accent: #f59e0b;
  --danger: #b42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .05), 0 1px 3px rgba(16, 24, 20, .06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); }
h2 { font-size: 17px; margin: 0 0 6px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.wrap { max-width: 860px; margin: 0 auto; padding: 18px 16px 48px; }
.wrap.wide, .topbar-inner.wide { max-width: 1200px; }

/* Topbar */
.topbar { background: var(--primary); color: #fff; }
.topbar-inner { max-width: 860px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: #1f1300; font-weight: 800; font-size: 20px; display: grid; place-items: center; flex: none; }
.brand-title { font-weight: 700; font-size: 17px; line-height: 1.2; }
.brand-sub { font-size: 12.5px; opacity: .8; }
.small-brand .brand-mark { width: 34px; height: 34px; font-size: 17px; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a { color: #fff; text-decoration: none; padding: 7px 12px; border-radius: 8px; opacity: .85; font-size: 14px; }
.nav a.active, .nav a:hover { background: rgba(255,255,255,.14); opacity: 1; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.12); }

/* Cards & stats */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value { font-size: 30px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 4px; }
.stat-name { font-size: 22px; }
.stat-of { font-size: 16px; color: var(--muted); font-weight: 600; }
.stat-note { font-size: 12px; color: var(--muted); }
.stat-accent { background: var(--primary-soft); border-color: #cfe5da; }

/* Forms */
label { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; font-weight: 600; color: #34413b; }
input, select {
  font: inherit; font-weight: 400; color: var(--ink); width: 100%;
  padding: 10px 12px; border: 1px solid #cdd6d1; border-radius: 9px; background: #fff;
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 81, 50, .15); }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; }
.span2 { grid-column: 1 / -1; }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix span { display: grid; place-items: center; padding: 0 12px; background: #eef2f0; border: 1px solid #cdd6d1; border-right: 0; border-radius: 9px 0 0 9px; color: var(--muted); font-weight: 700; }
.input-prefix input { border-radius: 0 9px 9px 0; font-size: 17px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters label { min-width: 150px; }
.filters .grow { flex: 1 1 220px; }
.filter-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form input { width: 150px; padding: 6px 10px; font-size: 13.5px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 650; font-size: 14.5px; padding: 10px 16px; border-radius: 9px; border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; padding: 13px; font-size: 16px; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: #0b3f27; }
.btn-secondary { background: var(--primary-soft); color: var(--primary); border-color: #cfe5da; }
.btn-secondary:hover { background: #d8ebe1; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #eef2f0; }
.btn-link-danger { background: none; border: 0; color: var(--danger); cursor: pointer; font: inherit; font-size: 13px; padding: 2px 4px; }
.btn-link-danger:hover { text-decoration: underline; }

/* Tables */
.table-scroll { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid #eef2f0; vertical-align: middle; }
tbody tr:hover { background: #fafcfb; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.zero { color: #b7c1bc; }
.nowrap { white-space: nowrap; }
tr.inactive td { color: var(--muted); }
.rank-no { font-weight: 750; color: var(--muted); width: 32px; }
tr.top1 .rank-no { color: var(--accent); }
tr.top1 td:nth-child(2) b::after { content: " 🏆"; }
.barcol { min-width: 220px; width: 32%; }
.bar { position: relative; height: 26px; background: #f0f4f2; border-radius: 6px; overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #1d7a50, var(--primary)); border-radius: 6px; min-width: 2px; }
tr.top1 .bar-fill { background: linear-gradient(90deg, #f7b43a, var(--accent)); }
.bar-val { position: relative; z-index: 1; line-height: 26px; padding-left: 8px; font-weight: 700; font-variant-numeric: tabular-nums; color: #fff; mix-blend-mode: normal; text-shadow: 0 0 3px rgba(0,0,0,.35); }

/* Misc */
.pill { display: inline-block; font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 999px; background: #eef2f0; color: var(--muted); }
.pill-ok { background: var(--primary-soft); color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; margin: 0; }
.flashes { display: grid; gap: 8px; margin-bottom: 14px; }
.flash { padding: 11px 14px; border-radius: 10px; font-size: 14.5px; font-weight: 550; }
.flash-ok { background: #e3f4ea; color: #0b4a2c; border: 1px solid #bfe3cd; }
.flash-error { background: #fdecea; color: #8a1c12; border: 1px solid #f6c7c1; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-page { background: linear-gradient(160deg, #0f5132 0%, #0b3f27 55%, #13261d 100%); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 26px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card .brand { margin-bottom: 22px; }
.login-card .brand-sub { color: var(--muted); opacity: 1; }
.login-card form { display: grid; gap: 14px; }
.login-wrap .flashes { width: 100%; max-width: 380px; }

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-form { grid-template-columns: 1fr; }
  .stat-value { font-size: 26px; }
  .nav a { padding: 6px 8px; }
  .brand-sub { display: none; }
  .login-card .brand-sub { display: block; }
}
.th-sub { font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; color: #93a09a; }
.pill-warn { background: #fff4de; color: #8a5a00; }
.inline-form input { width: 130px; }
