/* ET-NanoRouter Design System Tokens & Components — ETNexus.Portal (Enterprise Violet Edition) */
:root,
[data-theme="light"] {
  /* Authoritative Violet Scale */
  --violet-50: #F5F3FF;
  --violet-100: #EDE9FE;
  --violet-200: #DDD6FE;
  --violet-300: #C4B5FD;
  --violet-400: #A78BFA;
  --violet-500: #8B5CF6;
  --violet-600: #7C3AED;
  --violet-700: #6D28D9;
  --violet-800: #5B21B6;
  --violet-900: #4C1D95;
  --violet-950: #2E1065;

  /* Neutral Zinc Surfaces */
  --background: #FAFAFA;
  --foreground: #09090B;
  --card: #FFFFFF;
  --card-foreground: #09090B;
  --popover: #FFFFFF;
  --popover-foreground: #09090B;
  --secondary: #F4F4F5;
  --secondary-foreground: #18181B;
  --muted: #F4F4F5;
  --muted-foreground: #71717A;
  --border: #E4E4E7;
  --input: #E4E4E7;

  /* Primary & Brand Tokens */
  --primary: #7C3AED;
  --primary-hover: #6D28D9;
  --primary-active: #5B21B6;
  --primary-foreground: #FFFFFF;
  --primary-subtle: #F5F3FF;
  --primary-subtle-border: #DDD6FE;
  --accent: #F5F3FF;
  --accent-foreground: #5B21B6;
  --ring: #8B5CF6;
  --input-focus: #8B5CF6;
  --selected-bg: #F5F3FF;
  --selected-fg: #6D28D9;
  --selected-border: #DDD6FE;
  --active-bg: #EDE9FE;
  --active-fg: #5B21B6;
  --selection-bg: #EDE9FE;
  --selection-fg: #4C1D95;
  --brand: #7C3AED;
  --brand-foreground: #FFFFFF;

  /* Sidebar Tokens */
  --sidebar: #FAFAFA;
  --sidebar-foreground: #09090B;
  --sidebar-primary: #7C3AED;
  --sidebar-primary-foreground: #FFFFFF;
  --sidebar-accent: #F5F3FF;
  --sidebar-accent-foreground: #6D28D9;
  --sidebar-border: #E4E4E7;
  --sidebar-ring: #8B5CF6;

  /* Preserved Semantic Status Tokens */
  --success: #16A34A;
  --success-foreground: #FFFFFF;
  --success-subtle: #F0FDF4;
  --success-border: #BBF7D0;
  --warning: #D97706;
  --warning-foreground: #FFFFFF;
  --warning-subtle: #FFFBEB;
  --warning-border: #FDE68A;
  --destructive: #DC2626;
  --destructive-foreground: #FFFFFF;
  --destructive-subtle: #FEF2F2;
  --destructive-border: #FECACA;
  --info: #2563EB;
  --info-foreground: #FFFFFF;
  --info-subtle: #EFF6FF;
  --info-border: #BFDBFE;

  /* Chart Palette */
  --chart-1: #7C3AED;
  --chart-2: #8B5CF6;
  --chart-3: #16A34A;
  --chart-4: #2563EB;
  --chart-5: #D97706;

  --radius: .625rem;
  --card-shadow: 0 0 0 1px rgba(24, 24, 27, 0.06), 0 1px 3px 0 rgba(0, 0, 0, 0.04);
  --app-font-ui: 'Tajawal', 'Plus Jakarta Sans', 'IBM Plex Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --app-font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="mono"] {
  --background: #FAFAFA;
  --foreground: #09090B;
  --card: #FFFFFF;
  --card-foreground: #09090B;
  --popover: #FFFFFF;
  --popover-foreground: #09090B;
  --primary: #3F3F46;
  --primary-hover: #27272A;
  --primary-active: #18181B;
  --primary-foreground: #FFFFFF;
  --primary-subtle: #F4F4F5;
  --primary-subtle-border: #D4D4D8;
  --secondary: #F4F4F5;
  --secondary-foreground: #18181B;
  --muted: #F4F4F5;
  --muted-foreground: #71717A;
  --accent: #E4E4E7;
  --accent-foreground: #18181B;
  --ring: #52525B;
  --input-focus: #52525B;
  --selected-bg: #E4E4E7;
  --selected-fg: #18181B;
  --selected-border: #D4D4D8;
  --active-bg: #D4D4D8;
  --active-fg: #09090B;
  --selection-bg: #E4E4E7;
  --selection-fg: #09090B;
  --brand: #3F3F46;
  --brand-foreground: #FFFFFF;
  --border: #E4E4E7;
  --input: #D4D4D8;
  --sidebar: #F4F4F5;
  --sidebar-foreground: #09090B;
  --sidebar-primary: #27272A;
  --sidebar-primary-foreground: #FFFFFF;
  --sidebar-accent: #E4E4E7;
  --sidebar-accent-foreground: #09090B;
  --sidebar-border: #E4E4E7;
  --sidebar-ring: #52525B;
  --success: #15803D;
  --success-foreground: #FFFFFF;
  --success-subtle: #F0FDF4;
  --success-border: #BBF7D0;
  --warning: #B45309;
  --warning-foreground: #FFFFFF;
  --warning-subtle: #FFFBEB;
  --warning-border: #FDE68A;
  --destructive: #B91C1C;
  --destructive-foreground: #FFFFFF;
  --destructive-subtle: #FEF2F2;
  --destructive-border: #FECACA;
  --info: #1D4ED8;
  --info-foreground: #FFFFFF;
  --info-subtle: #EFF6FF;
  --info-border: #BFDBFE;
  --chart-1: #27272A;
  --chart-2: #52525B;
  --chart-3: #71717A;
  --chart-4: #A1A1AA;
  --chart-5: #D4D4D8;
}

[data-theme="dark"] {
  --background: #09090B;
  --foreground: #FAFAFA;
  --card: #121215;
  --card-foreground: #FAFAFA;
  --popover: #18181B;
  --popover-foreground: #FAFAFA;
  --primary: #A78BFA;
  --primary-hover: #C4B5FD;
  --primary-active: #8B5CF6;
  --primary-foreground: #2E1065;
  --primary-subtle: rgba(139, 92, 246, 0.14);
  --primary-subtle-border: rgba(167, 139, 250, 0.32);
  --secondary: #27272A;
  --secondary-foreground: #FAFAFA;
  --muted: #1F1F23;
  --muted-foreground: #A1A1AA;
  --accent: rgba(139, 92, 246, 0.16);
  --accent-foreground: #DDD6FE;
  --ring: #A78BFA;
  --input-focus: #A78BFA;
  --selected-bg: rgba(139, 92, 246, 0.16);
  --selected-fg: #DDD6FE;
  --selected-border: rgba(167, 139, 250, 0.35);
  --active-bg: rgba(139, 92, 246, 0.24);
  --active-fg: #EDE9FE;
  --selection-bg: rgba(139, 92, 246, 0.32);
  --selection-fg: #F5F3FF;
  --brand: #A78BFA;
  --brand-foreground: #2E1065;
  --border: #27272A;
  --input: #27272A;
  --sidebar: #0C0C0E;
  --sidebar-foreground: #F4F4F5;
  --sidebar-primary: #A78BFA;
  --sidebar-primary-foreground: #2E1065;
  --sidebar-accent: rgba(139, 92, 246, 0.15);
  --sidebar-accent-foreground: #DDD6FE;
  --sidebar-border: #27272A;
  --sidebar-ring: #A78BFA;
  --success: #22C55E;
  --success-foreground: #052E16;
  --success-subtle: rgba(34, 197, 94, 0.14);
  --success-border: rgba(34, 197, 94, 0.32);
  --warning: #F59E0B;
  --warning-foreground: #451A03;
  --warning-subtle: rgba(245, 158, 11, 0.14);
  --warning-border: rgba(245, 158, 11, 0.32);
  --destructive: #EF4444;
  --destructive-foreground: #FFFFFF;
  --destructive-subtle: rgba(239, 68, 68, 0.15);
  --destructive-border: rgba(239, 68, 68, 0.35);
  --info: #60A5FA;
  --info-foreground: #172554;
  --info-subtle: rgba(96, 165, 250, 0.14);
  --info-border: rgba(96, 165, 250, 0.32);
  --chart-1: #A78BFA;
  --chart-2: #8B5CF6;
  --chart-3: #22C55E;
  --chart-4: #60A5FA;
  --chart-5: #F59E0B;
  --card-shadow: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 2px 6px 0 rgba(0, 0, 0, 0.45);
}

/* Default Font & Font-Size Scale (S / M / L) */
[data-font="tajawal"],
[data-font="google-sans"],
[data-font="cairo"],
[data-font="plex"] {
  --app-font-ui: 'Tajawal', 'Plus Jakarta Sans', 'IBM Plex Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 14px; }
html[data-fontsize="sm"] { font-size: 12.5px; }
html[data-fontsize="md"] { font-size: 14px; }
html[data-fontsize="lg"] { font-size: 16px; }

*, *::before, *::after { box-sizing: border-box; }

::selection {
  background: var(--selection-bg);
  color: var(--selection-fg);
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--app-font-ui);
  line-height: 1.43;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body { font-size: 1rem; }

a { color: inherit; text-decoration: none; }
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
p a:not(.etn-btn), .etn-link {
  color: var(--primary);
  font-weight: 500;
  text-underline-offset: 3px;
}
p a:not(.etn-btn):hover, .etn-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

h1, h2, h3, h4, .etn-h1, .etn-h2, .etn-display {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--foreground);
}
.etn-display { font-size: 2.14rem; line-height: 1.2; }
h1, .etn-h1 { font-size: 1.43rem; line-height: 1.4; }
h2, .etn-h2 { font-size: 1.14rem; line-height: 1.5; }
.etn-small { font-size: 0.915rem; line-height: 1.4; }
.etn-muted { color: var(--muted-foreground); }
.etn-mono { font-family: var(--app-font-mono); font-size: 0.8rem; line-height: 1.36; }

/* Container & Generic Grid */
.etn-container {
  max-width: 1200px;
  width: 100%;
  margin-inline: auto;
  padding-inline: 24px;
}
.etn-grid { display: grid; gap: 16px; }

/* Cards */
.etn-card {
  background: var(--card);
  color: var(--card-foreground);
  border-radius: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
}

/* Buttons */
.etn-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 8px;
  font-family: var(--app-font-ui);
  font-size: 0.915rem;
  font-weight: 500;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.etn-btn:hover:not(:disabled) {
  background: var(--secondary);
  border-color: color-mix(in oklab, var(--primary) 30%, var(--border));
}
.etn-btn:active:not(:disabled) {
  background: var(--muted);
}
.etn-btn:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 25%, transparent);
}
.etn-btn:disabled,
.etn-btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.etn-btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}
.etn-btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--primary-foreground);
}
.etn-btn-primary:active:not(:disabled) {
  background: var(--primary-active);
  border-color: var(--primary-active);
}
.etn-btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-color: var(--border);
}
.etn-btn-secondary:hover:not(:disabled) {
  background: var(--primary-subtle);
  color: var(--selected-fg);
  border-color: var(--primary-subtle-border);
}
.etn-btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary-subtle-border);
}
.etn-btn-outline:hover:not(:disabled) {
  background: var(--primary-subtle);
  border-color: var(--primary);
}
.etn-btn-ghost {
  background: transparent;
  border-color: transparent;
}
.etn-btn-ghost:hover:not(:disabled) {
  background: var(--secondary);
  border-color: transparent;
}
.etn-btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }

/* Pills & Semantic Badges */
.etn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 26px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--foreground);
}
.etn-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 17px;
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--secondary-foreground);
  white-space: nowrap;
}
.etn-badge-primary,
.etn-pill-primary {
  background: var(--primary-subtle);
  color: var(--selected-fg);
  border-color: var(--primary-subtle-border);
}
.etn-badge-success,
.etn-pill-success {
  background: var(--success-subtle);
  color: var(--success);
  border-color: var(--success-border);
}
.etn-badge-warn {
  background: var(--warning-subtle);
  color: var(--warning);
  border-color: var(--warning-border);
}
.etn-badge-danger,
.etn-pill-danger {
  background: var(--destructive-subtle);
  color: var(--destructive);
  border-color: var(--destructive-border);
}
.etn-badge-info {
  background: var(--info-subtle);
  color: var(--info);
  border-color: var(--info-border);
}
.etn-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 0 color-mix(in oklab, var(--primary) 60%, transparent);
  animation: etn-pulse-ring 2s infinite;
}
.etn-pill-success .etn-live-dot {
  background: var(--success);
  box-shadow: 0 0 0 0 color-mix(in oklab, var(--success) 60%, transparent);
}
@keyframes etn-pulse-ring {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--primary) 55%, transparent); }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* App Shell */
.etn-shell {
  display: flex;
  min-height: 100vh;
  background: var(--background);
}
.etn-sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  border-inline-end: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 16px;
  transition: width 0.2s ease;
}
.etn-sidebar.is-collapsed { width: 72px; }
.etn-sidebar.is-collapsed .etn-nav-label,
.etn-sidebar.is-collapsed .etn-brand-text,
.etn-sidebar.is-collapsed .etn-sidebar-footer-card { display: none; }
.etn-sidebar.is-collapsed .etn-brand,
.etn-sidebar.is-collapsed .etn-nav-item { justify-content: center; }

.etn-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.4px;
}
.etn-brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--sidebar-primary);
  color: var(--sidebar-primary-foreground);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.etn-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.etn-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.93rem;
  font-weight: 500;
  color: var(--muted-foreground);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.etn-nav-item:hover {
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
}
.etn-nav-item.active {
  background: var(--selected-bg);
  color: var(--selected-fg);
  border-color: var(--selected-border);
  font-weight: 600;
}
.etn-nav-item:focus-visible {
  outline: 2px solid var(--sidebar-ring);
  outline-offset: -2px;
}
.etn-nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.etn-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.etn-topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.etn-topbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.etn-content {
  padding: 24px;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Hero Header */
.etn-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.etn-hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Grid & KPI */
.etn-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.etn-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.etn-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
@media (max-width: 1024px) {
  .etn-grid-4, .etn-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .etn-grid-4, .etn-grid-3, .etn-grid-2 { grid-template-columns: 1fr; }
  .etn-sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 60;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
  }
  [dir="rtl"] .etn-sidebar { transform: translateX(100%); }
  .etn-sidebar.is-open { transform: translateX(0); }
  .etn-topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
    height: auto;
    min-height: 56px;
  }
  .etn-content { padding: 14px; }
  .etn-container { padding-inline: 14px; }
  .etn-btn, .etn-nav-item, .etn-popover-item, .etn-segmented-btn { min-height: 44px; }
  .etn-popover-panel { max-width: calc(100vw - 24px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.etn-kpi-label { font-size: 0.915rem; color: var(--muted-foreground); font-weight: 500; }
.etn-kpi-value { font-size: 1.85rem; font-weight: 600; letter-spacing: -0.5px; margin: 6px 0 8px; }
.etn-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--secondary);
  overflow: hidden;
}
.etn-progress-bar { height: 100%; border-radius: 999px; background: var(--chart-1); }

/* Tables */
.etn-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.etn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.915rem;
}
.etn-table th {
  text-align: start;
  font-weight: 600;
  color: var(--muted-foreground);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.86rem;
}
.etn-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.etn-table tbody tr:hover { background: color-mix(in oklab, var(--primary-subtle) 55%, var(--muted)); }
.etn-table tbody tr.is-selected,
.etn-table tbody tr[aria-selected="true"] {
  background: var(--selected-bg);
  color: var(--selected-fg);
}
.etn-table tbody tr:last-child td { border-bottom: none; }

/* Popover / Dropdown */
.etn-popover-wrap { position: relative; display: inline-block; }
.etn-popover-panel {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  min-width: 220px;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--card-shadow), 0 10px 25px -5px rgba(0, 0, 0, 0.12);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.etn-popover-panel[hidden] { display: none; }
.etn-popover-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--foreground);
  font-family: var(--app-font-ui);
  font-size: 12.8px;
  cursor: pointer;
  text-align: start;
  width: 100%;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.etn-popover-item:hover { background: var(--secondary); }
.etn-popover-item.active {
  background: var(--selected-bg);
  color: var(--selected-fg);
  border-color: var(--selected-border);
  font-weight: 600;
}

/* Forms, Controls & Validation */
.etn-label {
  display: block;
  font-size: 0.89rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 5px;
}
.etn-input, .etn-select, .etn-textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--input);
  background: var(--card);
  color: var(--foreground);
  font-family: var(--app-font-ui);
  font-size: 0.93rem;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.etn-input:hover:not(:disabled):not([readonly]):not(:focus),
.etn-select:hover:not(:disabled):not([readonly]):not(:focus),
.etn-textarea:hover:not(:disabled):not([readonly]):not(:focus) {
  border-color: color-mix(in oklab, var(--primary) 40%, var(--input));
}
.etn-input:focus, .etn-select:focus, .etn-textarea:focus,
.etn-input:focus-visible, .etn-select:focus-visible, .etn-textarea:focus-visible {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 22%, transparent);
}
.etn-input:disabled, .etn-select:disabled, .etn-textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--muted);
}
.etn-input[readonly], .etn-textarea[readonly] {
  background: var(--muted);
  color: var(--muted-foreground);
  cursor: default;
}
.etn-input.is-invalid, .etn-select.is-invalid, .etn-textarea.is-invalid,
.etn-input[aria-invalid="true"], .etn-select[aria-invalid="true"], .etn-textarea[aria-invalid="true"] {
  border-color: var(--destructive) !important;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--destructive) 18%, transparent) !important;
}
.etn-input.is-valid, .etn-select.is-valid, .etn-textarea.is-valid {
  border-color: var(--success);
}
input[type="checkbox"],
input[type="radio"],
input[type="range"] {
  accent-color: var(--primary);
}
.etn-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground);
}
.etn-switch input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.etn-field-feedback,
[data-valmsg-for],
.etn-valmsg {
  display: block;
  font-size: 12px;
  color: var(--destructive);
  margin-top: 4px;
  min-height: 16px;
}

/* Unified Appearance Settings Group & 3-Option Segmented Rows */
.etn-settings-group { display: flex; flex-direction: column; gap: 6px; }
.etn-settings-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted-foreground);
  padding: 2px 4px;
}
.etn-settings-options { display: flex; flex-direction: column; gap: 2px; }
.etn-segmented-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.etn-segmented-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--muted-foreground);
  font-family: var(--app-font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.etn-segmented-btn:hover {
  background: var(--card);
  color: var(--foreground);
  border-color: color-mix(in oklab, var(--primary) 35%, var(--border));
}
.etn-segmented-btn.active {
  background: var(--selected-bg);
  color: var(--selected-fg);
  border-color: var(--selected-border);
}

/* Reconnect / Rejoin panel (Blazor circuit UI) */
#components-reconnect-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  transition: opacity 0.3s ease, display 0.6s allow-discrete;
}
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-retrying,
#components-reconnect-modal.components-reconnect-paused,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-resume-failed,
#components-reconnect-modal.components-reconnect-rejected {
  display: flex;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.rc-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(15, 10, 30, 0.32), rgba(9, 9, 11, 0.68));
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
}
.rc-panel {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  padding: 2.25rem 2rem 2rem;
  border-radius: 1.5rem;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--card) 92%, transparent);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  box-shadow: var(--card-shadow), 0 20px 50px -12px rgba(0, 0, 0, 0.25);
  text-align: center;
}
.rc-orb { position: relative; width: 104px; height: 104px; margin: 0 auto 1.5rem; }
.rc-ring {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 2px solid color-mix(in oklab, var(--primary) 45%, transparent);
  animation: rc-pulse 2.7s cubic-bezier(0.2, 0.6, 0.35, 1) infinite;
}
.rc-ring-2 { animation-delay: 0.9s; }
.rc-ring-3 { animation-delay: 1.8s; }
@keyframes rc-pulse {
  0%   { transform: scale(0.5); opacity: 0.9; }
  75%  { opacity: 0.15; }
  100% { transform: scale(1.15); opacity: 0; }
}
.rc-core {
  position: absolute;
  inset: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: color-mix(in oklab, var(--primary) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--primary) 30%, transparent);
  color: var(--primary);
  animation: rc-float 3.2s ease-in-out infinite;
}
@keyframes rc-float {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -4px; }
}
#components-reconnect-modal.components-reconnect-failed .rc-core,
#components-reconnect-modal.components-reconnect-resume-failed .rc-core,
#components-reconnect-modal.components-reconnect-rejected .rc-core {
  background: color-mix(in oklab, var(--destructive) 12%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--destructive) 30%, transparent);
  color: var(--destructive);
}
#components-reconnect-modal.components-reconnect-failed .rc-ring,
#components-reconnect-modal.components-reconnect-resume-failed .rc-ring,
#components-reconnect-modal.components-reconnect-rejected .rc-ring {
  border-color: color-mix(in oklab, var(--destructive) 45%, transparent);
}
.rc-state { display: none; }
#components-reconnect-modal.components-reconnect-show .rc-connecting,
#components-reconnect-modal.components-reconnect-retrying .rc-connecting,
#components-reconnect-modal.components-reconnect-paused .rc-paused,
#components-reconnect-modal.components-reconnect-failed .rc-failed,
#components-reconnect-modal.components-reconnect-resume-failed .rc-failed,
#components-reconnect-modal.components-reconnect-rejected .rc-rejected {
  display: block;
}
.rc-title { font-size: 1.15rem; font-weight: 700; color: var(--foreground); margin: 0 0 0.4rem; }
.rc-sub { font-size: 0.875rem; color: var(--muted-foreground); line-height: 1.55; margin: 0 auto 1rem; max-width: 36ch; }
.rc-dots { display: inline-flex; gap: 2px; margin-inline-start: 2px; }
.rc-dots span { animation: rc-dot 1.4s ease-in-out infinite; font-weight: 700; }
.rc-dots span:nth-child(2) { animation-delay: 0.2s; }
.rc-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes rc-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-4px); opacity: 1; }
}
.rc-meta { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; color: var(--muted-foreground); margin: 0 0 1rem; flex-wrap: wrap; }
.rc-badge { font-family: var(--app-font-mono); font-weight: 600; color: var(--foreground); background: var(--secondary); padding: 2px 7px; border-radius: 6px; border: 1px solid var(--border); }
.rc-progress { height: 4px; border-radius: 999px; background: var(--secondary); overflow: hidden; }
.rc-progress span { display: block; height: 100%; width: 40%; background: var(--primary); border-radius: 999px; animation: rc-sweep 1.5s ease-in-out infinite; }
@keyframes rc-sweep {
  0%   { translate: -100% 0; }
  100% { translate: 350% 0; }
}
.rc-actions { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 1rem; }
html[dir="ltr"] .rc-ar { display: none; }
html[dir="rtl"] .rc-en { display: none; }

/* RTL Technical Isolation & Enterprise Layout Utilities */
.etn-mono, code, pre {
  direction: ltr;
  unicode-bidi: isolate;
}
.etn-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted-foreground);
  margin-bottom: 6px;
}
.etn-breadcrumb a {
  color: var(--muted-foreground);
  text-decoration: none;
}
.etn-breadcrumb a:hover { color: var(--primary); }
.etn-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}
.etn-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 16px;
}
.etn-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.96rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.etn-tab:hover:not(.active) {
  background: var(--secondary);
  color: var(--foreground);
}
.etn-tab.active {
  background: var(--selected-bg);
  color: var(--selected-fg);
  border-color: var(--selected-border);
  font-weight: 600;
}
.etn-tab:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
.etn-tab-panel[hidden] { display: none !important; }
.etn-split-workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.etn-split-pane {
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}
@media (max-width: 900px) {
  .etn-split-workspace { grid-template-columns: 1fr; }
  .etn-split-pane { max-height: none; }
}
.etn-collapsible-card { padding: 0; overflow: hidden; }
.etn-collapsible-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: transparent;
  border: none;
  color: inherit;
  text-align: start;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.etn-collapsible-header:hover { background: var(--secondary); }
.etn-collapsible-header[aria-expanded="true"] {
  background: color-mix(in oklab, var(--primary-subtle) 45%, var(--card));
}
.etn-collapsible-body { padding: 14px 18px 18px; border-top: 1px solid var(--border); }
.etn-collapsible-body[hidden] { display: none; }
.etn-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  gap: 8px;
}
.etn-skeleton {
  height: 16px;
  border-radius: 6px;
  background: var(--muted);
  animation: etn-pulse 1.5s ease-in-out infinite;
}
@keyframes etn-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.etn-sticky-bar {
  position: sticky;
  bottom: 12px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow), 0 8px 20px rgba(0, 0, 0, 0.08);
}
.etn-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  justify-content: flex-end;
}
.etn-sheet {
  width: min(520px, 100vw);
  height: 100%;
  background: var(--card);
  color: var(--card-foreground);
  border-inline-start: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.etn-toast {
  position: fixed;
  bottom: 18px;
  inset-inline-end: 18px;
  z-index: 80;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--primary);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.14);
}
