/*
  admin.css — Daily Book Admin UI
  Dark-themed professional layout matching the Accident Report App design language.
  Supports dark (default) and light themes via html[data-theme="light"].
*/
@import url("https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@300;400;600;800&display=swap");

/* ── Design tokens ───────────────────────────────────────────── */
:root {
  --bg:               #0f1720;
  --bg-2:             #081018;
  --surface:          #1f2933;
  --surface-2:        #172026;
  --muted:            #9aa3a8;
  --accent:           #45ffbc;
  --accent-strong:    #2ad29a;
  --white:            #ffffff;
  --card:             #263238;
  --glass:            rgba(255,255,255,0.03);
  --ui-border:        rgba(69,255,188,0.24);
  --ui-border-strong: rgba(69,255,188,0.38);
  --ui-surface-soft:  rgba(255,255,255,0.04);
  --ui-hover:         rgba(69,255,188,0.12);
  --ui-head-bg:       rgba(255,255,255,0.04);
  --tone-success:     #2ad29a;
  --tone-success-bg:  rgba(42,210,154,0.14);
  --tone-warning:     #ffa940;
  --tone-warning-bg:  rgba(255,169,64,0.14);
  --tone-danger:      #ff6f61;
  --tone-danger-bg:   rgba(255,111,97,0.15);
}

html[data-theme="light"] {
  --bg:               #d8e3ee;
  --bg-2:             #c9d6e3;
  --surface:          #e8eff6;
  --surface-2:        #dde7f1;
  --muted:            #526071;
  --white:            #1c2b3a;
  --glass:            rgba(15,23,32,0.12);
  --accent:           #0f9d6f;
  --accent-strong:    #0c7f5a;
  --ui-border:        rgba(12,127,90,0.28);
  --ui-border-strong: rgba(12,127,90,0.4);
  --ui-surface-soft:  #dfe9f3;
  --ui-hover:         rgba(12,127,90,0.1);
  --ui-head-bg:       rgba(15,23,32,0.06);
  --tone-success:     #0c7f5a;
  --tone-success-bg:  rgba(12,127,90,0.13);
  --tone-warning:     #a25f0f;
  --tone-warning-bg:  rgba(162,95,15,0.13);
  --tone-danger:      #8f1f1f;
  --tone-danger-bg:   rgba(208,54,54,0.12);
}

/* ── Reset & base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--white);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── Page wrapper ────────────────────────────────────────────── */
.admin-wrapper {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  min-height: 100vh;
  padding: 1.25rem 1.75rem;
}

/* ── App header ──────────────────────────────────────────────── */
.app-header {
  display: grid;
  grid-template-columns: minmax(min-content,220px) 1fr minmax(min-content,240px);
  gap: 1.5rem;
  align-items: end;
  border-bottom: 1px solid var(--glass);
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}
.logo { display: flex; align-items: center; gap: .75rem; }
.company-logo {
  max-width: 220px;
  max-height: 46px;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.25));
}
.logo-icon { width: 40px; height: 40px; background: linear-gradient(135deg, var(--accent), var(--accent-strong)); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; color: #000; }
.logo-title { display: flex; flex-direction: column; line-height: 1; }
.logo-title span:first-child { font-weight: 800; font-size: 1.05rem; }
.logo-title span:last-child  { font-weight: 300; color: var(--muted); font-size: .9rem; }
.app-header-right { display: flex; justify-content: flex-end; align-items: center; gap: .75rem; }

/* ── Theme toggle ────────────────────────────────────────────── */
.theme-toggle {
  height: 34px;
  padding: 0 .8rem;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: var(--white);
  font-family: inherit;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.theme-toggle:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.3); }
html[data-theme="light"] .theme-toggle {
  background: rgba(15,23,32,0.04);
  border-color: rgba(15,23,32,0.2);
  color: var(--white);
}

/* ── Profile badge ───────────────────────────────────────────── */
.profile-badge {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  color: var(--white);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding: .4rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--ui-border-strong);
  background: linear-gradient(90deg, rgba(69,255,188,0.2), rgba(42,210,154,0.09));
  box-shadow: 0 8px 20px rgba(42,210,154,0.15);
  font-weight: 700;
  font-size: .85rem;
  transition: background .15s, border-color .15s, transform .12s, box-shadow .15s;
}
.profile-badge svg { flex-shrink: 0; opacity: .7; }
html[data-theme="light"] .profile-badge {
  color: #0f5132;
  background: linear-gradient(90deg, rgba(12,127,90,0.18), rgba(12,127,90,0.08));
  border-color: rgba(12,127,90,0.46);
  box-shadow: 0 8px 18px rgba(12,127,90,0.14);
}

/* ── Body grid: sidebar + content ────────────────────────────── */
.app-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
  padding-top: 1rem;
}

/* ── Navigation ──────────────────────────────────────────────── */
.app-body-nav { display: flex; flex-direction: column; min-height: 0; }
.navigation {
  display: flex;
  flex-direction: column;
  gap: .28rem;
  color: var(--muted);
}
.navigation a,
.navigation .nav-btn {
  display: flex;
  align-items: center;
  gap: .55rem;
  color: var(--muted);
  text-decoration: none;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.07);
  padding: .58rem .75rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background .14s, color .14s, border-color .14s, box-shadow .14s;
}
.navigation a svg,
.navigation .nav-btn svg { flex-shrink: 0; opacity: .55; transition: opacity .14s; }
.navigation a:hover,
.navigation .nav-btn:hover {
  color: var(--white);
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.14);
}
.navigation a:hover svg,
.navigation .nav-btn:hover svg { opacity: .9; }
.navigation a.active,
.navigation .nav-btn.active {
  color: var(--white);
  background: linear-gradient(90deg, rgba(69,255,188,0.18), rgba(42,210,154,0.07));
  border-color: var(--ui-border);
  box-shadow: inset 3px 0 0 var(--accent), 0 6px 18px rgba(42,210,154,0.12);
}
.navigation a.active svg,
.navigation .nav-btn.active svg { opacity: 1; color: var(--accent); }
html[data-theme="light"] .navigation a,
html[data-theme="light"] .navigation .nav-btn {
  background: rgba(15,23,32,0.04);
  border-color: rgba(15,23,32,0.1);
}
html[data-theme="light"] .navigation a:hover,
html[data-theme="light"] .navigation .nav-btn:hover {
  background: rgba(15,23,32,0.08);
  border-color: rgba(15,23,32,0.18);
}
html[data-theme="light"] .navigation a.active,
html[data-theme="light"] .navigation .nav-btn.active {
  background: linear-gradient(90deg, rgba(15,157,111,0.18), rgba(12,127,90,0.07));
  border-color: rgba(15,157,111,0.35);
  box-shadow: inset 3px 0 0 var(--accent), 0 6px 18px rgba(12,127,90,0.16);
}
.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: .4rem 0;
}
html[data-theme="light"] .nav-divider { background: rgba(15,23,32,0.1); }
.navigation a.nav-danger,
.navigation .nav-btn.nav-danger {
  color: var(--tone-danger);
  background: rgba(255,111,97,0.04);
  border-color: rgba(255,111,97,0.14);
}
.navigation a.nav-danger svg,
.navigation .nav-btn.nav-danger svg { color: var(--tone-danger); opacity: .7; }
.navigation a.nav-danger:hover,
.navigation .nav-btn.nav-danger:hover {
  background: var(--tone-danger-bg);
  border-color: rgba(255,111,97,0.35);
}
html[data-theme="light"] .navigation a.nav-danger,
html[data-theme="light"] .navigation .nav-btn.nav-danger {
  background: rgba(208,54,54,0.04);
  border-color: rgba(208,54,54,0.14);
}

/* ── Main content ────────────────────────────────────────────── */
.app-body-main { min-width: 0; }
.page-title   { font-size: 1.35rem; font-weight: 800; margin: 0 0 .4rem 0; }
.page-subtitle { font-size: .9rem; color: var(--muted); margin: 0 0 1.2rem 0; }

/* ── Stats grid ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .85rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015));
  border: 1px solid var(--ui-border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  box-shadow: 0 12px 30px rgba(42,210,154,0.08);
}
html[data-theme="light"] .stat-card { border-color: rgba(15,23,32,0.12); }
.stat-label {
  color: var(--muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}
.stat-value { font-size: 1.65rem; font-weight: 800; line-height: 1.1; }
.stat-sub   { font-size: .78rem; color: var(--muted); }

/* ── Outstanding pill strip ──────────────────────────────────── */
.summary-strip {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin: 0 0 1.1rem 0;
  padding: .65rem .85rem;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
}
html[data-theme="light"] .summary-strip { border-color: rgba(15,23,32,0.16); background: #edf4fb; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .65rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
  font-size: .82rem;
}
.pill-label { color: var(--muted); text-transform: uppercase; font-size: .74rem; letter-spacing: .04em; }
.pill-value { font-weight: 700; font-size: .95rem; }
.pill--warning { border-color: rgba(255,169,64,0.35); background: rgba(255,169,64,0.12); }
.pill--success { border-color: rgba(42,210,154,0.35); background: rgba(42,210,154,0.12); }
html[data-theme="light"] .pill { border-color: rgba(15,23,32,0.2); background: #f3f8fd; }
.strip-meta { margin-left: auto; color: var(--muted); font-size: .84rem; }

/* ── Outstanding list ────────────────────────────────────────── */
.outstanding-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.outstanding-list li {
  padding: .45rem .75rem;
  border-radius: 8px;
  border: 1px solid rgba(255,169,64,0.25);
  background: rgba(255,169,64,0.07);
  font-size: .88rem;
}
html[data-theme="light"] .outstanding-list li {
  border-color: rgba(162,95,15,0.25);
  background: rgba(162,95,15,0.07);
}

/* ── Filter toolbar ──────────────────────────────────────────── */
.filter-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .6rem .85rem;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  margin-bottom: .75rem;
}
html[data-theme="light"] .filter-toolbar { background: #eef4fb; border-color: rgba(15,23,32,0.1); }
.ft-divider { width: 1px; height: 22px; background: rgba(255,255,255,0.1); margin: 0 .15rem; }
html[data-theme="light"] .ft-divider { background: rgba(15,23,32,0.12); }

/* ── Shared control token ────────────────────────────────────── */
.ft-control {
  height: 36px;
  padding: 0 .75rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 7px;
  color: var(--white);
  font-family: inherit;
  font-size: .875rem;
  box-sizing: border-box;
  outline: none;
  transition: border-color .15s;
}
.ft-control:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(69,255,188,0.14);
}
.ft-control::placeholder { color: var(--muted); opacity: .8; }
html[data-theme="light"] .ft-control {
  background: #f3f8fd;
  border-color: rgba(15,23,32,0.2);
  color: var(--white);
}
html[data-theme="light"] .ft-control::placeholder { color: #6b7b8d; }
html[data-theme="light"] .ft-control:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15,157,111,0.18);
}
select.ft-control option { background: #172026; color: #e8f0f7; }
html[data-theme="light"] select.ft-control option { background: #f3f8fd; color: #14212f; }

/* ── Flat button ─────────────────────────────────────────────── */
.ft-btn {
  height: 36px;
  padding: 0 .85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 7px;
  color: var(--white);
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s, border-color .14s;
}
.ft-btn:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.18); }
.ft-btn:disabled { opacity: .45; cursor: not-allowed; }
html[data-theme="light"] .ft-btn {
  background: #eef5fb;
  border-color: rgba(15,23,32,0.18);
  color: var(--white);
}
html[data-theme="light"] .ft-btn:hover { background: #e3edf6; border-color: rgba(15,23,32,0.28); }

.ft-btn--accent {
  background: linear-gradient(90deg, rgba(69,255,188,0.28), rgba(42,210,154,0.18));
  border-color: var(--ui-border-strong);
  color: var(--white);
  box-shadow: 0 6px 18px rgba(42,210,154,0.15);
}
.ft-btn--accent:hover {
  background: linear-gradient(90deg, rgba(69,255,188,0.38), rgba(42,210,154,0.25));
  box-shadow: 0 8px 22px rgba(42,210,154,0.22);
}
html[data-theme="light"] .ft-btn--accent {
  background: linear-gradient(90deg, rgba(12,127,90,0.2), rgba(12,127,90,0.1));
  border-color: rgba(12,127,90,0.45);
  color: #0f5132;
}

.ft-btn--dl {
  background: rgba(42,210,154,0.1);
  border-color: rgba(42,210,154,0.35);
  color: var(--accent-strong);
}
.ft-btn--dl:hover { background: rgba(42,210,154,0.18); border-color: rgba(42,210,154,0.55); }
html[data-theme="light"] .ft-btn--dl {
  background: rgba(12,127,90,0.09);
  border-color: rgba(12,127,90,0.35);
  color: #0c7f5a;
}

.ft-btn--danger {
  background: var(--tone-danger-bg);
  border-color: rgba(255,111,97,0.35);
  color: var(--tone-danger);
}
.ft-btn--danger:hover { background: rgba(255,111,97,0.22); border-color: rgba(255,111,97,0.6); }
html[data-theme="light"] .ft-btn--danger {
  background: rgba(208,54,54,0.1);
  border-color: rgba(173,39,39,0.35);
  color: #8f1f1f;
}

/* ── Table wrapper ───────────────────────────────────────────── */
.table-wrap {
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: .75rem;
}
html[data-theme="light"] .table-wrap { border-color: rgba(15,23,32,0.12); }
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  padding: .7rem .8rem;
  background: var(--ui-head-bg);
  color: var(--muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}
tbody td {
  padding: .65rem .8rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: .88rem;
  vertical-align: middle;
  transition: background .14s;
}
html[data-theme="light"] tbody td { border-bottom-color: rgba(15,23,32,0.06); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.025); }
html[data-theme="light"] tbody tr:hover td { background: rgba(15,23,32,0.04); }

/* ── Table action button ─────────────────────────────────────── */
.tbl-btn {
  height: 28px;
  padding: 0 .6rem;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: var(--white);
  font-family: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .13s, border-color .13s;
}
.tbl-btn:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.18); }
.tbl-btn--dl  { background: rgba(42,210,154,0.1); border-color: rgba(42,210,154,0.32); color: var(--accent-strong); }
.tbl-btn--dl:hover { background: rgba(42,210,154,0.18); }
.tbl-btn--regen { background: rgba(69,255,188,0.08); border-color: rgba(69,255,188,0.25); }
.tbl-btn--regen:hover { background: rgba(69,255,188,0.15); }
.tbl-btn--danger { background: var(--tone-danger-bg); border-color: rgba(255,111,97,0.35); color: var(--tone-danger); }
.tbl-btn--danger:hover { background: rgba(255,111,97,0.22); }
html[data-theme="light"] .tbl-btn { background: #eef5fb; border-color: rgba(15,23,32,0.18); color: var(--white); }
html[data-theme="light"] .tbl-btn:hover { background: #e3edf6; }
html[data-theme="light"] .tbl-btn--dl { background: rgba(12,127,90,0.09); border-color: rgba(12,127,90,0.35); color: #0c7f5a; }
html[data-theme="light"] .tbl-btn--danger { background: rgba(208,54,54,0.1); border-color: rgba(173,39,39,0.35); color: #8f1f1f; }
.tbl-actions { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }

/* ── Pager ───────────────────────────────────────────────────── */
.pager-bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-top: .5rem;
}
.pager-info { font-size: .85rem; color: var(--muted); }

/* ── Admin form fields ───────────────────────────────────────── */
.admin-field {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  margin-bottom: .75rem;
}
.admin-field label,
.field-label {
  display: block;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 600;
}
.admin-field input,
.admin-field select,
.admin-field textarea {
  width: 100%;
  padding: .5rem .75rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--white);
  font-family: inherit;
  font-size: .88rem;
  outline: none;
  transition: border-color .15s;
}
.admin-field input:focus-visible,
.admin-field select:focus-visible,
.admin-field textarea:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(69,255,188,0.14);
}
html[data-theme="light"] .admin-field input,
html[data-theme="light"] .admin-field select,
html[data-theme="light"] .admin-field textarea {
  background: #f3f8fd;
  border-color: rgba(15,23,32,0.2);
  color: var(--white);
}

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: .75rem; align-items: end; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }

/* ── Section card (tools accordion panels, etc.) ─────────────── */
.section-card {
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
  overflow: hidden;
  margin-bottom: .75rem;
}
.section-card-head {
  padding: .85rem 1rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
html[data-theme="light"] .section-card { border-color: rgba(15,23,32,0.12); }
html[data-theme="light"] .section-card-head { border-bottom-color: rgba(15,23,32,0.06); }
.section-card-body { padding: .9rem 1rem; }

/* tools accordion */
.tools-accordion {
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
  overflow: hidden;
  margin-bottom: .65rem;
}
.tools-accordion summary {
  list-style: none;
  cursor: pointer;
  padding: .85rem 1rem;
  font-weight: 700;
  letter-spacing: .01em;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  user-select: none;
}
.tools-accordion summary::-webkit-details-marker { display: none; }
.tools-accordion summary::after  { content: "+"; float: right; color: var(--muted); font-weight: 700; }
.tools-accordion[open] summary::after { content: "−"; }
.tools-accordion-body { padding: .85rem 1rem; }
.tools-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.tools-result { margin-top: .45rem; min-height: 1.2rem; color: var(--muted); font-size: .88rem; }

/* ── User role chip ──────────────────────────────────────────── */
.role-chip {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.role-chip--admin { background: rgba(69,255,188,0.15); color: var(--accent-strong); border: 1px solid rgba(69,255,188,0.3); }
.role-chip--user  { background: rgba(255,255,255,0.07); color: var(--muted); border: 1px solid rgba(255,255,255,0.1); }
html[data-theme="light"] .role-chip--admin { background: rgba(12,127,90,0.12); color: #0c7f5a; border-color: rgba(12,127,90,0.35); }
html[data-theme="light"] .role-chip--user  { background: rgba(15,23,32,0.06); color: var(--muted); border-color: rgba(15,23,32,0.14); }

/* ── Active / inactive badge ─────────────────────────────────── */
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge--active   { background: var(--tone-success-bg); color: var(--tone-success); }
.badge--inactive { background: var(--tone-danger-bg); color: var(--tone-danger); }
.badge--pending  { background: var(--tone-warning-bg); color: var(--tone-warning); }

/* ── Inline edit row for users/pharmacies ────────────────────── */
.edit-inline-row { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.edit-inline-row input[type="text"],
.edit-inline-row input[type="email"],
.edit-inline-row input[type="password"],
.edit-inline-row select {
  height: 30px;
  padding: 0 .6rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: var(--white);
  font-family: inherit;
  font-size: .84rem;
  outline: none;
}
.edit-inline-row input:focus-visible,
.edit-inline-row select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(69,255,188,0.12);
}
html[data-theme="light"] .edit-inline-row input,
html[data-theme="light"] .edit-inline-row select {
  background: #f3f8fd;
  border-color: rgba(15,23,32,0.2);
  color: var(--white);
}

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  padding: 2.5rem;
  color: var(--muted);
  font-size: .9rem;
}
.empty-state svg { opacity: .35; }

/* ── Muted helper text ───────────────────────────────────────── */
.text-muted { color: var(--muted); font-size: .88rem; }
.text-sm    { font-size: .84rem; }

/* ── Flash messages ──────────────────────────────────────────── */
.flash-list { list-style: none; margin: 0 0 1rem 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.flash-list li {
  padding: .65rem 1rem;
  border-radius: 10px;
  font-size: .88rem;
  font-weight: 600;
}
.flash-list .success { background: var(--tone-success-bg); color: var(--tone-success); border: 1px solid rgba(42,210,154,0.28); }
.flash-list .error   { background: var(--tone-danger-bg);  color: var(--tone-danger);  border: 1px solid rgba(255,111,97,0.28); }
.flash-list .info    { background: var(--ui-surface-soft);  color: var(--white);       border: 1px solid rgba(255,255,255,0.1); }

/* ── Loader spinner ──────────────────────────────────────────── */
.loader {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { display: flex; align-items: center; gap: .6rem; color: var(--muted); padding: 1rem 0; font-size: .88rem; }

/* ── Password field group ────────────────────────────────────── */
.pass-group { position: relative; }
.pass-group input { padding-right: 2.6rem; }
.pass-toggle {
  position: absolute;
  right: .6rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.pass-toggle:hover { color: var(--white); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-body { grid-template-columns: 1fr; }
  .app-body-nav { flex-direction: row; }
  .navigation { flex-direction: row; flex-wrap: wrap; gap: .35rem; }
  .nav-divider { width: 1px; height: 22px; margin: 0; }
  .app-header { grid-template-columns: 1fr auto; }
  .app-header > :first-child { display: none; }
}
@media (max-width: 600px) {
  .admin-wrapper { padding: .85rem 1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-toolbar { gap: .35rem; }
  .app-header-right .profile-badge span { display: none; }
}

/* ── Reduce motion ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ── Dash panels grid (tools accordion inner layout) ─────────── */
.dash-panels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: .85rem;
}
.dash-panel {
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: .9rem 1rem;
}
html[data-theme="light"] .dash-panel {
  background: #f3f8fd;
  border-color: rgba(15,23,32,0.1);
}
.dash-panel h3 {
  margin: 0 0 .4rem 0;
  font-size: .95rem;
  font-weight: 700;
}
.dash-panel p { margin: 0 0 .6rem 0; }

/* ── DB maintenance button group ─────────────────────────────── */
.db-maint-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .5rem;
}
.db-maint-run { margin-top: .4rem; }

/* ── Tools inline fields (label + narrow input) ──────────────── */
.tools-inline-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .5rem;
  margin-bottom: .5rem;
}
.tools-inline-single {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .84rem;
  color: var(--muted);
  font-weight: 600;
}

/* ── Monospace result / log output ───────────────────────────── */
.tools-mono {
  font-family: "Cascadia Code", "Fira Mono", "Consolas", monospace;
  font-size: .78rem;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
  color: var(--muted);
}
.log-output {
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: .65rem .75rem;
  margin-top: .5rem;
  background: rgba(0,0,0,0.15);
}
html[data-theme="light"] .log-output {
  background: #f0f6fc;
  border-color: rgba(15,23,32,0.1);
}

/* ── Compact table rows ──────────────────────────────────────── */
table.compact tbody td { padding: .35rem .8rem; font-size: .82rem; }

/* ── Sortable column header ──────────────────────────────────── */
.th-sort { cursor: pointer; user-select: none; }
.th-sort:hover { color: var(--white); }

/* ── Pager button active state ───────────────────────────────── */
.pager-btn--active {
  background: linear-gradient(90deg, rgba(69,255,188,0.28), rgba(42,210,154,0.18));
  border-color: var(--ui-border-strong);
  color: var(--white);
}
html[data-theme="light"] .pager-btn--active {
  background: linear-gradient(90deg, rgba(12,127,90,0.2), rgba(12,127,90,0.1));
  border-color: rgba(12,127,90,0.45);
  color: #0f5132;
}
.pager-ellipsis {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: .85rem;
  padding: 0 .2rem;
}

/* ── Narrow filter control ───────────────────────────────────── */
.ft-narrow { width: 70px; padding: 0 .4rem; }
.ft-label  { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; color: var(--muted); font-weight: 600; white-space: nowrap; }

/* ── stat-card accent variant ────────────────────────────────── */
.stat-card.accent {
  background: linear-gradient(180deg, rgba(69,255,188,0.1), rgba(42,210,154,0.04));
  border-color: var(--ui-border-strong);
}
html[data-theme="light"] .stat-card.accent {
  background: linear-gradient(180deg, rgba(12,127,90,0.1), rgba(12,127,90,0.04));

  border-color: rgba(12,127,90,0.35);
}

/* ── Filter actions bar (below filter-toolbar) ───────────────── */
.filter-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .45rem;
  margin-bottom: .75rem;
}
.filter-actions-label {
  font-size: .78rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-right: .15rem;
}

/* ── User avatar circle ──────────────────────────────────────── */
.user-cell { display: flex; align-items: center; gap: .65rem; }
.user-name { font-weight: 600; }
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .02em;
  flex-shrink: 0;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--muted);
}
.user-avatar[data-role="admin"] {
  background: linear-gradient(135deg, rgba(69,255,188,0.28), rgba(42,210,154,0.12));
  border-color: rgba(69,255,188,0.38);
  color: var(--accent-strong);
}
.user-avatar[data-role="pending"] {
  background: rgba(255,169,64,0.14);
  border-color: rgba(255,169,64,0.32);
  color: var(--tone-warning);
}
html[data-theme="light"] .user-avatar {
  background: rgba(15,23,32,0.06);
  border-color: rgba(15,23,32,0.14);
  color: var(--muted);
}
html[data-theme="light"] .user-avatar[data-role="admin"] {
  background: rgba(12,127,90,0.14);
  border-color: rgba(12,127,90,0.32);
  color: #0c7f5a;
}

/* ── Expandable user edit row ────────────────────────────────── */
.user-edit-cell { padding: 0 !important; }
.user-edit-row { background: rgba(69,255,188,0.025) !important; }
.user-edit-form {
  padding: .85rem 1.1rem;
  border-top: 1px solid rgba(69,255,188,0.14);
  border-bottom: 1px solid rgba(69,255,188,0.1);
}
html[data-theme="light"] .user-edit-form {
  background: rgba(12,127,90,0.04);
  border-color: rgba(12,127,90,0.18);
}
.user-edit-fields {
  display: flex;
  flex-wrap: wrap;
  gap: .85rem;
  align-items: flex-end;
  margin-bottom: .7rem;
}
.user-edit-label {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-size: .82rem;
  color: var(--muted);
  font-weight: 600;
}
.user-edit-actions { display: flex; gap: .45rem; flex-wrap: wrap; }
