:root {
  --topbar-h: 43px;
  color-scheme: light dark;
  --bg: #f3f6fb;
  --bg-elevated: #f8fafc;
  --surface: #fdfdff;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #5b6472;
  --border: #dbe2ea;
  --border-strong: #c6d1dc;
  --shadow-soft: 0 18px 42px rgba(15, 23, 42, 0.08);
  --shadow-mid: 0 12px 28px rgba(15, 23, 42, 0.12);
  --shadow-float: 0 22px 54px rgba(15, 23, 42, 0.16);
  --shadow-edge: -18px 0 50px rgba(15, 23, 42, 0.18);
  --glass: linear-gradient(140deg, rgba(255, 255, 255, 0.9), rgba(247, 250, 255, 0.75));
  --glass-border: rgba(255, 255, 255, 0.55);
  --btn: #1d4ed8;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --accent-strong: rgba(37, 99, 235, 0.25);
  --accent-warm: #f97316;
  --accent-warm-soft: rgba(249, 115, 22, 0.18);
  --accent-sky: #06b6d4;
  --accent-sky-soft: rgba(6, 182, 212, 0.18);
  --accent-gold: #f4b740;
  --accent-gold-soft: rgba(244, 183, 64, 0.18);
  --action: #0f766e;
  --action-strong: #0c5f59;
  --action-glow: rgba(15, 118, 110, 0.38);
  --action-ghost: rgba(15, 118, 110, 0.14);
  --overlay: rgba(15, 23, 42, 0.06);
  --overlay-strong: rgba(15, 23, 42, 0.12);
  --accent-glow: rgba(37, 99, 235, 0.45);
  --accent-ghost: rgba(37, 99, 235, 0.06);
  --accent-ghost-strong: rgba(37, 99, 235, 0.14);
  --accent-fade: rgba(37, 99, 235, 0.5);
  --accent-sky-fade: rgba(6, 182, 212, 0.4);
  --accent-warm-fade: rgba(249, 115, 22, 0.45);
  --accent-gold-fade: rgba(244, 183, 64, 0.45);
  --highlight: rgba(255, 255, 255, 0.45);
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-2xl: 24px;
  --muted-strong: #3e4a5c;
  --panel-border: rgba(203, 213, 225, 0.75);
  --panel-bg: #f3f6fb;
  --line-soft: rgba(203, 213, 225, 0.5);
  --card-shadow: 0 4px 16px rgba(15, 23, 42, 0.07), 0 1px 4px rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-elevated: #111c2f;
  --surface: #121c31;
  --card: #18233a;
  --text: #e5e7eb;
  --muted: #9aa4b2;
  --border: #2a3750;
  --border-strong: #33425d;
  --shadow-soft: 0 18px 42px rgba(0, 0, 0, 0.35);
  --shadow-mid: 0 12px 28px rgba(0, 0, 0, 0.45);
  --shadow-float: 0 22px 54px rgba(0, 0, 0, 0.55);
  --shadow-edge: -18px 0 50px rgba(0, 0, 0, 0.6);
  --glass: linear-gradient(140deg, rgba(24, 35, 58, 0.84), rgba(18, 27, 45, 0.7));
  --glass-border: rgba(148, 163, 184, 0.18);
  --btn: #3b82f6;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.16);
  --accent-strong: rgba(96, 165, 250, 0.32);
  --accent-warm: #fb923c;
  --accent-warm-soft: rgba(251, 146, 60, 0.24);
  --accent-sky: #22d3ee;
  --accent-sky-soft: rgba(34, 211, 238, 0.22);
  --accent-gold: #f6c453;
  --accent-gold-soft: rgba(246, 196, 83, 0.26);
  --action: #22c1a8;
  --action-strong: #16a592;
  --action-glow: rgba(34, 193, 168, 0.4);
  --action-ghost: rgba(34, 193, 168, 0.18);
  --overlay: rgba(148, 163, 184, 0.08);
  --overlay-strong: rgba(148, 163, 184, 0.16);
  --accent-glow: rgba(96, 165, 250, 0.45);
  --accent-ghost: rgba(96, 165, 250, 0.08);
  --accent-ghost-strong: rgba(96, 165, 250, 0.18);
  --accent-fade: rgba(96, 165, 250, 0.5);
  --accent-sky-fade: rgba(34, 211, 238, 0.4);
  --accent-warm-fade: rgba(251, 146, 60, 0.45);
  --accent-gold-fade: rgba(246, 196, 83, 0.45);
  --highlight: rgba(255, 255, 255, 0.16);
  --muted-strong: #7c8ca0;
  --panel-border: rgba(42, 55, 80, 0.85);
  --panel-bg: #0f172a;
  --line-soft: rgba(42, 55, 80, 0.6);
  --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.28), 0 1px 4px rgba(0, 0, 0, 0.2);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Sora", "Segoe UI", "Segoe UI Web", "Segoe UI Variable", Arial, sans-serif;
}

.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: "Fraunces", "Sora", "Segoe UI", "Segoe UI Web", Arial, sans-serif;
  letter-spacing: -0.01em;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: auto 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;
}

.app-drawer {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100dvh;
  z-index: 100;
}

.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;
  gap: 18px;
  position: relative;
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}

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

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

.drawer-brand-logo-full {
  height: 24px;
  max-width: 160px;
}

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

.drawer-toggle {
  border: 0;
  background: var(--accent-ghost-strong);
  color: var(--text);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.drawer-toggle-pill {
  position: absolute;
  top: 32px;
  right: -31px;
  padding: 4px;
  width: auto;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  z-index: 2;
}

.drawer-toggle-pill .drawer-text {
  display: none;
}

.drawer-toggle-pill:hover {
  background: var(--accent-ghost);
  color: var(--text);
}

.drawer-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.drawer-nav .nav-link {
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  position: relative;
  align-items: center;
  gap: 10px;
  transition: background 160ms ease, transform 160ms ease;
}

.drawer-nav .nav-link i {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

.drawer-nav .nav-link.active {
  background: var(--accent-ghost-strong);
  color: var(--accent);
}

.drawer-nav .nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.drawer-nav .nav-link:hover {
  background: var(--accent-ghost);
  transform: translateY(-1px);
}

.drawer-text {
  white-space: nowrap;
}

.drawer-inbox-badge {
  margin-left: auto;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.38rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  color: #1f4064;
  background: rgba(203, 226, 248, 0.92);
  border: 1px solid rgba(131, 168, 202, 0.92);
}

.drawer-nav .nav-link.active .drawer-inbox-badge {
  background: rgba(217, 236, 255, 0.98);
  border-color: rgba(108, 150, 194, 0.92);
  color: #1b3859;
}

.drawer-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-settings-link {
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  width: 100%;
  position: relative;
}

.drawer-settings-link i {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

.drawer-settings-link:hover {
  background: var(--accent-ghost);
  transform: translateY(-1px);
}

.drawer-settings-link.active {
  background: var(--accent-ghost-strong);
  color: var(--accent);
}

.drawer-settings-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

/* Nav section divider */
.nav-section-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
}

.nav-section-divider::after {
  content: "";
  display: block;
  flex: 1;
  height: 1px;
  background: var(--border);
}

.drawer-collapsed .nav-section-divider {
  padding: 8px 8px 2px;
  justify-content: center;
}

.drawer-collapsed .nav-section-divider::after {
  flex: unset;
  width: 32px;
}

.profile-button {
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  width: 100%;
  text-align: left;
  color: var(--text);
}

.profile-menu-wrap {
  position: relative;
  width: 100%;
}

.profile-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-ghost-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  overflow: hidden;
}

.profile-icon i {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

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

.profile-menu {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 200px;
  box-shadow: var(--shadow-mid);
  backdrop-filter: blur(8px);
  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);
}

.drawer-collapsed {
  width: 76px;
  transition: width 160ms ease;
}

.drawer-expanded {
  width: 260px;
  transition: width 200ms ease;
}

.drawer-collapsed .drawer-text,
.drawer-collapsed .drawer-brand-text,
.drawer-collapsed .profile-name {
  display: none;
}

.drawer-collapsed .drawer-brand {
  justify-content: center;
}

.drawer-collapsed .drawer-brand-logo {
  height: 32px;
  width: 32px;
}

.drawer-expanded .drawer-brand {
  justify-content: center;
}

.drawer-collapsed .drawer-toggle,
.drawer-collapsed .drawer-nav .nav-link,
.drawer-collapsed .profile-button,
.drawer-collapsed .drawer-settings-link {
  justify-content: center;
}

.drawer-collapsed .drawer-toggle {
  padding: 4px;
}

.drawer-collapsed .drawer-nav .nav-link {
  padding: 12px 8px;
}

.drawer-collapsed .drawer-inbox-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  margin-left: 0;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.2rem;
  font-size: 0.65rem;
}

.drawer-collapsed .profile-button {
  padding: 6px 8px;
}

.drawer-collapsed .drawer-settings-link {
  padding: 12px 8px;
}

.drawer-collapsed .profile-menu {
  left: calc(100% + 8px);
  top: auto;
  bottom: 0;
}

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

.app-topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 32px;
  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: auto 1fr;
  }
}

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

  .app-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(290px, 82vw);
    max-width: 290px;
    border-right: 1px solid var(--border);
    border-bottom: none;
    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;
  }

  .app-drawer.drawer-collapsed,
  .app-drawer.drawer-expanded {
    width: min(290px, 82vw);
  }

  .app-drawer .drawer-toggle-pill {
    display: none;
  }

  .app-drawer.drawer-collapsed .drawer-text,
  .app-drawer.drawer-collapsed .drawer-brand-text,
  .app-drawer.drawer-collapsed .profile-name {
    display: inline;
  }

  .app-drawer.drawer-collapsed .drawer-brand {
    justify-content: flex-start;
  }

  .app-drawer.drawer-collapsed .drawer-brand-logo {
    height: 24px;
    width: auto;
  }

  .app-drawer.drawer-collapsed .drawer-nav .nav-link,
  .app-drawer.drawer-collapsed .profile-button,
  .app-drawer.drawer-collapsed .drawer-settings-link {
    justify-content: flex-start;
  }

  .app-drawer .drawer-footer {
    position: static;
  }

  .app-drawer.drawer-collapsed .drawer-footer,
  .app-drawer.drawer-expanded .drawer-footer {
    left: auto;
  }

  .app-drawer.drawer-collapsed .profile-menu {
    top: calc(100% + 6px);
    bottom: auto;
    left: 0;
    width: min(220px, calc(100vw - 52px));
  }

  .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,
  .app-drawer.drawer-collapsed,
  .app-drawer.drawer-expanded {
    width: min(250px, 78vw);
    max-width: 250px;
    padding: 14px 10px;
  }

  .app-drawer .drawer-nav .nav-link,
  .app-drawer .drawer-settings-link,
  .app-drawer .profile-button {
    padding: 8px 9px;
    font-size: 13px;
    gap: 8px;
  }

  .app-drawer .profile-icon {
    width: 30px;
    height: 30px;
  }

  .app-drawer .profile-icon i {
    font-size: 15px;
  }

  .app-drawer .profile-name {
    font-size: 13px;
  }

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

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

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

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

.drawer-toggle,
.drawer-nav .nav-link,
.profile-button,
.profile-menu {
  border-radius: var(--radius-sm);
}

.profile-icon {
  border-radius: var(--radius-lg);
}

/* ── 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: rgba(66, 133, 244, 0.04);
}

.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: rgba(66, 133, 244, 0.12);
  color: var(--accent-strong);
}

.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: #4285f4;
  margin-top: 5px;
}

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