:root {
  --topbar-h: 52px;
  color-scheme: light dark;

  /* ── Backgrounds ─────────────────────────────────────────────────────────── */
  --bg: #FBFBFD;           /* neutral-25 — warm off-white app canvas */
  --bg-elevated: #F6F7FA;  /* neutral-50 — subtle raised fill */
  --surface: #FFFFFF;      /* neutral-0 — cards, panels */
  --card: #FFFFFF;

  /* ── Text ────────────────────────────────────────────────────────────────── */
  --text: #22263C;         /* neutral-800 — headings / primary */
  --muted: #6B7088;        /* neutral-500 — secondary text */
  --muted-strong: #4B5068; /* neutral-600 — emphasis secondary */

  /* ── Borders ─────────────────────────────────────────────────────────────── */
  --border: #E2E4EC;       /* neutral-200 */
  --border-strong: #CBCED9;/* neutral-300 */

  /* ── Shadows (navy-tinted) ───────────────────────────────────────────────── */
  --shadow-soft: 0 18px 42px rgba(37, 43, 72, 0.08);
  --shadow-mid: 0 12px 28px rgba(37, 43, 72, 0.12);
  --shadow-float: 0 22px 54px rgba(37, 43, 72, 0.16);
  --shadow-edge: -18px 0 50px rgba(37, 43, 72, 0.18);
  --card-shadow: 0 4px 16px rgba(37, 43, 72, 0.07), 0 1px 4px rgba(37, 43, 72, 0.04);

  /* ── Glass ───────────────────────────────────────────────────────────────── */
  --glass: linear-gradient(140deg, rgba(255, 255, 255, 0.9), rgba(249, 249, 253, 0.75));
  --glass-border: rgba(255, 255, 255, 0.55);

  /* ── Primary accent — Sarrai navy #3F497F ────────────────────────────────── */
  --btn: #384171;                          /* brand-navy-600 — button bg */
  --accent: #3F497F;                       /* brand-navy */
  --accent-soft: rgba(63, 73, 127, 0.12);
  --accent-strong: rgba(63, 73, 127, 0.25);
  --accent-glow: rgba(63, 73, 127, 0.40);
  --accent-ghost: rgba(63, 73, 127, 0.06);
  --accent-ghost-strong: rgba(63, 73, 127, 0.14);
  --accent-fade: rgba(63, 73, 127, 0.5);

  /* ── Orange accent — Sarrai #EB780E ─────────────────────────────────────── */
  --accent-warm: #EB780E;                  /* brand-orange */
  --accent-warm-soft: rgba(235, 120, 14, 0.14);
  --accent-warm-fade: rgba(235, 120, 14, 0.45);

  /* ── Sky / gold (unchanged — supporting palette) ────────────────────────── */
  --accent-sky: #06b6d4;
  --accent-sky-soft: rgba(6, 182, 212, 0.18);
  --accent-sky-fade: rgba(6, 182, 212, 0.4);
  --accent-gold: #f4b740;
  --accent-gold-soft: rgba(244, 183, 64, 0.18);
  --accent-gold-fade: rgba(244, 183, 64, 0.45);

  /* ── Action / success (teal — save, confirm) ─────────────────────────────── */
  --action: #1F9D6A;
  --action-strong: #0F6B47;
  --action-glow: rgba(31, 157, 106, 0.35);
  --action-ghost: rgba(31, 157, 106, 0.12);

  /* ── Overlay ─────────────────────────────────────────────────────────────── */
  --overlay: rgba(34, 38, 60, 0.06);
  --overlay-strong: rgba(34, 38, 60, 0.12);

  /* ── Misc ────────────────────────────────────────────────────────────────── */
  --highlight: rgba(255, 255, 255, 0.45);
  --panel-border: rgba(203, 206, 217, 0.75);
  --panel-bg: #FBFBFD;
  --line-soft: rgba(203, 206, 217, 0.5);

  /* ── Radii ───────────────────────────────────────────────────────────────── */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 28px;

  /* ── Design system tokens (for Phase 2+) ─────────────────────────────────── */
  --brand-navy: #3F497F;
  --brand-navy-600: #384171;
  --brand-navy-700: #2F375E;
  --brand-navy-800: #252B48;
  --brand-navy-300: #8A93BA;
  --brand-navy-100: #E7E9F1;
  --brand-navy-50:  #F3F4F9;
  --brand-orange: #EB780E;
  --brand-orange-600: #D26A07;
  --brand-orange-300: #F5B06B;
  --brand-orange-100: #FDEEDB;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --danger: #D64545;
  --danger-bg:  rgba(214, 69, 69, 0.10);
  --danger-border: rgba(214, 69, 69, 0.32);

  /* ── Semantic foreground aliases (mirror tokens.css) ─────────────────────── */
  --fg-1: #22263C;   /* neutral-800 — headings */
  --fg-2: #343852;   /* neutral-700 — body */
  --fg-3: #6B7088;   /* neutral-500 — secondary */
  --fg-4: #9A9FB0;   /* neutral-400 — placeholder */

  /* ── Neutrals (warm gray, navy-tinted) ───────────────────────────────────── */
  --neutral-0:   #FFFFFF;
  --neutral-25:  #FBFBFD;
  --neutral-50:  #F6F7FA;
  --neutral-100: #EEEFF4;
  --neutral-200: #E2E4EC;
  --neutral-300: #CBCED9;
  --neutral-400: #9A9FB0;

  /* ── Brand sub-tints (extending navy/orange ramps) ───────────────────────── */
  --brand-navy-200:   #C7CBDD;
  --brand-orange-50:  #FFF7EF;
  --brand-orange-200: #FBDDBD;
  --brand-orange-700: #B25904;

  /* ── Border aliases ──────────────────────────────────────────────────────── */
  --border-subtle:  var(--neutral-200);
  --border-default: var(--neutral-300);

  /* ── Status (semantic bg/fg pairs) ───────────────────────────────────────── */
  --success:    #1F9D6A;
  --success-bg: #E4F5ED;
  --success-fg: #0F6B47;
  --warning:    #D98A0A;
  --warning-bg: #FDF1DA;
  --warning-fg: #8A5400;
  --danger-fg:  #902626;
  --info:       #3F72B8;
  --info-bg:    #E4EDF8;
  --info-fg:    #1F4578;

  /* ── Radii (design naming, additive to --radius-*) ───────────────────────── */
  --r-xs:  4px;
  --r-sm:  6px;
  --r-md:  8px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* ── Shadows / motion (additive) ─────────────────────────────────────────── */
  --shadow-xs:    0 1px 2px rgba(37, 43, 72, 0.06);
  --shadow-focus: 0 0 0 4px rgba(63, 73, 127, 0.22);
  --ease-out:     cubic-bezier(0.2, 0.8, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #12142A;
  --bg-elevated: #181B35;
  --surface: #1E2140;
  --card: #232748;
  --text: #E7E9F1;
  --muted: #8A93BA;
  --muted-strong: #B0B6D0;
  --border: #2E3260;
  --border-strong: #3D4270;
  --shadow-soft: 0 18px 42px rgba(0, 0, 0, 0.40);
  --shadow-mid: 0 12px 28px rgba(0, 0, 0, 0.50);
  --shadow-float: 0 22px 54px rgba(0, 0, 0, 0.60);
  --shadow-edge: -18px 0 50px rgba(0, 0, 0, 0.65);
  --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.32), 0 1px 4px rgba(0, 0, 0, 0.22);
  --glass: linear-gradient(140deg, rgba(30, 33, 64, 0.88), rgba(18, 20, 42, 0.75));
  --glass-border: rgba(138, 147, 186, 0.18);
  --btn: #5C66A0;
  --accent: #8A93BA;           /* navy-300 — legible on dark bg */
  --accent-soft: rgba(138, 147, 186, 0.16);
  --accent-strong: rgba(138, 147, 186, 0.32);
  --accent-glow: rgba(138, 147, 186, 0.40);
  --accent-ghost: rgba(138, 147, 186, 0.08);
  --accent-ghost-strong: rgba(138, 147, 186, 0.18);
  --accent-fade: rgba(138, 147, 186, 0.5);
  --accent-warm: #F5B06B;      /* orange-300 — softer on dark */
  --accent-warm-soft: rgba(245, 176, 107, 0.20);
  --accent-warm-fade: rgba(245, 176, 107, 0.45);
  --accent-sky: #22d3ee;
  --accent-sky-soft: rgba(34, 211, 238, 0.22);
  --accent-sky-fade: rgba(34, 211, 238, 0.4);
  --accent-gold: #f6c453;
  --accent-gold-soft: rgba(246, 196, 83, 0.26);
  --accent-gold-fade: rgba(246, 196, 83, 0.45);
  --action: #34C78A;
  --action-strong: #1F9D6A;
  --action-glow: rgba(52, 199, 138, 0.38);
  --action-ghost: rgba(52, 199, 138, 0.16);
  --overlay: rgba(138, 147, 186, 0.08);
  --overlay-strong: rgba(138, 147, 186, 0.16);
  --highlight: rgba(255, 255, 255, 0.12);
  --panel-border: rgba(46, 50, 96, 0.85);
  --panel-bg: #12142A;
  --line-soft: rgba(46, 50, 96, 0.6);
  --danger: #e88080;
}

html {
  font-feature-settings: "cv11", "ss01", "ss03"; /* Inter humanist alternates */
  text-rendering: optimizeLegibility;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-with-icon i {
  font-size: 1rem;
  line-height: 0;
}

.ha-breadcrumb {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
}

.ha-breadcrumb-link {
  color: var(--muted);
  text-decoration: none;
  transition: color 140ms ease;
}

.ha-breadcrumb-link:hover,
.ha-breadcrumb-link:focus-visible {
  color: var(--text);
}

.ha-breadcrumb-button {
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  line-height: inherit;
}

.ha-breadcrumb-separator {
  color: var(--border-strong);
  display: inline-flex;
  align-items: center;
}

.ha-breadcrumb-separator i {
  font-size: 10px;
  line-height: 1;
}

.ha-breadcrumb-current {
  color: var(--text);
  font-weight: 500;
}

h1,
h2,
h3 {
  font-family: var(--font-sans);
  letter-spacing: -0.02em;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 0;
}

.app-shell::before {
  content: "";
  position: fixed;
  inset: -30% 0 auto 0;
  height: 60vh;
  background: none;
  z-index: -1;
  pointer-events: none;
}

[data-theme="dark"] body {
  background: var(--bg);
}

[data-theme="dark"] .app-shell::before {
  background: none;
}

/* ── Navy icon rail ──────────────────────────────────────────────────────── */
.app-drawer {
  background: var(--brand-navy);
  width: 64px;
  border-right: none;
  border-radius: 0;
  padding: 14px 0 10px;
  position: sticky;
  top: 0;
  height: 100dvh;
  z-index: 100;
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.18);
}

.app-drawer-right {
  background: var(--surface);
  border-left: 1px solid var(--border);
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  height: calc(100dvh - var(--topbar-h));
  width: 75vw;
  transform: translateX(100%);
  opacity: 0;
  transition: transform 240ms ease, opacity 200ms ease;
  z-index: 30;
  box-shadow: var(--shadow-edge);
  overflow-y: auto;
}

@media (max-width: 1024px) {
  .app-drawer-right {
    width: 92vw;
  }
}

@media (max-width: 640px) {
  .app-drawer-right {
    width: 100vw;
    border-left: none;
    border-radius: 0;
  }
}

.app-shell.drawer-right-open .app-drawer-right {
  transform: translateX(0);
  opacity: 1;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay-strong);
  backdrop-filter: blur(6px);
  z-index: 20;
}

.drawer-nav-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay-strong);
  backdrop-filter: blur(4px);
  z-index: 40;
}

@media (min-width: 769px) {
  .drawer-nav-backdrop {
    display: none;
  }
}

.drawer {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
}

.drawer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 10px;
  margin-bottom: 10px;
  text-decoration: none;
  transition: background 120ms ease;
  flex-shrink: 0;
}

.drawer-brand:hover {
  background: #fff;
  color: inherit;
  text-decoration: none;
}

.drawer-brand-logo {
  display: block;
  height: 26px;
  width: 26px;
  object-fit: contain;
}

.drawer-nav {
  flex: 1;
  min-height: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
}

.drawer-nav .nav-link {
  color: rgba(255, 255, 255, 0.62);
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 10px;
  display: flex;
  position: relative;
  align-items: center;
  justify-content: center;
  overflow: visible;
  transition: background 160ms ease, color 160ms ease;
}

.drawer-nav .nav-link i {
  font-size: 20px;
  line-height: 1;
}

.drawer-nav .nav-link.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.drawer-nav .nav-link.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  background: var(--brand-orange);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px rgba(235, 120, 14, 0.55);
}

.drawer-nav .nav-link:hover {
  background: rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.95);
}

.drawer-text {
  display: none;
}

.drawer-inbox-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.18rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  background: var(--brand-orange);
  border: 2px solid var(--brand-navy);
}

.drawer-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.drawer-settings-link {
  color: rgba(255, 255, 255, 0.62);
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  position: relative;
  overflow: visible;
  transition: background 160ms ease, color 160ms ease;
}

.drawer-settings-link i {
  font-size: 20px;
  line-height: 1;
}

.drawer-settings-link:hover {
  background: rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.95);
}

.drawer-settings-link.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.drawer-settings-link.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  background: var(--brand-orange);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px rgba(235, 120, 14, 0.55);
}

.nav-section-divider {
  display: none;
}

.profile-button {
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 10px;
  width: 44px;
  height: 44px;
  color: rgba(255, 255, 255, 0.62);
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.profile-button:hover {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
}

.profile-menu-wrap {
  position: relative;
}

.profile-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}

.profile-icon i {
  font-size: 16px;
  line-height: 1;
}

.profile-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.profile-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: absolute;
  bottom: 0;
  left: calc(100% + 12px);
  width: 210px;
  box-shadow: var(--shadow-mid);
  z-index: 50;
}

.profile-menu a,
.profile-menu button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  display: block;
  width: 100%;
}

.profile-menu a:hover,
.profile-menu button:hover {
  background: var(--accent-ghost-strong);
}

.profile-menu-header {
  padding: 8px 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.profile-menu-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-menu-email {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.profile-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  width: 100%;
  font-size: inherit;
  cursor: pointer;
  font-family: inherit;
}

.profile-menu-item:hover {
  background: var(--accent-ghost-strong);
  color: var(--text);
  text-decoration: none;
}

.profile-menu-item i {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.7;
}

.profile-menu-danger {
  color: var(--accent-warm);
}

.profile-menu-danger:hover {
  background: var(--accent-warm-soft);
  color: var(--accent-warm);
}

.app-main {
  padding: 0 32px 28px;
  min-width: 0;
}

.app-topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: var(--topbar-h);
  margin: 0 -32px 20px;
  position: sticky;
  top: 0;
  z-index: 95;
}

.app-nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
}

.app-topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.app-topbar-utilities {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--glass);
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
}

.app-topbar-utility-link {
  width: 26px;
  height: 26px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.app-topbar-utility-link:hover {
  background: rgba(232, 241, 252, 0.95);
  transform: translateY(-1px);
  color: var(--text);
}

.app-topbar-utility-link:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.app-topbar-utility-divider {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  opacity: 0.9;
}

.app-topbar-spacer {
  flex: 1;
}

.app-topbar-breadcrumb {
  margin: 0;
  font-size: 13px;
  letter-spacing: -0.01em;
  padding-left: 2px;
}

.app-topbar-breadcrumb .ha-breadcrumb-current {
  font-weight: 600;
}

.app-lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.app-lang-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.app-lang-link.active {
  color: var(--text);
  font-weight: 700;
}

.app-lang-link:hover {
  color: var(--text);
}

.app-lang-divider {
  color: var(--border-strong);
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--text);
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-mid);
  border-color: var(--border-strong);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.theme-toggle-icon {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--accent-ghost-strong);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 14px;
}

.theme-toggle-text {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-float);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: min(460px, 90vw);
  z-index: 60;
  animation: toastIn 180ms ease;
}

.app-toast--info {
  border-color: var(--accent-strong);
  box-shadow: 0 16px 38px rgba(37, 99, 235, 0.18);
}

.app-toast--warning {
  border-color: var(--accent-gold);
  box-shadow: 0 16px 38px rgba(244, 183, 64, 0.2);
}

.app-toast--critical {
  border-color: var(--accent-warm);
  box-shadow: 0 18px 44px rgba(249, 115, 22, 0.22);
}

.app-toast--success {
  border-color: var(--action);
  box-shadow: 0 18px 44px rgba(34, 193, 168, 0.22);
}

.app-toast-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text);
  font-size: 14px;
}

.app-toast-body span {
  color: var(--muted);
  font-size: 13px;
}

.toast-undo {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
}

.toast-undo:hover {
  background: var(--accent-ghost);
  border-color: var(--border-strong);
}

.app-toast--critical .toast-undo {
  border-color: rgba(249, 115, 22, 0.4);
  background: rgba(249, 115, 22, 0.08);
}

[data-theme="dark"] .app-toast--critical .toast-undo {
  border-color: rgba(251, 146, 60, 0.5);
  background: rgba(251, 146, 60, 0.12);
}

.app-toast--success .toast-undo {
  border-color: rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.09);
}

[data-theme="dark"] .app-toast--success .toast-undo {
  border-color: rgba(34, 193, 168, 0.5);
  background: rgba(34, 193, 168, 0.14);
}

.modal-content {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-float);
}

.modal-header,
.modal-footer {
  border-color: var(--border);
}

.modal-title,
.modal-body {
  color: var(--text);
}

[data-theme="dark"] .modal .btn-light {
  background: #25344d;
  color: #e5e7eb;
  border-color: #3a4c6c;
}

[data-theme="dark"] .modal .btn-light:hover,
[data-theme="dark"] .modal .btn-light:focus {
  background: #2d3f5d;
  color: #f8fafc;
  border-color: #4a6187;
}

[data-theme="dark"] .modal .btn-close {
  filter: invert(1) grayscale(100%) brightness(180%);
  opacity: 0.9;
}

@keyframes toastIn {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 600px) {
  .app-toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    flex-direction: column;
    align-items: flex-start;
  }
}

.theme-toggle .icon-moon {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: inline-flex;
}

.content {
  padding-top: 0;
  font-size: 15px;
}

.app-shell .content h1 {
  font-size: clamp(30px, 2.3vw, 38px);
}

.app-shell .content h2 {
  font-size: clamp(24px, 1.9vw, 31px);
}

.app-shell .content h3 {
  font-size: clamp(19px, 1.5vw, 24px);
}

.app-shell .content .btn,
.app-shell .content button,
.app-shell .content .form-control,
.app-shell .content .form-select,
.app-shell .content .form-label,
.app-shell .content input,
.app-shell .content textarea,
.app-shell .content select {
  font-size: 14px;
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 64px 1fr;
  }
}

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  /* On mobile the drawer slides in as a full panel with labels */
  .app-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(260px, 82vw);
    padding: 18px 14px;
    border-right: 1px solid rgba(255, 255, 255, 0.10);
    transform: translate3d(calc(-100% - 14px), 0, 0);
    opacity: 0;
    transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease;
    z-index: 100;
    overflow-y: auto;
    will-change: transform, opacity;
  }

  .app-shell.mobile-nav-open .app-drawer {
    transform: translate3d(0, 0, 0);
    opacity: 1;
  }

  .app-shell.mobile-nav-closed .app-drawer {
    pointer-events: none;
  }

  .app-shell.mobile-nav-open .app-drawer {
    pointer-events: auto;
  }

  /* On mobile: wider panel — show labels */
  .app-drawer .drawer {
    align-items: flex-start;
  }

  .app-drawer .drawer-brand {
    width: auto;
    height: 36px;
    background: transparent;
    border-radius: 0;
    padding: 0;
    gap: 10px;
    margin-bottom: 16px;
    justify-content: flex-start;
  }

  .app-drawer .drawer-brand:hover {
    background: transparent;
  }

  .app-drawer .drawer-brand-logo {
    height: 28px;
    width: 28px;
  }

  .app-drawer .drawer-nav {
    align-items: flex-start;
    width: 100%;
  }

  .app-drawer .drawer-nav .nav-link {
    width: 100%;
    height: auto;
    padding: 10px 12px;
    justify-content: flex-start;
    gap: 10px;
    border-radius: 10px;
  }

  .app-drawer .drawer-nav .nav-link.active::before {
    left: 0;
    top: 18%;
    bottom: 18%;
  }

  .app-drawer .drawer-text {
    display: inline;
  }

  .app-drawer .drawer-footer {
    align-items: flex-start;
    width: 100%;
  }

  .app-drawer .drawer-settings-link {
    width: 100%;
    height: auto;
    padding: 10px 12px;
    justify-content: flex-start;
    gap: 10px;
  }

  .app-drawer .drawer-settings-link.active::before {
    left: 0;
    top: 18%;
    bottom: 18%;
  }

  .app-drawer .profile-button {
    width: 100%;
    height: auto;
    padding: 8px 10px;
    justify-content: flex-start;
    gap: 10px;
  }

  .app-drawer .profile-menu {
    position: static;
    width: 100%;
    margin-top: 4px;
  }

  .app-drawer .drawer-inbox-badge {
    position: static;
    margin-left: auto;
  }

  .app-main {
    padding: 14px 14px 18px;
  }

  .app-topbar {
    justify-content: space-between;
    margin-bottom: 10px;
  }

  .app-nav-toggle {
    display: inline-flex;
  }

  .content {
    font-size: 14px;
  }

  .content h1 {
    font-size: clamp(22px, 7vw, 26px);
  }

  .content h2 {
    font-size: clamp(20px, 6vw, 24px);
  }

  .content h3 {
    font-size: clamp(17px, 5.5vw, 20px);
  }

  .content .btn,
  .content button,
  .content .form-control,
  .content .form-select,
  .content .form-label,
  .content input,
  .content textarea,
  .content select {
    font-size: 14px;
  }

  .content .btn {
    padding: 8px 12px;
  }

  .drawer-footer {
    position: static;
  }

  .app-drawer-right {
    width: 100vw;
  }
}

@media (max-width: 420px) {
  .app-drawer {
    width: min(240px, 78vw);
    padding: 14px 10px;
  }

  .app-nav-toggle {
    padding: 5px 10px;
    font-size: 12px;
  }
}

@media (max-width: 1200px) {
  .app-drawer-right {
    width: 92vw;
  }
}

.app-drawer-right {
  border-radius: var(--radius-xs) 0 0 var(--radius-xs);
}

/* ── Notification Bell ─────────────────────────────────────────────── */

.notif-bell {
  position: relative;
}

.notif-bell-btn {
  position: relative;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.notif-badge {
  position: absolute;
  top: -3px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e53e3e;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--surface);
  animation: notif-pop 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes notif-pop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.notif-backdrop {
  position: fixed;
  inset: 0;
  z-index: 199;
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 340px;
  max-height: 420px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  z-index: 200;
  overflow: hidden;
  animation: notif-slide-in 160ms ease;
}

@keyframes notif-slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0);    }
}

.notif-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.notif-dropdown-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.notif-mark-all-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 500;
}

.notif-mark-all-btn:hover {
  text-decoration: underline;
}

.notif-dropdown-body {
  overflow-y: auto;
  flex: 1;
}

.notif-empty {
  padding: 28px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 120ms ease;
  position: relative;
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item:hover {
  background: var(--hover);
}

.notif-item-unread {
  background: var(--accent-ghost);
}

.notif-item-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text);
  margin-top: 1px;
}

.notif-item-unread .notif-item-icon {
  background: var(--accent-soft);
  color: var(--accent);
}

.notif-item-content {
  flex: 1;
  min-width: 0;
}

.notif-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-item-message {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notif-item-time {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.notif-item-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-navy);
  margin-top: 5px;
}

@media (max-width: 480px) {
  .notif-dropdown {
    width: calc(100vw - 24px);
    right: -8px;
  }
}

/* Blazor reconnect-modal — eigen UI met delay zodat korte SignalR-hiccups
   (zoals de initial connect bij prerender=false) niet zichtbaar zijn. */
#components-reconnect-modal {
  display: none;
}

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(37, 43, 72, 0.45);
  backdrop-filter: blur(2px);
  z-index: 10000;
}

#components-reconnect-modal.components-reconnect-show {
  animation: ha-reconnect-reveal 2.2s forwards;
}

@keyframes ha-reconnect-reveal {
  0%,
  90% { opacity: 0; }
  100% { opacity: 1; }
}

.ha-reconnect-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  color: var(--brand-navy-800);
  padding: 14px 22px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  font-size: 14px;
  font-weight: 500;
}

.ha-reconnect-spinner {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 2px solid var(--brand-navy-100);
  border-top-color: var(--brand-orange);
  border-radius: 50%;
  animation: ha-reconnect-spin 0.8s linear infinite;
}

@keyframes ha-reconnect-spin {
  to { transform: rotate(360deg); }
}

.ha-reconnect-text-show { display: inline; }
.ha-reconnect-text-failed { display: none; }

.ha-reconnect-reload {
  display: none;
  border: 1px solid var(--brand-navy-200);
  background: var(--brand-navy-50);
  color: var(--brand-navy-800);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}

#components-reconnect-modal.components-reconnect-failed .ha-reconnect-spinner,
#components-reconnect-modal.components-reconnect-rejected .ha-reconnect-spinner,
#components-reconnect-modal.components-reconnect-failed .ha-reconnect-text-show,
#components-reconnect-modal.components-reconnect-rejected .ha-reconnect-text-show {
  display: none;
}

#components-reconnect-modal.components-reconnect-failed .ha-reconnect-text-failed,
#components-reconnect-modal.components-reconnect-rejected .ha-reconnect-text-failed {
  display: inline;
}

#components-reconnect-modal.components-reconnect-failed .ha-reconnect-reload,
#components-reconnect-modal.components-reconnect-rejected .ha-reconnect-reload {
  display: inline-flex;
}

/* ==========================================================================
   Overlay-mode for the right drawer — used by the article editor (.aed).
   Hijst de bestaande .app-drawer-right slot tot bijna full-bleed, met een
   28 px sliver van de tree links zichtbaar (zachte navy-tint backdrop).
   ========================================================================== */
.app-shell.drawer-right-overlay .app-drawer-right {
  top: 0;
  height: 100dvh;
  width: calc(100vw - 28px);
  max-width: 1640px;
  background: #FBFBFD;
  border-left: none;
  border-top-left-radius: 14px;
  border-bottom-left-radius: 14px;
  box-shadow: -28px 0 60px -18px rgba(20, 23, 39, 0.30);
  overflow: hidden;
  z-index: 200;
}
.app-shell.drawer-right-overlay .drawer-backdrop {
  background: rgba(20, 23, 39, 0.42);
  backdrop-filter: none;
  z-index: 199;
}

@media (max-width: 1024px) {
  .app-shell.drawer-right-overlay .app-drawer-right {
    width: calc(100vw - 16px);
  }
}

@media (max-width: 640px) {
  .app-shell.drawer-right-overlay .app-drawer-right {
    width: 100vw;
    border-radius: 0;
    box-shadow: none;
  }
}
