/*
 * SIM7600 Operations Console — unified 2026 application shell.
 * This file is intentionally loaded after the legacy component stylesheet.
 * It owns visual tokens, the responsive shell and shared production UI patterns.
 */

:root {
  color-scheme: light;
  --app-sidebar-width: 272px;
  --app-sidebar-collapsed: 82px;
  --app-header-height: 72px;
  --app-content-max: 1540px;

  --app-bg: #f4f7fb;
  --app-bg-subtle: #eef3f9;
  --app-sidebar: #0f172a;
  --app-sidebar-elevated: #172033;
  --app-sidebar-border: rgba(255, 255, 255, 0.08);
  --app-header: rgba(255, 255, 255, 0.96);
  --app-surface: #ffffff;
  --app-surface-2: #f8fafc;
  --app-surface-3: #eef2f7;
  --app-elevated: #ffffff;
  --app-text: #111827;
  --app-text-soft: #334155;
  --app-muted: #64748b;
  --app-border: #dbe3ee;
  --app-border-strong: #c7d2e0;
  --app-primary: #2563eb;
  --app-primary-hover: #1d4ed8;
  --app-primary-soft: #e8f0ff;
  --app-success: #15803d;
  --app-success-soft: #eaf8ef;
  --app-warning: #b45309;
  --app-warning-soft: #fff6e6;
  --app-danger: #dc2626;
  --app-danger-soft: #fff0f0;
  --app-info: #0369a1;
  --app-info-soft: #e9f6fd;
  --app-terminal: #0b1220;
  --app-terminal-text: #d9e7f7;

  --app-radius-xs: 7px;
  --app-radius-sm: 10px;
  --app-radius-md: 14px;
  --app-radius-lg: 18px;
  --app-radius-xl: 24px;
  --app-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --app-shadow-sm: 0 5px 18px rgba(15, 23, 42, 0.07);
  --app-shadow-md: 0 16px 42px rgba(15, 23, 42, 0.13);
  --app-focus: 0 0 0 3px rgba(37, 99, 235, 0.22);
  --app-transition: 180ms ease;

  /* Compatibility mappings for legacy templates. */
  --bg-0: var(--app-bg);
  --bg-1: var(--app-bg);
  --bg-2: var(--app-bg-subtle);
  --bg-3: var(--app-bg-subtle);
  --surface: var(--app-surface);
  --surface-strong: var(--app-elevated);
  --surface-border: var(--app-border);
  --ink: var(--app-text);
  --ink-soft: var(--app-text-soft);
  --muted: var(--app-muted);
  --line: var(--app-border-strong);
  --line-soft: var(--app-border);
  --primary: var(--app-primary);
  --primary-strong: var(--app-primary-hover);
  --primary-soft: var(--app-primary-soft);
  --danger: var(--app-danger);
  --danger-soft: var(--app-danger-soft);
  --ok: var(--app-success);
  --ok-soft: var(--app-success-soft);
  --warn: var(--app-warning);
  --warn-soft: var(--app-warning-soft);
  --content-max: var(--app-content-max);
  --radius-card: var(--app-radius-lg);
  --radius-input: var(--app-radius-sm);
  --radius-button: var(--app-radius-sm);
  --focus-ring: var(--app-focus);
  --shadow-soft: var(--app-shadow-xs);
  --shadow-hover: var(--app-shadow-sm);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --app-bg: #0b1120;
  --app-bg-subtle: #111827;
  --app-sidebar: #070c16;
  --app-sidebar-elevated: #111827;
  --app-sidebar-border: rgba(255, 255, 255, 0.09);
  --app-header: rgba(11, 17, 32, 0.96);
  --app-surface: #111827;
  --app-surface-2: #172033;
  --app-surface-3: #1e293b;
  --app-elevated: #182235;
  --app-text: #f1f5f9;
  --app-text-soft: #cbd5e1;
  --app-muted: #94a3b8;
  --app-border: #263449;
  --app-border-strong: #334155;
  --app-primary: #60a5fa;
  --app-primary-hover: #93c5fd;
  --app-primary-soft: rgba(59, 130, 246, 0.16);
  --app-success: #4ade80;
  --app-success-soft: rgba(34, 197, 94, 0.14);
  --app-warning: #fbbf24;
  --app-warning-soft: rgba(245, 158, 11, 0.14);
  --app-danger: #f87171;
  --app-danger-soft: rgba(239, 68, 68, 0.14);
  --app-info: #38bdf8;
  --app-info-soft: rgba(14, 165, 233, 0.14);
  --app-terminal: #050914;
  --app-terminal-text: #d7e5f5;
  --app-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.28);
  --app-shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.28);
  --app-shadow-md: 0 22px 54px rgba(0, 0, 0, 0.42);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--app-border-strong) transparent;
}

html {
  min-height: 100%;
  background: var(--app-bg);
}

body.app-body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background: var(--app-bg);
  color: var(--app-text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

body.app-body::before {
  display: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea,
summary {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--app-primary);
}

a:hover {
  color: var(--app-primary-hover);
}

:focus-visible {
  outline: none;
  box-shadow: var(--app-focus) !important;
}

::selection {
  background: rgba(37, 99, 235, 0.24);
  color: var(--app-text);
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.app-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 30000;
  padding: 10px 14px;
  border-radius: var(--app-radius-sm);
  background: var(--app-primary);
  color: #fff;
  transform: translateY(-160%);
  transition: transform var(--app-transition);
}

.skip-link:focus {
  transform: translateY(0);
}

/* Application shell */
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1000;
  display: flex;
  width: var(--app-sidebar-width);
  min-width: var(--app-sidebar-width);
  flex-direction: column;
  color: #dbe7f5;
  background: var(--app-sidebar);
  border-right: 1px solid var(--app-sidebar-border);
  transition: width var(--app-transition), transform var(--app-transition);
}

.sidebar-brand {
  display: flex;
  min-height: var(--app-header-height);
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 18px;
  border-bottom: 1px solid var(--app-sidebar-border);
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 3px;
  padding: 8px;
  border: 1px solid rgba(147, 197, 253, 0.25);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.34), rgba(14, 165, 233, 0.12));
}

.brand-mark span {
  display: block;
  border-radius: 999px;
  background: #93c5fd;
}

.brand-mark span:nth-child(1) { height: 38%; }
.brand-mark span:nth-child(2) { height: 100%; }
.brand-mark span:nth-child(3) { height: 66%; }

.brand-copy {
  display: grid;
  min-width: 0;
  flex: 1;
  line-height: 1.18;
}

.brand-copy strong {
  color: #f8fafc;
  font-size: 15px;
  letter-spacing: 0.08em;
}

.brand-copy span {
  margin-top: 3px;
  color: #8fa4c1;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.icon-button {
  display: inline-flex;
  width: 42px;
  height: 42px;
  min-width: 42px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  background: var(--app-surface);
  color: var(--app-text-soft);
  cursor: pointer;
  transition: color var(--app-transition), background var(--app-transition), border-color var(--app-transition), transform var(--app-transition);
}

.icon-button:hover {
  border-color: var(--app-border-strong);
  background: var(--app-surface-2);
  color: var(--app-text);
}

.icon-button:active {
  transform: translateY(1px);
}

.sidebar-collapse {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: #9fb2cc;
}

.sidebar-collapse:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.app-nav {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 17px;
  overflow-y: auto;
  padding: 16px 12px 22px;
}

.app-nav-section {
  display: grid;
  gap: 4px;
}

.app-nav-heading {
  padding: 0 10px 6px;
  color: #6f86a5;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  white-space: nowrap;
}

.app-nav-link {
  position: relative;
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 12px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #b7c7dc;
  font-size: 13.5px;
  font-weight: 560;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--app-transition), background var(--app-transition), border-color var(--app-transition);
}

.app-nav-link:hover {
  border-color: rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.055);
  color: #f8fafc;
}

.app-nav-link.is-active {
  border-color: rgba(96, 165, 250, 0.22);
  background: rgba(37, 99, 235, 0.19);
  color: #eff6ff;
}

.app-nav-link.is-active::before {
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: -12px;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: #60a5fa;
  content: "";
}

.app-nav-link .app-icon {
  width: 19px;
  height: 19px;
  flex-basis: 19px;
}

.app-nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--app-sidebar-border);
}

.sidebar-device-card {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.035);
}

.sidebar-device-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-device-row > div {
  display: grid;
  min-width: 0;
  line-height: 1.25;
}

.sidebar-device-label {
  color: #8298b6;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-device-row strong {
  color: #f1f5f9;
  font-size: 13px;
}

.sidebar-device-meta {
  display: grid;
  gap: 3px;
  margin-top: 10px;
  color: #8298b6;
  font-size: 11px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 999px;
  background: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.14);
}

.status-dot.is-good {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.14);
}

.status-dot.is-warn {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.14);
}

.status-dot.is-bad {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14);
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  margin-left: var(--app-sidebar-width);
  transition: margin-left var(--app-transition);
}

.app-header.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  display: grid;
  min-height: var(--app-header-height);
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  padding: 10px 22px;
  border: 0;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-header);
  box-shadow: var(--app-shadow-xs);
  backdrop-filter: blur(14px);
}

.header-leading,
.header-status,
.header-actions,
.user-menu {
  display: flex;
  align-items: center;
}

.header-leading {
  min-width: 0;
  gap: 12px;
}

.mobile-menu-button {
  display: none;
}

.page-identity {
  min-width: 0;
}

.page-identity h1 {
  overflow: hidden;
  margin: 1px 0 0;
  color: var(--app-text);
  font-family: inherit;
  font-size: clamp(17px, 1.5vw, 21px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--app-muted);
  font-size: 11px;
}

.breadcrumb strong {
  overflow: hidden;
  color: var(--app-text-soft);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-status {
  justify-content: center;
  gap: 8px;
}

.header-status-chip {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--app-border);
  border-radius: 999px;
  background: var(--app-surface-2);
  color: var(--app-text-soft);
  font-size: 11px;
  text-decoration: none;
  white-space: nowrap;
}

.header-status-chip strong {
  color: var(--app-text);
  font-size: 11px;
  font-weight: 700;
}

.header-status-chip.live-chip {
  border-color: rgba(239, 68, 68, 0.26);
  background: var(--app-danger-soft);
  color: var(--app-danger);
  font-weight: 700;
}

.header-status-chip.live-chip.is-active {
  border-color: rgba(34, 197, 94, 0.28);
  background: var(--app-success-soft);
  color: var(--app-success);
}

.header-status-chip.live-chip.is-ringing {
  border-color: rgba(239, 68, 68, 0.3);
  background: var(--app-danger-soft);
  color: var(--app-danger);
}

.header-actions {
  justify-content: flex-end;
  gap: 7px;
}

.notification-button {
  position: relative;
}

.notif-count {
  position: absolute;
  top: -5px;
  right: -5px;
  display: inline-flex;
  min-width: 19px;
  height: 19px;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid var(--app-header);
  border-radius: 999px;
  background: var(--app-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.user-menu {
  gap: 8px;
  margin-left: 4px;
  padding-left: 10px;
  border-left: 1px solid var(--app-border);
}

.user-avatar {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: var(--app-primary-soft);
  color: var(--app-primary);
  font-size: 13px;
  font-weight: 800;
}

.user-copy {
  display: grid;
  min-width: 0;
  line-height: 1.2;
}

.user-copy strong {
  max-width: 120px;
  overflow: hidden;
  color: var(--app-text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-copy span {
  color: var(--app-muted);
  font-size: 10px;
}

body.sidebar-collapsed .app-sidebar {
  width: var(--app-sidebar-collapsed);
  min-width: var(--app-sidebar-collapsed);
}

body.sidebar-collapsed .app-shell {
  margin-left: var(--app-sidebar-collapsed);
}

body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .app-nav-heading,
body.sidebar-collapsed .app-nav-label,
body.sidebar-collapsed .sidebar-device-card {
  display: none;
}

body.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding-inline: 10px;
}

body.sidebar-collapsed .sidebar-collapse {
  position: absolute;
  right: -16px;
  background: var(--app-sidebar-elevated);
  transform: rotate(180deg);
}

body.sidebar-collapsed .app-nav {
  align-items: center;
  padding-inline: 10px;
}

body.sidebar-collapsed .app-nav-section {
  width: 100%;
}

body.sidebar-collapsed .app-nav-link {
  justify-content: center;
  padding-inline: 0;
}

body.sidebar-collapsed .app-nav-link.is-active::before {
  left: -10px;
}

/* Main content */
.page.app-main {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(var(--app-content-max), calc(100% - 36px));
  max-width: var(--app-content-max);
  min-width: 0;
  gap: 18px;
  margin: 20px auto 48px;
}

.page.app-main > * {
  min-width: 0;
}

.page-header,
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page-header-copy,
.section-header-copy {
  min-width: 0;
}

.page-header h2,
.section-header h2,
.section-header h3 {
  margin: 0;
}

.eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--app-primary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.card,
.panel {
  position: relative;
  min-width: 0;
  overflow: visible;
  padding: 18px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  background: var(--app-surface);
  box-shadow: var(--app-shadow-xs);
  backdrop-filter: none;
  transition: border-color var(--app-transition), box-shadow var(--app-transition);
}

.card::after {
  display: none;
}

.card:hover {
  border-color: var(--app-border-strong);
  box-shadow: var(--app-shadow-xs);
  transform: none;
}

.card h1,
.card h2,
.card h3,
.card h4,
h1,
h2,
h3,
h4 {
  color: var(--app-text);
  font-family: inherit;
  letter-spacing: -0.015em;
}

.card h2 {
  display: block;
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 700;
}

.card h2::after {
  display: none;
}

.card h3 {
  font-size: 14px;
}

p,
.hint {
  color: var(--app-text-soft);
}

.hint {
  font-size: 12.5px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.stack {
  display: grid;
  gap: 13px;
}

.max-600 {
  width: 100%;
  max-width: 600px;
}

/* Dashboard */
.dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  display: flex;
  min-height: 112px;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  padding: 15px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  background: var(--app-surface);
  box-shadow: var(--app-shadow-xs);
}

.metric-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.metric-card-label {
  color: var(--app-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.metric-card-icon {
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--app-primary-soft);
  color: var(--app-primary);
}

.metric-card-icon .app-icon {
  width: 16px;
  height: 16px;
  flex-basis: 16px;
}

.metric-card-value {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--app-text);
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.metric-card-value .pill {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  text-transform: none;
}

.metric-card-foot {
  overflow: hidden;
  color: var(--app-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-primary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(320px, 0.78fr);
  gap: 18px;
}

.live-operation-card {
  overflow: hidden;
  padding: 0;
}

.live-operation-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--app-border);
}

.live-call-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 20px 18px;
}

.live-call-orb {
  display: inline-flex;
  width: 54px;
  height: 54px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 17px;
  background: var(--app-primary-soft);
  color: var(--app-primary);
}

.live-call-orb .app-icon {
  width: 25px;
  height: 25px;
  flex-basis: 25px;
}

.live-call-main {
  min-width: 0;
}

.live-call-main strong {
  display: block;
  overflow: hidden;
  color: var(--app-text);
  font-size: clamp(20px, 2.4vw, 30px);
  letter-spacing: -0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-call-main span {
  color: var(--app-muted);
  font-size: 12px;
}

.live-call-duration {
  color: var(--app-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.live-call-details {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  border-top: 1px solid var(--app-border);
  background: var(--app-border);
}

.live-call-detail {
  min-width: 0;
  padding: 13px 15px;
  background: var(--app-surface-2);
}

.live-call-detail span {
  display: block;
  margin-bottom: 4px;
  color: var(--app-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.live-call-detail strong {
  display: block;
  overflow: hidden;
  color: var(--app-text-soft);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quick-action {
  display: flex;
  min-height: 62px;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  background: var(--app-surface-2);
  color: var(--app-text-soft);
  text-decoration: none;
  transition: border-color var(--app-transition), background var(--app-transition), color var(--app-transition);
}

.quick-action:hover {
  border-color: rgba(37, 99, 235, 0.3);
  background: var(--app-primary-soft);
  color: var(--app-primary);
}

.quick-action .app-icon {
  width: 19px;
  height: 19px;
}

.quick-action-copy {
  display: grid;
  min-width: 0;
  line-height: 1.25;
}

.quick-action-copy strong {
  color: var(--app-text);
  font-size: 12.5px;
}

.quick-action-copy span {
  overflow: hidden;
  color: var(--app-muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-groups {
  display: grid;
  gap: 12px;
}

.health-group {
  overflow: hidden;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  background: var(--app-surface);
}

.health-group > summary {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  color: var(--app-text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.health-group > summary::-webkit-details-marker {
  display: none;
}

.health-group > summary::after {
  color: var(--app-muted);
  content: "+";
  font-size: 18px;
  font-weight: 400;
}

.health-group[open] > summary::after {
  content: "−";
}

.health-group-content {
  padding: 0 14px 12px;
  border-top: 1px solid var(--app-border);
}

.dashboard-lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.danger-zone {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--app-border);
}

/* Status and data */
.status-list {
  display: grid;
  gap: 0;
}

.status-row {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--app-border);
}

.status-row:last-child {
  border-bottom: 0;
}

.status-row > span:first-child {
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 600;
}

.status-row > span:last-child {
  max-width: 64%;
  color: var(--app-text-soft);
  font-size: 12px;
  font-weight: 600;
  overflow-wrap: anywhere;
  text-align: right;
}

.port-desc {
  color: var(--app-muted) !important;
  font-size: 11px !important;
  font-weight: 400 !important;
}

.pill,
.status-badge {
  display: inline-flex;
  min-width: 0;
  min-height: 25px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid var(--app-border);
  border-radius: 999px;
  background: var(--app-surface-2);
  color: var(--app-text-soft);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.035em;
  line-height: 1.1;
  text-transform: uppercase;
}

.pill.is-good,
.status-badge.is-good {
  border-color: rgba(21, 128, 61, 0.24);
  background: var(--app-success-soft);
  color: var(--app-success);
}

.pill.is-warn,
.status-badge.is-warn {
  border-color: rgba(180, 83, 9, 0.25);
  background: var(--app-warning-soft);
  color: var(--app-warning);
}

.pill.is-bad,
.status-badge.is-bad {
  border-color: rgba(220, 38, 38, 0.25);
  background: var(--app-danger-soft);
  color: var(--app-danger);
}

.pill-at1,
.pill-at2,
.pill-pcm {
  border-color: var(--app-border);
  background: var(--app-surface-2);
  color: var(--app-text-soft);
}

.status-text {
  color: var(--app-muted);
  font-size: 11px;
}

/* Buttons and forms */
.btn {
  position: relative;
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: var(--app-radius-sm);
  box-shadow: none;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.15;
  text-decoration: none;
  transition: background var(--app-transition), border-color var(--app-transition), color var(--app-transition), transform var(--app-transition), opacity var(--app-transition);
}

.btn::after {
  display: none;
}

.btn:hover {
  box-shadow: none;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn[disabled],
.btn.is-loading {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.btn-primary {
  border-color: var(--app-primary);
  background: var(--app-primary);
  color: #fff;
}

.btn-primary:hover {
  border-color: var(--app-primary-hover);
  background: var(--app-primary-hover);
  color: #fff;
  filter: none;
}

.btn-secondary {
  border-color: var(--app-border-strong);
  background: var(--app-surface);
  color: var(--app-text-soft);
}

.btn-secondary:hover {
  border-color: var(--app-primary);
  background: var(--app-primary-soft);
  color: var(--app-primary);
}

.btn-danger {
  border-color: var(--app-danger);
  background: var(--app-danger);
  color: #fff;
}

.btn-danger:hover {
  border-color: #b91c1c;
  background: #b91c1c;
  color: #fff;
}

.btn-danger-ghost {
  border-color: rgba(220, 38, 38, 0.25);
  background: var(--app-danger-soft);
  color: var(--app-danger);
}

.btn-small {
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 11.5px;
}

.button-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-actions {
  gap: 5px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--app-text-soft);
  font-size: 12px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--app-border-strong);
  border-radius: var(--app-radius-sm);
  outline: none;
  background: var(--app-surface);
  box-shadow: none;
  color: var(--app-text);
  transition: border-color var(--app-transition), box-shadow var(--app-transition), background var(--app-transition);
}

input::placeholder,
textarea::placeholder {
  color: var(--app-muted);
  opacity: 0.72;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--app-muted);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--app-primary);
  background: var(--app-surface);
  box-shadow: var(--app-focus);
}

input:disabled,
select:disabled,
textarea:disabled,
input[readonly] {
  background: var(--app-surface-3);
  color: var(--app-muted);
  cursor: not-allowed;
  opacity: 0.8;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.checkbox-row {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 9px;
}

.checkbox-row input,
input[type="checkbox"],
input[type="radio"] {
  width: 17px;
  min-height: 17px;
  height: 17px;
  accent-color: var(--app-primary);
}

code {
  border: 1px solid var(--app-border);
  border-radius: 7px;
  background: var(--app-surface-2);
  color: var(--app-text-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Tables */
.table-wrap {
  position: relative;
  overflow: auto;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  background: var(--app-surface);
  scrollbar-gutter: stable;
}

table {
  width: 100%;
  border-spacing: 0;
  border-collapse: separate;
  color: var(--app-text-soft);
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-surface);
  color: var(--app-text-soft);
  font-size: 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--app-surface-2);
  color: var(--app-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tbody tr:hover td {
  background: var(--app-primary-soft);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.table-bulk-actions,
.table-pagination {
  border-color: var(--app-border);
  background: var(--app-surface-2);
}

/* Logs and terminal */
.log-box,
.terminal-box,
.floating-log-box {
  border: 1px solid #25344a;
  border-radius: var(--app-radius-md);
  background: var(--app-terminal);
  color: var(--app-terminal-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  scrollbar-gutter: stable;
}

.log-box {
  min-height: 210px;
  max-height: 390px;
}

.terminal-usb-list {
  border-color: var(--app-border);
  background: var(--app-surface-2);
  color: var(--app-text-soft);
}

/* Alerts, marquee and notifications */
.flash-wrap {
  display: grid;
  gap: 9px;
}

.flash {
  padding: 11px 13px 11px 16px;
  border: 1px solid var(--app-border);
  border-left-width: 4px;
  border-radius: var(--app-radius-sm);
  background: var(--app-surface);
  color: var(--app-text-soft);
  font-size: 12.5px;
  font-weight: 650;
}

.flash::before {
  display: none;
}

.flash-ok,
.flash-success {
  border-color: rgba(21, 128, 61, 0.25);
  border-left-color: var(--app-success);
  background: var(--app-success-soft);
  color: var(--app-success);
}

.flash-error {
  border-color: rgba(220, 38, 38, 0.25);
  border-left-color: var(--app-danger);
  background: var(--app-danger-soft);
  color: var(--app-danger);
}

.top-marquee {
  position: sticky;
  top: var(--app-header-height);
  z-index: 880;
  width: 100%;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-warning-soft);
  color: var(--app-warning);
  font-size: 12px;
  font-weight: 650;
}

.top-marquee.is-error {
  background: var(--app-danger-soft);
  color: var(--app-danger);
}

.top-marquee.is-warn {
  background: var(--app-warning-soft);
  color: var(--app-warning);
}

.top-marquee.is-live {
  animation: none;
}

.marquee-content {
  display: flex;
  width: min(var(--app-content-max), calc(100% - 36px));
  min-height: 42px;
  align-items: center;
  gap: 12px;
  margin: 0 auto;
}

.marquee-text {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.marquee-action {
  font-weight: 800;
}

.marquee-close {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border: 0;
  background: transparent;
  color: inherit;
}

.notif-center {
  position: fixed;
  inset: 0;
  z-index: 20000;
  align-items: flex-start;
  justify-content: flex-end;
  padding: calc(var(--app-header-height) + 10px) 14px 14px;
  background: rgba(4, 10, 20, 0.38);
  backdrop-filter: blur(4px);
}

.notif-center-card {
  width: min(430px, 100%);
  max-height: calc(100dvh - var(--app-header-height) - 28px);
  overflow: hidden;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  background: var(--app-elevated);
  box-shadow: var(--app-shadow-md);
}

.notif-center-head {
  padding: 15px 16px;
  border-bottom: 1px solid var(--app-border);
}

.notif-center-head h2 {
  margin: 0;
  font-size: 16px;
}

.notif-list {
  padding: 8px;
  background: var(--app-surface-2);
}

.notif-item {
  margin: 6px;
  border-color: var(--app-border);
  background: var(--app-surface);
  color: var(--app-text-soft);
}

.notif-item-message {
  color: var(--app-text-soft);
}

.notif-center-foot {
  border-color: var(--app-border);
  color: var(--app-muted);
}

/* Utility drawers */
.utility-drawer-root {
  position: fixed !important;
  z-index: 14500;
}

.floating-log-root {
  inset: auto auto 16px calc(var(--app-sidebar-width) + 16px) !important;
  transition: left var(--app-transition);
}

body.sidebar-collapsed .floating-log-root {
  left: calc(var(--app-sidebar-collapsed) + 16px) !important;
}

.floating-ai-root {
  inset: auto 16px 16px auto !important;
}

.utility-fab,
.floating-log-toggle,
.floating-ai-toggle {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid rgba(37, 99, 235, 0.3);
  border-radius: 999px;
  background: var(--app-primary);
  box-shadow: 0 9px 24px rgba(37, 99, 235, 0.24);
  color: #fff;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.floating-log-toggle {
  border-color: #263449;
  background: #172033;
  box-shadow: 0 9px 24px rgba(0, 0, 0, 0.23);
}

.utility-drawer,
.floating-log-panel,
.floating-ai-panel {
  position: fixed !important;
  display: grid;
  gap: 11px;
  width: min(480px, calc(100vw - 32px));
  max-height: min(720px, calc(100dvh - 92px));
  overflow: hidden;
  padding: 13px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  background: var(--app-elevated);
  box-shadow: var(--app-shadow-md);
}

.floating-log-panel {
  bottom: 66px !important;
  left: calc(var(--app-sidebar-width) + 16px) !important;
}

body.sidebar-collapsed .floating-log-panel {
  left: calc(var(--app-sidebar-collapsed) + 16px) !important;
}

.floating-ai-panel {
  right: 16px !important;
  bottom: 66px !important;
}

.utility-drawer-head,
.floating-log-head,
.floating-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.utility-drawer-head strong {
  color: var(--app-text);
  font-size: 14px;
}

.floating-log-box,
.floating-ai-log {
  min-height: 260px;
  max-height: 390px;
  overflow: auto;
}

.floating-ai-log {
  border: 1px solid var(--app-border);
  background: var(--app-surface-2);
}

.floating-ai-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: end;
}

.floating-ai-toolbar .button-row {
  grid-column: 1 / -1;
}

.floating-log-badge {
  border: 0;
  background: #fff;
  color: #0f172a;
}

/* Contact suggestions created by shell.js */
.contact-suggest-menu {
  position: absolute;
  z-index: 25000;
  max-height: 260px;
  overflow: auto;
  padding: 5px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  background: var(--app-elevated);
  box-shadow: var(--app-shadow-md);
}

.contact-suggest-option {
  display: grid;
  width: 100%;
  gap: 2px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--app-text-soft);
  cursor: pointer;
  text-align: left;
}

.contact-suggest-option:hover,
.contact-suggest-option[aria-selected="true"] {
  background: var(--app-primary-soft);
  color: var(--app-primary);
}

.contact-suggest-option strong {
  color: var(--app-text);
  font-size: 12px;
}

.contact-suggest-option span {
  color: var(--app-muted);
  font-size: 11px;
}

/* AI and live page compatibility */
.ai-chat-shell,
.ai-model-catalog,
.ai-ivr-config-wrap,
.ai-history-card {
  border-color: var(--app-border);
  background: var(--app-surface-2);
}

.ai-chat-head {
  border-color: var(--app-border);
  background: var(--app-surface-3);
}

.ai-chat-log,
.ai-chat-compose {
  border-color: var(--app-border);
}

.ai-bubble,
.ai-history-item,
.ai-model-item {
  border-color: var(--app-border);
  background: var(--app-surface);
  color: var(--app-text-soft);
}

.ai-msg-user .ai-bubble {
  border-color: rgba(37, 99, 235, 0.22);
  background: var(--app-primary-soft);
}

.ai-chat-empty,
.ai-bubble-role,
.ai-model-item-id,
.ai-history-title,
.floating-ai-history-title {
  color: var(--app-muted);
}

.live-layout {
  gap: 18px;
}

.sticky-live-actions {
  border-color: var(--app-border);
  background: var(--app-elevated);
}

/* Login */
.auth-body {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 12% 10%, rgba(37, 99, 235, 0.12), transparent 38%),
    radial-gradient(circle at 88% 85%, rgba(14, 165, 233, 0.1), transparent 34%),
    var(--app-bg);
}

.auth-main {
  display: grid;
  width: min(440px, 100%);
  gap: 14px;
}

.auth-main .card {
  width: 100%;
  max-width: none;
  padding: 28px;
  box-shadow: var(--app-shadow-md);
}

/* Toast region for new shell utility feedback */
.app-toast-region {
  position: fixed;
  top: calc(var(--app-header-height) + 14px);
  right: 16px;
  z-index: 26000;
  display: grid;
  width: min(380px, calc(100vw - 32px));
  gap: 8px;
  pointer-events: none;
}

.shell-toast {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--app-border);
  border-left: 4px solid var(--app-info);
  border-radius: var(--app-radius-sm);
  background: var(--app-elevated);
  box-shadow: var(--app-shadow-md);
  color: var(--app-text-soft);
  pointer-events: auto;
}

.shell-toast.is-success { border-left-color: var(--app-success); }
.shell-toast.is-warning { border-left-color: var(--app-warning); }
.shell-toast.is-error { border-left-color: var(--app-danger); }

.shell-toast button {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: 0;
  background: transparent;
}

/* Legacy reveal is deliberately static for operational reliability. */
.reveal-section,
.reveal-section.is-visible {
  opacity: 1;
  transform: none;
  transition: none;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(3, 8, 18, 0.52);
  backdrop-filter: blur(2px);
}

@media (max-width: 1280px) {
  .dashboard-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hide-below-wide {
    display: none !important;
  }

  .app-header.topbar {
    grid-template-columns: minmax(200px, 1fr) auto auto;
    gap: 12px;
    padding-inline: 16px;
  }
}

@media (max-width: 1060px) {
  .app-sidebar {
    transform: translateX(-102%);
    box-shadow: var(--app-shadow-md);
  }

  .app-shell,
  body.sidebar-collapsed .app-shell {
    margin-left: 0;
  }

  .mobile-menu-button {
    display: inline-flex;
  }

  .sidebar-collapse {
    display: none;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .floating-log-root,
  body.sidebar-collapsed .floating-log-root {
    left: 16px !important;
  }

  .floating-log-panel,
  body.sidebar-collapsed .floating-log-panel {
    left: 16px !important;
  }

  .dashboard-primary-grid,
  .dashboard-lower-grid {
    grid-template-columns: 1fr;
  }

  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  :root {
    --app-header-height: 62px;
  }

  .app-header.topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: var(--app-header-height);
    padding: 8px 10px;
  }

  .header-status {
    display: none;
  }

  .header-actions {
    gap: 5px;
  }

  .header-actions .icon-button,
  .mobile-menu-button {
    width: 40px;
    height: 40px;
    min-width: 40px;
  }

  .page-identity h1 {
    font-size: 16px;
  }

  .breadcrumb {
    display: none;
  }

  .hide-below-tablet {
    display: none !important;
  }

  .page.app-main {
    width: calc(100% - 20px);
    gap: 12px;
    margin-top: 12px;
    margin-bottom: 92px;
  }

  .card,
  .panel {
    padding: 14px;
    border-radius: var(--app-radius-md);
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .dashboard-metrics {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .metric-card {
    min-height: 94px;
  }

  .live-call-hero {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
  }

  .live-call-duration {
    grid-column: 1 / -1;
    padding-top: 12px;
    border-top: 1px solid var(--app-border);
    font-size: 20px;
  }

  .live-call-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-actions-grid {
    grid-template-columns: 1fr;
  }

  .status-row {
    align-items: flex-start;
  }

  .status-row > span:last-child {
    max-width: 60%;
  }

  .table-wrap {
    overflow-x: auto;
  }

  table {
    min-width: 720px;
  }

  .utility-fab span:not(.floating-log-badge) {
    display: none;
  }

  .utility-fab,
  .floating-log-toggle,
  .floating-ai-toggle {
    width: 48px;
    height: 48px;
    min-width: 48px;
    justify-content: center;
    padding: 0;
  }

  .floating-log-root {
    bottom: max(12px, env(safe-area-inset-bottom)) !important;
    left: 12px !important;
  }

  .floating-ai-root {
    right: 12px !important;
    bottom: max(12px, env(safe-area-inset-bottom)) !important;
  }

  .floating-log-panel,
  body.sidebar-collapsed .floating-log-panel,
  .floating-ai-panel {
    inset: auto 8px calc(70px + env(safe-area-inset-bottom)) 8px !important;
    width: auto;
    max-height: calc(100dvh - 88px);
    border-radius: var(--app-radius-md);
  }

  .floating-ai-toolbar {
    grid-template-columns: 1fr;
  }

  .floating-ai-toolbar .button-row {
    grid-column: auto;
  }

  .notif-center {
    padding: calc(var(--app-header-height) + 6px) 6px 6px;
  }

  .notif-center-card {
    width: 100%;
    max-height: calc(100dvh - var(--app-header-height) - 12px);
  }

  .marquee-content {
    width: calc(100% - 20px);
  }

  .auth-body {
    padding: 12px;
  }

  .auth-main .card {
    padding: 20px;
  }
}

@media (max-width: 420px) {
  .page-identity h1 {
    max-width: 170px;
  }

  .user-avatar {
    display: none;
  }

  .user-menu {
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
  }

  .live-call-details {
    grid-template-columns: 1fr;
  }

  .button-row .btn {
    flex: 1 1 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .app-sidebar,
  .app-header,
  .utility-drawer-root,
  .top-marquee,
  .notif-center {
    display: none !important;
  }

  .app-shell {
    margin: 0;
  }

  .page.app-main {
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .card {
    break-inside: avoid;
    box-shadow: none;
  }
}


/* RBAC, login and user administration */
.auth-body {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px;
  overflow-x: hidden;
}

.auth-main {
  width: min(1160px, 100%);
  min-height: min(760px, calc(100dvh - 40px));
  align-content: center;
}

.auth-main > .flash-wrap {
  width: min(520px, calc(100% - 32px));
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 30000;
  transform: translateX(-50%);
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(400px, .92fr);
  min-height: min(760px, calc(100dvh - 40px));
  overflow: hidden;
  border: 1px solid var(--app-border);
  border-radius: 28px;
  background: var(--app-surface);
  box-shadow: 0 28px 80px rgba(15, 23, 42, .18);
}

.auth-brand-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 680px;
  padding: clamp(34px, 5vw, 64px);
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 80% 15%, rgba(56, 189, 248, .34), transparent 32%),
    radial-gradient(circle at 12% 86%, rgba(37, 99, 235, .52), transparent 38%),
    linear-gradient(145deg, #07162f 0%, #0f2a59 55%, #123d79 100%);
}

.auth-brand-panel::before,
.auth-brand-panel::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 50%;
  pointer-events: none;
}

.auth-brand-panel::before {
  width: 420px;
  height: 420px;
  top: -210px;
  right: -160px;
}

.auth-brand-panel::after {
  width: 320px;
  height: 320px;
  bottom: -190px;
  left: -130px;
}

.auth-brand-top,
.auth-brand-copy,
.auth-feature-list,
.auth-security-note {
  position: relative;
  z-index: 1;
}

.auth-brand-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-brand-top > div:last-child {
  display: grid;
  gap: 2px;
}

.auth-brand-top strong {
  font-size: 1.15rem;
  letter-spacing: .08em;
}

.auth-brand-top span {
  color: rgba(255,255,255,.68);
  font-size: .82rem;
}

.auth-logo {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 46px;
  height: 46px;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 14px;
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(12px);
}

.auth-logo span {
  width: 5px;
  border-radius: 999px;
  background: #7dd3fc;
}

.auth-logo span:nth-child(1) { height: 10px; }
.auth-logo span:nth-child(2) { height: 20px; }
.auth-logo span:nth-child(3) { height: 28px; }

.auth-brand-copy {
  max-width: 590px;
  margin: 54px 0 42px;
}

.auth-brand-copy .eyebrow { color: #7dd3fc; }

.auth-brand-copy h1 {
  margin: 12px 0 18px;
  color: #fff;
  font-size: clamp(2.1rem, 4vw, 3.7rem);
  line-height: 1.03;
  letter-spacing: -.045em;
}

.auth-brand-copy p {
  max-width: 540px;
  margin: 0;
  color: rgba(255,255,255,.72);
  font-size: 1rem;
  line-height: 1.7;
}

.auth-feature-list {
  display: grid;
  gap: 13px;
  max-width: 560px;
}

.auth-feature-list > div {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 13px;
  padding: 13px 14px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 15px;
  background: rgba(255,255,255,.055);
}

.auth-feature-list > div > span:last-child {
  display: grid;
  gap: 3px;
}

.auth-feature-list strong { font-size: .9rem; }
.auth-feature-list small { color: rgba(255,255,255,.62); }

.auth-feature-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: #bae6fd;
  background: rgba(125,211,252,.12);
  font-size: .72rem;
  font-weight: 800;
}

.auth-security-note {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 28px;
  color: rgba(255,255,255,.68);
  font-size: .8rem;
}

.auth-form-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(30px, 5vw, 68px);
  background: var(--app-surface);
}

.auth-form-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 42px;
  color: var(--app-muted);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.auth-card {
  width: 100%;
  max-width: 450px;
  margin: auto;
}

.auth-card-heading h2 {
  margin: 8px 0 8px;
  font-size: clamp(1.75rem, 3vw, 2.35rem);
  letter-spacing: -.035em;
}

.auth-card-heading p {
  margin: 0;
  color: var(--app-muted);
}

.auth-form {
  display: grid;
  gap: 19px;
  margin-top: 32px;
}

.field-group {
  display: grid;
  gap: 8px;
  color: var(--app-text);
  font-size: .84rem;
  font-weight: 700;
}

.field-group > span:first-child {
  letter-spacing: .01em;
}

.field-group input,
.field-group select,
.field-group textarea {
  width: 100%;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 68px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  min-width: 48px;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  color: var(--app-primary);
  background: transparent;
  font: inherit;
  font-size: .76rem;
  font-weight: 800;
  transform: translateY(-50%);
  cursor: pointer;
}

.password-toggle:hover { background: var(--app-primary-soft); }

.auth-remember {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--app-muted);
  font-size: .83rem;
  cursor: pointer;
}

.auth-remember input { width: 17px; height: 17px; }

.auth-submit {
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding-inline: 18px;
}

.auth-help {
  margin-top: 24px;
  padding: 13px 14px;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  color: var(--app-muted);
  background: var(--app-bg);
  font-size: .78rem;
  line-height: 1.55;
}

.auth-footer-copy {
  max-width: 450px;
  margin: 28px auto 0;
  color: var(--app-muted);
  font-size: .74rem;
  text-align: center;
}

.users-page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.users-page-heading h2 { margin: 5px 0; }
.users-page-heading p { margin: 0; color: var(--app-muted); }

.users-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.users-summary-grid .summary-card {
  min-height: 132px;
}

.users-summary-grid .summary-card > span {
  color: var(--app-muted);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.users-summary-grid .summary-card > strong {
  display: block;
  margin: 9px 0 2px;
  font-size: 2rem;
}

.users-summary-grid .summary-card > small { color: var(--app-muted); }

.users-create-card,
.users-list-card {
  padding: clamp(20px, 3vw, 28px);
}

.card-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.card-heading-row h3 { margin: 4px 0; }
.card-heading-row p { margin: 0; color: var(--app-muted); }

.user-editor-form { display: grid; gap: 20px; }

.user-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.switch-row.compact-switch-row,
.switch-row.inline-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 60px;
  padding: 12px 14px;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-bg);
}

.switch-row.compact-switch-row > span,
.switch-row.inline-switch-row > span {
  display: grid;
  gap: 2px;
}

.switch-row.compact-switch-row small,
.switch-row.inline-switch-row small { color: var(--app-muted); }

.permission-editor {
  padding: 18px;
  border: 1px solid var(--app-border);
  border-radius: 16px;
  background: var(--app-bg);
}

.permission-editor[hidden] { display: none !important; }

.permission-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.permission-editor-head > div { display: grid; gap: 3px; }
.permission-editor-head span { color: var(--app-muted); font-size: .8rem; }

.permission-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.permission-group {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-surface);
}

.permission-group legend {
  padding: 0 6px;
  color: var(--app-muted);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.permission-option {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: start;
  gap: 9px;
  padding: 8px 6px;
  border-radius: 9px;
  cursor: pointer;
}

.permission-option:hover { background: var(--app-primary-soft); }
.permission-option input { margin-top: 2px; }
.permission-option > span { display: grid; gap: 2px; min-width: 0; }
.permission-option strong { font-size: .8rem; }
.permission-option small { overflow: hidden; color: var(--app-muted); font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }

.user-directory { display: grid; gap: 12px; }

.user-access-card {
  border: 1px solid var(--app-border);
  border-radius: 16px;
  background: var(--app-surface);
  transition: border-color .18s ease, box-shadow .18s ease;
}

.user-access-card:hover {
  border-color: rgba(37, 99, 235, .3);
  box-shadow: var(--app-shadow-sm);
}

.user-access-card.is-inactive { opacity: .72; }

.user-access-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
}

.user-access-identity {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 13px;
}

.user-avatar-large {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  font-size: 1rem;
}

.user-access-identity > div:last-child { min-width: 0; }

.user-name-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.user-name-line h4 { margin: 0; }
.user-access-identity p { margin: 3px 0; color: var(--app-muted); }
.user-access-identity small { color: var(--app-muted); }

.role-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: .66rem;
  font-weight: 800;
}

.role-badge { color: var(--app-primary); background: var(--app-primary-soft); }
.role-super_admin { color: #7c3aed; background: rgba(124,58,237,.1); }
.status-active { color: #047857; background: rgba(16,185,129,.12); }
.status-inactive { color: #b45309; background: rgba(245,158,11,.14); }

.user-access-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-editor-details { position: relative; }
.user-editor-details > summary { list-style: none; cursor: pointer; }
.user-editor-details > summary::-webkit-details-marker { display: none; }

.user-editor-popover {
  position: fixed;
  inset: 5vh max(24px, 6vw);
  z-index: 24000;
  max-width: 1100px;
  max-height: 90vh;
  margin: auto;
  padding: clamp(20px, 3vw, 30px);
  overflow: auto;
  border: 1px solid var(--app-border);
  border-radius: 20px;
  background: var(--app-surface);
  box-shadow: 0 28px 90px rgba(15,23,42,.28);
}

.user-editor-details[open]::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 23999;
  background: rgba(15,23,42,.56);
  backdrop-filter: blur(3px);
}

.user-security-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--app-border);
}

.user-password-form,
.user-danger-zone {
  display: grid;
  align-content: start;
  gap: 12px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--app-border);
  border-radius: 14px;
}

.user-password-form h5,
.user-danger-zone h5 { margin: 0; }
.user-danger-zone p { margin: 0; color: var(--app-muted); }
.user-danger-zone { border-color: rgba(220,38,38,.22); background: rgba(220,38,38,.035); }

.access-denied-card {
  max-width: 620px;
  margin: 8vh auto;
  padding: 38px;
  text-align: center;
}

.access-denied-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin: 0 auto 18px;
  border-radius: 18px;
  color: #b91c1c;
  background: rgba(220,38,38,.1);
  font-size: 1.8rem;
  font-weight: 900;
}

.access-denied-card h2 { margin: 7px 0; }
.access-denied-card > p { max-width: 500px; margin: 0 auto 22px; color: var(--app-muted); }
.permission-code { display: inline-grid; gap: 5px; padding: 12px 16px; border: 1px solid var(--app-border); border-radius: 12px; background: var(--app-bg); }
.permission-code span { color: var(--app-muted); font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.permission-code code { color: var(--app-primary); }
.access-denied-card .form-actions { justify-content: center; }

@media (max-width: 980px) {
  .auth-shell { grid-template-columns: 1fr; max-width: 620px; margin: auto; }
  .auth-brand-panel { min-height: 330px; padding: 34px; }
  .auth-brand-copy { margin: 38px 0 0; }
  .auth-brand-copy h1 { font-size: 2.3rem; }
  .auth-feature-list, .auth-security-note { display: none; }
  .auth-form-panel { padding: 34px; }
  .auth-form-toolbar { margin-bottom: 30px; }
  .users-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .permission-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .auth-body { padding: 0; }
  .auth-main { min-height: 100dvh; }
  .auth-shell { min-height: 100dvh; border: 0; border-radius: 0; }
  .auth-brand-panel { min-height: 260px; padding: 28px 22px; }
  .auth-brand-copy { margin: 30px 0 0; }
  .auth-brand-copy h1 { font-size: 1.9rem; }
  .auth-brand-copy p { font-size: .88rem; }
  .auth-form-panel { padding: 28px 22px 36px; }
  .auth-form-toolbar { margin-bottom: 24px; }
  .users-page-heading { align-items: flex-start; flex-direction: column; }
  .users-summary-grid { grid-template-columns: 1fr 1fr; }
  .user-form-grid,
  .permission-groups,
  .user-security-grid { grid-template-columns: 1fr; }
  .user-access-summary { align-items: flex-start; flex-direction: column; }
  .user-access-actions { width: 100%; justify-content: flex-end; }
  .user-editor-popover { inset: 10px; max-height: calc(100dvh - 20px); border-radius: 16px; }
}

@media (max-width: 430px) {
  .users-summary-grid { grid-template-columns: 1fr; }
  .permission-editor-head { align-items: flex-start; flex-direction: column; }
}


/* Protected settings and user edit controls */
.settings-card-heading {
  align-items: flex-start;
}

.settings-edit-button,
.user-edit-icon {
  flex: 0 0 auto;
  border-color: var(--app-primary);
  color: var(--app-primary);
  background: var(--app-primary-soft);
}

.user-editor-details > summary {
  list-style: none;
}

.user-editor-details > summary::-webkit-details-marker {
  display: none;
}

.settings-readonly-form.is-readonly input:not([type="checkbox"]):not([type="radio"]),
.settings-readonly-form.is-readonly select,
.settings-readonly-form.is-readonly textarea {
  cursor: default;
  color: var(--app-text);
  border-color: transparent;
  background: var(--app-elevated);
  box-shadow: inset 0 0 0 1px var(--app-border);
}

.settings-readonly-form.is-readonly input:disabled,
.settings-readonly-form.is-readonly select:disabled {
  opacity: 1;
  -webkit-text-fill-color: var(--app-text);
}

.settings-readonly-form.is-editing input,
.settings-readonly-form.is-editing select,
.settings-readonly-form.is-editing textarea {
  border-color: var(--app-primary);
}

.settings-edit-actions {
  position: sticky;
  bottom: 12px;
  z-index: 8;
  padding: 12px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  background: color-mix(in srgb, var(--app-elevated) 92%, transparent);
  box-shadow: var(--app-shadow-md);
  backdrop-filter: blur(12px);
}

@media (max-width: 640px) {
  .settings-card-heading {
    display: flex;
    flex-direction: row;
    gap: 12px;
  }

  .settings-edit-actions {
    bottom: calc(10px + env(safe-area-inset-bottom));
  }
}


/* Disabled optional feature state */
.app-nav-link.is-disabled-feature {
  opacity: 0.78;
}

.nav-feature-badge {
  margin-left: auto;
  padding: 2px 6px;
  border: 1px solid var(--app-border);
  border-radius: 999px;
  color: var(--app-muted);
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.feature-disabled-card {
  display: grid;
  justify-items: start;
  max-width: 760px;
  gap: 12px;
  padding: clamp(24px, 4vw, 42px);
}

.feature-disabled-card h2,
.feature-disabled-card p {
  margin: 0;
}

.feature-disabled-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid var(--app-border);
  border-radius: 16px;
  background: var(--app-surface-muted);
  color: var(--app-muted);
}

.feature-disabled-icon .app-icon {
  width: 26px;
  height: 26px;
}

.feature-disabled-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: var(--app-surface-muted);
  color: var(--app-muted);
}
