/* ============================================================================
 * KODER OS – KODER INDUSTRIAL GLASS DESIGN SYSTEM
 * Dual Navigation (64px Workspace Rail + Dynamic Panel), Liquid Glass,
 * Workspace Tabs, App Launcher, Focus Mode, Figma-Style Document Studio
 * ============================================================================ */

:root {
  --ig-rail-w: 64px;
  --ig-panel-w: 224px;
  --ig-topbar-h: 48px;
  --ig-tabs-h: 34px;
  --ig-radius: 8px;
  --ig-glass-blur: blur(16px);
  --ig-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* --- KODER Industrial Glass Dark Mode --- */
body.theme-dark {
  color-scheme: dark;
  --bg-app: #111315;
  --bg-nav: #17191B;
  --bg-sidebar: #17191B;
  --bg-surface: #1C1F21;
  --bg-muted: #1A1D1F;
  --bg-card: #222527;
  --bg-card-hover: #2B2E31;
  --border: #373B3E;
  --border-subtle: #2B2F32;
  --border-light: #303538;
  --border-medium: #42474A;
  --border-focus: #C5C9CB;
  --primary: #D7DADB;
  --primary-hover: #E8EAEB;
  --primary-subtle: rgba(226, 230, 232, 0.09);
  --primary-light: rgba(226, 230, 232, 0.12);
  --primary-border: rgba(226, 230, 232, 0.22);
  --text-main: #F0F1F1;
  --text-muted: #ADB2B5;
  --text-subtle: #858B8F;
  --text-sidebar: #ADB2B5;
  --text-sidebar-active: #F7F8F8;
  --ig-glass-bg: rgba(23, 25, 27, 0.94);
  --ig-glass-border: rgba(255, 255, 255, 0.08);
  --ig-shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
  background: var(--bg-app);
  color: var(--text-main);
}

/* --- KODER Industrial Glass Light Mode --- */
body.theme-light {
  --bg-app: #F1F5F9;
  --bg-nav: #FFFFFF;
  --bg-surface: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-card-hover: #EEF2F7;
  --border: #CBD5E1;
  --border-subtle: #E2E8F0;
  --primary: #404040;
  --primary-hover: #171717;
  --primary-subtle: rgba(23, 23, 23, 0.06);
  --primary-border: rgba(23, 23, 23, 0.18);
  --text-main: #0F172A;
  --text-muted: #475569;
  --text-subtle: #64748B;
  --ig-glass-bg: rgba(255, 255, 255, 0.84);
  --ig-glass-border: rgba(15, 23, 42, 0.08);
  --ig-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
}

/* Shell Frame: Rail + Dynamic Subpanel + Main Container */
body {
  display: flex !important;
  flex-direction: row !important;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--text-main);
}

/* 1. PRIMARY WORKSPACE RAIL (64px) */
.ig-rail {
  width: var(--ig-rail-w);
  min-width: var(--ig-rail-w);
  height: 100vh;
  background: var(--bg-nav);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 4px;
  z-index: 60;
  user-select: none;
  flex-shrink: 0;
}

.ig-rail-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #555B63 0%, #292D33 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-bottom: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.24);
  transition: transform 0.16s var(--ig-ease), box-shadow 0.16s var(--ig-ease);
}
.ig-rail-logo:hover {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.32);
}

.ig-rail-scroll {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 0;
}

.ig-rail-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.16s var(--ig-ease);
}
.ig-rail-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  transform: translateY(-1px);
}
.ig-rail-btn.active {
  background: var(--primary-subtle);
  color: var(--ws-accent, var(--primary));
  border-color: var(--primary-border);
  box-shadow: 0 0 14px rgba(0, 0, 0, 0.12);
}
.ig-rail-btn.status-pill-online { color: var(--success); }
.ig-rail-btn.status-pill-offline { color: var(--danger); }
.ig-rail-btn.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--ws-accent, var(--primary));
}
.ig-rail-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
}
.ig-rail-badge.visible {
  display: inline-flex;
}

.ig-rail-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
  width: 100%;
}
.ig-rail-actions-menu[hidden] { display: none; }
.ig-rail-actions-menu {
  position: fixed;
  z-index: 120;
  left: calc(var(--ig-rail-w) + 10px);
  bottom: 12px;
  display: flex;
  width: min(272px, calc(100vw - var(--ig-rail-w) - 24px));
  max-height: min(76vh, 540px);
  flex-direction: column;
  gap: 3px;
  overflow: auto;
  padding: 7px;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .38);
}
.ig-rail-actions-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}
.ig-rail-actions-menu button:hover,
.ig-rail-actions-menu button:focus-visible { background: var(--bg-card-hover); outline: 0; }
.ig-rail-actions-menu button:focus-visible { box-shadow: inset 0 0 0 1px var(--primary-border); }
.ig-rail-actions-menu button.btn-primary { color: var(--text-main); background: var(--primary-subtle); border-color: transparent; }
.ig-rail-actions-menu button > svg { width: 17px; height: 17px; flex: 0 0 auto; color: var(--text-muted); }
.ig-rail-actions-menu button > span { flex: 1; font-size: 12.5px; }
.ig-rail-actions-menu .ig-rail-actions-logout { margin-top: 4px; border-top: 1px solid var(--border-subtle); border-radius: 0 0 7px 7px; color: var(--danger, #ef4444); }
.ig-rail-actions-menu .ig-rail-actions-logout > svg { color: inherit; }

/* 2. DYNAMIC WORKSPACE PANEL */
.ig-subpanel {
  width: var(--ig-panel-w);
  min-width: 170px;
  max-width: 340px;
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: width 0.18s var(--ig-ease), opacity 0.18s var(--ig-ease);
  flex-shrink: 0;
  overflow: hidden;
}
body.ig-panel-hidden .ig-subpanel,
body.ig-panel-hidden .ig-resizer,
body.focus-mode .ig-subpanel,
body.focus-mode .ig-resizer {
  width: 0 !important;
  min-width: 0 !important;
  opacity: 0;
  pointer-events: none;
  border: none !important;
}

.ig-subpanel-header {
  height: var(--ig-topbar-h);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.ig-subpanel-title {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ig-subpanel-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ig-nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.12s ease;
}
.ig-nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}
.ig-nav-item.active {
  background: var(--primary-subtle);
  color: var(--primary);
  border-color: var(--primary-border);
  font-weight: 600;
}
.ig-nav-item-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--primary-subtle);
  color: var(--primary);
}

.ig-resizer {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  z-index: 55;
  transition: background 0.12s;
}
.ig-resizer:hover, .ig-resizer.active {
  background: var(--primary);
}

/* 3. MAIN CONTAINER + TOPBAR + WORKSPACE TABS */
.app-container {
  flex: 1;
  min-width: 0;
  margin-left: 0 !important;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ig-topbar {
  height: var(--ig-topbar-h);
  min-height: var(--ig-topbar-h);
  padding: 0 14px;
  background: var(--ig-glass-bg);
  backdrop-filter: var(--ig-glass-blur);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 40;
}

.ig-topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.global-search-backdrop[hidden],
.global-search-panel[hidden] { display: none; }
.global-search-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9990;
  background: rgba(0, 0, 0, .44);
  backdrop-filter: blur(2px);
}
.global-search-panel {
  position: fixed;
  z-index: 9991;
  top: 12px;
  left: max(20px, calc(var(--ig-rail-w) + var(--ig-panel-w) + 18px));
  right: 24px;
  width: min(760px, calc(100vw - var(--ig-rail-w) - var(--ig-panel-w) - 42px));
  max-height: min(76vh, 680px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .4);
}
.global-search-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 17px 18px 12px;
}
.global-search-heading > div { display: grid; gap: 3px; }
.global-search-heading strong { font-size: 15px; }
.global-search-heading span { color: var(--text-muted); font-size: 12px; }
.global-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin: 0 16px 12px;
  padding: 0 13px;
  color: var(--text-muted);
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.global-search-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}
.global-search-input-wrap > svg { width: 17px; height: 17px; flex: 0 0 auto; }
.global-search-input-wrap input {
  flex: 1;
  min-width: 0;
  height: 44px;
  color: var(--text-main);
  background: transparent;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: 14px;
}
.global-search-input-wrap input::placeholder { color: var(--text-subtle); }
.global-search-enter-hint {
  padding: 3px 7px;
  color: var(--text-subtle);
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 10px;
}
.global-search-results {
  min-height: 88px;
  overflow: auto;
  padding: 0 10px 10px;
}
.global-search-empty {
  display: flex;
  min-height: 88px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
}
.global-search-empty svg { width: 22px; height: 22px; color: var(--text-subtle); }
.global-search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 11px 10px;
  color: var(--text-main);
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 7px;
  cursor: pointer;
}
.global-search-result:hover,
.global-search-result:focus-within { background: var(--bg-card-hover); }
.global-search-result-main {
  display: block;
  min-width: 0;
  flex: 1;
  padding: 0;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.global-search-result-main:focus-visible,
.global-search-result-actions button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.global-search-result-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.global-search-result-title strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.global-search-result-subtitle { display: block; margin-top: 4px; overflow: hidden; color: var(--text-muted); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.global-search-result-actions { display: flex; flex: 0 0 auto; gap: 4px; }
.global-search-result-actions button { width: 32px; height: 32px; }
.global-search-status { padding: 14px 12px; color: var(--text-muted); font-size: 12px; text-align: center; }

.ig-topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ig-icon-btn {
  width: 30px !important;
  height: 30px !important;
  min-height: 30px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 7px !important;
}

.ig-status-dot-wrap {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ig-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.7);
}
.status-pill-offline .ig-status-dot {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.7);
}

/* Clean KPI Card Icon Alignment (CSS Grid: icon left, label/value/sub stacked right) */
.kpi-card {
  display: grid !important;
  grid-template-columns: 38px minmax(0, 1fr) !important;
  column-gap: 12px !important;
  row-gap: 2px !important;
  align-items: center !important;
  padding: 12px 14px !important;
  min-height: 76px !important;
  text-align: left !important;
}
.kpi-card:not(:has(.kpi-icon)) {
  grid-template-columns: minmax(0, 1fr) !important;
}
.kpi-card .kpi-icon {
  position: static !important;
  grid-column: 1 !important;
  grid-row: 1 / span 3 !important;
  width: 38px !important;
  height: 38px !important;
  border-radius: 9px !important;
  background: var(--primary-subtle) !important;
  color: var(--primary) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.kpi-card .kpi-label,
.kpi-card .kpi-value,
.kpi-card .kpi-sub {
  grid-column: 2 !important;
  min-width: 0;
}
.kpi-card:not(:has(.kpi-icon)) .kpi-label,
.kpi-card:not(:has(.kpi-icon)) .kpi-value,
.kpi-card:not(:has(.kpi-icon)) .kpi-sub {
  grid-column: 1 !important;
}

/* Workspace Tabs Bar */
.ig-tabs-bar {
  height: var(--ig-tabs-h);
  min-height: var(--ig-tabs-h);
  padding: 0 10px;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  flex-shrink: 0;
}
.ig-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 8px 0 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  max-width: 190px;
}
.ig-tab:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}
.ig-tab.active {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border);
  font-weight: 600;
}
.ig-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  opacity: 0.6;
}
.ig-tab-close:hover {
  opacity: 1;
  background: rgba(239, 68, 68, 0.16);
  color: #ef4444;
}

.content-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* 4. LIQUID GLASS APP LAUNCHER & COMMAND PALETTE OVERLAYS */
.ig-overlay {
  position: fixed;
  inset: 0;
  z-index: 10080;
  background: rgba(8, 11, 17, 0.68);
  backdrop-filter: blur(18px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 7vh 16px 24px;
}
.ig-overlay.open {
  display: flex;
  animation: igFadeIn 0.14s var(--ig-ease);
}
@keyframes igFadeIn {
  from { opacity: 0; transform: scale(0.985); }
  to { opacity: 1; transform: scale(1); }
}

.ig-launcher-box {
  width: min(980px, 95vw);
  max-height: 84vh;
  background: var(--ig-glass-bg);
  backdrop-filter: blur(22px);
  border: 1px solid var(--ig-glass-border);
  border-radius: 14px;
  box-shadow: var(--ig-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text-main);
}
.ig-launcher-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.ig-launcher-head input {
  flex: 1;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  font-size: 14.5px;
  color: var(--text-main);
}
.ig-launcher-body {
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ig-launcher-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.ig-app-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: transform 0.14s var(--ig-ease), border-color 0.14s ease, box-shadow 0.14s ease;
}
.ig-app-tile:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.16);
}
.ig-app-svg {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

/* Command Palette (Raycast/Linear) */
.ig-cmd-box {
  width: min(680px, 94vw);
  max-height: 76vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--ig-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text-main);
}

/* Responsive Tablet / Small Screens */
@media (max-width: 900px) {
  .ig-subpanel {
    position: fixed;
    left: var(--ig-rail-w);
    top: 0;
    box-shadow: var(--ig-shadow);
  }
  .global-search-panel {
    top: calc(58px + env(safe-area-inset-top));
    left: 10px;
    right: 10px;
    width: auto;
    max-height: calc(78vh - env(safe-area-inset-top));
  }
  .ig-rail-actions-menu { display: none !important; }
  .global-search-heading { padding: 14px 14px 10px; }
  .global-search-input-wrap { margin: 0 12px 10px; }
  .global-search-result { align-items: flex-start; }
  .ig-topbar-right .btn span {
    display: none;
  }
}

/* Unified neutral graphite dark theme */
body.theme-dark .ig-rail,
body.theme-dark .ig-subpanel,
body.theme-dark .app-container,
body.theme-dark .content-body,
body.theme-dark .view-section {
  background-color: var(--bg-app);
  color: var(--text-main);
}
body.theme-dark .ig-rail,
body.theme-dark .ig-subpanel {
  background-color: var(--bg-nav);
  border-color: var(--border-subtle);
}
body.theme-dark .ig-subpanel-header,
body.theme-dark .ig-subpanel > div[style*="border-top"] {
  border-color: var(--border-subtle) !important;
}
body.theme-dark .ig-nav-item.active,
body.theme-dark .nav-item.active,
body.theme-dark .sub-nav-pill.active {
  color: var(--text-main) !important;
  background: var(--primary-subtle) !important;
  border-color: var(--primary-border) !important;
}
body.theme-dark .btn-primary,
body.theme-dark .app-header .btn-primary {
  color: #181A1B !important;
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  box-shadow: none !important;
}
body.theme-dark .btn-primary:hover,
body.theme-dark .app-header .btn-primary:hover {
  color: #111315 !important;
  background: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
}
body.theme-dark .btn-secondary {
  color: var(--text-main) !important;
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  box-shadow: none !important;
}
body.theme-dark .btn-secondary:hover {
  background: var(--bg-card-hover) !important;
  border-color: var(--border-medium) !important;
}
body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea,
body.theme-dark .form-input,
body.theme-dark .form-select,
body.theme-dark input.form-control,
body.theme-dark select.form-control {
  color: var(--text-main) !important;
  background-color: var(--bg-surface) !important;
  border-color: var(--border) !important;
  color-scheme: dark;
}
body.theme-dark input::placeholder,
body.theme-dark textarea::placeholder { color: var(--text-subtle) !important; }
body.theme-dark input:focus,
body.theme-dark select:focus,
body.theme-dark textarea:focus,
body.theme-dark .form-input:focus,
body.theme-dark .form-select:focus {
  border-color: var(--border-focus) !important;
  box-shadow: 0 0 0 3px var(--primary-subtle) !important;
  outline: 0;
}
body.theme-dark option { color: var(--text-main); background: var(--bg-surface); }
body.theme-dark .panel,
body.theme-dark .card,
body.theme-dark .kpi-card,
body.theme-dark .modal-content,
body.theme-dark .table-container,
body.theme-dark .global-search-panel,
body.theme-dark .ig-rail-actions-menu {
  color: var(--text-main);
  background-color: var(--bg-card);
  border-color: var(--border);
}
body.theme-dark .tab-sublinks-bar {
  background: var(--bg-nav) !important;
  border-color: var(--border-subtle) !important;
}
body.theme-dark .tab-sublink {
  color: var(--text-muted) !important;
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
}
body.theme-dark .tab-sublink:hover {
  color: var(--text-main) !important;
  background: var(--bg-card-hover) !important;
  border-color: var(--border-medium) !important;
}
body.theme-dark .tab-sublink.active {
  color: #181A1B !important;
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  box-shadow: none !important;
}
body.theme-dark .panel-header,
body.theme-dark .table-toolbar,
body.theme-dark .modal-header,
body.theme-dark .modal-footer {
  color: var(--text-main) !important;
  background: var(--bg-surface) !important;
  border-color: var(--border-subtle) !important;
}
body.theme-dark table,
body.theme-dark th,
body.theme-dark td { border-color: var(--border-subtle) !important; }
body.theme-dark thead th,
body.theme-dark .data-table th {
  color: var(--text-muted) !important;
  background: var(--bg-surface) !important;
  border-color: var(--border-subtle) !important;
}
body.theme-dark .data-table td {
  color: var(--text-main) !important;
  background: var(--bg-card) !important;
  border-color: var(--border-subtle) !important;
}
body.theme-dark .data-table tbody tr:nth-child(even) td { background: #25282A !important; }
body.theme-dark .data-table tbody tr:hover td,
body.theme-dark tbody tr:hover { background: var(--bg-card-hover) !important; }
body.theme-dark .kpi-card:hover { background: var(--bg-card-hover) !important; border-color: var(--border-medium) !important; box-shadow: var(--ig-shadow) !important; }
body.theme-dark .kpi-icon { color: var(--text-main); background: var(--bg-surface); border-color: var(--border); }
body.theme-dark .badge-neutral,
body.theme-dark .badge-secondary { color: var(--text-muted) !important; background: var(--bg-surface) !important; border-color: var(--border) !important; }
body.theme-dark .mail-folders-pane,
body.theme-dark .mail-list-pane,
body.theme-dark .mail-items-scroll,
body.theme-dark .mail-view-pane,
body.theme-dark .mail-view-header,
body.theme-dark .mail-list-search,
body.theme-dark .mail-attachment-card,
body.theme-dark .mail-load-more {
  color: var(--text-main) !important;
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
}
body.theme-dark .mail-list-filters select,
body.theme-dark .mail-mobile-tab {
  color: var(--text-main) !important;
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
}
body.theme-dark .mail-mobile-tab.active { background: var(--bg-card-hover) !important; color: var(--text-main) !important; }
body.theme-dark ::selection { color: #111315; background: #D7DADB; }
body.theme-dark :focus-visible { outline-color: var(--border-focus); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
