/* =====================================================================
   Erode Rural SWM 2026 Quiz
   Visual system is built from the four waste streams the rules define:
   green = wet, blue = dry, red = sanitary, amber = special care.
   That four-colour band is the signature device - it carries meaning
   (segregation), it is not decoration.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Tamil:wght@400;500;600;700&family=Noto+Serif+Tamil:wght@500;600;700&display=swap');

:root {
  --wet:      #157f47;
  --dry:      #1264a3;
  --sani:     #b8342a;
  --special:  #c98a06;

  --ink:      #14261d;
  --ink-soft: #46584d;
  --muted:    #7b8a80;
  --line:     #dbe3dc;
  --paper:    #eef2ec;
  --card:     #ffffff;

  --radius:   10px;
  --shadow:   0 1px 2px rgba(20,38,29,.06), 0 8px 24px -16px rgba(20,38,29,.35);

  --sans:  'Noto Sans Tamil', 'Latha', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Noto Serif Tamil', 'Noto Sans Tamil', Georgia, serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
}

a { color: var(--wet); }

/* ---------- the four-stream band ---------- */
.stream-band {
  display: flex;
  height: 5px;
  width: 100%;
}
.stream-band i { flex: 1; display: block; }
.stream-band i:nth-child(1) { background: var(--wet); }
.stream-band i:nth-child(2) { background: var(--dry); }
.stream-band i:nth-child(3) { background: var(--sani); }
.stream-band i:nth-child(4) { background: var(--special); }

/* ---------- page chrome ---------- */
.site-head {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.site-head .inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.crest {
  width: 42px; height: 42px;
  flex: none;
  border-radius: 50%;
  background: var(--wet);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .5px;
}
.site-head h1 {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.4;
}
.site-head p {
  margin: 2px 0 0;
  font-size: .82rem;
  color: var(--muted);
}
.head-actions { margin-left: auto; display: flex; gap: 8px; }

.wrap {
  max-width: 660px;
  margin: 0 auto;
  padding: 24px 18px 64px;
}
.wrap-wide { max-width: 1180px; }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}
.card.flush { padding: 0; overflow: hidden; }
.card h2 {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 4px;
}
.card .hint {
  margin: 0 0 18px;
  font-size: .86rem;
  color: var(--muted);
}

/* ---------- forms ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: .88rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.field label .en { font-weight: 400; color: var(--muted); }

input[type=text], input[type=tel], input[type=email],
input[type=password], input[type=number], select, textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 1rem;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfa;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--wet);
  outline-offset: 1px;
  border-color: var(--wet);
  background: #fff;
}
select:disabled { background: #eef0ee; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* role chooser */
.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}
.role-opt { position: relative; }
.role-opt input {
  position: absolute; opacity: 0;
  width: 100%; height: 100%; margin: 0; cursor: pointer;
}
.role-opt span {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  background: #fbfdfa;
  font-weight: 600;
  font-size: .94rem;
  cursor: pointer;
}
.role-opt span small {
  display: block;
  font-weight: 400;
  font-size: .78rem;
  color: var(--muted);
}
.role-opt input:checked + span {
  border-color: var(--wet);
  border-left-color: var(--wet);
  background: #eef7f1;
}
.role-opt input:focus-visible + span { outline: 2px solid var(--wet); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 22px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--wet);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn:hover { background: #106138; }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn-block { display: block; width: 100%; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover { background: #f1f5f0; }
.btn-sm { padding: 7px 14px; font-size: .85rem; }
.btn-danger { background: var(--sani); }
.btn-danger:hover { background: #99271e; }

/* ---------- alerts ---------- */
.alert {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: .9rem;
  margin-bottom: 16px;
  border-left: 4px solid;
}
.alert-error { background: #fdeeec; border-color: var(--sani); color: #7d211a; }
.alert-ok    { background: #eaf6ef; border-color: var(--wet); color: #0d5731; }
.alert-info  { background: #eaf1f8; border-color: var(--dry); color: #0f4a79; }
.alert-warn  { background: #fdf4e3; border-color: var(--special); color: #7a5403; }

/* ---------- quiz ---------- */
.quiz-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 10px 18px;
}
.quiz-bar .row {
  max-width: 660px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .86rem;
  font-weight: 600;
}
.timer { margin-left: auto; font-variant-numeric: tabular-nums; }
.timer.low { color: var(--sani); }
.progress-track {
  max-width: 660px;
  margin: 8px auto 0;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--wet);
  transition: width .25s ease;
}

.qcard { display: none; }
.qcard.active { display: block; }

.qnum {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.qtext {
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.6;
  margin: 0 0 18px;
}

.opts { display: grid; gap: 9px; }
.opt { position: relative; }
.opt input {
  position: absolute; opacity: 0;
  width: 100%; height: 100%; margin: 0; cursor: pointer;
}
.opt span {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfa;
  cursor: pointer;
  line-height: 1.5;
}
.opt span b {
  flex: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-size: .78rem;
  font-weight: 700;
  color: var(--ink-soft);
  background: #fff;
}
.opt input:checked + span {
  border-color: var(--wet);
  background: #eef7f1;
}
.opt input:checked + span b {
  background: var(--wet);
  border-color: var(--wet);
  color: #fff;
}
.opt input:focus-visible + span { outline: 2px solid var(--wet); outline-offset: 2px; }

.qnav {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.qnav .btn { flex: 1; }

.qmap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.qmap button {
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-family: var(--sans);
  font-size: .8rem;
  cursor: pointer;
  color: var(--ink-soft);
}
.qmap button.done { background: var(--wet); border-color: var(--wet); color: #fff; }
.qmap button.here { outline: 2px solid var(--ink); outline-offset: 1px; }

/* ---------- result ---------- */
.score-hero {
  text-align: center;
  padding: 30px 22px 26px;
}
.score-big {
  font-family: var(--serif);
  font-size: 3.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--wet);
  font-variant-numeric: tabular-nums;
}
.score-big em {
  font-style: normal;
  font-size: 1.3rem;
  color: var(--muted);
  font-weight: 500;
}
.score-meta {
  display: flex;
  justify-content: center;
  gap: 26px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.score-meta div { min-width: 90px; }
.score-meta strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}
.score-meta small { color: var(--muted); font-size: .8rem; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
table.data th, table.data td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.data th {
  font-size: .78rem;
  font-weight: 700;
  color: var(--ink-soft);
  background: #f5f8f4;
  white-space: nowrap;
}
table.data tbody tr:hover { background: #f8faf7; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

.rank-chip {
  display: inline-grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  font-size: .82rem;
  font-weight: 700;
  background: #eef2ec;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
tr.r1 .rank-chip { background: var(--special); color: #fff; }
tr.r2 .rank-chip { background: var(--dry);     color: #fff; }
tr.r3 .rank-chip { background: var(--sani);    color: #fff; }
tr.me { background: #eef7f1; }
tr.me td { font-weight: 600; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .74rem;
  font-weight: 600;
  background: #eef2ec;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* ---------- admin ---------- */
.admin-nav {
  background: var(--ink);
  color: #cfdbd3;
}
.admin-nav .inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
}
.admin-nav a {
  color: #cfdbd3;
  text-decoration: none;
  padding: 13px 14px;
  font-size: .89rem;
  font-weight: 500;
  border-bottom: 3px solid transparent;
}
.admin-nav a:hover { color: #fff; }
.admin-nav a.on { color: #fff; border-bottom-color: var(--wet); }
.admin-nav .sp { margin-left: auto; }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--wet);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi:nth-child(2) { border-top-color: var(--dry); }
.kpi:nth-child(3) { border-top-color: var(--special); }
.kpi:nth-child(4) { border-top-color: var(--sani); }
.kpi:nth-child(5) { border-top-color: var(--ink-soft); }
.kpi b {
  display: block;
  font-family: var(--serif);
  font-size: 1.9rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi small { color: var(--muted); font-size: .82rem; }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}
.chart-box { position: relative; height: 300px; }

.bar-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
  font-size: .85rem;
}
.bar-line .lbl { width: 46%; }
.bar-line .track {
  flex: 1;
  height: 9px;
  background: var(--line);
  border-radius: 5px;
  overflow: hidden;
}
.bar-line .fill { height: 100%; background: var(--wet); border-radius: 5px; }
.bar-line .val { width: 52px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bar-line.weak .fill { background: var(--sani); }
.bar-line.mid  .fill { background: var(--special); }

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
}
.filters .field { margin: 0; min-width: 160px; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-box { width: 100%; max-width: 380px; }

.foot {
  text-align: center;
  font-size: .8rem;
  color: var(--muted);
  padding: 24px 18px 40px;
}

@media print {
  .site-head, .admin-nav, .btn, .qnav, .foot { display: none !important; }
  body { background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}