/* Shared styling for the /admin dashboard — mobile-first, matches the
   clinic owner mostly checking this on a phone. Plain CSS, no build step. */

/* Self-hosted, same convention as styles.css's Inter/IBM Plex Sans Arabic
   vendoring (public/vendor/fonts/, files copied from node_modules/@fontsource
   packages listed in package.json). Not a Google Fonts <link> — this
   project's CSP (vercel.json: font-src 'self' data:; style-src 'self'
   'unsafe-inline') has no fonts.googleapis.com/fonts.gstatic.com allowance,
   so a CDN link is silently blocked by the browser with no console error.
   Inter reuses the woff2 styles.css already vendors — only Bricolage
   Grotesque and IBM Plex Mono are new files, at only the weights used
   below (600/700 display, 500 mono). */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/public/vendor/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url('/public/vendor/fonts/bricolage-grotesque-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url('/public/vendor/fonts/bricolage-grotesque-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url('/public/vendor/fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
  --ink: #173337;
  --muted: #617477;
  --line: #dce7e5;
  --bg: #f4f8f7;
  --card: #ffffff;
  --surface-soft: #f8fbfa;
  --surface-raised: #ffffff;
  --field-bg: #fbfdfd;
  --field-line: #ccdcda;
  --accent: #087f83;
  --accent-hover: #066c70;
  --accent-strong: #07585e;
  --accent-soft: #e3f2f1;
  --good: #0f9368;
  --warning: #c88616;
  --bad: #d24d59;
  --clay: #c97962;
  --violet: #7768ad;
  --chart-teal: #087f83;
  --chart-coral: #d27a63;
  --chart-gold: #c99a2f;
  --chart-violet: #7768ad;
  --shadow-xs: 0 1px 2px rgba(16, 52, 57, .04);
  --shadow-sm: 0 8px 24px rgba(16, 52, 57, .06);
  --shadow-md: 0 18px 46px rgba(16, 52, 57, .10);
  --shadow-lg: 0 28px 80px rgba(16, 52, 57, .16);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --focus-ring: 0 0 0 4px rgba(8, 127, 131, .16);
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
}
body.auth-pending { visibility: hidden; }

.language-toggle {
  min-height: 34px; padding: 6px 11px; border: 1px solid var(--field-line);
  border-radius: 999px; background: var(--card); color: var(--accent);
  font: 650 12px/1 var(--font-body); cursor: pointer; white-space: nowrap;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url('/public/vendor/fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url('/public/vendor/fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2') format('woff2');
}
.language-toggle:hover { border-color: var(--accent); background: var(--accent-soft); }
.login-wrap > .language-toggle { position: fixed; top: 16px; inset-inline-end: 16px; }
html[dir="rtl"] body { font-family: "IBM Plex Sans Arabic", var(--font-body); }
html[dir="rtl"] .admin-main, html[dir="rtl"] dialog, html[dir="rtl"] .modal { text-align: right; }
html[dir="rtl"] .admin-nav a.active { box-shadow: inset -3px 0 0 var(--accent); }
html[dir="rtl"] input[type="email"], html[dir="rtl"] input[type="tel"],
html[dir="rtl"] input[type="number"], html[dir="rtl"] input[type="date"],
html[dir="rtl"] input[type="time"], html[dir="rtl"] input[inputmode="numeric"],
html[dir="rtl"] .mono { direction: ltr; text-align: right; }
html[dir="rtl"] table th, html[dir="rtl"] table td { text-align: right; }

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 950;
}
.admin-header .brand { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }

.nav-toggle {
  background: none; border: none; cursor: pointer; padding: 6px;
  font-size: 22px; line-height: 1; color: var(--ink);
  display: flex; align-items: center;
}
.nav-toggle:hover { color: var(--accent); }

.nav-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 899; /* below book.html's .modal-overlay (1000) and native
                   <dialog> elements, which always render in the
                   top layer regardless of z-index — so no conflict
                   with staff.html's delete-confirm dialog or
                   patientProfile.js's modal either way, but keep
                   this below 1000 as a deliberate margin anyway */
}
.nav-backdrop.is-open { display: block; }

.admin-nav {
  position: fixed; top: 0; right: 0; height: 100vh; width: 260px;
  max-width: 80vw;
  display: flex; flex-direction: column; gap: 2px;
  padding: 64px 12px 16px; /* top padding clears the sticky header */
  background: var(--card); border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(0,0,0,0.12);
  transform: translateX(100%);
  transition: transform 220ms ease;
  z-index: 900;
  overflow-y: auto;
}
.admin-nav.is-open { transform: translateX(0); }
.admin-nav a {
  padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted);
  font-size: 14px; white-space: nowrap; font-weight: 500;
  opacity: 0;
}
.admin-nav a.active { background: var(--accent-soft); color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }

/* Rhythm stagger: nav items tick in on the same ~40ms cadence as the
   tick-motif divider, echoing the appointment-slot pattern the rest of the
   theme is built around. Pure CSS, no change to shared.js's open()/close(). */
.admin-nav.is-open a { animation: valeria-nav-in 200ms ease forwards; }
.admin-nav.is-open a:nth-child(1) { animation-delay: 0ms; }
.admin-nav.is-open a:nth-child(2) { animation-delay: 40ms; }
.admin-nav.is-open a:nth-child(3) { animation-delay: 80ms; }
.admin-nav.is-open a:nth-child(4) { animation-delay: 120ms; }
.admin-nav.is-open a:nth-child(5) { animation-delay: 160ms; }
.admin-nav.is-open a:nth-child(6) { animation-delay: 200ms; }
.admin-nav.is-open a:nth-child(7) { animation-delay: 240ms; }
.admin-nav.is-open a:nth-child(8) { animation-delay: 280ms; }
.admin-nav.is-open a:nth-child(9) { animation-delay: 320ms; }
.admin-nav.is-open a:nth-child(10) { animation-delay: 360ms; }
.admin-nav.is-open a:nth-child(n+11) { animation-delay: 400ms; }
@keyframes valeria-nav-in {
  from { opacity: 0; transform: translateX(6px); }
  to { opacity: 1; transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .admin-nav a { opacity: 1; }
  .admin-nav.is-open a { animation: none; }
}

.admin-main { padding: 16px; max-width: 1100px; margin: 0 auto; }

/* ---- Shared clinical workspace ----
   Every admin screen is a working surface for clinic staff, not a marketing
   page. These rules give ordinary forms, cards, tables, and dialogs the same
   calm, structured character as the patient assessment without changing the
   existing markup or any form submission behavior. */
.admin-main > .page-heading,
.admin-main > .sales-heading {
  margin-bottom: 20px;
}
.admin-main > .page-heading h1,
.admin-main > .sales-heading h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(25px, 3vw, 32px);
  letter-spacing: -.025em;
  color: var(--ink);
}
.admin-main > .page-heading p,
.admin-main > .sales-heading p {
  max-width: 620px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

/* Inputs look and behave consistently everywhere: quiet at rest, unmistakable
   when active. Checkboxes/ranges keep their specialised native controls. */
.admin-main form input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
.admin-main form select,
.admin-main form textarea,
.modal-overlay form input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
.modal-overlay form select,
.modal-overlay form textarea {
  min-height: 42px;
  border: 1px solid var(--field-line);
  border-radius: 9px;
  background: var(--field-bg);
  color: var(--ink);
  font: 500 13px var(--font-body);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.admin-main form textarea,
.modal-overlay form textarea { min-height: 78px; line-height: 1.45; }
.admin-main form input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus,
.admin-main form select:focus,
.admin-main form textarea:focus,
.modal-overlay form input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus,
.modal-overlay form select:focus,
.modal-overlay form textarea:focus {
  outline: 3px solid rgba(12,124,140,.14);
  border-color: var(--accent);
  background: #fff;
}
.admin-main form label,
.modal-overlay form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

/* One predictable action language across pages and dialogs. */
.btn-primary, .btn-secondary, .btn-danger,
.admin-main button:not(.nav-toggle),
.modal-overlay button {
  touch-action: manipulation;
}
.btn-primary, .btn-secondary, .btn-danger { border-radius: 9px; }
.btn-primary { box-shadow: 0 1px 1px rgba(10,107,121,.14); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 5px 13px rgba(10,107,121,.18); }
.btn-secondary:hover:not(:disabled), .btn-danger:hover:not(:disabled) { transform: translateY(-1px); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(12,124,140,.22);
  outline-offset: 2px;
}

.range-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.range-bar button {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 7px 12px; border-radius: 20px; font-size: 13px; cursor: pointer;
}
.range-bar button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.range-bar #range-custom-apply { border-color: var(--accent); background: var(--accent); color: #fff; }
.range-bar #range-custom-apply:hover { background: #0a6b79; }

.range-bar .preset-pill {
  display: inline-flex; align-items: center; border: 1px solid var(--line);
  background: var(--card); border-radius: 20px; overflow: hidden;
}
.range-bar .preset-pill.active { background: var(--accent); border-color: var(--accent); }
.range-bar .preset-pill button { border: none; background: none; border-radius: 0; }
.range-bar .preset-pill-label { padding: 7px 4px 7px 12px; font-size: 13px; color: var(--ink); }
.range-bar .preset-pill.active .preset-pill-label { color: #fff; }
.range-bar .preset-pill-remove { padding: 6px 10px 6px 2px; font-size: 14px; line-height: 1; color: var(--muted); }
.range-bar .preset-pill.active .preset-pill-remove { color: rgba(255, 255, 255, 0.75); }
.range-bar .preset-pill-remove:hover { color: var(--bad); }

.range-bar .range-custom-form {
  flex: 1 0 100%; display: flex; flex-wrap: wrap; align-items: end; gap: 10px;
  margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line);
}
.range-custom-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.range-custom-form input[type="date"], .range-custom-form input[type="text"] {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
}

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi-card {
  position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px;
  transition: transform 170ms ease, box-shadow 170ms ease;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(22, 38, 43, 0.08); }
.kpi-card .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-card .value { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -0.01em; margin-top: 6px; }
.kpi-card .kpi-scope { color: var(--muted); font-size: 10px; font-weight: 500; }

/* Tick motif: an appointment-slot rhythm across the top of every KPI card.
   background-size is fixed px, not %, so the pitch never stretches — a
   150px card and a 320px card both get clean, evenly-spaced ticks, just a
   different repeat count. overflow:hidden above clips the last partial
   tick under the card's own border-radius, so the edge reads as
   intentional rather than cut off. Per-type modifier classes keep the same
   accent colors the old solid bars used, just rendered as ticks now. */
.kpi-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background-image: repeating-linear-gradient(to right, var(--kpi-accent, var(--accent)) 0 6px, transparent 6px 10px);
  background-size: 10px 100%;
  background-repeat: repeat-x;
}
.kpi-card.kpi-today::before, .kpi-card.kpi-new-patients::before { --kpi-accent: var(--accent); }
.kpi-card.kpi-pending::before { --kpi-accent: #eab308; }
.kpi-card.kpi-cancelled::before { --kpi-accent: var(--bad); }
.kpi-card.kpi-no-show::before { --kpi-accent: #94a3b8; }
.kpi-card.kpi-completed::before { --kpi-accent: var(--good); }

.chart-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 20px;
  transition: transform 170ms ease, box-shadow 170ms ease;
}
.chart-card:hover { transform: translateY(-2px); box-shadow: 0 12px 25px rgba(22, 38, 43, 0.08); }
.chart-card h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); font-weight: 600; }

/* Structural classes used by index.html's dashboard sections (previously
   locked inside the removed .dashboard-page gradient block) — now plain
   global rules on the flat Warm Paper background every page shares. */
.dashboard-intro { margin-bottom: 22px; }
.dashboard-eyebrow, .section-kicker {
  margin: 0 0 6px; color: var(--clay); font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
}
.dashboard-intro h1 {
  font-family: var(--font-display); margin: 0; color: var(--ink);
  font-size: clamp(26px, 3vw, 34px); font-weight: 700; letter-spacing: -0.02em;
}
.dashboard-welcome { max-width: 640px; margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.dashboard-section { margin-bottom: 22px; }
.dashboard-overview { padding: 4px 0; }

/* Section-heading tick divider: same fixed-px repeating-gradient mechanism
   as the KPI card ticks, in Valeria Clay — the one place the signature
   accent color is actually visible rather than implied. */
.section-heading { position: relative; margin: 0 0 14px; padding-bottom: 9px; }
.section-heading h2 { font-family: var(--font-display); margin: 0; color: var(--ink); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.section-heading::after {
  content: ""; display: block; margin-top: 9px; height: 2px;
  background-image: repeating-linear-gradient(to right, var(--clay) 0 4px, transparent 4px 8px);
  background-size: 8px 100%; background-repeat: repeat-x;
  opacity: 0.55;
}
.section-heading-overview { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter-bar input, .filter-bar select {
  min-height: 40px; padding: 8px 10px; border: 1px solid var(--field-line); border-radius: 9px;
  font: 500 13px var(--font-body); color: var(--ink); background: var(--field-bg);
}
.filter-bar input:focus, .filter-bar select:focus {
  outline: 3px solid rgba(12,124,140,.14); border-color: var(--accent); background: #fff;
}

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
/* Only agents.html actually wires up click-to-sort (th[data-key], see its
   own inline <script>) — every other table's th previously inherited this
   pointer cursor with nothing behind it, a misleading affordance (Data
   table redesign gate). Default cursor everywhere, pointer restored only
   where a real click handler exists. */
th { color: var(--muted); background: #fbfdfc; font-weight: 700; font-size: 11px; letter-spacing: .045em; text-transform: uppercase; cursor: default; }
th[data-key] { cursor: pointer; }
tr:last-child td { border-bottom: none; }
.table-wrap tbody tr:not(.reschedule-row) { transition: background-color 130ms ease; }
.table-wrap tbody tr:not(.reschedule-row):hover { background: #f6fbfa; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; }
/* completed reads as a positive outcome, same as confirmed — not the
   quiet-gray "just resolved" treatment it had before (button/badge system
   pass). no_show stays quiet gray below, unaffected by this change. */
.badge.confirmed, .badge.converted, .badge.active-agent, .badge.completed { background: #dcfce7; color: var(--good); }
.badge.pending, .badge.active { background: #fef9c3; color: #a16207; }
.badge.failed, .badge.cancelled { background: #fee2e2; color: var(--bad); }
.badge.rescheduled, .badge.ended { background: #e0e7ff; color: #4338ca; }
/* no_show: promoted from admin/bookings.html's page-scoped rule (Bookings
   redesign gate) — a resolved-and-quiet visual, not scoped to that page
   only, so any other page rendering this status (e.g. the Patient Profile
   modal) reads the same way. .badge.cancelled stays page-scoped in
   bookings.html/the profile modal only — the base red above is still needed
   globally for staff.html's unrelated "Inactive" badge use. */
.badge.no_show { background: #f3f4f6; color: #6b7280; }

.pagination { display: flex; justify-content: center; gap: 10px; padding: 14px; align-items: center; font-size: 13px; }
.pagination button { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.pagination button:disabled { opacity: 0.4; cursor: default; }

.empty-state, .loading-state { text-align: center; color: var(--muted); padding: 30px; }
.empty-state::before, .loading-state::before {
  content: ""; display: block; width: 28px; height: 3px; margin: 0 auto 10px;
  border-radius: 999px; background: repeating-linear-gradient(to right, var(--accent) 0 5px, transparent 5px 8px); opacity: .55;
}

.login-wrap {
  max-width: 380px; margin: 14vh auto; padding: 28px;
  border: 1px solid #dbe9e6; border-radius: 16px; background: var(--card);
  box-shadow: 0 22px 60px rgba(22,38,43,.12);
}
.login-wrap::before {
  content: "Clinic workspace"; display: block; margin-bottom: 8px; color: var(--clay);
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
}
.login-wrap h1 { margin: 0 0 20px; font-family: var(--font-display); font-size: 25px; letter-spacing: -.02em; }
.login-wrap input {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--field-line); border-radius: 9px;
  margin-bottom: 10px; background: var(--field-bg); color: var(--ink); font: 500 14px var(--font-body);
}
.login-wrap input:focus { outline: 3px solid rgba(12,124,140,.14); border-color: var(--accent); background: #fff; }
.login-wrap button {
  width: 100%; min-height: 44px; padding: 10px; border: 1px solid var(--accent); border-radius: 9px;
  background: var(--accent); color: #fff; font-weight: 700; cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}
.login-wrap button:hover { transform: translateY(-1px); background: #0a6b79; box-shadow: 0 6px 14px rgba(10,107,121,.2); }
.login-wrap .error { color: var(--bad); font-size: 13px; margin-bottom: 10px; }

/* Button system — three roles, reusing existing tokens only (no new hex
   values). One primary per form; secondary for cancel/dismiss; danger for
   irreversible actions. Applies to previously-unstyled native <button>s
   across book/resources/services/staff.html — doesn't touch already-styled
   buttons (.range-bar, .sort-bar, .pagination, .nav-toggle, etc.). */
.btn-primary, .btn-secondary, .btn-danger {
  padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}
.btn-primary { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.btn-primary:hover { background: #0a6b79; border-color: #0a6b79; }
.btn-secondary { border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { border: 1px solid var(--bad); background: var(--card); color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

/* Row-actions: consolidated from three near-identical page-scoped copies
   (bookings.html, resources.html, services.html — Button system gate).
   bookings.html's version is the superset (it also has an <a> — the "Open
   WhatsApp" link from shared.js's renderBookingActions — with
   text-decoration:none); resources.html/services.html only ever have
   buttons in here, so the extra `a` selectors are simply inert on those
   two pages, not a visual change. */
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button, .row-actions a {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 4px 9px; border-radius: 6px; font-size: 12px; cursor: pointer; text-decoration: none;
}
.row-actions button:hover, .row-actions a:hover { border-color: var(--accent); color: var(--accent); }
.row-actions button.danger { color: var(--bad); border-color: #fecaca; }
.row-actions button.danger:hover { border-color: var(--bad); color: var(--bad); background: #fef2f2; }

@media (min-width: 640px) {
  .admin-main { padding: 24px; }
}

/* Page-local modal overlays share the same deliberate, softly elevated
   treatment as the native patient-profile dialog. */
.modal-overlay { background: rgba(16,34,38,.5) !important; backdrop-filter: blur(2px); }
.modal-overlay .chart-card {
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(22,38,43,.22);
}

@media (max-width: 540px) {
  .chart-card { padding: 15px; border-radius: 12px; }
  .admin-main > .page-heading h1, .admin-main > .sales-heading h1 { font-size: 25px; }
  .btn-primary, .btn-secondary, .btn-danger { min-height: 40px; }
  .login-wrap { margin: 10vh 16px; padding: 22px; }
}

/* ---- Page-specific working surfaces ----
   These selectors are intentionally anchored to existing ids/classes. They
   refine each page's unique tool without introducing another markup system. */

/* Bookings: patient lookup and slot selection read as one calm sequence. */
#book-form .book-field { margin-bottom: 17px; }
#book-form .book-field > label { display: block; margin-bottom: 6px; color: var(--muted); font-weight: 700; }
.patient-results { margin-top: 7px; border-color: #dbe9e6; border-radius: 10px; box-shadow: 0 10px 24px rgba(22,38,43,.08); }
.patient-results button { padding: 10px 12px; }
#slot-grid { padding: 10px; border: 1px dashed #c8dcd8; border-radius: 10px; background: #f8fcfb; }
#slot-grid button { min-width: 78px; border-radius: 8px; transition: border-color 150ms ease, background 150ms ease, color 150ms ease; }
#slot-grid button:hover { background: var(--accent-soft); }

/* Patient lookup: give search and results their own contained workspace. */
.pp-lookup-wrap { max-width: 440px; padding: 10px; border: 1px solid #dbe9e6; border-radius: 12px; background: #f8fcfb; }
.pp-lookup-results { border-color: #c8dcd8; border-radius: 10px; box-shadow: 0 14px 28px rgba(22,38,43,.12); }
.pp-lookup-item { padding: 10px 12px; }

/* Catalogue: make the category-to-product order feel explicit. */
#catalogue-kpi { border-color: #d7e7e3; background: linear-gradient(135deg, #f4fbf9, #fff); }
#category-panel { border-color: #dbe9e6; }
#category-panel > h3, .product-list-heading h3 { font-family: var(--font-display); letter-spacing: -.015em; }
.category-table { border-radius: 10px; }
.category-table-actions { gap: 8px; }
.product-list-heading { padding: 4px 0 10px; border-bottom: 1px solid var(--line); }

/* Purchase history: suppliers are reference cards; orders retain a denser
   operational layout beneath them. */
.purchase-page .section-card { border-color: #dbe9e6; box-shadow: 0 8px 22px rgba(22,38,43,.04); }
.purchase-page .section-heading h2, .purchase-page .po-heading h2 { font-family: var(--font-display); letter-spacing: -.02em; }
.purchase-page .supplier-card { border-color: #dbe9e6; background: linear-gradient(145deg, #fff, #f9fcfb); transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease; }
.purchase-page .supplier-card:hover { transform: translateY(-2px); border-color: #b8d7d2; box-shadow: 0 10px 22px rgba(22,38,43,.08); }
.purchase-page .offering-tag { border-color: #c9dfda; color: var(--accent); background: var(--accent-soft); }
.purchase-page .po-list button { border-radius: 9px; }
.purchase-page .product-offerings { border-color: #d6e0de; background: #fcfefd; }

/* Sales: retain the dark scan station as the one high-contrast moment, with
   a warmer, tactile cart and a clear completed-receipt state. */
.sales-page .scan-card { box-shadow: 0 16px 34px rgba(22,38,43,.17); }
.sales-page .scan-card::before { content: "Point of sale"; display: block; margin-bottom: 8px; color: #8cd4d9; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.sales-page .cart-card { border-color: #dbe9e6; }
.sales-page .cart-total { padding: 15px 2px 0; }
.sales-page .cart-total strong { color: var(--accent); }
.sales-page .receipt { border: 1px solid #bae2c7; border-left: 4px solid var(--good); background: #f4fcf6; }
.sales-page .history-filters { padding: 10px; border: 1px solid #e2ebe9; border-radius: 11px; background: #fafdfc; }

/* Revenue: forms are compact accounting slips, so the entry controls group
   together instead of floating separately below the reporting cards. */
#expense-form, #recurring-form { padding: 13px; border: 1px solid #dbe9e6; border-radius: 11px; background: #fafdfc; }
#expense-form > div, #recurring-form > div { min-width: min(100%, 155px); }
.revenue-series-row { padding: 9px 0; }

/* Dialogs used outside the patient panel inherit the same considered shell. */
dialog#delete-confirm-dialog { border-radius: 16px; box-shadow: 0 24px 70px rgba(22,38,43,.22); }
dialog#delete-confirm-dialog::backdrop { background: rgba(16,34,38,.5); backdrop-filter: blur(2px); }

@media (prefers-reduced-motion: reduce) {
  .chart-card, .kpi-card, .purchase-page .supplier-card, .btn-primary, .btn-secondary, .btn-danger { transition: none; }
  .chart-card:hover, .kpi-card:hover, .purchase-page .supplier-card:hover, .btn-primary:hover:not(:disabled), .btn-secondary:hover:not(:disabled), .btn-danger:hover:not(:disabled) { transform: none; }
}

/* ---- Patient Profile quick-view (admin/patientProfile.js) — a shared
   component, opened from either the "Profile" action (bookings table +
   calendar day view) or patients.html's own quick-lookup box. Native
   <dialog>, same pattern as staff.html's delete-confirmation modal. */
.patient-profile-modal {
  border: none; border-radius: 16px; padding: 0; max-width: 880px; width: min(94vw, 880px);
  max-height: 88vh; box-shadow: 0 24px 70px rgba(22,38,43,.22); background: var(--card);
}
.patient-profile-modal::backdrop { background: rgba(16,34,38,.5); backdrop-filter: blur(2px); }
.pp-body { padding: 24px; overflow-y: auto; max-height: 88vh; position: relative; }
.pp-close {
  position: absolute; top: 14px; right: 14px; border: none; background: none;
  font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px;
}
.pp-close:hover { color: var(--ink); }
.pp-profile-heading { padding-inline-end: 34px; }
.pp-profile-heading .chart-eyebrow { margin: 0 0 4px; }
.pp-body h3 { margin: 0 0 2px; font-family: var(--font-display); font-size: 24px; letter-spacing: -.02em; color: var(--ink); padding-right: 30px; }
.pp-phone { color: var(--muted); font-family: var(--font-mono); font-size: 12px; margin-bottom: 18px; }
.pp-stat-row { display: flex; gap: 10px; margin-bottom: 18px; }
.pp-stat { flex: 1; background: linear-gradient(135deg, #f6faf9, var(--bg)); border: 1px solid #e1ebe9; border-radius: 10px; padding: 11px 12px; text-align: center; }
.pp-stat-value { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--ink); }
.pp-stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }
.pp-profile-tabs {
  display: inline-flex;
  gap: 5px;
  margin: 0 0 18px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}
.pp-profile-tab {
  min-height: 42px;
  padding: 8px 14px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font: 700 13px var(--font-body);
  cursor: pointer;
  transition: color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}
.pp-profile-tab:hover { color: var(--ink); background: #fff; }
.pp-profile-tab.is-active { color: #fff; background: var(--accent); box-shadow: 0 5px 14px rgba(8,127,131,.20); }
.pp-profile-tab span {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  margin-inline-start: 5px;
  padding: 0 6px;
  place-items: center;
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 10px;
}
.pp-profile-tab.is-active span { color: var(--accent-strong); background: #fff; }
.pp-profile-panel[hidden] { display: none; }
.pp-past-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 2px 0 14px; }
.pp-past-heading h4 { margin: 0; color: var(--ink); font-family: var(--font-display); font-size: 18px; letter-spacing: -.02em; }
.pp-past-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.pp-past-list { position: relative; display: grid; gap: 10px; }
.pp-past-visit {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-xs);
}
.pp-past-visit > summary {
  position: relative;
  min-height: 58px;
  display: grid;
  grid-template-columns: 142px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 42px 10px 14px;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}
.pp-past-visit > summary::-webkit-details-marker { display: none; }
.pp-past-visit > summary::after {
  content: "";
  position: absolute;
  right: 18px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 160ms ease;
}
.pp-past-visit[open] > summary { background: var(--surface-soft); }
.pp-past-visit[open] > summary::after { transform: rotate(225deg) translate(-2px, -2px); }
.pp-past-date { color: var(--muted); font-family: var(--font-mono); font-size: 11px; }
.pp-past-title { overflow: hidden; font-size: 13px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.pp-past-body { display: grid; gap: 14px; padding: 16px; border-top: 1px solid var(--line); }
.pp-past-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 14px; color: var(--muted); font-size: 11px; }
.pp-past-meta span { min-width: 0; }
.pp-past-meta strong { color: var(--ink); }
.pp-clinical-note { padding: 12px 14px; border-left: 3px solid var(--accent); border-radius: 0 10px 10px 0; background: var(--accent-soft); }
.pp-clinical-note strong { color: var(--accent-strong); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.pp-clinical-note p { margin: 4px 0 0; color: var(--ink); font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.pp-past-services { display: grid; gap: 9px; }
.pp-past-service { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.pp-past-service-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pp-past-service-head strong { color: var(--ink); font-size: 13px; }
.pp-past-service-head > span { color: var(--accent-strong); font-family: var(--font-mono); font-size: 12px; font-weight: 700; }
.pp-past-service p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.pp-past-service p strong { color: var(--ink); }
.pp-material-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.pp-material-pill { padding: 5px 8px; border: 1px solid #cde2df; border-radius: 999px; color: var(--accent-strong); background: #fff; font-size: 10px; font-weight: 650; }
.pp-past-muted { color: var(--muted) !important; font-style: italic; }
.pp-payment-summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; border-radius: 12px; }
.pp-payment-summary.is-paid { color: #0b684a; background: #edf8f3; }
.pp-payment-summary.is-pending { color: #815c16; background: #fff8e9; }
.pp-payment-summary > div { display: grid; gap: 2px; }
.pp-payment-summary strong { font-size: 12px; }
.pp-payment-summary span { color: var(--muted); font-size: 11px; }
.pp-payment-summary b { font-family: var(--font-mono); font-size: 14px; white-space: nowrap; }
.pp-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  margin: 22px 0 8px; font-weight: 700;
}
.pp-section-label:first-of-type { margin-top: 0; }
.pp-visit-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 0;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.pp-visit-row:last-child { border-bottom: none; }
.pp-visit-row span:first-child { color: var(--ink); font-family: var(--font-mono); flex-shrink: 0; }

/* Main patients table's Phone column (3rd td: arrow, name, phone, ...) —
   scoped via the .patients-page body class already in patients.html's
   markup (untouched), not a markup change. Keeps the mono/rhythm face
   somewhere people actually look, not just inside the profile modal. */
.patients-page .table-wrap td:nth-child(3) { font-family: var(--font-mono); }
.pp-visit-row span:nth-child(2) { color: var(--muted); flex: 1; }
.pp-visit-card { border-bottom: 1px solid var(--line); padding: 4px 0 8px; }
.pp-visit-card:last-child { border-bottom: none; }
.pp-visit-card .pp-visit-row { border-bottom: none; }
.pp-visit-details { display: grid; gap: 4px; padding: 4px 0 2px; color: var(--muted); font-size: 12px; }
.pp-visit-details strong { color: var(--ink); font-weight: 600; }
.pp-empty { color: var(--muted); font-size: 13px; padding: 4px 0; }
.pp-full-link {
  display: block; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line);
  color: var(--accent); font-size: 13px; text-decoration: none; font-weight: 500;
}
.pp-full-link:hover { text-decoration: underline; }
/* Same rationale as bookings.html's own page-scoped override — the base
   global .badge.cancelled (red) is staff.html's "Inactive" meaning; this
   modal wants the quieter resolved-state reading instead, same as Bookings. */
.patient-profile-modal .badge.cancelled { background: #f3f4f6; color: #6b7280; }
.pp-wellness-grid, .pp-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pp-wellness-grid { margin: 8px 0; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pp-wellness-grid > div { background: linear-gradient(145deg, #f7fbfa, var(--bg)); border: 1px solid #e1ebe9; border-radius: 10px; padding: 10px 12px; }
.pp-wellness-grid strong, .pp-wellness-grid span { display: block; }
.pp-wellness-grid strong { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.pp-wellness-grid span { color: var(--ink); font-size: 13px; margin-top: 2px; }
.pp-wellness-notes { display: grid; gap: 5px; font-size: 13px; color: var(--muted); margin: 10px 0; }
.pp-wellness-notes strong { color: var(--ink); }
.pp-assessment-editor, .pp-assessment-history { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; }
.pp-assessment-editor { background: #fbfdfc; border: 1px solid #dbe9e6; border-radius: 14px; padding: 0 16px; }
.pp-assessment-editor summary, .pp-assessment-history summary { cursor: pointer; color: var(--accent); font-weight: 700; font-size: 14px; }
.pp-assessment-editor summary { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 15px 0; list-style: none; }
.pp-assessment-editor summary::-webkit-details-marker { display: none; }
.pp-assessment-editor summary small { color: var(--muted); font-family: var(--font-body); font-size: 11px; font-weight: 500; }
.pp-assessment-editor form { display: grid; gap: 14px; margin: 0 -16px; padding: 0 16px 16px; }
.pp-assessment-editor label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.pp-assessment-editor input, .pp-assessment-editor select, .pp-assessment-editor textarea { width: 100%; box-sizing: border-box; min-height: 42px; padding: 9px 10px; border: 1px solid #d6e0de; border-radius: 8px; background: var(--card); color: var(--ink); font: inherit; font-weight: 500; }
.pp-assessment-editor input:focus, .pp-assessment-editor select:focus, .pp-assessment-editor textarea:focus { outline: 3px solid rgba(12,124,140,.14); border-color: var(--accent); }
.pp-assessment-editor textarea { min-height: 76px; resize: vertical; line-height: 1.45; }
.pp-form-section { display: grid; gap: 12px; padding: 16px; border: 1px solid #e2ebe9; border-radius: 12px; background: var(--card); }
.pp-form-section-baseline { border-color: #cce3df; background: linear-gradient(135deg, #f4fbf9, #fff); }
.pp-form-section-notes { background: #fffdf9; border-color: #eee2d4; }
.pp-form-section-heading { display: flex; gap: 10px; align-items: flex-start; }
.pp-form-section-heading > span { display: grid; place-items: center; flex: 0 0 25px; height: 25px; border-radius: 50%; background: var(--accent); color: #fff; font-family: var(--font-mono); font-size: 10px; }
.pp-form-section-heading h4 { margin: 0; color: var(--ink); font-size: 14px; }
.pp-form-section-heading p { margin: 2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.pp-score-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pp-score-field { min-width: 0; padding: 11px; border: 1px solid #e2ebe9; border-radius: 10px; background: #fcfefd; }
.pp-field-label { display: flex; justify-content: space-between; gap: 8px; color: var(--ink); }
.pp-field-label small { color: var(--muted); font-weight: 500; white-space: nowrap; }
.pp-score-control { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; margin-top: 8px; }
.pp-score-field input[type=range] { min-height: auto; height: 5px; padding: 0; border: 0; accent-color: var(--accent); cursor: pointer; }
.pp-score-field output { min-width: 37px; padding: 5px 6px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-family: var(--font-mono); font-size: 12px; text-align: center; }
.pp-score-field output small { font-size: 9px; }
.pp-score-scale { display: flex; justify-content: space-between; margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 500; }
.pp-assessment-submit { position: sticky; bottom: -16px; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; margin: 0 -16px -16px; border-top: 1px solid #dbe9e6; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); }
.pp-assessment-submit > span { color: var(--muted); font-size: 11px; }
.pp-assessment-submit .btn-primary { padding: 10px 16px; white-space: nowrap; }
.pp-history-assessment { border-top: 1px solid var(--line); padding: 12px 0; margin-top: 10px; font-size: 13px; }
.pp-treatment-gate, .pp-required-booking {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 10px 0; padding: 10px 12px; border-radius: 8px;
  background: var(--accent-soft); color: var(--ink); font-size: 13px;
}
.pp-treatment-gate { flex-wrap: wrap; }
.pp-treatment-gate span, .pp-required-booking span { color: var(--muted); }
.pp-treatment-gate-ready { background: #edf7f0; }
.pp-required-booking { display: grid; gap: 3px; border: 1px solid #cce3df; }
.pp-open-profile { margin-left: 6px; border: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: 12px; padding: 0; }
@media (max-width: 540px) {
  .pp-body { padding: 18px; }
  .pp-wellness-grid, .pp-form-grid, .pp-score-grid { grid-template-columns: 1fr; }
  .pp-wellness-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pp-assessment-editor { padding: 0 12px; }
  .pp-assessment-editor form { margin: 0 -12px; padding: 0 12px 12px; }
  .pp-assessment-submit { bottom: -12px; margin: 0 -12px -12px; padding: 11px 12px; }
  .pp-assessment-submit > span { display: none; }
  .pp-profile-tabs { width: 100%; }
  .pp-profile-tab { flex: 1; }
  .pp-past-visit > summary { grid-template-columns: 1fr auto; gap: 4px 8px; padding: 11px 38px 11px 12px; }
  .pp-past-date { grid-column: 1 / -1; }
  .pp-past-meta { grid-template-columns: 1fr; }
  .pp-past-body { padding: 12px; }
  .pp-payment-summary { align-items: flex-start; flex-direction: column; }
}

html[dir="rtl"] .pp-past-visit > summary { padding: 10px 14px 10px 42px; }
html[dir="rtl"] .pp-past-visit > summary::after { right: auto; left: 18px; }
html[dir="rtl"] .pp-clinical-note { border-left: 0; border-right: 3px solid var(--accent); border-radius: 10px 0 0 10px; }

/* Two-stage treatment/payment workflow. Created dynamically by shared.js so
   the same panel works in both the booking table and calendar. */
.booking-workflow-modal { border: 0; padding: 0; border-radius: 14px; width: min(720px, 94vw); color: var(--ink); }
.booking-workflow-modal::backdrop { background: rgba(0,0,0,.5); }
.booking-workflow-card { padding: 20px; display: grid; gap: 16px; }
.booking-workflow-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.booking-workflow-head h3 { margin: 0; font-size: 20px; }
.booking-workflow-close { border: 0; background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.booking-workflow-content { display: grid; gap: 14px; }
.booking-workflow-content label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.booking-workflow-content select,
.booking-workflow-content input,
.booking-workflow-content textarea { width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); font: inherit; }
.booking-workflow-patient { margin: 0; font-weight: 700; font-size: 16px; }
.booking-workflow-summary { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
.booking-workflow-summary span { font-size: 12px; color: var(--muted); }
.booking-workflow-actions { display: flex; justify-content: flex-end; gap: 8px; }
.badge.awaiting_payment { background: #fef3c7; color: #92400e; }
.badge.arrived { background: #dbeafe; color: #1d4ed8; }
.badge.in_treatment { background: #ede9fe; color: #6d28d9; }
.booking-workflow-hint { margin: 0; color: var(--muted); font-size: 12px; }
.clinical-service-lines { display: grid; gap: 12px; }
.clinical-service-card { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.clinical-service-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.clinical-materials { display: grid; gap: 9px; margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.clinical-materials legend { padding: 0 5px; color: var(--ink); font-size: 12px; font-weight: 650; }
.clinical-material-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, .45fr); gap: 10px; align-items: end; }
.clinical-material-choice { display: flex !important; grid-template-columns: auto 1fr !important; align-items: center; }
.clinical-material-choice input { width: auto; }
.clinical-material-choice span { display: grid; gap: 2px; color: var(--ink); }
.clinical-material-choice small { color: var(--muted); font-size: 10px; font-weight: 400; }
.clinical-add-service { justify-self: start; }
.service-materials-panel { flex-basis: 100%; display: grid; gap: 12px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.service-materials-panel[hidden] { display: none; }
.service-materials-heading { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.service-materials-heading h4, .service-materials-heading p { margin: 0; }
.service-materials-heading p { margin-top: 4px; color: var(--muted); font-size: 12px; }
#service-material-rows { display: grid; gap: 10px; }
.service-material-row { display: grid; grid-template-columns: minmax(170px, 1.4fr) minmax(120px, .65fr) auto auto minmax(150px, 1fr) minmax(135px, .75fr) minmax(125px, .7fr) auto; gap: 10px; align-items: end; padding: 10px; border: 1px solid var(--line); border-radius: 9px; }
.service-material-row label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; }
.service-material-row .material-flag { display: flex; grid-template-columns: auto 1fr; align-items: center; white-space: nowrap; padding-bottom: 9px; }
.service-material-row .material-flag input { width: auto; }
.clinical-patient-price { color: var(--accent, #0d7c8c) !important; font-weight: 650 !important; }
.workflow-queue-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.workflow-queue-card { display: grid; align-content: start; gap: 8px; }
.workflow-queue-card h3 { margin: 0; font-size: 15px; }
.workflow-queue-count { color: var(--muted); font-size: 11px; }
.workflow-queue-item { display: grid; gap: 5px; padding: 9px 0; border-top: 1px solid var(--line); }
.workflow-queue-item:first-of-type { border-top: 0; }
.workflow-queue-item p { margin: 0; }
.workflow-queue-meta { color: var(--muted); font-size: 11px; }
.workflow-queue-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.empty-small { padding: 14px; text-align: center; color: var(--muted); font-size: 12px; }

@media (max-width: 760px) {
  .booking-workflow-modal { width: min(96vw, 620px); }
  .clinical-material-row, .service-material-row { grid-template-columns: 1fr; }
  .service-material-row .material-flag { padding-bottom: 0; }
}

/* Global range-bar/action-list polish — was duplicated near-identically
   inside the removed .dashboard-page/.patients-page blocks; consolidated
   here once since it's the same rhythm-adjacent pill treatment either
   page's range or sort control needs. */
.range-bar button, .sort-bar button {
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}
.range-bar button:hover, .sort-bar button:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.range-bar button:focus-visible, .sort-bar button:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }

.pp-lookup-wrap {
  max-width: none;
  margin-bottom: 20px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}

@media (prefers-reduced-motion: reduce) {
  .kpi-card, .chart-card, .range-bar button, .sort-bar button { transition: none; }
}

/* ===========================================================================
   Mobile card-layout table mechanism — proven on patients.html (Gate A),
   now promoted to global (Gate 2) so every admin table reuses ONE
   definition instead of six near-duplicate page-scoped copies — same
   promotion pattern .row-actions and the button system went through.
   Renamed the Gate A title-line classes (.card-arrow/.card-name/.card-phone,
   patients-specific) to generic reusable ones (.card-icon/.card-lead/
   .card-sub) any page's title line composes from. Breakpoint matches the
   one already in use elsewhere in this file (@media (min-width: 640px)
   above) — 640px is "desktop and up" there, so mobile-and-below here is
   consistently (max-width: 639px).
   =========================================================================== */
@media (max-width: 639px) {
  .table-wrap {
    background: none;
    border: none;
    overflow-x: visible;
  }
  .table-wrap table,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: 100%;
    min-width: 0; /* overrides shared.css's base `table { min-width: 640px }`,
                     which exists for the desktop horizontal-scroll pattern —
                     the whole point of the card layout is not needing that. */
  }
  .table-wrap thead { display: none; }

  /* Every data row IS a card. */
  .table-wrap tbody tr {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 8px;
  }
  /* Expanded: flatten the bottom edge so an attached continuation row
     (.history-row, .reschedule-row) reads as this same card's lower half,
     not a second floating card. Generic class, not tied to patients.html —
     any page's expandable/inline-panel row uses this same marker. */
  .table-wrap tbody tr.is-expanded {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
    margin-bottom: 0;
    padding-bottom: 8px;
  }
  .table-wrap tbody tr.history-row,
  .table-wrap tbody tr.reschedule-row {
    background: var(--card);
    border: 1px solid var(--line);
    border-top: none;
    border-radius: 0 0 12px 12px;
    margin-bottom: 8px;
  }
  .table-wrap tbody tr.history-row td,
  .table-wrap tbody tr.reschedule-row td {
    padding: 0 14px 12px;
  }

  /* Title line: a card's identity (name, name+phone, name+role, etc.) is
     not a field — no data-label, flows together as one line via
     display:inline. .card-icon is the optional small leading glyph
     (patients.html's expand arrow); .card-lead is the bold primary value;
     .card-sub is the muted secondary value beside it. Not every page uses
     all three. */
  .table-wrap td.card-icon,
  .table-wrap td.card-lead,
  .table-wrap td.card-sub {
    display: inline;
    padding: 0;
    border: none;
    white-space: nowrap;
  }
  .table-wrap td.card-icon { color: var(--muted); margin-right: 2px; }
  .table-wrap td.card-lead { font-weight: 600; color: var(--ink); }
  .table-wrap td.card-sub {
    color: var(--muted);
    font-size: 12.5px;
    margin-left: 8px;
  }
  /* Phone numbers specifically still get the mono treatment established in
     Phase 2/3 — a page opts in by adding this alongside .card-sub. */
  .table-wrap td.card-sub.card-sub-mono { font-family: var(--font-mono); }

  /* Everything else: a labeled row. content:attr() replaces the vanished
     column header — this is the only place a value needs its label spelled
     out, since the title line above already established who this card is. */
  .table-wrap td[data-label] {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-top: 1px solid var(--line);
    font-size: 13px;
    color: var(--ink);
  }
  .table-wrap td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
  }

  /* Secondary/metadata fields (bookings.html: Service/Doctor/Room/Staff/
     Source/Payment/Last Updated — real columns that can't be merged into
     one <td> without breaking desktop's column alignment against thead,
     but stacking all 7 at full weight would be the "6 stacked pairs isn't
     more minimalist than a table" anti-pattern). Same data-label mechanism,
     smaller and tighter, with the divider removed between consecutive
     .meta-row cells so all 7 read as one compact block instead of 7
     separately-boxed rows — only the first one (preceded by a non-meta-row)
     keeps the divider that separates it from the primary fields above. */
  .table-wrap td[data-label].meta-row {
    padding: 3px 0;
    font-size: 11.5px;
  }
  .table-wrap td[data-label].meta-row::before { font-size: 11px; }
  .table-wrap td.meta-row + td.meta-row {
    border-top: none;
    padding-top: 0;
  }

  /* Row-actions inside a card: own full-width line, own top divider, same
     wrapping .row-actions div every page already uses — no data-label
     needed, it's visibly a row of buttons. */
  .table-wrap td:has(> .row-actions) {
    padding: 8px 0 0;
    border-top: 1px solid var(--line);
    margin-top: 6px;
  }

  /* Nested history table (patients.html, inside an expanded card): same
     "don't 1:1 every column" logic, but simpler — no data-label needed, the
     format (date, time, status) is self-evident. flex `order` reflows
     date/time/status onto one line and service/booked-by onto a meta line
     beneath, without touching DOM order (desktop's plain left-to-right
     table cells stay exactly as they render today). Scoped through the real
     .history-wrap ancestor (not just .history-table) so it unambiguously
     outranks the generic ".table-wrap table/tbody/tr/td { display:block }"
     rule above on specificity — both were tied via .history-table alone,
     which left source order to decide, and that didn't resolve the way it
     should have in testing. */
  .history-wrap .history-table tr:not(:has(.history-section-label)) {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 3px 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
  }
  .history-wrap .history-table tr:last-child { border-bottom: none; }
  .history-wrap .history-table td {
    display: inline;
    width: auto; /* overrides the outer ".table-wrap td { width:100% }" rule —
                    display alone isn't enough, width cascades per-property */
    padding: 0;
    border: none;
    white-space: normal;
  }
  .history-wrap .history-table td.hist-date { font-weight: 600; color: var(--ink); order: 1; }
  .history-wrap .history-table td.hist-time { color: var(--muted); font-family: var(--font-mono); font-size: 12.5px; order: 2; }
  .history-wrap .history-table td.hist-status { order: 3; margin-left: auto; }
  /* Flexbox line-break hack: a zero-height, 100%-basis generated box between
     order 3 and order 5 forces service/by onto their own line, without
     giving hist-service itself 100% width (which would leave no room for
     hist-by beside it — the bug the first pass of this CSS had). */
  .history-wrap .history-table tr::after {
    content: "";
    flex-basis: 100%;
    order: 4;
    height: 0;
  }
  .history-wrap .history-table td.hist-service,
  .history-wrap .history-table td.hist-by {
    color: var(--muted);
    font-size: 12.5px;
    order: 5;
  }
  .history-wrap .history-table td.hist-service::after { content: " · "; }
}

/* Service RAG panel ------------------------------------------------------- */
.rag-intro { margin-bottom: 20px; }
.rag-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.rag-service-card { padding: 0; overflow: hidden; }
.rag-service-card .rag-section-heading { padding: 18px 18px 12px; }
.rag-section-heading, .rag-editor-heading, .rag-faq-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.rag-section-heading h2, .rag-section-heading h3, .rag-editor-heading h2 { margin: 0; }
.rag-service-list { display: grid; border-top: 1px solid var(--line); }
.rag-service-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 13px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.rag-service-item:last-child { border-bottom: 0; }
.rag-service-item:hover, .rag-service-item.selected { background: var(--accent-soft); }
.rag-service-item:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: -3px; }
.rag-service-name { font-weight: 650; }
.rag-service-detail, .rag-service-meta, .rag-hint, .rag-empty-faq { color: var(--muted); font-size: 12px; }
.rag-status {
  display: inline-flex;
  width: fit-content;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
}
.rag-status.configured { color: #166534; background: #dcfce7; }
.rag-status.unconfigured { color: #92400e; background: #fef3c7; }
.rag-status.draft { color: #3730a3; background: #e0e7ff; }
.rag-editor { min-width: 0; }
.rag-editor-heading { margin-bottom: 12px; }
.rag-price-note { margin: 0 0 6px; color: var(--muted); }
.rag-price-note strong { color: var(--ink); }
.rag-hint { margin: 0 0 18px; }
.rag-library-box {
  display: grid;
  gap: 12px;
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid #c7d2fe;
  border-radius: 14px;
  background: linear-gradient(135deg, #f8faff 0%, #f5f3ff 100%);
}
.rag-library-box h3 { margin: 2px 0 4px; font-size: 17px; }
.rag-library-box p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.rag-library-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.rag-library-controls label { display: grid; gap: 6px; font-size: 13px; font-weight: 650; }
.rag-library-controls select { width: 100%; min-width: 0; }
.rag-library-controls .btn-secondary { white-space: nowrap; }
.rag-library-box .rag-review-warning { color: #92400e; font-weight: 600; }
.rag-form { display: grid; gap: 16px; }
.rag-form label, .rag-faq-row label { display: grid; gap: 6px; color: var(--ink); font-size: 13px; font-weight: 600; }
.rag-form textarea, .rag-form input, .rag-faq-row textarea, .rag-faq-row input { width: 100%; font: inherit; }
.rag-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.rag-faq-section { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.rag-faqs { display: grid; gap: 10px; }
.rag-faq-row { display: grid; gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface, #fff); }
.rag-faq-head { align-items: center; }
.rag-faq-head .btn-link { color: #b91c1c; }
.rag-actions { display: flex; justify-content: flex-end; padding-top: 4px; }
.rag-empty { align-self: start; color: var(--muted); }

@media (max-width: 820px) {
  .rag-layout { grid-template-columns: 1fr; }
  .rag-field-grid { grid-template-columns: 1fr; }
  .rag-library-controls { grid-template-columns: 1fr; }
}

/* ===========================================================================
   Valeria workspace refresh
   A calm, high-clarity operating surface shared by every admin page.
   ========================================================================== */
html { background: var(--bg); }
body {
  min-height: 100dvh;
  line-height: 1.5;
  background:
    radial-gradient(circle at 92% -8%, rgba(8, 127, 131, .08), transparent 30rem),
    linear-gradient(180deg, #f8fbfa 0, var(--bg) 22rem);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.admin-header {
  min-height: 64px;
  padding: 10px clamp(16px, 3vw, 34px);
  border-bottom: 1px solid rgba(204, 220, 218, .82);
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow-xs);
  backdrop-filter: blur(14px);
}
.admin-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 16px;
  letter-spacing: -.015em;
}
.admin-header .brand::before {
  content: "V";
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 8px 20px rgba(8, 127, 131, .22);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 750;
}
.admin-header #logout-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted) !important;
  background: var(--surface-soft);
  font-weight: 600;
}
.admin-header #logout-link:hover { color: var(--ink) !important; background: var(--accent-soft); }
.nav-toggle {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  background: var(--surface-soft);
  font-size: 20px;
}

.admin-nav {
  width: 270px;
  padding: 76px 14px 24px;
  border-left: 1px solid var(--line);
  background: rgba(252, 254, 253, .98);
  box-shadow: var(--shadow-lg);
}
.admin-nav a {
  min-height: 43px;
  display: flex;
  align-items: center;
  padding: 9px 13px;
  border-radius: 11px;
  color: var(--muted);
  font-weight: 600;
  transition: color 160ms ease, background-color 160ms ease, transform 160ms ease;
}
.admin-nav a:hover { color: var(--ink); background: var(--surface-soft); transform: translateX(2px); }
.admin-nav a.active {
  color: var(--accent-strong);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.admin-main {
  width: min(100%, 1380px);
  max-width: 1380px;
  padding: clamp(20px, 3vw, 38px);
}
.admin-main > .page-heading,
.admin-main > .sales-heading,
.dashboard-intro {
  margin-bottom: clamp(22px, 3vw, 34px);
}
.admin-main > .page-heading h1,
.admin-main > .sales-heading h1,
.dashboard-intro h1 {
  color: var(--ink);
  font-size: clamp(28px, 3vw, 38px);
  letter-spacing: -.035em;
}
.dashboard-welcome,
.admin-main > .page-heading p,
.admin-main > .sales-heading p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}
.dashboard-section { margin-bottom: clamp(22px, 3vw, 34px); }
.section-heading { margin-bottom: 14px; }
.section-heading h2 { color: var(--ink); font-size: clamp(18px, 2vw, 23px); letter-spacing: -.02em; }
.section-kicker,
.dashboard-eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .11em;
}

.chart-card,
.kpi-card,
.table-wrap,
.modal,
.pp-dialog {
  border-color: rgba(204, 220, 218, .88);
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow-sm);
}
.chart-card {
  border-radius: var(--radius-lg);
  padding: clamp(17px, 2.2vw, 24px);
}
.chart-card:hover,
.kpi-card:hover { transform: none; box-shadow: var(--shadow-sm); }
.chart-card h3 { color: var(--ink); font-size: 15px; }
.kpi-grid { gap: 14px; }
.kpi-card {
  min-height: 116px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-radius: var(--radius-md);
  padding: 18px;
}
.kpi-card::after {
  content: "";
  position: absolute;
  right: -26px;
  bottom: -34px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--accent-soft);
  opacity: .55;
  pointer-events: none;
}
.kpi-card .label { color: var(--muted); font-weight: 650; letter-spacing: .055em; }
.kpi-card .value { position: relative; z-index: 1; color: var(--ink); letter-spacing: -.035em; }

.range-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}
.range-bar button {
  min-height: 36px;
  padding: 7px 12px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-weight: 650;
}
.range-bar button:hover { color: var(--ink); background: #fff; }
.range-bar button.active { color: #fff; background: var(--accent); box-shadow: 0 5px 14px rgba(8, 127, 131, .20); }

.admin-main form input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
.admin-main form select,
.modal-overlay form input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
.modal-overlay form select {
  min-height: 46px;
  border-radius: 12px;
  border-color: var(--field-line);
  background: var(--field-bg);
}
.admin-main form textarea,
.modal-overlay form textarea { border-radius: 12px; border-color: var(--field-line); background: var(--field-bg); }
.btn-primary,
.btn-secondary,
.btn-danger {
  min-height: 42px;
  border-radius: 11px;
  font-weight: 700;
  box-shadow: none;
}
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible { outline: 3px solid rgba(8, 127, 131, .25); outline-offset: 2px; }

.table-wrap { border-radius: var(--radius-md); }
th {
  padding-top: 12px;
  padding-bottom: 12px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .055em;
}
td { padding-top: 13px; padding-bottom: 13px; }
tbody tr { transition: background-color 150ms ease; }
tbody tr:hover { background: rgba(227, 242, 241, .42); }

.modal-overlay { background: rgba(17, 42, 46, .48); backdrop-filter: blur(5px); }
.modal,
.pp-dialog { border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }

.loading-state { color: var(--muted); }
.loading-state::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-inline-end: 8px;
  vertical-align: -2px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: valeria-spin 700ms linear infinite;
}
@keyframes valeria-spin { to { transform: rotate(360deg); } }

/* Dashboard data visualisation system */
.dashboard-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.chart-panel {
  min-width: 0;
  margin: 0;
  border: 1px solid rgba(204, 220, 218, .88);
  border-radius: var(--radius-lg);
  padding: clamp(17px, 2.2vw, 24px);
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow-sm);
}
.chart-panel--wide { grid-column: 1 / -1; }
.chart-panel-head { margin-bottom: 16px; }
.chart-eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.chart-title { margin: 0; color: var(--ink); font-family: var(--font-display); font-size: 18px; letter-spacing: -.02em; }
.chart-description { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.chart-visual { width: 100%; min-height: 260px; }
.chart-tooltip {
  min-width: 150px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .98);
  box-shadow: var(--shadow-md);
  color: var(--ink);
  font-size: 12px;
}
.chart-tooltip-label { margin: 0 0 7px; color: var(--muted); font-weight: 700; }
.chart-tooltip-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 4px; }
.chart-tooltip-row strong { font-variant-numeric: tabular-nums; }
.chart-tooltip-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; }
.chart-legend-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px; margin: 8px 0 0; padding: 0; list-style: none; }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.chart-legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.chart-empty { min-height: 260px; display: grid; place-items: center; padding: 28px; color: var(--muted); text-align: center; }
.chart-loading-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.chart-skeleton {
  min-height: 310px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(100deg, var(--surface-soft) 25%, #fff 40%, var(--surface-soft) 55%);
  background-size: 220% 100%;
  animation: valeria-shimmer 1.25s ease-in-out infinite;
}
.chart-skeleton:first-child { grid-column: 1 / -1; }
@keyframes valeria-shimmer { to { background-position-x: -220%; } }

@media (min-width: 1180px) {
  .admin-header { position: sticky; top: 0; z-index: 120; }
  .nav-toggle,
  .nav-backdrop { display: none !important; }
  .admin-nav {
    top: 64px;
    left: 0;
    right: auto;
    width: 246px;
    max-width: none;
    height: calc(100dvh - 64px);
    padding: 18px 12px 28px;
    transform: none;
    border: 0;
    border-right: 1px solid var(--line);
    box-shadow: none;
    overflow-y: auto;
  }
  .admin-nav a { opacity: 1; }
  .admin-main { width: auto; margin: 0 auto 0 246px; }
  html[dir="rtl"] .admin-nav { left: auto; right: 0; border-right: 0; border-left: 1px solid var(--line); }
  html[dir="rtl"] .admin-main { margin: 0 246px 0 auto; }
  html[dir="rtl"] .admin-nav a.active { box-shadow: inset -3px 0 0 var(--accent); }
  html[dir="rtl"] .admin-nav a:hover { transform: translateX(-2px); }
}

@media (max-width: 859px) {
  .section-heading-overview { align-items: stretch; }
  .range-bar { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .range-bar button { flex: 0 0 auto; }
  .dashboard-chart-grid,
  .chart-loading-grid { grid-template-columns: 1fr; }
  .chart-panel--wide,
  .chart-skeleton:first-child { grid-column: auto; }
}

@media (max-width: 639px) {
  .admin-header { min-height: 60px; padding: 8px 12px; }
  .admin-header .brand { font-size: 14px; }
  .admin-header .brand::before { width: 32px; height: 32px; border-radius: 10px; }
  .admin-header #logout-link { padding: 0 10px; }
  .admin-main { padding: 18px 14px 32px; }
  .kpi-grid,
  #kpi-tier1,
  #kpi-tier2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-card,
  #kpi-tier1 .kpi-card,
  #kpi-tier2 .kpi-card { min-height: 106px; padding: 14px; }
  #kpi-tier1 .value { font-size: 28px; }
  .chart-panel { padding: 16px 12px; border-radius: var(--radius-md); }
  .chart-visual { min-height: 240px; }
}

@media (max-width: 390px) {
  .kpi-grid,
  #kpi-tier1,
  #kpi-tier2 { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .loading-state::before { animation: none; border-color: var(--accent); }
  .chart-skeleton { animation: none; }
}
