:root {
  --green-950: #052b17;
  --green-900: #083d22;
  --green-800: #0b5130;
  --green-700: #0f6b3a;
  --green-600: #149648;
  --green-50: #ecf6ef;
  --red: #da251d;
  --red-700: #b51b14;
  --gold: #f5c400;
  --gold-600: #d9a900;
  --gold-50: #fff8d9;
  --ink: #17231b;
  --muted: #5c6b61;
  --line: #dfe6e0;
  --bg: #f3f5f1;
  --card: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(5, 43, 23, .06), 0 4px 16px rgba(5, 43, 23, .06);
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.5; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }

/* ---------- buttons & fields ---------- */
a.btn { text-decoration: none; color: inherit; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; white-space: nowrap; background: #fff; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn svg { width: 18px; height: 18px; }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(245, 196, 0, .55); outline-offset: 1px; }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-700); }
.btn-green { background: var(--green-700); color: #fff; }
.btn-green:hover { background: var(--green-800); }
.btn-outline { border-color: var(--line); background: #fff; }
.btn-outline:hover { border-color: var(--green-700); color: var(--green-700); }
.btn-danger-outline { border-color: #f1c4c1; color: var(--red-700); background: #fff; }
.btn-danger-outline:hover { background: #fdeceb; }
.btn-ghost-light { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.18); }
.btn-ghost-light:hover { background: rgba(255,255,255,.16); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--green-50); color: var(--green-700); }
.icon-btn.danger:hover { background: #fdeceb; color: var(--red); }

.field { display: grid; gap: 5px; font-weight: 500; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea, .input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fff; color: var(--ink); font-size: 14px; }
.field textarea { resize: vertical; min-height: 70px; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--green-600); outline: none; box-shadow: 0 0 0 3px rgba(20, 150, 72, .15); }
.form-error { color: var(--red); min-height: 20px; margin: 4px 0; font-size: 13px; font-weight: 500; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; position: relative; overflow: hidden;
  background: radial-gradient(ellipse at 50% 20%, var(--green-700) 0%, var(--green-900) 55%, var(--green-950) 100%); }
.login-rays { position: absolute; inset: -50%; background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(245,196,0,.06) 0deg 4deg, transparent 4deg 12deg); pointer-events: none; }
.login-card { position: relative; width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 32px 28px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.35); border-top: 5px solid var(--red); text-align: center; display: grid; gap: 12px; }
.login-card .field { text-align: left; }
.login-logo { width: 104px; height: auto; margin: -78px auto 0; filter: drop-shadow(0 6px 14px rgba(0,0,0,.25)); }
.login-kicker { margin: 4px 0 0; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 700; color: var(--red); }
.login-card h1 { font-size: 20px; font-weight: 800; color: var(--green-900); text-transform: uppercase; }
.login-sub { margin: 0; color: var(--muted); font-weight: 500; }
.gold-rule { height: 3px; width: 64px; margin: 4px auto 6px; background: var(--gold); border-radius: 3px; }
.login-foot { margin: 6px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, var(--green-900), var(--green-950)); color: #e5efe8; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; border-right: 3px solid var(--gold); }
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand img { width: 50px; height: auto; }
.brand strong { display: block; color: var(--gold); font-size: 15px; letter-spacing: .04em; }
.brand span { font-size: 12px; opacity: .85; }
.nav { display: grid; gap: 2px; padding: 14px 10px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: inherit; text-decoration: none; font-weight: 500; border-left: 3px solid transparent; }
.nav a:hover { background: rgba(255,255,255,.07); }
.nav a.active { background: rgba(245,196,0,.14); color: var(--gold); border-left-color: var(--gold); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 16px; border-top: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: var(--green-950); font-weight: 800; text-transform: uppercase; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; display: flex; align-items: center; gap: 12px; padding: 14px 28px; }
.topbar-title { min-width: 0; }
.crumb { font-size: 12px; font-weight: 700; color: var(--red); text-transform: uppercase; letter-spacing: .08em; }
.topbar h2 { font-size: 17px; font-weight: 700; color: var(--green-900); }
.flag-stripe { height: 4px; background: linear-gradient(90deg, var(--red) 0 33%, var(--gold) 33% 66%, var(--green-600) 66%); }
.menu-btn { display: none; }
.content { padding: 24px 28px 48px; display: grid; gap: 20px; align-content: start; }
.scrim { display: none; }

/* ---------- cards / dashboard ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid #e8ede9; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-h h3 { font-size: 15px; font-weight: 700; color: var(--green-900); display: flex; align-items: center; gap: 8px; }
.card-h h3::before { content: ''; width: 4px; height: 16px; background: var(--red); border-radius: 2px; }
.card-b { padding: 16px 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi::after { content: ''; position: absolute; right: -18px; top: -18px; width: 80px; height: 80px; border-radius: 50%; background: var(--accent, var(--green-50)); opacity: .5; }
.kpi .label { font-size: 12.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 30px; font-weight: 800; color: var(--green-900); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 12.5px; color: var(--muted); }
.kpi.k-red .value { color: var(--red); }
.kpi.k-red { --accent: #fbd5d3; }
.kpi.k-gold { --accent: var(--gold-50); }
.kpi.k-gold .value { color: #8a6a00; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
.grid-2 > * { min-width: 0; }
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 8px; background: var(--gold-50); border: 1px solid #f0dc8a; color: #6b5300; }
.alert svg { color: var(--gold-600); margin-top: 1px; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- table ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.toolbar .search { flex: 1 1 240px; position: relative; }
.toolbar .search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; }
.toolbar .search input { padding-left: 34px; }
.toolbar select { width: auto; }
.toolbar .spacer { flex: 1; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #edf1ee; white-space: nowrap; }
th { background: #f7f9f7; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; position: sticky; top: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--green-700); }
th .arrow { opacity: .8; font-size: 10px; margin-left: 3px; }
tbody tr:hover { background: #f8fbf8; }
td.num, th.num { text-align: right; }
td.name { font-weight: 600; white-space: normal; min-width: 160px; }
td.wrap { white-space: normal; min-width: 120px; }
.cb { width: 16px; height: 16px; accent-color: var(--green-700); cursor: pointer; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.score { display: inline-block; min-width: 46px; text-align: center; padding: 2px 8px; border-radius: 99px; font-weight: 700; font-size: 13px; background: #eef1ef; }
.score.full { background: var(--green-50); color: var(--green-700); }
.score.low { background: #fdeceb; color: var(--red-700); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.badge.p1 { background: linear-gradient(135deg, #ffe066, var(--gold)); color: #5a4200; box-shadow: inset 0 0 0 1px #e6b800; }
.badge.p2 { background: #e8edf2; color: #3b4a5a; box-shadow: inset 0 0 0 1px #c5d0db; }
.badge.p3 { background: #f7e3d3; color: #7a4219; box-shadow: inset 0 0 0 1px #e8c3a5; }
.badge.p4 { background: var(--green-50); color: var(--green-700); }
.rank { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 7px; font-weight: 700; background: #f0f3f1; }
.rank.top { background: var(--red); color: #fff; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; flex-wrap: wrap; color: var(--muted); }
.pager .pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pager button { min-width: 32px; height: 32px; border: 1px solid var(--line); background: #fff; border-radius: 7px; cursor: pointer; font-weight: 600; }
.pager button.on { background: var(--green-700); color: #fff; border-color: var(--green-700); }
.pager button:disabled { opacity: .45; cursor: default; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

/* ---------- questions ---------- */
.q-list { display: grid; gap: 14px; padding: 16px 18px; }
.q-item { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: grid; gap: 10px; background: #fff; }
.q-head { display: flex; gap: 12px; align-items: flex-start; }
.q-no { flex: none; width: 34px; height: 34px; border-radius: 8px; background: var(--green-900); color: var(--gold); display: grid; place-items: center; font-weight: 800; }
.q-text { flex: 1; font-weight: 600; font-size: 15px; color: var(--ink); padding-top: 5px; }
.q-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-left: 46px; }
.q-opt { display: flex; gap: 8px; padding: 8px 10px; border-radius: 8px; background: #f6f8f6; border: 1px solid transparent; }
.q-opt b { color: var(--muted); }
.q-opt.ok { background: var(--green-50); border-color: #b9dfc6; color: var(--green-800); font-weight: 500; }
.q-opt.ok b { color: var(--green-700); }
.q-opt.ok::after { content: '✓'; margin-left: auto; font-weight: 800; color: var(--green-600); }

/* ---------- modal & toast ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(5, 25, 14, .55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 620px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(0,0,0,.3); border-top: 4px solid var(--green-700); }
.modal.sm { max-width: 420px; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal header h3 { font-size: 16px; color: var(--green-900); }
.modal-body { padding: 18px; overflow-y: auto; display: grid; gap: 12px; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-row label { display: flex; align-items: center; gap: 6px; font-weight: 500; cursor: pointer; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--green-600); background: var(--green-50); }
.drop strong { color: var(--green-700); }
.muted { color: var(--muted); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: var(--green-900); color: #fff; padding: 10px 18px; border-radius: 8px; font-weight: 500; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; border-left: 4px solid var(--gold); max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--red-700); border-left-color: #fff; }
.loading { padding: 60px; text-align: center; color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 12px 16px; }
  .topbar h2 { font-size: 14px; }
  .content { padding: 16px 16px 40px; }
  .q-opts { grid-template-columns: 1fr; margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .kpi .value { font-size: 26px; }
}
