:root {
  --bg: #f6f3ee; --card: #ffffff; --ink: #1d2a2e; --muted: #64747a; --line: #e4ded4;
  --brand: #0f6b62; --brand-ink: #ffffff; --brand-soft: #e2f1ee;
  --good: #1a7f4b; --good-soft: #e3f4ea; --warn: #9a6400; --warn-soft: #fbefd3;
  --bad: #b3261e; --bad-soft: #fbe6e4; --info: #2b5aa8; --info-soft: #e5edfa;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Tamil", sans-serif; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
p { margin: 0 0 12px; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; }
.right { text-align: right; }
.grow { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 16px; }
.hidden { display: none !important; }

/* sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: 0 10px 30px rgba(29, 42, 46, .07); }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.logo-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }

/* shell */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: #12302d; color: #d5e4e1; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .logo { color: #fff; padding: 4px 8px 16px; }
.side .logo-mark { background: #e9c46a; color: #12302d; }
.nav { display: block; width: 100%; text-align: left; background: none; border: 0; color: inherit; font: inherit; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.nav:hover { background: rgba(255, 255, 255, .08); }
.nav.on { background: #e9c46a; color: #12302d; font-weight: 600; }
.side .who { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid rgba(255, 255, 255, .14); font-size: 13px; }
.side .who .muted { color: #9fb8b4; }
.main { padding: 26px 30px 60px; min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.head p { max-width: 720px; margin: 0; }
.menu-btn { display: none; }

/* pieces */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile b { display: block; font-size: 26px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 13px; }
.tile small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.cols { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.banner { border-radius: var(--radius); padding: 12px 16px; background: var(--warn-soft); color: #5c3c00; border: 1px solid #efd9a0; }
.gap { height: 12px; }
.banner.bad { background: var(--bad-soft); color: #7a1711; border-color: #f1c2be; }
.banner.ok { background: var(--good-soft); color: #0f5230; border-color: #bfe3cd; }

.btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c9c0b1; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.primary:hover { background: #0c5a52; }
.btn.danger { color: var(--bad); border-color: #ecc7c4; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .nav:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #8fc7bf; outline-offset: 1px; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
input, select, textarea { font: inherit; width: 100%; padding: 9px 11px; border: 1px solid #cfc7ba; border-radius: 8px; background: #fff; color: var(--ink); }
textarea { min-height: 76px; resize: vertical; }
input[type=checkbox] { width: auto; margin-right: 6px; }
label input:not([type=checkbox]) { margin-top: 4px; font-weight: 400; }
audio { width: 100%; }
.field { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 14px; }
.inline > * { width: auto; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid #efeae2; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: 6px; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: #eee9e0; color: #4c5a5f; white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 10px; }
.chart { width: 100%; height: 170px; display: block; }
.chart .bar { fill: #cfe5e1; }
.chart .bar2 { fill: var(--brand); }
.chart text { fill: var(--muted); font-size: 10px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }
.legend .a { background: #cfe5e1; } .legend .b { background: var(--brand); }

.bubble { max-width: 620px; padding: 9px 13px; border-radius: 12px; background: #f1ede6; margin-bottom: 8px; }
.bubble.guest { background: var(--brand-soft); margin-left: 40px; }
.bubble small { display: block; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; }
.drop { border: 2px dashed #cfc7ba; border-radius: var(--radius); padding: 26px; text-align: center; background: #fbf9f5; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1d2a2e; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; z-index: 50; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--bad); }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(520px, 92vw); color: var(--ink); }
dialog::backdrop { background: rgba(18, 48, 45, .45); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 240px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu-btn { display: inline-block; margin-bottom: 12px; }
  .main { padding: 16px 14px 60px; }
  .cols { grid-template-columns: 1fr; }
  .bubble.guest { margin-left: 16px; }
}
