/* Guardian53 Parent Dashboard — design system
 * Mobile-first; sidebar ≥ 960px. Dark console theme matching the public site:
 * slate-950 canvas, blue→indigo brand, calm cards, high-contrast text. */
:root {
  color-scheme: dark;
  --bg: #020617;          /* slate-950 */
  --bg-2: #0f172a;        /* slate-900 */
  --card: #0f172a;
  --card-2: #111c33;
  --ink: #f1f5f9;         /* slate-100 */
  --ink-2: #cbd5e1;       /* slate-300 */
  --muted: #94a3b8;       /* slate-400 */
  --muted-2: #64748b;     /* slate-500 */
  --line: #1e293b;        /* slate-800 */
  --line-2: #16213a;
  --brand: #2563eb;       /* blue-600 */
  --brand-2: #6366f1;     /* indigo-500 */
  --brand-bright: #3b82f6;
  --brand-soft: rgba(59, 130, 246, 0.14);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --danger: #fb7185;
  --danger-soft: rgba(244, 63, 94, 0.16);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 14px 34px rgba(2, 6, 23, 0.55);
  --shadow-soft: 0 6px 18px rgba(2, 6, 23, 0.4);
  font-size: 16px;
}
* { box-sizing: border-box; }
/* The hidden attribute must always win, even over classes that set display
   (e.g. .modal). Without this, fixed overlays stay on top of the page and
   block every scroll and tap. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Noto Sans", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, h4 { letter-spacing: -0.2px; margin: 0 0 6px; line-height: 1.3; }
a { color: var(--brand-bright); }
.mono { font-family: "SFMono-Regular", ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.92em; }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-size: 13.5px; margin: 6px 0; }

.brand-mark {
  display: inline-grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 800; font-size: 12px;
  border-radius: 9px; padding: 6px 8px; letter-spacing: 0.4px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}
.brand-name { font-size: 14px; letter-spacing: 2.2px; color: var(--ink); font-weight: 700; }
.brand-name b { color: var(--brand-bright); }

/* ================= Buttons ================= */
.btn {
  border: 1px solid var(--line); background: var(--bg-2); color: var(--ink);
  border-radius: var(--radius-sm); padding: 9px 15px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
}
.btn:hover { border-color: #334155; background: #16213a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-color: transparent;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.32); color: #fff;
}
.btn-primary:hover { background: linear-gradient(135deg, #3b82f6, #818cf8); }
.btn-secondary { background: var(--card-2); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { color: var(--ink); }
.btn-danger { background: #e11d48; border-color: transparent; color: #fff; }
.btn-danger:hover { background: #f43f5e; }
.btn-danger-ghost { background: transparent; border-color: rgba(251, 113, 133, 0.4); color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-block { width: 100%; }
.link-btn {
  background: none; border: 0; color: var(--brand-bright); cursor: pointer;
  font-size: 13px; font-weight: 600; padding: 4px 2px;
}
.link-btn:hover { text-decoration: underline; }
.link-muted { color: var(--muted); text-decoration: none; font-size: 12.5px; }
.link-muted:hover { color: var(--ink-2); }
.icon-btn {
  background: var(--bg-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: 13px; line-height: 1;
}
.icon-btn:hover { color: var(--danger); border-color: rgba(251, 113, 133, 0.5); }

/* ================= Auth ================= */
.auth-screen {
  min-height: 100dvh; display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(700px 380px at 50% -8%, rgba(37, 99, 235, 0.16), transparent 70%),
    var(--bg);
}
.auth-card {
  width: min(430px, 100%); background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 30px 26px 22px; box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-card h1 { font-size: 22px; }
.auth-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; }
.auth-card label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin: 12px 0 5px; }
.auth-card input {
  width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px;
}
.auth-card input:focus { outline: none; border-color: var(--brand-bright); box-shadow: 0 0 0 3px var(--brand-soft); }
.auth-card .btn-block { margin-top: 18px; padding: 11px; font-size: 14.5px; }
.auth-switch { margin-top: 14px; display: flex; gap: 8px; }
.mode-btn {
  flex: 1; background: var(--bg); border: 1px solid var(--line); color: var(--muted);
  border-radius: var(--radius-sm); padding: 10px 8px; font-size: 13px; font-weight: 700; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.mode-btn:hover { color: var(--ink); border-color: #334155; }
.mode-btn.active {
  background: var(--brand-soft); border-color: rgba(59, 130, 246, 0.55); color: #93c5fd;
}
.auth-foot { display: flex; justify-content: space-between; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.optional { color: var(--muted-2); font-weight: 500; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.form-message { min-height: 18px; font-size: 13px; margin: 10px 0 0; color: var(--warn); }
.form-message:empty { margin: 0; }

/* ================= App shell ================= */
.app-shell { display: flex; min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 40;
  background: var(--bg-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px;
  transform: translateX(-105%); transition: transform 0.22s ease;
}
.sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; border-bottom: 1px solid var(--line-2); }
.side-brand small { display: block; font-size: 10px; letter-spacing: 1.6px; color: var(--ok); font-weight: 700; }
.side-nav { display: flex; flex-direction: column; gap: 3px; margin-top: 14px; flex: 1; }
.navbtn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; color: var(--muted); font-size: 13.5px; font-weight: 600;
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
}
.navbtn:hover { color: var(--ink); background: var(--card-2); }
.navbtn.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3); }
.nav-ico { width: 18px; text-align: center; opacity: 0.9; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 800;
  border-radius: 999px; padding: 1px 7px;
}
.side-foot { border-top: 1px solid var(--line-2); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.side-user { font-size: 12.5px; color: var(--muted); padding: 0 4px; overflow-wrap: anywhere; }

.main {
  flex: 1; min-width: 0; width: 100%; max-width: 1120px; margin: 0 auto;
  padding: 0 16px calc(84px + env(safe-area-inset-bottom));
}
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 13px 2px; background: rgba(2, 6, 23, 0.86); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-2); margin: 0 -2px 18px;
}
.topbar h2 { font-size: 19px; margin: 0; flex: 1; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.conn-chip { font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.conn-chip[data-conn="ok"] { color: var(--ok); border-color: rgba(52, 211, 153, 0.4); background: var(--ok-soft); }
.conn-chip[data-conn="off"] { color: var(--warn); border-color: rgba(251, 191, 36, 0.4); background: var(--warn-soft); }

/* ================= Views ================= */
.view { display: flex; flex-direction: column; gap: 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 15px; display: flex; flex-direction: column; gap: 3px; box-shadow: var(--shadow-soft);
}
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -0.4px; }
.stat-value.ok { color: var(--ok); }
.stat-value.brand { background: linear-gradient(135deg, #60a5fa, #a5b4fc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-sub { color: var(--muted-2); font-size: 11.5px; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 18px; }
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 17px 17px 15px; box-shadow: var(--shadow-soft); margin-bottom: 18px;
}
.grid-2 .panel { margin-bottom: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.panel-head h3 { font-size: 15px; margin: 0; }
.panel-sub { color: var(--muted); font-size: 12.5px; margin: 2px 0 12px; }

.pill {
  background: var(--bg); border: 1px solid var(--line); color: var(--ink-2);
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.pill-soft { background: var(--brand-soft); border-color: transparent; color: #93c5fd; }

.stack { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 2px; border-top: 1px solid var(--line-2); flex-wrap: wrap;
}
.row:first-child { border-top: 0; }
.row-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.row-main strong { font-size: 14px; overflow-wrap: anywhere; }
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-pending { background: var(--warn-soft); border-radius: var(--radius-sm); padding: 11px 12px; border-top: 0; margin: 6px 0; }
.row-revoked { opacity: 0.55; }

.chip { font-size: 11px; font-weight: 800; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-muted { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

/* ================= Categories ================= */
.cat-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.cat-card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 15px; opacity: 0.72; transition: opacity 0.15s ease, border-color 0.15s ease;
}
.cat-card.on { opacity: 1; border-color: rgba(59, 130, 246, 0.55); box-shadow: 0 8px 22px rgba(37, 99, 235, 0.12); }
.cat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.cat-head h4 { font-size: 14px; margin: 0; }
.cat-desc { color: var(--muted); font-size: 12.5px; margin: 4px 0 10px; }
.cat-meta { display: flex; gap: 6px; flex-wrap: wrap; }

.toggle { position: relative; display: inline-block; width: 44px; height: 25px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle .knob {
  position: absolute; inset: 0; background: #334155; border-radius: 999px; transition: background 0.15s ease;
}
.toggle .knob::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px;
  background: #e2e8f0; border-radius: 50%; transition: transform 0.15s ease;
}
.toggle input:checked + .knob { background: var(--brand); }
.toggle input:checked + .knob::after { transform: translateX(19px); }

/* ================= Lists & forms ================= */
.inline-form { display: flex; gap: 8px; margin: 4px 0 10px; flex-wrap: wrap; }
.inline-form input {
  flex: 1; min-width: 150px; background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13.5px;
}
.inline-form input:focus { outline: none; border-color: var(--brand-bright); }
.inline-form select, .select-inline {
  background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--radius-sm); padding: 8px 10px; font-size: 12.5px;
}
input[type="search"]#site-search {
  width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--radius-sm); padding: 11px 13px; font-size: 14px; margin: 2px 0 10px;
}
input[type="search"]#site-search:focus { outline: none; border-color: var(--brand-bright); box-shadow: 0 0 0 3px var(--brand-soft); }
.mini-actions { display: flex; gap: 10px; align-items: center; margin: 0 0 10px; }
.file-btn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--card-2); border: 1px dashed #334155;
  color: var(--ink-2); border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 600;
  padding: 7px 12px; cursor: pointer;
}
.file-btn:hover { border-color: var(--brand-bright); color: var(--ink); }
.list { display: flex; flex-direction: column; max-height: 320px; overflow-y: auto; }
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 2px; border-top: 1px solid var(--line-2); font-size: 13px; flex-wrap: wrap;
}
.list-item:first-child { border-top: 0; }
.pair-box { margin-top: 10px; }
.pair-code-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.pair-code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 30px; font-weight: 800;
  letter-spacing: 8px; color: #93c5fd; background: var(--bg); border: 1px dashed rgba(59, 130, 246, 0.5);
  border-radius: var(--radius-sm); padding: 10px 16px 10px 22px;
}

/* ================= Modals ================= */
.modal {
  position: fixed; inset: 0; z-index: 60; background: rgba(2, 6, 23, 0.72);
  display: grid; place-items: center; padding: 18px; backdrop-filter: blur(3px);
}
.modal-card {
  width: min(460px, 100%); max-height: 86dvh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 22px; box-shadow: var(--shadow);
}
.modal-wide { width: min(560px, 100%); }
.modal-card label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin: 12px 0 5px; }
.modal-card input[type="text"], .modal-card input:not([type]), .modal-card input[type="time"] {
  width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px;
}
.modal-card input:focus { outline: none; border-color: var(--brand-bright); }
.modal-card input[type="time"] { font-family: ui-monospace, Consolas, monospace; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.day-row { display: flex; gap: 6px; flex-wrap: wrap; }
.day {
  display: inline-flex; align-items: center; gap: 5px; background: var(--bg); border: 1px solid var(--line);
  padding: 6px 9px; border-radius: 8px; font-size: 12px; cursor: pointer; color: var(--ink-2);
}
.day:has(input:checked) { border-color: var(--brand-bright); color: var(--ink); background: var(--brand-soft); }
.day input { accent-color: var(--brand); }
.check-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); margin: 12px 0 4px; cursor: pointer; }
.check-label input { accent-color: var(--brand); width: 16px; height: 16px; }
.cat-checks { display: grid; grid-template-columns: 1fr; gap: 2px; max-height: 200px; overflow-y: auto; border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 8px; background: var(--bg); }
.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); padding: 4px 2px; cursor: pointer; border-radius: 6px; }
.check:hover { background: var(--card-2); }
.check input { accent-color: var(--brand); }
.suggest-box { background: var(--brand-soft); border: 1px solid rgba(59, 130, 246, 0.4); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.suggest-box .btn { margin-top: 8px; }

/* ================= Reports ================= */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 150px) 1fr 52px; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-label { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--bg); border-radius: 999px; height: 10px; border: 1px solid var(--line-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.bar-value { text-align: right; color: var(--muted); }

.kv-list { display: flex; flex-direction: column; }
.kv-row { display: flex; justify-content: space-between; gap: 14px; padding: 8px 2px; border-top: 1px solid var(--line-2); font-size: 13px; }
.kv-row:first-child { border-top: 0; }
.kv-row span { color: var(--muted); }
.kv-row strong { text-align: right; overflow-wrap: anywhere; }
.privacy-list { color: var(--muted); font-size: 12.5px; padding-left: 18px; margin: 6px 0 0; display: flex; flex-direction: column; gap: 6px; }

/* ================= Tab bar (mobile) ================= */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: rgba(15, 23, 42, 0.96); border-top: 1px solid var(--line); backdrop-filter: blur(10px);
}
.tabbtn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1;
  background: none; border: 0; color: var(--muted-2); font-size: 10.5px; font-weight: 700; cursor: pointer; padding: 4px 0;
}
.tabbtn span { font-size: 17px; line-height: 1; }
.tabbtn.active { color: var(--brand-bright); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 80; background: #1d4ed8; color: #fff; font-size: 13px; font-weight: 600;
  border-radius: 999px; padding: 10px 18px; box-shadow: var(--shadow); max-width: min(92vw, 480px); text-align: center;
}

/* ================= Responsive ================= */
@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .cat-checks { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 960px) {
  .sidebar { transform: translateX(0); }
  .main { padding: 0 28px 40px; margin-left: 264px; max-width: none; }
  .topbar { padding: 15px 4px; }
  .menu-toggle { display: none; }
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  .tabbar { display: none; }
}
@media (max-width: 959px) {
  .menu-toggle { display: inline-flex; }
}
