/* Hostel complaint dashboard.
   Plain CSS, no build step, no external fonts — the Devanagari stack falls back
   to whatever the machine has, which on the demo laptop is Noto Sans Devanagari. */

:root {
  --navy: #143a63;
  --navy-dark: #0d2848;
  --accent: #0e8f6f;          /* health-service green rather than PMC's orange */
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #e2e7f0;
  --text: #16213a;
  --muted: #6b7896;
  --green: #059669;
  --red: #dc2626;
  --amber: #b45309;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 33, 66, .08), 0 8px 24px rgba(16, 33, 66, .06);
}

* { box-sizing: border-box; }

/* The `hidden` attribute hides an element only through the user-agent
 * stylesheet's `display: none`, which ANY author-level `display` beats. Both
 * .drawer and .empty set their own display, so `el.hidden = true` left them on
 * screen: the detail drawer stayed open over the table for the rest of the
 * session while the DOM cheerfully reported hidden === true. Nothing but
 * looking at the rendered page catches that. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Inter", "Segoe UI", system-ui, -apple-system,
        "Noto Sans Devanagari", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace; }
.muted { color: var(--muted); }

/* ---------------- top bar ---------------- */
.topbar {
  background: linear-gradient(100deg, var(--navy-dark), var(--navy));
  color: #fff;
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.crest {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-weight: 700; letter-spacing: .5px; font-size: 13px;
}
.brand h1 { margin: 0; font-size: 18px; font-weight: 650; }
.brand p { margin: 1px 0 0; font-size: 12px; color: #b8c8e4; }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.search {
  width: 320px; max-width: 46vw;
  padding: 8px 12px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.1);
  color: #fff; font-size: 13px; outline: none;
  font-family: inherit;
}
.search::placeholder { color: #a8bcdd; }
.search:focus { border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.16); }

.live { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: #b8f0d4; }
.live i {
  width: 7px; height: 7px; border-radius: 50%; background: #34d399;
  box-shadow: 0 0 0 0 rgba(52,211,153,.7); animation: pulse 2s infinite;
}
.live-down { color: #fecaca; }
.live-down i { background: #f87171; animation: none; }
@keyframes pulse {
  70%  { box-shadow: 0 0 0 7px rgba(52,211,153,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
}

/* ---------------- layout ---------------- */
.main { max-width: 1440px; margin: 0 auto; padding: 24px 28px 60px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-card.alert { border-color: #fca5a5; background: #fffafa; }
.stat-label {
  font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px;
}
.stat-value { font-size: 30px; font-weight: 650; margin-top: 4px; line-height: 1.15; }
.stat-card.alert .stat-value { color: var(--red); }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.stat-bars { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.stat-bar { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.stat-bar span:first-child { width: 62px; color: var(--muted); }
.stat-bar .track { flex: 1; height: 6px; background: #eef1f7; border-radius: 4px; overflow: hidden; }
.stat-bar .fill { height: 100%; border-radius: 4px; background: var(--navy); }
.stat-bar b { width: 26px; text-align: right; font-weight: 600; }
.p-fill-CRITICAL { background: #dc2626; }
.p-fill-HIGH     { background: #f59e0b; }
.p-fill-MEDIUM   { background: #3b82f6; }
.p-fill-LOW      { background: #94a3b8; }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.count { font-size: 12px; color: var(--muted); }

/* ---------------- filters ---------------- */
.filters {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  padding: 12px 20px; background: #fafbfd; border-bottom: 1px solid var(--border);
}
.filter-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 550;
  cursor: pointer; font-family: inherit; transition: all .12s;
}
.chip:hover { border-color: #c7d1e2; color: var(--text); }
.chip-on { background: var(--navy); border-color: var(--navy); color: #fff; }
.select {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 5px 10px; border-radius: 8px; font-size: 12px;
  font-family: inherit; cursor: pointer; max-width: 220px;
}
.toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); cursor: pointer; user-select: none;
}
.toggle input { cursor: pointer; margin: 0; }
.rcount {
  display: none; background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  border-radius: 10px; padding: 0 6px; font-size: 11px; font-weight: 600;
}
.rcount.show { display: inline-block; }

.banner { padding: 12px 20px; font-size: 13px; }
.banner.error { background: #fef2f2; color: #991b1b; border-bottom: 1px solid #fecaca; }
.banner.muted { background: #fafbfd; color: var(--muted); border-bottom: 1px solid var(--border); }
.banner.restricted {
  background: #f5f3ff; color: #5b21b6; border-bottom: 1px solid #ddd6fe;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.link-btn {
  border: 1px solid #c4b5fd; background: #fff; color: #6d28d9;
  padding: 4px 11px; border-radius: 20px; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.link-btn:hover { background: #ede9fe; }
.banner code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; }

/* ---------------- table ---------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
  padding: 11px 16px; background: #fafbfd;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid #f0f3f8; vertical-align: middle; }
.row { cursor: pointer; transition: background .12s; }
.row:hover { background: #f7f9fd; }
.row-selected { background: #eef4ff; }
.row-fresh { animation: flash 6s ease-out; }
@keyframes flash {
  0%, 12% { background: #e6f7f1; }
  100%    { background: transparent; }
}
.token { font-weight: 600; color: var(--navy); white-space: nowrap; }
.nowrap { white-space: nowrap; }
.col-desc { min-width: 280px; max-width: 420px; }
.desc {
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; color: #43506b;
}
.hostel-name { font-weight: 550; }
.hostel-spoken { font-size: 12px; color: var(--amber); display: block; margin-top: 2px; }

/* ---------------- badges ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 550; white-space: nowrap;
  border: 1px solid transparent;
}
.p-CRITICAL { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.p-HIGH     { background: #fff7ed; color: #b45309; border-color: #fed7aa; }
.p-MEDIUM   { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.p-LOW      { background: #f1f4f9; color: var(--muted); border-color: var(--border); }
.badge-warn { background: #fffbeb; color: var(--amber); border-color: #fde68a; font-size: 11px; }
.badge-ok   { background: #ecfdf5; color: #047857; border-color: #a7f3d0; font-size: 11px; }
.badge-restricted { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; font-size: 11px; }
.hits { display: inline-flex; gap: 4px; flex-wrap: wrap; margin-left: 6px; }
.hit {
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  border-radius: 4px; padding: 0 5px; font-size: 11px; font-weight: 500;
}

/* ---------------- empty ---------------- */
.empty { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty-icon { font-size: 38px; opacity: .35; }
.empty h3 { margin: 12px 0 4px; color: var(--text); font-size: 15px; }
.empty p { margin: 0; font-size: 13px; }

.footnote {
  margin: 18px 2px 0; font-size: 12px; color: var(--muted); line-height: 1.6;
  max-width: 860px;
}

/* ---------------- drawer ---------------- */
.scrim {
  position: fixed; inset: 0; background: rgba(11, 26, 51, .35);
  animation: fade .18s ease-out; z-index: 40;
}
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(580px, 94vw);
  background: var(--surface); z-index: 41;
  display: flex; flex-direction: column;
  box-shadow: -10px 0 40px rgba(15, 34, 70, .18);
  animation: slide .22s cubic-bezier(.22,.68,.36,1);
}
@keyframes slide { from { transform: translateX(100%); } }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  background: var(--navy); color: #fff; flex: none;
}
.drawer-token { font-size: 17px; font-weight: 650; }
.drawer-sub { font-size: 12px; color: #b8c8e4; margin-top: 2px; }
.close {
  background: transparent; border: 0; color: #fff; font-size: 26px;
  line-height: 1; cursor: pointer; opacity: .75; padding: 0 2px;
}
.close:hover { opacity: 1; }
.drawer-body { padding: 20px 22px 40px; overflow-y: auto; }

.field { margin-bottom: 18px; }
.field label {
  display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); margin-bottom: 5px; font-weight: 600;
}
.field p { margin: 0; }
.complaint-text {
  background: #f7f9fd; border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px; line-height: 1.6;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

.notice {
  border-radius: 8px; padding: 10px 13px; font-size: 12.5px;
  line-height: 1.55; margin-bottom: 18px;
}
.notice-warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.notice-restricted { background: #f5f3ff; border: 1px solid #ddd6fe; color: #5b21b6; }

.transcript {
  display: flex; flex-direction: column; gap: 9px;
  background: #f7f9fd; border: 1px solid var(--border);
  border-radius: 8px; padding: 14px; max-height: 460px; overflow-y: auto;
}
.bubble {
  display: flex; flex-direction: column; gap: 3px;
  padding: 9px 12px; border-radius: 10px; max-width: 88%;
  font-size: 13px; line-height: 1.55;
}
.bubble-who {
  font-size: 10px; text-transform: uppercase; letter-spacing: .4px;
  opacity: .6; font-weight: 600;
}
.bubble-assistant {
  background: var(--navy); color: #fff;
  align-self: flex-start; border-bottom-left-radius: 3px;
}
.bubble-user {
  background: #fff; border: 1px solid var(--border);
  align-self: flex-end; border-bottom-right-radius: 3px;
}

@media (max-width: 760px) {
  .main { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .search { width: 100%; max-width: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .filters { padding: 10px 14px; }
}
