/* App shell, shared controls and the lock screen.
   The portal wears the sign-in page's two panels: the Sprint3 navy panel is the navigation rail,
   the white Darbi panel is the workspace. Page layouts live in portal.css; the sign-in kit in darbi/*.css. */

/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  /* Workspace (the Darbi panel) */
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;          /* 4.8:1 on white */
  --paper: #ffffff;
  --wash: #f8fafc;
  --wash-2: #f1f5f9;
  --rule: #e2e8f0;
  --rule-strong: #cbd5e1;
  --control: #8494aa;        /* 3:1 control edge on white */
  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --blue-press: #1e40af;
  --blue-wash: #eff6ff;
  --ok: #166534;     --ok-wash: #dcfce7;
  --warn: #92400e;   --warn-wash: #fef3c7;
  --bad: #b91c1c;    --bad-wash: #fef2f2;
  --danger-solid: #b3261e;

  /* Rail (the Sprint3 panel) */
  --navy: #1b2636;
  --navy-deep: #141d2a;
  --cream: #f2efe8;
  --cream-soft: #c9cfda;
  --cream-muted: #a7b0bf;
  --sky: #8ec3f7;
  --navy-rule: rgba(242, 239, 232, .12);
  --navy-hover: rgba(242, 239, 232, .07);
  --navy-active: rgba(142, 195, 247, .16);

  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-control: 0 1px 2px rgba(15, 23, 42, .06);
  --sidebar-w: 248px;
  --sidebar-n: 64px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  /* Older names still used by components */
  --text: var(--ink);
  --text-muted: var(--muted);
  --accent: var(--blue);
  --accent-dim: var(--blue-wash);
  --border: var(--rule);
  --surface: var(--paper);
  --surface-2: var(--wash);
  --danger: var(--bad);
  --sans: var(--font);
  --mono: var(--font-mono);
  --bg: var(--paper);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef4ff;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --paper: #101827;
  --wash: #151f31;
  --wash-2: #1e293b;
  --rule: #29364a;
  --rule-strong: #3b4b63;
  --control: #64748b;
  --blue: #60a5fa;
  --blue-hover: #93c5fd;
  --blue-press: #3b82f6;
  --blue-wash: #172b46;
  --ok: #86efac;
  --ok-wash: #123524;
  --warn: #fcd34d;
  --warn-wash: #3a2b11;
  --bad: #fca5a5;
  --bad-wash: #3d1b22;
  --danger-solid: #dc2626;
  --navy: #0b1220;
  --navy-deep: #070d18;
  --shadow-control: 0 1px 2px rgba(0, 0, 0, .28);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body, #app { height: 100%; width: 100%; }

body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .2s ease, color .2s ease;
}

::selection { background: #bfdbfe; color: var(--ink); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1:focus-visible, h1:focus { outline: none; }   /* FocusOnNavigate focuses the page title */
button { font: inherit; }

/* Thin, quiet scrollbars in the workspace */
* { scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; }

/* ── Boot screen (before Blazor starts): the navy brand panel ──────────── */
.boot-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100vh; gap: 24px; background: var(--navy);
}
.boot-logo { display: block; height: 48px; width: auto; }
.boot-bar { width: 200px; height: 2px; background: var(--navy-rule); border-radius: 99px; overflow: hidden; }
.boot-progress { height: 100%; width: 40%; background: var(--sky); border-radius: 99px; animation: boot-slide 1.4s ease-in-out infinite; }
@keyframes boot-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(400%); } }
@media (prefers-reduced-motion: reduce) { .boot-progress { animation: none; width: 100%; opacity: .5; } }

/* ── App shell ───────────────────────────────────────────────────────────── */
.app-shell { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

.sidebar {
  flex: none; width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--navy); color: var(--cream);

}
.sidebar.collapsed { width: var(--sidebar-n); }

.sidebar-brand {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 72px; padding: 16px 12px 16px 20px;
  border-bottom: 1px solid var(--navy-rule);
}
.sidebar-logo { display: inline-flex; min-width: 0; border-radius: 4px; }
.sidebar-logo img { display: block; height: 30px; width: auto; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 16px 0; }
.sidebar.collapsed .sidebar-logo { display: none; }

.sidebar-toggle, .menu-toggle {
  flex: none; display: inline-grid; place-items: center;
  width: 32px; height: 32px; border: 0; border-radius: var(--radius);
  background: transparent; color: var(--cream-muted); cursor: pointer;
  transition: background-color .15s, color .15s;
}
.sidebar-toggle:hover, .menu-toggle:hover { background: var(--navy-hover); color: var(--cream); }
.sidebar-toggle:focus-visible, .menu-toggle:focus-visible { outline-color: var(--sky); }
.toggle-chevron { display: inline-block; font-size: 20px !important; transition: transform .22s var(--ease-out); }
.sidebar.collapsed .toggle-chevron { transform: rotate(180deg); }
.menu-toggle { display: none; width: 40px; height: 40px; }

.sidebar-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.nav-items { flex: 1; overflow-x: hidden; overflow-y: auto; list-style: none; padding: 12px 10px; display: grid; gap: 2px;
  grid-template-columns: minmax(0, 1fr); align-content: start; scrollbar-color: var(--navy-rule) transparent; }
/* minmax(0, 1fr): the rail's width wins, so a hidden group label can't stretch the column */
.nav-items li { list-style: none; }

.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px;
  padding: 8px 12px; border: 0; border-radius: var(--radius);
  background: transparent; color: var(--cream-soft);
  font: 500 14px/20px var(--font); text-align: left; text-decoration: none; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.nav-item .rzi { flex: none; font-size: 20px !important; color: var(--cream-muted); transition: color .15s; }
.nav-item:hover { background: var(--navy-hover); color: var(--cream); }
.nav-item:hover .rzi { color: var(--cream); }
.nav-item[aria-current="page"] { background: var(--navy-active); color: #fff; font-weight: 600; }
.nav-item[aria-current="page"] .rzi { color: var(--sky); }
.nav-item:focus-visible { outline: 2px solid var(--sky); outline-offset: -2px; }
.nav-item sup { font-size: .65em; line-height: 0; }

.nav-group { padding: 18px 12px 6px; }
.nav-group .nav-label { font: 600 11px/16px var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--cream-muted); }

.sidebar.collapsed .nav-items { padding: 12px 8px; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 8px 0; }
.sidebar.collapsed .nav-item .nav-label { display: none; }
.sidebar.collapsed .nav-group { padding: 8px 4px 6px; }
.sidebar.collapsed .nav-group .nav-label { display: block; height: 1px; overflow: hidden; color: transparent; background: var(--navy-rule); }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px 12px 14px; border-top: 1px solid var(--navy-rule); background: var(--navy-deep);
}
.user-avatar {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: 50%; background: var(--navy-active); color: var(--sky);
  font: 700 13px/1 var(--font); letter-spacing: .02em; cursor: pointer; text-decoration: none;
}
/* Account lives here (no separate menu item): the whole block links to it */
.sidebar-account {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  margin: -6px; padding: 6px; border-radius: var(--radius); color: inherit; text-decoration: none;
}
.sidebar-account:hover { background: rgba(142, 195, 247, .08); }
.sidebar-account:hover .user-avatar:not(.avatar--preset) { background: rgba(142, 195, 247, .26); }
.sidebar-account:focus-visible { outline: 2px solid var(--sky); outline-offset: 0; }
.sidebar-account[aria-current="page"] .user-avatar { box-shadow: 0 0 0 2px var(--sky); }
.sidebar.collapsed .sidebar-account { flex: none; }

/* A chosen avatar (Account page), filling the holder's circle: a white symbol on the preset's colour
   (sized from the holder's font), or an image (portrait, logo) on its disc */
.avatar--symbol { background: var(--avatar-bg) !important; color: #fff !important; }
.avatar--symbol .rzi { font-size: 1.5em !important; line-height: 1; }
.avatar--image { overflow: hidden; background: var(--avatar-bg, #dbe7f6) !important; box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .12); }   /* edge keeps white logo discs visible on white */
.avatar--image img { display: block; width: 86%; height: 86%; object-fit: contain; }
.user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-name { font: 600 13px/18px var(--font); color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-roles { font: 400 12px/16px var(--font); color: var(--cream-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-signout {
  flex: none; display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--cream-muted); cursor: pointer;
  transition: background-color .15s, color .15s;
}
.btn-signout .rzi { font-size: 20px !important; }
.btn-signout:hover { background: var(--navy-hover); color: var(--cream); }
.btn-signout:focus-visible { outline-color: var(--sky); }
.sidebar.collapsed .sidebar-user { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .user-info, .sidebar.collapsed .btn-signout { display: none; }

/* Workspace */
.content-area { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; background: var(--paper); overflow: hidden; }
.portal-view { flex: 1; min-height: 0; overflow-y: auto; }
.legacy-view { flex: 1; min-height: 0; position: relative; }
.frame-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.frame-loading[hidden] { display: none; }

/* Phone tab bar (hidden on wider screens, where the rail does the job) */
.tabbar { display: none; }
.sidebar-panel .in-sheet { display: none; }   /* phone More sheet only; the rail has the account link at the bottom */
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0;
  border: 0; background: transparent; color: var(--cream-muted); cursor: pointer; text-decoration: none;
  font: 600 11px/14px var(--font); -webkit-tap-highlight-color: transparent; transition: color .15s;
}
.tab .rzi {
  display: grid; place-items: center; width: 56px; height: 30px; border-radius: 99px;
  font-size: 22px !important; transition: background-color .2s var(--ease-out), color .2s, transform .15s var(--ease-out);
}
.tab span { max-width: 100%; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab sup { font-size: .7em; line-height: 0; }
.tab:active .rzi { transform: scale(.92); }
.tab[aria-current="page"], .tab.is-current, .tab[aria-expanded="true"] { color: var(--cream); }
.tab[aria-current="page"] .rzi, .tab.is-current .rzi, .tab[aria-expanded="true"] .rzi { background: var(--navy-active); color: var(--sky); }
.tab:focus-visible { outline: 2px solid var(--sky); outline-offset: -4px; border-radius: 10px; }

@keyframes sheet-up { from { transform: translateY(32px); opacity: 0; } }
@keyframes scrim-in { from { opacity: 0; } }

/* Phone: slim navy top bar for the brand, navigation at the bottom in thumb reach */
@media (max-width: 860px) {
  .app-shell { flex-direction: column; --tabbar-h: calc(62px + env(safe-area-inset-bottom, 0px)); }
  .sidebar, .sidebar.collapsed { width: 100%; position: relative; z-index: 30; }
  .sidebar-brand, .sidebar.collapsed .sidebar-brand {
    min-height: 52px; padding: max(8px, env(safe-area-inset-top)) 16px 8px; justify-content: flex-start; border-bottom: 0;
  }
  .sidebar.collapsed .sidebar-logo { display: inline-flex; }
  .sidebar-logo img { height: 24px; }
  .sidebar-toggle, .menu-toggle { display: none; }

  .tabbar {
    flex: none; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    height: var(--tabbar-h); padding: 0 8px env(safe-area-inset-bottom, 0px);
    background: var(--navy); border-top: 1px solid var(--navy-rule);
  }

  /* The full menu: a sheet rising from the tab bar */
  .sidebar-panel {
    display: none; position: fixed; left: 0; right: 0; bottom: var(--tabbar-h);
    max-height: calc(100dvh - var(--tabbar-h) - 64px); overflow: hidden; padding-top: 20px;
    background: var(--navy); border-radius: 18px 18px 0 0; box-shadow: 0 -16px 40px rgba(15, 23, 42, .32);
    animation: sheet-up .32s var(--ease-out);
  }
  .sidebar-panel::before {
    content: ""; position: absolute; top: 8px; left: 50%; width: 36px; height: 4px; margin-left: -18px;
    border-radius: 99px; background: rgba(242, 239, 232, .22);
  }
  .sidebar.menu-open .sidebar-panel { display: flex; }
  .sidebar-panel .nav-items { padding-top: 4px; }
  .sidebar-panel .in-tabbar { display: none; }   /* already one tap away in the tab bar */
  .sidebar-panel .in-sheet { display: revert; }
  .sidebar-panel .in-tabbar + .nav-group { padding-top: 8px; }   /* first heading left at the top of the sheet */
  .sidebar-panel .sidebar-user { background: transparent; padding-bottom: 14px; }
  .menu-scrim { position: fixed; inset: 0 0 var(--tabbar-h); z-index: -1; background: rgba(15, 23, 42, .5); animation: scrim-in .2s ease; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 8px 12px; }
  .sidebar.collapsed .nav-item .nav-label, .sidebar.collapsed .user-info, .sidebar.collapsed .btn-signout { display: revert; }
  .sidebar.collapsed .nav-group .nav-label { height: auto; color: var(--cream-muted); background: none; }
  .sidebar.collapsed .sidebar-user { justify-content: flex-start; padding: 12px 12px 12px 14px; }
  .nav-item { min-height: 44px; }
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary, .btn-ghost, .btn-secondary, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--radius);
  font: 600 14px/20px var(--font); white-space: nowrap; text-decoration: none; cursor: pointer;
  box-shadow: var(--shadow-control);
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-hover); }
.btn-primary:active:not(:disabled) { background: var(--blue-press); }

.btn-ghost, .btn-secondary { background: var(--paper); border-color: var(--rule-strong); color: var(--ink-2); }
.btn-ghost:hover:not(:disabled), .btn-secondary:hover:not(:disabled) { background: var(--wash); border-color: #94a3b8; color: var(--ink); }

.btn-danger { background: var(--danger-solid); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #991b1b; }

.btn-primary:disabled, .btn-ghost:disabled, .btn-secondary:disabled, .btn-danger:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary .rzi, .btn-ghost .rzi { font-size: 18px !important; }
.btn-auto { width: auto; }
.btn-block { width: 100%; }
.btn-small { height: 32px; padding: 0 12px; font-size: 13px; }

.btn-link {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 0; border: 0; background: none;
  color: var(--blue); font: 600 13px/18px var(--font); cursor: pointer; text-decoration: none; text-underline-offset: 3px;
}
.btn-link:hover:not(:disabled) { text-decoration: underline; }
.btn-link .rzi { font-size: 18px !important; }
.btn-link:disabled { opacity: .5; cursor: not-allowed; }

.btn-ghost-danger {
  display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px; border: 0; border-radius: var(--radius);
  background: none; color: var(--bad); font: 600 13px/18px var(--font); cursor: pointer; transition: background-color .15s;
}
.btn-ghost-danger:hover:not(:disabled) { background: var(--bad-wash); }
.btn-ghost-danger:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost-danger .rzi { font-size: 18px !important; }

/* Square icon buttons for row actions; the name lives in aria-label and title */
.btn-icon {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--paper); color: var(--ink-2);
  box-shadow: var(--shadow-control); cursor: pointer; transition: background-color .15s, border-color .15s, color .15s;
}
.btn-icon .rzi { font-size: 19px !important; }
.btn-icon:hover:not(:disabled) { background: var(--wash); border-color: #94a3b8; color: var(--ink); }
.btn-icon:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon--danger { color: var(--bad); }
.btn-icon--danger:hover:not(:disabled) { background: var(--bad-wash); border-color: #fca5a5; color: var(--bad); }
/* Lock toggle: pressed = the login is locked */
.btn-icon--lock[aria-pressed="true"] { background: var(--bad-wash); border-color: #fca5a5; color: var(--bad); }
.btn-icon--lock[aria-pressed="true"]:hover:not(:disabled) { background: #fee2e2; color: var(--bad); }
html[data-theme="dark"] .btn-icon--lock[aria-pressed="true"],
html[data-theme="dark"] .btn-icon--danger:hover:not(:disabled) { border-color: #7f1d1d; }

.spinner { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Fields ──────────────────────────────────────────────────────────────── */
.form-body { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; align-content: start; }

label { font: 600 13px/18px var(--font); color: var(--ink-2); }

input.no-razden, select.admin-select, textarea.no-razden {
  width: 100%; height: 40px; padding: 0 12px !important;
  border: 1px solid var(--control); border-radius: var(--radius);
  background: var(--paper) !important; color: var(--ink) !important;
  font: 400 14px/20px var(--font) !important;
  box-shadow: var(--shadow-control); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input.no-razden:hover:not(:disabled), select.admin-select:hover:not(:disabled) { border-color: var(--muted); }
input.no-razden:focus, select.admin-select:focus { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
input.no-razden::placeholder { color: var(--muted); opacity: 1; }
input.no-razden:disabled, select.admin-select:disabled { background: var(--wash) !important; color: var(--muted) !important; cursor: not-allowed; }
input.no-razden[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
input.no-razden[type="number"] { font-variant-numeric: tabular-nums; }

select.admin-select {
  appearance: none; padding-right: 34px !important; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important; background-position: right 10px center !important;
}

input[type="radio"], input[type="checkbox"] { accent-color: var(--blue); }

.hint { font-size: 13px; line-height: 18px; color: var(--muted); }
.sm { font-size: 13px; line-height: 18px; color: var(--muted); }
.field-error { display: block; font-size: 13px; line-height: 18px; color: var(--bad); }

/* Password with a show/hide button */
.input-with-icon { position: relative; display: flex; align-items: center; }
.input-with-icon input.no-razden { padding-right: 46px !important; }
.eye-btn {
  position: absolute; top: 0; right: 0; bottom: 0;
  display: inline-flex; align-items: center; padding: 0 14px;
  border: 0; border-radius: 0 var(--radius) var(--radius) 0; background: transparent; color: var(--muted); cursor: pointer;
}
.eye-btn .rzi { font-size: 20px !important; }
.eye-btn:hover { color: var(--ink); }
.eye-btn[aria-pressed="true"] { color: var(--blue); }

/* Password strength */
.strength-bar-wrap { display: flex; align-items: center; gap: 12px; }
.strength-bar { flex: 1; height: 4px; border-radius: 99px; background: var(--rule); overflow: hidden; position: relative; }
.strength-bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 100%; border-radius: inherit; transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease-out), background-color .3s; }
.strength-bar.strength-1::after { transform: scaleX(.25); background: var(--bad); }
.strength-bar.strength-2::after { transform: scaleX(.5);  background: #b45309; }
.strength-bar.strength-3::after { transform: scaleX(.75); background: var(--blue); }
.strength-bar.strength-4::after { transform: scaleX(1);   background: #15803d; }
.strength-label { min-width: 52px; font-size: 13px; line-height: 18px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .strength-bar::after { transition: none; } }

/* Toggle switch */
.toggle-switch { position: relative; flex: none; width: 44px; height: 24px; }
.toggle-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.toggle-track { position: absolute; inset: 0; border-radius: 99px; background: var(--rule-strong); transition: background-color .18s; }
.toggle-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .25); transition: transform .2s var(--ease-out);
}
.toggle-switch input:checked + .toggle-track { background: var(--blue); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(20px); }
.toggle-switch input:hover:not(:disabled) + .toggle-track { box-shadow: 0 0 0 4px var(--wash-2); }
.toggle-switch input:focus-visible + .toggle-track { outline: 2px solid var(--blue); outline-offset: 2px; }
.toggle-switch input:disabled + .toggle-track { opacity: .5; }
.toggle-switch input:disabled { cursor: not-allowed; }

/* Alerts */
.alert-error, .alert-success {
  padding: 12px 14px; border: 1px solid; border-radius: var(--radius); font-size: 14px; line-height: 20px;
}
.alert-error { border-color: #fca5a5; background: var(--bad-wash); color: #7f1d1d; }
.alert-success { border-color: #86efac; background: #f0fdf4; color: #14532d; }

html[data-theme="dark"] .alert-error { border-color: #7f1d1d; color: #fecaca; }
html[data-theme="dark"] .alert-success { border-color: #166534; background: #102f22; color: #bbf7d0; }

/* ── Misc states ─────────────────────────────────────────────────────────── */
.loading-state, .not-found {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  min-height: 60vh; padding: 32px; color: var(--muted); text-align: center;
}
.not-found h1 { font: 800 28px/1.2 var(--font); letter-spacing: -.025em; color: var(--ink); }
.not-found a { color: var(--blue); font-weight: 600; }

#blazor-error-ui {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 9999;
  padding: 12px 56px 12px 16px; background: var(--danger-solid); color: #fff; font-size: 14px;
}
#blazor-error-ui a { color: inherit; font-weight: 600; }
#blazor-error-ui .dismiss {
  position: absolute; right: 4px; top: 0; min-width: 44px; min-height: 44px;
  border: 0; background: none; color: inherit; font-size: 22px; line-height: 1; cursor: pointer;
}
.blazor-error-boundary { padding: 16px; border-radius: var(--radius); background: var(--danger-solid); color: #fff; }
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ── Lock screen: the navy brand panel over everything ──────────────────── */
.shield-overlay {
  position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; padding: 24px;
  background: var(--navy); color: var(--cream);
  outline: none; animation: shield-in .24s var(--ease-out);
}
@keyframes shield-in { from { opacity: 0; } to { opacity: 1; } }

.shield-card { display: flex; flex-direction: column; align-items: center; gap: 16px; width: min(320px, 100%); animation: card-rise .32s var(--ease-out); }
@keyframes card-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.shield-logo { display: block; height: 30px; width: auto; margin-bottom: 12px; }
.shield-avatar {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%;
  background: var(--navy-active); color: var(--sky); font: 700 22px/1 var(--font);
}
.shield-name { font: 700 18px/24px var(--font); color: var(--cream); }
.shield-sub { margin-top: -12px; font-size: 14px; line-height: 20px; color: var(--cream-muted); }

.pin-dots { display: flex; gap: 16px; margin: 8px 0 4px; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--cream-muted); transition: background-color .12s, border-color .12s, transform .12s var(--ease-out); }
.pin-dot.filled { background: var(--sky); border-color: var(--sky); transform: scale(1.1); }

.shield-error { min-height: 20px; font-size: 14px; line-height: 20px; color: #fca5a5; text-align: center; animation: shake .3s ease; }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.numpad { display: grid; grid-template-columns: repeat(3, 72px); gap: 12px; }
.numpad-key {
  display: grid; place-items: center; height: 60px; border: 1px solid var(--navy-rule); border-radius: 12px;
  background: rgba(242, 239, 232, .05); color: var(--cream); font: 600 22px/1 var(--font); font-variant-numeric: tabular-nums;
  cursor: pointer; user-select: none; transition: background-color .1s, border-color .1s, transform .08s;
}
.numpad-key:hover:not(:disabled) { background: rgba(242, 239, 232, .1); border-color: rgba(242, 239, 232, .24); }
.numpad-key:active:not(:disabled) { transform: scale(.95); background: var(--navy-active); }
.numpad-key:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
.numpad-key:disabled { opacity: .35; cursor: not-allowed; }
.numpad-action { border-color: transparent; background: transparent; color: var(--cream-muted); }
.numpad-action .rzi { font-size: 24px !important; }

.shield-actions { display: grid; gap: 12px; justify-items: center; width: 100%; margin-top: 4px; }
.shield-actions .btn-primary { width: 100%; }
.shield-link { border: 0; background: none; padding: 6px 4px; color: var(--sky); font: 600 14px/20px var(--font); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.shield-link:focus-visible { outline-color: var(--sky); }

.shield-foot { position: absolute; left: 0; right: 0; bottom: 24px; display: flex; align-items: center; justify-content: center; gap: 10px;
  font: 500 11px/16px var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--cream-muted); }
.shield-foot img { display: block; height: 28px; width: auto; }
@media (max-height: 700px) { .shield-foot { display: none; } }

.shield-lockout { display: grid; justify-items: center; gap: 8px; padding: 16px 0; text-align: center; }
.lockout-icon { color: #fca5a5; }
.lockout-icon .rzi { font-size: 40px !important; }
.shield-lockout p { font-size: 15px; color: var(--cream-soft); }
.lockout-timer { font-variant-numeric: tabular-nums; color: #fca5a5 !important; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .shield-overlay, .shield-card, .shield-error { animation: none; }
  .toggle-chevron, .toggle-track::after { transition: none; }
}
@media (prefers-reduced-motion: reduce) { .sidebar-panel, .menu-scrim { animation: none; } }

/* ── First visit: welcome box and tour (both sit under the lock screen at 9999) ── */
.welcome-backdrop {
  position: fixed; inset: 0; z-index: 9000; display: grid; place-items: center; padding: 24px;
  overflow-y: auto; background: rgba(15, 23, 42, .56); animation: shield-in .2s ease;
}
.welcome-card {
  width: min(460px, 100%); overflow: hidden; border-radius: 14px;
  background: var(--paper); color: var(--ink); box-shadow: 0 24px 64px rgba(15, 23, 42, .32);
  animation: card-rise .32s var(--ease-out);
}
.welcome-hero {
  display: grid; place-items: center; height: 112px;
  background: radial-gradient(120% 140% at 85% 0%, rgba(142, 195, 247, .22), transparent 60%), var(--navy);
}
.welcome-hero img { display: block; height: 48px; width: auto; }

.welcome-body { padding: 24px 28px 4px; }
.welcome-eyebrow { display: block; font: 600 12px/16px var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--blue);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.welcome-body h2 { margin-top: 6px; font: 800 26px/1.2 var(--font); letter-spacing: -.02em; color: var(--ink); }
.welcome-body h2 sup { font-size: .55em; }
.welcome-body > p { margin-top: 6px; font-size: 15px; line-height: 22px; color: var(--muted); }

.welcome-points { display: grid; gap: 14px; margin-top: 20px; list-style: none; }
.welcome-points li { display: flex; align-items: flex-start; gap: 12px; }
.welcome-points__icon { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: var(--blue-wash); color: var(--blue); }
.welcome-points__icon .rzi { font-size: 20px; }
.welcome-points b { display: block; font: 600 14px/20px var(--font); color: var(--ink); }
.welcome-points span:not(.welcome-points__icon) { display: block; font-size: 13.5px; line-height: 20px; color: var(--muted); }

.welcome-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; padding: 24px 28px; }
.welcome-hint { flex-basis: 100%; order: 3; margin-top: 4px; font-size: 12.5px; line-height: 18px; color: var(--muted); text-align: right; }
.welcome-actions .rzi { font-size: 18px; }

@media (max-width: 520px) {
  .welcome-backdrop { padding: 16px; }
  .welcome-body { padding: 20px 20px 4px; }
  .welcome-actions { padding: 20px; }
  .welcome-hint { text-align: center; }
  .welcome-actions button { flex: 1; }
}

/* "Welcome back" toast for returning users */
.welcome-toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 9000; display: flex; align-items: center; gap: 12px;
  width: min(360px, calc(100vw - 32px)); padding: 12px 8px 12px 12px;
  border: 1px solid var(--rule); border-radius: 12px; background: var(--paper); color: var(--ink);
  box-shadow: 0 16px 40px rgba(15, 23, 42, .18); animation: card-rise .32s var(--ease-out);
}
.welcome-toast__avatar { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--navy); color: var(--sky); font: 700 14px/1 var(--font); }
.welcome-toast__text { flex: 1; min-width: 0; display: grid; }
.welcome-toast__text span { font-size: 12.5px; line-height: 18px; color: var(--muted); }
.welcome-toast__text b { font: 600 14px/20px var(--font); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }   /* wrap the name, don't clip it */
.welcome-toast__close { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: none; color: var(--muted); cursor: pointer; }
.welcome-toast__close:hover { background: var(--wash); color: var(--ink); }
.welcome-toast__close:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.welcome-toast__close .rzi { font-size: 18px; }
@media (max-width: 860px) { .welcome-toast { right: 16px; bottom: calc(74px + env(safe-area-inset-bottom, 0px)); } }   /* clear of the tab bar */

/* driver.js, dressed as a portal card */
.driver-overlay { z-index: 9990 !important; }
.driver-popover.portal-tour {
  z-index: 9991; min-width: 260px; max-width: 320px; padding: 18px 20px 16px;
  border: 1px solid var(--rule); border-radius: 12px; background: var(--paper); color: var(--ink);
  box-shadow: 0 16px 48px rgba(15, 23, 42, .28); font-family: var(--font);
}
.portal-tour .driver-popover-title { font: 700 16px/22px var(--font); color: var(--ink); padding-right: 20px; }
.portal-tour .driver-popover-description { margin-top: 6px; font: 400 14px/21px var(--font); color: var(--ink-2); }
.portal-tour .driver-popover-description b { color: var(--ink); }
.portal-tour .driver-popover-footer { margin-top: 16px; align-items: center; }
.portal-tour .driver-popover-progress-text { font: 500 12.5px/16px var(--font); color: var(--muted); font-variant-numeric: tabular-nums; }
.portal-tour .driver-popover-close-btn { top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 50%; color: var(--muted); }
.portal-tour .driver-popover-close-btn:hover, .portal-tour .driver-popover-close-btn:focus-visible { background: var(--wash); color: var(--ink); }
.portal-tour .driver-popover-footer-btn {
  padding: 7px 14px; border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--paper); color: var(--ink-2); font: 600 13px/18px var(--font); text-shadow: none;
}
.portal-tour .driver-popover-footer-btn:hover { background: var(--wash); color: var(--ink); }
.portal-tour .driver-popover-next-btn { border-color: var(--blue); background: var(--blue); color: #fff; }
.portal-tour .driver-popover-next-btn:hover { border-color: var(--blue-hover); background: var(--blue-hover); color: #fff; }
.portal-tour .driver-popover-footer-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.portal-tour .driver-popover-navigation-btns button + button { margin-left: 8px; }
.portal-tour .driver-popover-arrow-side-left   { border-left-color: var(--paper); }
.portal-tour .driver-popover-arrow-side-right  { border-right-color: var(--paper); }
.portal-tour .driver-popover-arrow-side-top    { border-top-color: var(--paper); }
.portal-tour .driver-popover-arrow-side-bottom { border-bottom-color: var(--paper); }

@media (prefers-reduced-motion: reduce) {
  .welcome-backdrop, .welcome-card, .welcome-toast { animation: none; }
  .driver-fade .driver-overlay, .driver-fade .driver-popover { animation: none; }
}
