@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,700&display=swap');

/* ═══════════════════════════════════════════════════════
   BuzzRadius — Refined Navy & Gold Design System
   ═══════════════════════════════════════════════════════ */
:root {
  /* Brand */
  --navy:      #0b1f47;
  --navy2:     #163a7a;
  --navy3:     #1e4ea0;
  --navy4:     #091736;
  --gold:      #f5b301;
  --gold2:     #ffcf45;
  --gold-soft: #fffbeb;
  --gold-dim:  rgba(245,179,1,.12);

  /* State */
  --green:     #16a34a;
  --green-bg:  #dcfce7;
  --red:       #dc2626;
  --red-bg:    #fee2e2;
  --blue:      #2563eb;
  --blue-bg:   #dbeafe;
  --amber:     #d97706;
  --amber-bg:  #fef3c7;

  /* Surfaces */
  --bg:        #f0f4fb;
  --bg2:       #e8eef8;
  --card:      #ffffff;
  --line:      #e2e8f4;
  --line2:     #c8d4eb;
  --ink:       #0f172a;
  --ink2:      #1e293b;
  --muted:     #64748b;
  --muted2:    #94a3b8;

  /* Elevation */
  --shadow-sm: 0 1px 3px rgba(11,31,71,.06);
  --shadow:    0 4px 20px rgba(11,31,71,.08);
  --shadow-md: 0 8px 32px rgba(11,31,71,.10);
  --shadow-lg: 0 20px 56px rgba(11,31,71,.18);

  /* Geometry */
  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --sidebar-w: 220px;
  --topbar-h:  64px;
}

/* ── Motion preference ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }

body {
  font-family: 'Inter', system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--navy3); text-decoration: none; font-weight: 500 }
a:hover { text-decoration: underline }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ══════════════════ TOP BAR (user dashboard) ══════════════════ */
.topbar {
  background: linear-gradient(110deg, var(--navy) 0%, var(--navy2) 55%, var(--navy3) 100%);
  color: #fff;
  padding: 0 32px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 4px 24px rgba(11,31,71,.22);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar .right {
  display: flex;
  gap: 18px;
  align-items: center;
  font-size: .9rem;
}

.topbar .right a { color: rgba(255,255,255,.75) }
.topbar .right a:hover { color: var(--gold2); text-decoration: none }
#who { font-weight: 700; color: var(--gold2) }

/* ══════════════════ LAYOUT ══════════════════ */
.wrap {
  max-width: 1200px;
  margin: 26px auto;
  padding: 0 24px;
  display: grid;
  gap: 20px;
}

.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

/* ══════════════════ CARDS ══════════════════ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold2) 100%);
}

.card h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--navy);
}

.card h2 svg { color: var(--navy2); flex-shrink: 0 }

/* ══════════════════ FORMS ══════════════════ */
label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  margin: 14px 0 5px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

input, select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line2);
  border-radius: var(--radius);
  font: inherit;
  font-size: .94rem;
  background: #fafbff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245,179,1,.14);
  background: #fff;
}

input::placeholder { color: var(--muted2) }
textarea { min-height: 88px; resize: vertical }

/* ══════════════════ BUTTONS ══════════════════ */
button {
  cursor: pointer;
  border: 0;
  border-radius: var(--radius);
  padding: 12px 22px;
  font: inherit;
  font-weight: 600;
  font-size: .94rem;
  color: var(--navy);
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold2) 100%);
  box-shadow: 0 3px 12px rgba(245,179,1,.28);
  transition: transform .15s, box-shadow .15s, opacity .15s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

button:hover  { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(245,179,1,.38) }
button:active { transform: translateY(0);    box-shadow: 0 2px 8px  rgba(245,179,1,.28) }
button:disabled { opacity: .45; cursor: not-allowed; transform: none !important; box-shadow: none !important }

button.navy {
  background: linear-gradient(135deg, var(--navy2), var(--navy3));
  color: #fff;
  box-shadow: 0 3px 12px rgba(22,58,122,.28);
}
button.navy:hover { box-shadow: 0 6px 18px rgba(22,58,122,.38) }

button.ghost {
  background: transparent;
  color: var(--ink2);
  box-shadow: none;
  border: 1.5px solid var(--line2);
}
button.ghost:hover { background: var(--bg2); transform: translateY(-1px); box-shadow: none }

button.danger {
  background: linear-gradient(135deg, #ef4444, var(--red));
  color: #fff;
  box-shadow: 0 3px 12px rgba(220,38,38,.24);
}
button.danger:hover { box-shadow: 0 6px 18px rgba(220,38,38,.34) }

button.sm {
  padding: 7px 13px;
  font-size: .8rem;
  border-radius: var(--radius-sm);
  box-shadow: none;
}
button.sm:hover { transform: translateY(-1px) }

/* ══════════════════ TABLES ══════════════════ */
table { width: 100%; border-collapse: collapse; font-size: .87rem }

th, td {
  text-align: left;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

thead th {
  position: sticky;
  top: 0;
  background: #f4f6fd;
  color: var(--muted);
  font-weight: 700;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  white-space: nowrap;
}

tbody tr { transition: background .12s }
tbody tr:hover { background: #f8faff }
tbody tr:last-child td { border-bottom: 0 }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: .73rem;
  font-weight: 600;
}

/* ══════════════════ STATS ══════════════════ */
.statgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 13px;
}

.stat {
  padding: 15px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, #f6f9ff, var(--bg2));
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat .n {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat .l {
  font-size: .7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}

/* ══════════════════ UTILITIES ══════════════════ */
.row   { display: flex; gap: 12px; align-items: center; flex-wrap: wrap }
.muted { color: var(--muted) }
.hide  { display: none !important }

/* Connection */
.conn-status { font-size: 1.05rem; font-weight: 700; color: var(--navy); margin-bottom: 8px }
.conn-status #connStatus .badge { font-size: .88rem; padding: 5px 15px }

.conn-actions { gap: 10px; margin-top: 8px }
.conn-actions button {
  flex: 1;
  min-width: 110px;
  padding: 13px 16px;
  font-size: .94rem;
  border-radius: var(--radius);
  justify-content: center;
}

.qrbox { text-align: center }
.qrbox canvas {
  width: 220px; height: 220px;
  border: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 5px;
  background: #fff;
  box-shadow: var(--shadow-md);
}

.scroll { max-height: 440px; overflow: auto; border-radius: var(--radius-sm) }

.disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--gold-soft);
  border: 1px solid rgba(245,179,1,.35);
  border-left: 4px solid var(--gold);
  color: #78350f;
  padding: 13px 17px;
  border-radius: var(--radius);
  font-size: .87rem;
  line-height: 1.55;
}
.disclaimer .ico { flex-shrink: 0; color: var(--amber); margin-top: 1px }
.disclaimer strong { color: var(--navy) }

.tips {
  background: linear-gradient(160deg, #f0f6ff, #e8f0fd);
  border: 1px solid var(--line);
  border-left: 4px solid var(--navy3);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 18px;
}
.tips h3 {
  font-size: .88rem;
  color: var(--navy);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}
.tips h3 svg { color: var(--navy3); flex-shrink: 0 }
.tips ul { list-style: none; display: grid; gap: 8px }
.tips li {
  position: relative;
  padding-left: 27px;
  font-size: .86rem;
  color: var(--ink2);
}
.tips li::before {
  content: "";
  position: absolute;
  left: 0; top: 3px;
  width: 17px; height: 17px;
  background: var(--gold);
  border-radius: 50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230b1f47' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-size: 68%;
  background-repeat: no-repeat;
  background-position: center;
}

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px }
.filters .fld { display: grid; gap: 4px }
.filters label { margin: 0; text-transform: none; font-size: .78rem; letter-spacing: 0 }
.filters select, .filters input { width: auto; min-width: 128px; padding: 9px 11px }

/* ══════════════════ ADMIN HOME — DATA CARDS ══════════════════ */
.mini-col { display: flex; flex-direction: column; gap: 13px }
.mini-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 13px;
}
.mini-badge {
  min-width: 50px;
  height: 50px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  font-weight: 800;
  background: var(--gold-dim);
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.mini-body { flex: 1 }
.mini-body .ml { font-weight: 600; color: var(--ink2); display: block; margin-bottom: 6px; font-size: .85rem }
.prog { height: 7px; background: var(--line); border-radius: 99px; overflow: hidden }
.prog i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--navy3), var(--gold)); transition: width .5s ease }

/* Charts */
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap }
.donut { width: 160px; height: 160px; flex-shrink: 0 }
.donut .hole-n { font-weight: 800; fill: var(--navy) }
.donut .hole-l { fill: var(--muted); text-transform: uppercase; letter-spacing: .07em }
.donut circle.seg { transition: stroke-width .15s }
.donut circle.seg:hover { stroke-width: 7.5; cursor: pointer }
.donut-card .donut { width: 135px; height: 135px }

.legend { display: grid; gap: 8px; flex: 1; min-width: 130px }
.legend .li { display: flex; align-items: center; gap: 8px; font-size: .85rem }
.legend .dot { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0 }
.legend .li b { margin-left: auto; font-variant-numeric: tabular-nums }

.bars { display: grid; gap: 12px }
.bar-row .bar-top { display: flex; justify-content: space-between; font-size: .84rem; margin-bottom: 5px }
.bar-row .bar-top .cap { font-weight: 600; color: var(--navy); text-transform: capitalize }
.bar-track { height: 11px; background: var(--line); border-radius: 99px; overflow: hidden }
.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--navy3), var(--gold));
  transition: width .5s ease;
}

.rank {
  display: inline-grid;
  place-items: center;
  width: 23px; height: 23px;
  border-radius: 50%;
  background: var(--gold-dim);
  color: var(--navy);
  font-weight: 700;
  font-size: .72rem;
  border: 1.5px solid rgba(245,179,1,.25);
}

.pill {
  font-size: .73rem;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--bg2);
  color: var(--muted);
}

/* KPI (compat) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px }
.kpi {
  padding: 17px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy2) 100%);
  color: #fff;
  border-left: 4px solid var(--gold);
}
.kpi .n { font-size: 1.9rem; font-weight: 800; line-height: 1; color: var(--gold2); font-variant-numeric: tabular-nums }
.kpi .l { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; opacity: .8; font-weight: 600 }

/* chart-row (compat) */
.chart-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px }

/* Watermark (compat) */
.watermark {
  position: absolute; right: -20px; top: 50%;
  transform: translateY(-50%);
  height: 200px; opacity: .04;
  pointer-events: none; filter: grayscale(1);
}

/* ══════════════════ TOAST ══════════════════ */
#toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--navy);
  color: #fff;
  padding: 13px 24px;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  border-left: 4px solid var(--gold);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: transform .28s cubic-bezier(.34,1.56,.64,1), opacity .2s;
  z-index: 300;
  white-space: nowrap;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1 }

/* ══════════════════ LOGIN — SPLIT PANEL ══════════════════ */
.center {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}

.login-brand {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--navy) 0%, var(--navy2) 55%, var(--navy3) 100%);
  padding: 60px 48px;
  gap: 40px;
  position: relative;
  overflow: hidden;
}
.login-brand::before {
  content: "";
  position: absolute;
  width: 480px; height: 480px;
  background: radial-gradient(circle, rgba(245,179,1,.14) 0%, transparent 70%);
  top: -120px; right: -100px;
  pointer-events: none;
}
.login-brand::after {
  content: "";
  position: absolute;
  width: 380px; height: 380px;
  background: radial-gradient(circle, rgba(245,179,1,.07) 0%, transparent 70%);
  bottom: -80px; left: -80px;
  pointer-events: none;
}

.login-brand-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 340px;
}
.login-brand-content .logo { height: 80px; margin-bottom: 18px; display: block; margin-left: auto; margin-right: auto }
.login-brand-content .brand-heading {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1;
  margin-bottom: 12px;
  background: linear-gradient(90deg, var(--gold) 0%, #ffffff 65%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-brand-content .brand-heading i { font-style: italic }
.login-brand-content p {
  color: rgba(255,255,255,.65);
  font-size: .9rem;
  line-height: 1.65;
}

.login-brand-features {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 13px;
  max-width: 280px;
}
.login-brand-features .feat {
  display: flex;
  align-items: center;
  gap: 13px;
  color: rgba(255,255,255,.8);
  font-size: .88rem;
}
.login-brand-features .feat svg { color: var(--gold); flex-shrink: 0 }

.login-form-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 48px 80px;
  background: var(--bg);
  max-width: 480px;
}

.login {
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 38px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--line);
}

.login h1 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 3px;
  text-align: center;
  color: var(--navy);
}

.login p.sub {
  text-align: center;
  color: var(--muted);
  margin-bottom: 22px;
  font-size: .88rem;
}

.login button {
  width: 100%;
  margin-top: 18px;
  justify-content: center;
  font-size: .97rem;
  padding: 14px;
}

/* Terms */
.terms {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  padding: 13px 15px;
  margin-top: 16px;
  font-size: .83rem;
  color: var(--ink2);
  line-height: 1.5;
}
.terms input[type="checkbox"] {
  width: 19px; height: 19px;
  min-width: 19px;
  margin-top: 1px;
  accent-color: var(--gold);
  cursor: pointer;
}
.terms-body { flex: 1 }
.terms label { margin: 0; font-weight: 500; color: var(--ink2); cursor: pointer; text-transform: none; font-size: .83rem; letter-spacing: 0 }
.terms strong { color: var(--navy) }

.terms-details { margin-top: 6px }
.terms-details summary {
  cursor: pointer; list-style: none;
  font-weight: 600; font-size: .78rem;
  color: var(--navy3);
  display: inline-flex; align-items: center; gap: 5px;
  user-select: none;
}
.terms-details summary::-webkit-details-marker { display: none }
.terms-details summary::before { content: "▸"; font-size: .66rem; transition: transform .15s }
.terms-details[open] summary::before { transform: rotate(90deg) }
.terms-details summary:hover { text-decoration: underline }
.terms-details p { margin-top: 8px; font-size: .79rem; color: var(--muted); line-height: 1.55 }

.err {
  color: var(--red);
  font-size: .86rem;
  margin-top: 11px;
  text-align: center;
  font-weight: 600;
}

/* Notice strip */
.notice-strip {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 20px;
  font-size: .78rem;
  color: var(--navy);
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold2) 50%, var(--gold) 100%);
  border-top: 1.5px solid rgba(11,31,71,.1);
  box-shadow: 0 -4px 16px rgba(11,31,71,.1);
}
.notice-strip svg { flex-shrink: 0 }

/* ══════════════════ ADMIN SHELL ══════════════════ */
body.admin { background: var(--bg) }

.app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy4) 100%);
  display: flex;
  flex-direction: column;
  padding: 18px 10px;
  position: sticky;
  top: 0;
  height: 100vh;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none }

.side-logo {
  height: 38px;
  margin: 4px 8px 20px;
  display: block;
}

.sidenav { display: flex; flex-direction: column; gap: 2px; flex: 1 }
.side-bottom {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.1);
  margin-top: auto;
}

.navitem {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  box-shadow: none;
  color: rgba(255,255,255,.58);
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 11px;
  font-size: .86rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  text-decoration: none;
  white-space: nowrap;
  text-align: left;
}
.navitem .ic { flex-shrink: 0; display: flex; align-items: center; line-height: 0 }
.navitem .lb { flex: 1 }
.navitem:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.9);
  text-decoration: none;
}
.navitem.active {
  background: rgba(245,179,1,.12);
  color: var(--gold2);
  border-color: rgba(245,179,1,.2);
  font-weight: 600;
}

/* ── Main column ── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 26px 30px }

.mainhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.mainhead h1 { font-size: 1.7rem; font-weight: 800; color: var(--navy); letter-spacing: -.02em }
.mainhead .crumb { color: var(--muted); font-size: .82rem; font-weight: 500; margin-top: 2px }
.head-actions { display: flex; align-items: center; gap: 11px; flex-wrap: wrap }

.searchbox {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1.5px solid var(--line2);
  border-radius: 99px;
  padding: 7px 15px;
  color: var(--muted2);
  transition: border-color .15s, box-shadow .15s;
}
.searchbox:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245,179,1,.12);
  color: var(--muted);
}
.searchbox input { border: 0; background: transparent; padding: 2px 0; width: 190px; font-size: .88rem; color: var(--ink) }
.searchbox input:focus { outline: 0; box-shadow: none }
.searchbox.hide { display: none }

.whoChip {
  background: var(--card);
  border: 1.5px solid var(--line2);
  border-radius: 99px;
  padding: 7px 16px;
  font-weight: 600;
  font-size: .85rem;
  color: var(--navy);
}

#headAction.hide { display: none }
.content { flex: 1; display: flex; flex-direction: column }

/* Views */
.view { display: none }
.view.active { display: grid; gap: 20px; animation: fadeIn .2s ease both }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px) } to { opacity: 1; transform: none } }

.view .card.full { flex: 1; display: flex; flex-direction: column }
.view .card.full .scroll { flex: 1; max-height: none }
.card-top { display: flex; align-items: center; gap: 9px; margin-bottom: 14px }
.card-top h2 { margin: 0; padding: 0; border: 0; flex: 1; font-size: .97rem }
.dots { color: var(--muted2); font-weight: 800; letter-spacing: 2px; cursor: default }

/* ── Home grid ── */
.home-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 17px;
  margin-bottom: 17px;
}

.hero-card {
  border-radius: var(--radius-lg);
  padding: 22px;
  color: #fff;
  background: linear-gradient(140deg, var(--navy2) 0%, var(--navy3) 50%, #2563eb 100%);
  box-shadow: 0 10px 28px rgba(22,58,122,.28);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.hero-card::after {
  content: "";
  position: absolute;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(245,179,1,.16) 0%, transparent 70%);
  top: -55px; right: -55px;
  pointer-events: none;
}
.hero-top { display: flex; justify-content: space-between; font-weight: 600; opacity: .85; font-size: .85rem; position: relative; z-index: 1 }
.hero-top .dots { color: rgba(255,255,255,.4) }
.hero-num { font-size: 2.6rem; font-weight: 800; margin: 7px 0 3px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; position: relative; z-index: 1 }
.hero-spark { margin: 8px 0 12px; position: relative; z-index: 1 }
.hero-spark svg { width: 100%; height: 38px; display: block }
.hero-foot {
  display: flex; gap: 10px; margin-top: auto;
  border-top: 1px solid rgba(255,255,255,.18); padding-top: 12px;
  position: relative; z-index: 1;
}
.hero-foot > div { flex: 1; display: flex; flex-direction: column; gap: 2px }
.hero-foot .hl { font-size: .7rem; opacity: .7; font-weight: 600; text-transform: uppercase; letter-spacing: .05em }
.hero-foot .hv { font-size: 1.1rem; font-weight: 800; font-variant-numeric: tabular-nums }

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11,31,71,.48);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-overlay.show { display: flex }
.modal {
  position: relative;
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 30px;
  width: 100%;
  max-width: 510px;
  box-shadow: var(--shadow-lg);
  border-top: 4px solid var(--gold);
  animation: fadeIn .2s ease both;
}
.modal h2 { font-size: 1.22rem; color: var(--navy); margin-bottom: 3px }
.modal .modal-sub { color: var(--muted); font-size: .86rem; margin-bottom: 18px }
.modal .close {
  position: absolute; top: 14px; right: 14px;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--bg2);
  color: var(--muted);
  font-size: .95rem;
  box-shadow: none; padding: 0;
  justify-content: center;
  border: 1.5px solid var(--line);
}
.modal .close:hover { background: var(--line); color: var(--ink); transform: none; box-shadow: none }

.iconbtn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1.5px solid var(--line2);
  color: var(--navy);
  cursor: pointer;
  box-shadow: none;
  text-decoration: none;
  flex-shrink: 0;
  transition: background .15s;
}
.iconbtn:hover { background: var(--bg2); transform: none; box-shadow: none }

.mobile-only { display: none }

/* ══════════════════ LOGO / BRAND ══════════════════ */
.topbar h1 .logo { height: 34px; vertical-align: middle; margin-right: 8px }
.login .logo { display: block; margin: 0 auto 14px; height: 68px }
#loader .logo { height: 92px; animation: brandPop .6s ease both }

.brand { font-weight: 800; letter-spacing: -.02em; font-style: normal }
.brand i { font-style: italic }
.topbar .brand { color: #fff }
.topbar .brand i { color: var(--gold) }
.login .brand {
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy3) 40%, var(--gold) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* brand-lg used in #loader */
.brand-lg {
  font-size: 3.1rem;
  font-weight: 800;
  letter-spacing: -.03em;
}
#loader .brand-lg {
  background: linear-gradient(90deg, var(--gold) 0%, #fff 70%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
#loader .brand-lg i { font-style: italic }

/* ══════════════════ LOADER ══════════════════ */
#loader {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column;
  gap: 22px; align-items: center; justify-content: center;
  color: #fff;
  background: linear-gradient(145deg, var(--navy) 0%, var(--navy2) 100%);
  animation: loaderOut .45s ease 1.1s forwards;
}
#loader .ring {
  width: 46px; height: 46px;
  border: 4px solid rgba(255,255,255,.18);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

@keyframes spin     { to { transform: rotate(360deg) } }
@keyframes brandPop { from { opacity: 0; transform: scale(.93) } to { opacity: 1; transform: scale(1) } }
@keyframes loaderOut { to { opacity: 0; visibility: hidden } }

/* adminnav (compat) */
.adminnav {
  position: sticky; top: 0; z-index: 40;
  background: var(--card);
  border-bottom: 1.5px solid var(--line);
  box-shadow: 0 2px 10px rgba(11,31,71,.04);
  display: flex; gap: 4px; padding: 0 20px; overflow-x: auto;
}
.adminnav .tab {
  appearance: none; background: transparent; border: 0; box-shadow: none;
  color: var(--muted); font-weight: 600; font-size: .9rem;
  padding: 15px 16px; border-bottom: 2.5px solid transparent;
  border-radius: 0; white-space: nowrap; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.adminnav .tab:hover { color: var(--navy); transform: none; box-shadow: none }
.adminnav .tab.active { color: var(--navy); border-bottom-color: var(--gold) }

/* ══════════════════ RESPONSIVE ══════════════════ */
@media (max-width: 1080px) {
  .home-grid { grid-template-columns: 1fr 1fr }
}

@media (max-width: 760px) {
  .app { flex-direction: column }

  .sidebar {
    position: fixed;
    left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; height: auto;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-around;
    border-radius: 16px 16px 0 0;
    padding: 7px 6px calc(7px + env(safe-area-inset-bottom, 0px));
    gap: 2px; z-index: 100;
    box-shadow: 0 -6px 22px rgba(11,31,71,.22);
    overflow: visible;
  }
  .side-logo, .side-bottom { display: none }
  .sidenav { flex-direction: row; flex: 1; justify-content: space-around; gap: 2px }
  .navitem {
    flex: 1; flex-direction: column;
    padding: 7px 4px; border-radius: 11px;
    gap: 3px; align-items: center;
    font-size: .62rem; border: 0;
  }
  .navitem .lb { font-size: .62rem }

  .main { padding: 16px 14px calc(78px + env(safe-area-inset-bottom, 0px)) }
  .mainhead { margin-bottom: 15px; gap: 10px }
  .mainhead h1 { font-size: 1.35rem }
  .head-actions { width: 100%; gap: 8px }
  .searchbox { flex: 1 }
  .searchbox input { width: 100% }
  .whoChip { display: none }
  .mobile-only { display: inline-grid }

  .home-grid { grid-template-columns: 1fr }
  .hero-num { font-size: 2.2rem }

  .modal-overlay { align-items: flex-end; padding: 0 }
  .modal {
    max-width: none;
    border-radius: 22px 22px 0 0;
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom, 0px));
    animation: sheetUp .25s ease both;
  }
  .modal .grid { grid-template-columns: 1fr; gap: 0 }
}
@keyframes sheetUp { from { transform: translateY(100%) } to { transform: none } }

@media (max-width: 768px) {
  .center { flex-direction: column }
  .login-brand { display: none }
  .login-form-panel { max-width: none; padding: 36px 22px 76px }
  .login { padding: 26px 20px; border-radius: var(--radius-lg) }
  .login h1 { font-size: 1.6rem }
}

@media (max-width: 640px) {
  body { font-size: 15px }
  .topbar { padding: 0 16px; height: 56px }
  .topbar h1 { font-size: .98rem }
  .topbar h1 .logo { height: 30px }
  .wrap { margin: 14px auto; padding: 0 14px; gap: 14px }
  .grid { gap: 14px }
  .card { padding: 16px; border-radius: var(--radius) }

  .conn-actions button { padding: 12px 13px; font-size: .88rem }
  .statgrid { grid-template-columns: 1fr 1fr; gap: 10px }
  .stat .n { font-size: 1.7rem }

  .scroll { -webkit-overflow-scrolling: touch }
  .scroll table { min-width: 500px }
  th, td { padding: 10px 11px }

  #toast { left: 12px; right: 12px; bottom: 78px; transform: translateY(110px); white-space: normal; text-align: center }
  #toast.show { transform: translateY(0) }
  .notice-strip { font-size: .74rem; padding: 8px 14px }
}

@media (max-width: 380px) {
  .mainhead h1 { font-size: 1.22rem }
  .hero-num { font-size: 2rem }
  .navitem .lb { font-size: .58rem }
}
