/*
  Design system: premium neo-minimalist SaaS shell with an editorial grid,
  soft depth, and backend-driven brand tokens.

  --primary/--primary-hover/--primary-active/--primary-soft/--primary-subtle/
  --primary-foreground and the --secondary-* equivalents are injected per
  request as a :root style block (see layouts/app.blade.php and
  layouts/guest.blade.php), computed server-side in App\Support\ThemeColors
  from config('theme.primary_color' / 'secondary_color'). No component in
  this file ever hardcodes a brand color — change the backend config and
  the whole app re-themes.

  No external fonts/icon libraries/CDNs: the CSP is default-src 'self' and
  there is no build step, so typography leans on the platform Helvetica/SF
  stack and icons are inline SVG.

  Breakpoint scale (custom properties can't be read inside @media
  conditions, so this is documented here rather than tokenized):
    480px  — phone / phone-landscape
    768px  — tablet
    960px  — sidebar becomes persistent, mobile topbar disappears
    1200px — wide desktop
*/

:root {
    /* Neutral surface ramp (light) */
    --background: #f5f6f8;
    --surface: #ffffff;
    --surface-elevated: #ffffff;
    --surface-hover: #f1f2f4;
    --border: #e4e6ea;
    --border-subtle: #edeef1;

    --text: #14161a;
    --text-secondary: #4b5159;
    --text-muted: #6b7280;

    --success: #067647;
    --success-bg: #ecfdf3;
    --success-border: #b8e4cb;
    --warning: #b54708;
    --warning-bg: #fffaeb;
    --warning-border: #f3dca3;
    --danger: #b42318;
    --danger-bg: #fef3f2;
    --danger-border: #f4c7c3;
    --info: #1d4ed8;
    --info-bg: #eef2ff;
    --info-border: #c7d2fe;

    /* 4px spacing scale */
    --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
    --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
    --sp-12: 48px; --sp-16: 64px;

    --radius-sm: 7px;
    --radius-md: 11px;
    --radius-lg: 18px;

    --shadow-xs: 0 1px 2px rgba(15, 18, 22, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 18, 22, 0.06), 0 1px 1px rgba(15, 18, 22, 0.04);
    --shadow-md: 0 12px 32px -12px rgba(15, 18, 22, 0.16), 0 2px 6px rgba(15, 18, 22, 0.05);
    --shadow-lg: 0 24px 56px -16px rgba(15, 18, 22, 0.28), 0 4px 10px rgba(15, 18, 22, 0.06);

    --font-sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Inter, Roboto, Arial, sans-serif;

    --text-xs: 0.6875rem;  --text-sm: 0.8125rem; --text-base: 0.9375rem;
    --text-md: 1.0625rem;  --text-lg: 1.25rem;   --text-xl: 1.625rem;
    --text-2xl: 2.0625rem;

    --fw-regular: 400; --fw-medium: 550; --fw-semibold: 650; --fw-bold: 700;
    --lh-tight: 1.2; --lh-normal: 1.5; --lh-relaxed: 1.65;

    --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
    --duration-fast: 120ms;
    --duration-base: 180ms;
}

/* Dark theme: distinct surfaces/elevation, not an inverted light theme.
   Soft/subtle brand tints and semantic *-bg colors are remixed against the
   dark surface with color-mix() so any backend-supplied brand color still
   reads correctly, instead of using the light-mode precomputed tints.

   data-theme is always resolved to an explicit "light"/"dark" by the
   pre-paint bootstrap script in <head> (localStorage, falling back to
   the OS's prefers-color-scheme) — so this is the single source of
   truth for dark mode, nothing is duplicated behind a parallel
   @media(prefers-color-scheme) block. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --background: #0a0c0f;
    --surface: #13161b;
    --surface-elevated: #181c22;
    --surface-hover: #1d222a;
    --border: #262b33;
    --border-subtle: #1b1f26;

    --text: #f2f3f5;
    --text-secondary: #c3c8d1;
    --text-muted: #868d97;

    --success-bg: color-mix(in srgb, var(--success) 20%, var(--surface));
    --warning-bg: color-mix(in srgb, var(--warning) 20%, var(--surface));
    --danger-bg: color-mix(in srgb, var(--danger) 20%, var(--surface));
    --info-bg: color-mix(in srgb, var(--info) 22%, var(--surface));

    --primary-soft: color-mix(in srgb, var(--primary) 22%, var(--surface));
    --primary-subtle: color-mix(in srgb, var(--primary) 12%, var(--surface));
    --secondary-soft: color-mix(in srgb, var(--secondary) 22%, var(--surface));
    --secondary-subtle: color-mix(in srgb, var(--secondary) 12%, var(--surface));

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 12px 32px -12px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 24px 56px -16px rgba(0, 0, 0, 0.6);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font: var(--text-base)/var(--lh-normal) var(--font-sans);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-feature-settings: "tnum" 1;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 {
    font-size: var(--text-xl);
    line-height: var(--lh-tight);
    font-weight: var(--fw-semibold);
    letter-spacing: -0.015em;
    margin: 0 0 4px;
}
h2 {
    font-size: var(--text-md);
    line-height: 1.3;
    font-weight: var(--fw-semibold);
    letter-spacing: -0.005em;
    margin: 0 0 var(--sp-4);
}
h3 { font-size: var(--text-base); font-weight: var(--fw-semibold); margin: 0 0 var(--sp-1); }
p { margin: 0 0 var(--sp-4); }
.muted { color: var(--text-muted); }

.eyebrow {
    display: block;
    font-size: var(--text-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 6px;
}

.skip-link {
    position: absolute;
    left: -999px;
    top: auto;
    background: var(--primary);
    color: var(--primary-foreground);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    z-index: 200;
    font-weight: var(--fw-semibold);
    font-size: var(--text-sm);
}
.skip-link:focus { left: var(--sp-4); top: var(--sp-4); }

/* ---------- Guest (login/reset) layout: editorial split screen ---------- */
.guest { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 880px) { .guest { grid-template-columns: 1.05fr 1fr; } }

.guest-panel {
    display: none;
    position: relative;
    flex-direction: column;
    justify-content: space-between;
    padding: var(--sp-12) var(--sp-10);
    background: linear-gradient(165deg, var(--primary-active) 0%, var(--primary) 62%, var(--primary-hover) 100%);
    color: var(--primary-foreground);
    overflow: hidden;
}
.guest-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.14) 1px, transparent 0);
    background-size: 28px 28px;
    opacity: 0.6;
}
@media (min-width: 880px) { .guest-panel { display: flex; } }
.guest-panel-top { position: relative; display: flex; align-items: center; gap: 10px; font-weight: var(--fw-semibold); letter-spacing: -0.01em; }
.guest-panel-mark {
    width: 30px; height: 30px; border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.16);
    display: flex; align-items: center; justify-content: center;
    font-size: var(--text-sm); font-weight: var(--fw-bold);
}
.guest-panel-tagline {
    position: relative;
    font-size: var(--text-2xl);
    font-weight: var(--fw-semibold);
    letter-spacing: -0.02em;
    line-height: 1.25;
    max-width: 22ch;
}
.guest-panel-foot { position: relative; font-size: var(--text-sm); opacity: 0.8; }

.guest-form-pane { display: flex; align-items: center; justify-content: center; padding: var(--sp-8) var(--sp-4); background: var(--background); }
.guest-card { width: 100%; max-width: 380px; }
.guest-form-brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: var(--fw-semibold); letter-spacing: -0.01em; color: var(--text);
    margin-bottom: var(--sp-8); font-size: var(--text-base);
}
@media (min-width: 880px) { .guest-form-brand { display: none; } }
.guest-form-brand .brand-mark { width: 26px; height: 26px; font-size: var(--text-xs); }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
    width: 252px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform var(--duration-base) var(--ease);
}
.sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
@media (min-width: 960px) {
    .sidebar { position: sticky; top: 0; height: 100vh; transform: none; box-shadow: none; }
}

.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(10, 12, 16, 0.45);
    z-index: 45; opacity: 0; pointer-events: none; transition: opacity var(--duration-base) var(--ease);
}
.sidebar-backdrop.is-visible { opacity: 1; pointer-events: auto; }
@media (min-width: 960px) { .sidebar-backdrop { display: none; } }

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: var(--sp-5) var(--sp-5) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
    font-weight: var(--fw-semibold); letter-spacing: -0.01em; color: var(--text);
}
@media (min-width: 960px) { .sidebar-brand [data-sidebar-close] { display: none; } }
.brand-mark {
    width: 28px; height: 28px; border-radius: var(--radius-sm);
    background: var(--primary); color: var(--primary-foreground);
    display: flex; align-items: center; justify-content: center;
    font-size: var(--text-sm); font-weight: var(--fw-bold); flex-shrink: 0;
}

.sidebar-nav { padding: var(--sp-4) var(--sp-3); display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px var(--sp-3); border-radius: var(--radius-md);
    color: var(--text-secondary); font-size: var(--text-sm); font-weight: var(--fw-medium);
    transition: background-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: var(--fw-semibold); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-icon svg { width: 100%; height: 100%; }

.nav-group-title {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 9px var(--sp-3); border-radius: var(--radius-md);
    font-size: var(--text-xs); font-weight: var(--fw-semibold);
    text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
    cursor: pointer; list-style: none; user-select: none;
    transition: background-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.nav-group-title::-webkit-details-marker { display: none; }
.nav-group-title:hover { background: var(--surface-hover); color: var(--text-secondary); }
.nav-group-chevron { width: 14px; height: 14px; flex-shrink: 0; transition: transform var(--duration-fast) var(--ease); }
.nav-group[open] > .nav-group-title .nav-group-chevron { transform: rotate(90deg); }
.nav-group-items { display: flex; flex-direction: column; gap: 2px; padding-top: 2px; }
.nav-group + .nav-group,
.nav-group + .nav-item,
.nav-item + .nav-group { margin-top: var(--sp-2); }

.sidebar-footer { padding: var(--sp-3); border-top: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: var(--sp-2); }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    border: 1px solid transparent; background: transparent; color: var(--text-secondary);
    cursor: pointer; transition: background-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

.account-row { display: flex; align-items: center; gap: 10px; padding: 4px; }
.avatar {
    width: 30px; height: 30px; border-radius: 999px; flex-shrink: 0;
    background: var(--secondary-soft); color: var(--secondary);
    display: flex; align-items: center; justify-content: center;
    font-size: var(--text-sm); font-weight: var(--fw-semibold);
}
.account-meta { min-width: 0; flex: 1; }
.account-name { display: block; font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-links { display: flex; gap: 10px; font-size: var(--text-xs); color: var(--text-muted); }
.account-links a, .account-links .btn-link { font-size: var(--text-xs); }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar-mobile {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
    background: var(--surface); position: sticky; top: 0; z-index: 30;
}
.topbar-mobile .brand-name { font-weight: var(--fw-semibold); font-size: var(--text-sm); }
@media (min-width: 960px) { .topbar-mobile { display: none; } }

main { width: 100%; padding: var(--sp-8) var(--sp-5) var(--sp-16); flex: 1; }
@media (min-width: 768px) { main { padding: var(--sp-10) var(--sp-6) var(--sp-16); } }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-6); }

/* ---------- Cards & editorial grid ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    padding: var(--sp-6);
    margin-bottom: var(--sp-5);
}

.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 var(--sp-5); }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.form-grid .field-wide { grid-column: 1 / -1; }

.bento-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--sp-5);
    box-shadow: var(--shadow-xs);
}
.bento-tile { background: var(--surface); padding: var(--sp-5) var(--sp-5); display: flex; flex-direction: column; gap: 6px; }
.bento-tile .value { font-size: var(--text-xl); font-weight: var(--fw-semibold); letter-spacing: -0.02em; line-height: 1.1; }
.bento-tile.accent { background: var(--primary-subtle); }
.bento-tile.accent .value { color: var(--primary); }

.bento-hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    padding: var(--sp-16) var(--sp-8);
    text-align: center;
    color: var(--text-muted);
    background-image: radial-gradient(circle at 1px 1px, var(--border-subtle) 1px, transparent 0);
    background-size: 24px 24px;
    background-position: center;
}
.tile-note { font-size: var(--text-xs); color: var(--text-muted); }

/* Personal dashboard: main column + side column of cards */
.dashboard-grid { display: grid; grid-template-columns: 1fr; gap: 0 var(--sp-5); align-items: start; }
@media (min-width: 900px) { .dashboard-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }

.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-2) var(--sp-4); margin: 0; font-size: var(--text-sm); }
.detail-list dt { color: var(--text-muted); }
.detail-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* One-time credential hand-over (admin temporary passwords) */
.credential-card { border-color: var(--warning-border); background: var(--warning-bg); }
.credential-card .eyebrow { color: var(--warning); }
.credential-list { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-2) var(--sp-4); margin: 0; font-size: var(--text-sm); }
.credential-list dt { color: var(--text-secondary); font-weight: var(--fw-semibold); }
.credential-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; }
.credential-secret { font-size: var(--text-md); user-select: all; }

/* ---------- Forms ---------- */
label { display: block; font-weight: var(--fw-semibold); font-size: var(--text-sm); margin-bottom: 6px; color: var(--text-secondary); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=search],
input[type=date], input[type=time], input[type=number], select, textarea {
    width: 100%;
    height: 40px;
    padding: 0 var(--sp-3);
    font: inherit; font-size: var(--text-base); color: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}
input[type=text]:hover, input[type=email]:hover, input[type=password]:hover, input[type=tel]:hover, input[type=search]:hover,
input[type=date]:hover, input[type=time]:hover, input[type=number]:hover, select:hover, textarea:hover { border-color: var(--text-muted); }
textarea { height: auto; min-height: 84px; padding: 10px var(--sp-3); resize: vertical; line-height: var(--lh-normal); }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}
button:focus-visible, a:focus-visible, label:focus-within {
    outline: none; box-shadow: 0 0 0 3px var(--primary-subtle); border-radius: var(--radius-sm);
}
.field { margin-bottom: var(--sp-4); }
fieldset.choice-group { border: 0; padding: 0; margin: 0 0 var(--sp-5); min-width: 0; }
.choice-group legend { font-weight: var(--fw-semibold); font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: var(--sp-2); padding: 0; }
.choice { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: var(--sp-2); font-weight: var(--fw-regular); color: var(--text); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-subtle); }
.choice input { margin-top: 3px; accent-color: var(--primary); }
.choice .hint { margin-top: 2px; display: block; }
.field-error { color: var(--danger); font-size: var(--text-sm); margin-top: 6px; }
.hint { color: var(--text-muted); font-size: var(--text-sm); margin-top: 6px; }
.required-mark { color: var(--danger); margin-left: 2px; }

.logo-field { display: flex; align-items: center; gap: var(--sp-3); }
.logo-preview {
    width: 56px; height: 56px; border-radius: var(--radius-md);
    border: 1px solid var(--border); background: var(--background);
    object-fit: contain; padding: 4px; flex-shrink: 0;
}

/* ---------- Buttons: primary / secondary / ghost / destructive ----------
   Only the bare .btn (every page's main call-to-action - Save, Book
   appointment, Record payment, etc.) is sized up; .btn-secondary/-ghost/
   -danger/-sm stay at the original, more understated size so the primary
   action always stands out as the one to notice. */
.btn {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 44px; padding: 0 var(--sp-5);
    border-radius: var(--radius-sm); border: 1px solid transparent;
    font: inherit; font-size: var(--text-base); font-weight: var(--fw-bold);
    cursor: pointer; text-decoration: none; white-space: nowrap;
    background: var(--primary); color: var(--primary-foreground);
    box-shadow: var(--shadow-sm);
    transition: background-color var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}
.btn:hover { background: var(--primary-hover); text-decoration: none; box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(1px); background: var(--primary-active); box-shadow: var(--shadow-xs); }
.btn:disabled { cursor: not-allowed; opacity: 0.6; transform: none; box-shadow: var(--shadow-xs); }
.btn-block { width: 100%; }

.btn-secondary, .btn-ghost, .btn-danger {
    height: 38px; padding: 0 var(--sp-4); font-size: var(--text-sm); font-weight: var(--fw-semibold); box-shadow: none;
}

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-secondary:active { background: var(--surface-hover); transform: translateY(1px); }

.btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--danger-bg); }

.btn-sm { height: 30px; padding: 0 var(--sp-3); font-size: var(--text-xs); gap: 4px; }

.btn-link { background: none; border: 0; padding: 0; height: auto; color: var(--text-muted); font-weight: var(--fw-regular); cursor: pointer; font: inherit; font-size: var(--text-sm); text-decoration: underline; box-shadow: none; }

.btn.is-loading { pointer-events: none; color: transparent !important; }
.btn.is-loading::after {
    content: ""; position: absolute; width: 15px; height: 15px; border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff;
    animation: btn-spin 0.6s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after, .btn-danger.is-loading::after {
    border-color: var(--border); border-top-color: var(--text-secondary);
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* ---------- Alerts & toasts ---------- */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: var(--sp-4); font-size: 0.9rem; border: 1px solid transparent; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.alert-info { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }

.toast-region {
    position: fixed; top: var(--sp-4); right: var(--sp-4); z-index: 100;
    display: flex; flex-direction: column; gap: 10px;
    width: min(360px, calc(100vw - 32px));
}
.toast {
    background: var(--surface-elevated); border: 1px solid var(--border); border-left: 3px solid var(--text-muted);
    border-radius: var(--radius-md); box-shadow: var(--shadow-md);
    padding: var(--sp-3) var(--sp-4); display: flex; align-items: flex-start; gap: 10px;
    font-size: var(--text-sm); color: var(--text);
    animation: toast-in var(--duration-base) var(--ease);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast-body { flex: 1; }
.toast-close { margin-left: auto; background: none; border: 0; color: var(--text-muted); cursor: pointer; padding: 0; line-height: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); font-weight: var(--fw-semibold); }
tbody tr { transition: background-color var(--duration-fast) var(--ease); }
tbody tr:hover { background: var(--surface-hover); }
tr:last-child td { border-bottom: 0; }

.badge { display: inline-block; font-size: var(--text-xs); font-weight: var(--fw-semibold); padding: 3px 9px; border-radius: 999px; letter-spacing: 0.01em; }
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-disabled { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-role { background: var(--primary-soft); color: var(--primary); margin-left: 6px; vertical-align: 1px; }

/* ---------- Empty states ---------- */
.empty-state { text-align: center; padding: var(--sp-16) var(--sp-5); display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); color: var(--text-muted); }
.empty-icon { width: 40px; height: 40px; color: var(--text-muted); opacity: 0.55; }
.empty-icon svg { width: 100%; height: 100%; }
.empty-state h3 { color: var(--text); }
.empty-state p { margin: 0; max-width: 360px; }
.empty-state .btn { margin-top: var(--sp-2); }

/* ---------- Tabs (no-JS CSS fallback; app.js upgrades to real ARIA tabs) ---------- */
.tabs input[type="radio"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tabs-list { display: flex; gap: var(--sp-5); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-5); }
.tab { padding: 10px 2px; font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--duration-fast) var(--ease); }
.tab:hover { color: var(--text); }
.tab-panel { display: none; }

#tab-users:checked ~ .tabs-list .tab[for="tab-users"],
#tab-details:checked ~ .tabs-list .tab[for="tab-details"],
#tab-licensing:checked ~ .tabs-list .tab[for="tab-licensing"],
#tab-access:checked ~ .tabs-list .tab[for="tab-access"] { color: var(--text); border-color: var(--primary); }

#tab-users:checked ~ .panel-users,
#tab-details:checked ~ .panel-details,
#tab-licensing:checked ~ .panel-licensing,
#tab-access:checked ~ .panel-access { display: block; }

/* JS-upgraded ARIA tabs use aria-selected instead of :checked */
.tabs[data-enhanced] .tab[aria-selected="true"] { color: var(--text); border-color: var(--primary); }
.tabs[data-enhanced] .tab-panel { display: none; }
.tabs[data-enhanced] .tab-panel[data-active="true"] { display: block; }

/* ---------- Confirm dialog ---------- */
dialog.confirm-dialog {
    border: 0; border-radius: var(--radius-lg); padding: 0;
    box-shadow: var(--shadow-lg); max-width: 400px; width: calc(100vw - 32px);
    background: var(--surface); color: var(--text);
}
dialog.confirm-dialog::backdrop { background: rgba(10, 12, 16, 0.5); }
.confirm-icon { width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--danger-bg); color: var(--danger); display: flex; align-items: center; justify-content: center; margin-bottom: var(--sp-3); }
.confirm-icon svg { width: 18px; height: 18px; }
.confirm-body { padding: var(--sp-6) var(--sp-6) var(--sp-5); }
.confirm-actions { padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--sp-2); }

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

.toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; margin-bottom: var(--sp-5); }
.toolbar input[type=search] { max-width: 360px; flex: 1 1 220px; }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card-head h2 { margin: 0; }

.nav-count {
    margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
    background: var(--warning-bg); color: var(--warning); font-size: var(--text-xs); font-weight: var(--fw-semibold);
    display: inline-flex; align-items: center; justify-content: center;
}

.week-day { padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-3); }
.week-day.is-today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary-subtle); }
.week-day-head { display: flex; align-items: center; gap: var(--sp-3); }
.week-day-head h2 { margin: 0; font-size: var(--text-base); }
.week-day-add { margin-left: auto; }
.week-day-empty { margin: var(--sp-2) 0 0; font-size: var(--text-sm); }

.appointment-list { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.appointment-row {
    display: grid; grid-template-columns: 7.5rem 1fr auto; align-items: center; gap: var(--sp-3);
    padding: 10px var(--sp-3); border-radius: var(--radius-sm); color: var(--text);
    transition: background-color var(--duration-fast) var(--ease);
}
.appointment-row:hover { background: var(--surface-hover); text-decoration: none; }
.appointment-row.is-muted { opacity: 0.6; }
.appointment-row.is-muted .appointment-main { text-decoration: line-through; }
.appointment-time { font-weight: var(--fw-semibold); font-size: var(--text-sm); white-space: nowrap; }
.appointment-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) {
    .appointment-row { grid-template-columns: 1fr auto; }
    .appointment-time { grid-column: 1 / -1; }
}

details.new-patient { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4); }
details.new-patient summary { cursor: pointer; font-weight: var(--fw-semibold); font-size: var(--text-sm); }
details.new-patient[open] summary { margin-bottom: var(--sp-2); }

/* Calendar view switch (week/day/month) - plain navigation, not a tabpanel. */
.view-switch { display: flex; gap: 2px; margin-bottom: var(--sp-4); }
.view-switch a { border-radius: 0; }
.view-switch a:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.view-switch a:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.view-switch a.is-active { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }

/* Day view: one column per practitioner, rows are 30-minute slots. */
.day-grid-wrap { overflow-x: auto; }
.day-grid { border-collapse: collapse; width: 100%; }
.day-grid th, .day-grid td { border: 1px solid var(--border); padding: 0; }
.day-grid th { padding: var(--sp-2) var(--sp-3); background: var(--background); text-align: left; font-size: var(--text-sm); }
.day-grid .day-slot-time { padding: 4px 8px; font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; vertical-align: top; }
.day-slot { height: 2.25rem; vertical-align: top; transition: background-color var(--duration-fast) var(--ease); }
.day-slot.is-drop-target { background: var(--primary-subtle); }
.day-slot.is-unavailable { background: repeating-linear-gradient(135deg, var(--border-subtle) 0, var(--border-subtle) 4px, transparent 4px, transparent 10px); }
.day-slot-add {
    display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
    min-height: 2.25rem; color: var(--text-muted); font-size: var(--text-sm); text-decoration: none;
    opacity: 0; transition: opacity var(--duration-fast) var(--ease), background-color var(--duration-fast) var(--ease);
}
.day-slot-add:hover, .day-slot-add:focus-visible { opacity: 1; background: var(--surface-hover); }
.appt-block {
    display: block; height: 100%; padding: 4px 8px; font-size: var(--text-xs); line-height: 1.3;
    border-left: 3px solid var(--primary); background: var(--surface-hover); cursor: grab; overflow: hidden;
}
.appt-block.is-dragging { opacity: 0.4; }
.appt-block strong { display: block; font-size: var(--text-sm); }

/* Month view: a plain grid of day cells, each a link to that day's view. */
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.month-grid-head { background: var(--background); padding: var(--sp-2); text-align: center; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.month-day { background: var(--surface); padding: var(--sp-2); min-height: 5.5rem; display: flex; flex-direction: column; gap: 4px; color: var(--text); }
.month-day:hover { background: var(--surface-hover); text-decoration: none; }
.month-day.is-today { box-shadow: inset 0 0 0 2px var(--primary); }
.month-day.is-outside { opacity: 0.4; }
.month-day-date { font-size: var(--text-sm); font-weight: var(--fw-semibold); }
.month-day-counts { display: flex; flex-wrap: wrap; gap: 3px; margin-top: auto; }
.month-day-dot { width: 7px; height: 7px; border-radius: 999px; }

.hours-grid { display: grid; grid-template-columns: 7rem 1fr; gap: var(--sp-2) var(--sp-4); align-items: center; margin-bottom: var(--sp-4); }
.hours-day { font-weight: var(--fw-semibold); font-size: var(--text-sm); grid-row: span 2; }
.hours-range { display: flex; align-items: center; gap: var(--sp-2); }
.hours-range input { max-width: 140px; }
.hours-error { grid-column: 2; margin-top: 0; }
@media (min-width: 640px) {
    .hours-grid { grid-template-columns: 7rem 1fr 1fr; }
    .hours-day { grid-row: auto; }
    .hours-error { grid-column: 2 / -1; }
}

.pagination { display: flex; gap: var(--sp-3); align-items: center; margin: var(--sp-4) 0 0; font-size: var(--text-sm); }
.pagination a, .pagination .is-disabled {
    display: inline-flex; align-items: center; height: 34px; padding: 0 var(--sp-3);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.pagination .is-disabled { color: var(--text-muted); opacity: 0.6; }

/* Public booking page */
.public-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.public-header-inner { max-width: 820px; margin: 0 auto; padding: var(--sp-4) var(--sp-5); display: flex; align-items: center; gap: var(--sp-3); }
.public-clinic-name { font-weight: var(--fw-semibold); }
.public-clinic-meta { font-size: var(--text-sm); }
.public-main { max-width: 820px; }

.booking-steps { list-style: none; margin: 0; padding: 0; }
.step-number {
    display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; margin-right: 6px;
    border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: var(--text-xs); vertical-align: 2px;
}
.option-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-2); }
.option-grid.days { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
.option {
    display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3);
    border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text); background: var(--surface);
    transition: border-color var(--duration-fast) var(--ease), background-color var(--duration-fast) var(--ease);
}
.option:hover { border-color: var(--primary); text-decoration: none; }
.option.is-selected { border-color: var(--primary); background: var(--primary-subtle); box-shadow: 0 0 0 1px var(--primary); }
.option.day { flex-direction: column; gap: 0; padding: var(--sp-2); text-align: center; }
.day-name, .day-month { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.day-number { font-size: var(--text-lg); font-weight: var(--fw-semibold); line-height: 1.3; }

.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: var(--sp-2); }
.slot { position: relative; margin: 0; cursor: pointer; }
.slot input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.slot span {
    display: flex; align-items: center; justify-content: center; height: 40px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: var(--fw-semibold); color: var(--text);
    transition: border-color var(--duration-fast) var(--ease), background-color var(--duration-fast) var(--ease);
}
.slot:hover span { border-color: var(--primary); }
.slot input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.slot input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-subtle); }

.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Motion & accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}
