/* ═══════════════════════════════════════════════════════════════════════════
   Saconis RAG  –  Teal Design System  (v2)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. DESIGN TOKENS ──────────────────────────────────────────────────── */
:root {
/*noinspection CssUnusedSymbol*/
  /* Brand palette */
  --brand-900: #0C4A6E;
  --brand-800: #075985;
  --brand-700: #0369A1;
  --brand-600: #0E7490;
  --brand-500: #0891B2;
  --brand-400: #06B6D4;
  --brand-300: #22D3EE;
  --brand-200: #67E8F9;
  --brand-100: #E0F2FE;

  /* Surfaces */
  --bg:          #EFF6FF;
  --surf:        #ffffff;
  --surf-h:      rgba(8,145,178,.05);
  --surf-raised: #F0F9FF;
  --surf-inset:  #F8FAFC;
  --glass:       rgba(255,255,255,.75);

  /* Borders */
  --border:       rgba(8,145,178,.13);
  --border-h:     rgba(8,145,178,.38);
  --border-glass: rgba(255,255,255,.85);

  /* Text */
  --text:   #0F172A;
  --text-2: #164E63;
  --muted:  #64748B;

  /* Semantic */
  --primary:      #0891B2;
  --primary-2:    #22D3EE;
  --primary-glow: rgba(8,145,178,.22);
  --cyan:         #0891b2;
  --good:         #059669;
  --bad:          #dc2626;
  --err:          #ef4444;
  --red:          #ef4444;
  --green:        #16a34a;
  --warn:         #f59e0b;
  --bg-2:         #f1f5f9;
  --mono:         ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Shadows — layered for realism */
  --shadow-xs: 0 1px 3px rgba(8,145,178,.07);
  --shadow-sm: 0 1px 4px rgba(8,145,178,.08),
               0 4px 12px rgba(8,145,178,.07);
  --shadow:    0 1px 2px rgba(8,145,178,.06),
               0 4px 12px rgba(8,145,178,.09),
               0 16px 40px rgba(8,145,178,.08);
  --shadow-lg: 0 2px 4px rgba(8,145,178,.07),
               0 8px 24px rgba(8,145,178,.12),
               0 32px 64px rgba(8,145,178,.10);
  --glow:      0 0 0 1px rgba(8,145,178,.18),
               0 4px 20px rgba(8,145,178,.22),
               0 16px 48px rgba(8,145,178,.12);

  /* Layout */
  --topbar-h: 64px;
  --sidebar-w: 244px;

  /* Radii */
  --r-xs: 6px;
  --r-sm: 9px;
  --r:    14px;
  --r2:   12px;
  --r-lg: 20px;
  --r-xl: 28px;

  /* Easing */
  --ease:        cubic-bezier(.4,0,.2,1);
  --ease-out:    cubic-bezier(0,0,.2,1);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --t:           all .2s var(--ease);
  --t-slow:      all .38s var(--ease);

  /* Misc */
  --dot:        rgba(8,145,178,.045);
  --sidebar-bg: #EFF6FF;
  --sidebar-footer-bg: rgba(255,255,255,.60);
}

/* ── Dark tokens ────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  color-scheme: dark;

  --bg:          #060F1E;
  --surf:        #0D1829;
  --surf-h:      rgba(103,232,249,.08);
  --surf-raised: #122332;
  --surf-inset:  #1E293B;
  --glass:       rgba(15,12,30,.80);

  --border:       rgba(103,232,249,.11);
  --border-h:     rgba(103,232,249,.38);
  --border-glass: rgba(103,232,249,.14);

  --text:   #F1F5F9;
  --text-2: #67E8F9;
  --muted:  #B0BCC8;  /* bumped from #94A3B8 — better contrast on dark surfaces */

  --primary:      #22D3EE;
  --primary-2:    #67E8F9;
  --primary-glow: rgba(103,232,249,.22);

  --err:   #f87171;
  --red:   #f87171;
  --green: #4ade80;
  --warn:  #fbbf24;
  --bg-2:  #1E293B;
  --cyan:         #22d3ee;
  --good:         #34d399;
  --bad:          #f87171;

  --shadow-xs: 0 1px 3px rgba(0,0,0,.40);
  --shadow-sm: 0 1px 4px rgba(0,0,0,.45),
               0 4px 12px rgba(0,0,0,.35);
  --shadow:    0 1px 2px rgba(0,0,0,.45),
               0 4px 12px rgba(0,0,0,.40),
               0 16px 40px rgba(0,0,0,.35);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.50),
               0 8px 24px rgba(0,0,0,.45),
               0 32px 64px rgba(0,0,0,.40);
  --glow:      0 0 0 1px rgba(103,232,249,.18),
               0 4px 20px rgba(103,232,249,.18),
               0 16px 48px rgba(103,232,249,.10);

  --dot:        rgba(103,232,249,.04);
  --sidebar-bg: #0F172A;
  --sidebar-footer-bg: rgba(255,255,255,.03);
}

/* ── 2. RESET + BASE ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ── Aurora / background decoration ── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 100% 60% at 60% -10%,
      rgba(8,145,178,.12) 0%, transparent 65%),
    radial-gradient(ellipse 60% 40% at -10% 30%,
      rgba(8,145,178,.08) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 110% 70%,
      rgba(8,145,178,.07) 0%, transparent 55%);
}
body::after {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: .8;
}

[data-theme="dark"] body::before {
  background:
    radial-gradient(ellipse 100% 55% at 60% -5%,
      rgba(8,145,178,.22) 0%, transparent 60%),
    radial-gradient(ellipse 55% 40% at -5% 35%,
      rgba(8,145,178,.10) 0%, transparent 50%),
    radial-gradient(ellipse 65% 45% at 108% 72%,
      rgba(6,95,127,.18) 0%, transparent 55%);
}

.bg-mesh, .orb { display: none; }

/* ── 3. TOPBAR ──────────────────────────────────────────────────────────── */
.topbar {
  position: fixed; inset: 0 0 auto 0;
  height: var(--topbar-h); z-index: 100;
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 22px;
  /* Frosted glass with beautiful gradient */
  background: linear-gradient(105deg,
    rgba(7,32,58,.98) 0%,
    rgba(8,75,100,.97) 45%,
    rgba(8,100,130,.97) 100%);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(255,255,255,.10);
  box-shadow:
    0 1px 0 rgba(255,255,255,.07) inset,
    0 4px 32px rgba(8,85,115,.45);
}

/* Animated rainbow underline */
.topbar::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(103,232,249,.6) 20%,
    rgba(255,255,255,.8) 50%,
    rgba(34,211,238,.6) 80%,
    transparent 100%);
  animation: topbarShimmer 5s ease-in-out infinite;
}
@keyframes topbarShimmer {
  0%,100% { opacity: .6; background-position: 0 0; }
  50%      { opacity: 1;  background-position: 100% 0; }
}

.brand img {
  height: 40px;
  filter: brightness(1.15) drop-shadow(0 2px 12px rgba(0,0,0,.25));
}
/* .topbar's background is a fixed dark gradient in BOTH themes (see .topbar
   above) — it never turns light. So .brand must not inherit var(--text),
   which goes near-black in light theme and becomes unreadable against that
   permanently-dark bar. Pin it to a light color always. */
.brand { color: #E0F2FE; }
.right { display: flex; align-items: center; gap: 7px; justify-content: flex-end; min-width: 0; }

/* ── Topbar left / right flex sections ── */
/* Topbar uses grid-template-columns: 1fr auto 1fr.
   Pin left to col 1 and right to the LAST column (-1) so they always sit
   at the edges regardless of how many columns exist (responsive safe). */
.topbar-left {
  grid-column: 1;
  display: flex; align-items: center; gap: 10px;
  justify-content: flex-start; min-width: 0;
}
.topbar-right {
  grid-column: -1;
  display: flex; align-items: center; gap: 8px;
  justify-content: flex-end; min-width: 0; flex-wrap: nowrap;
}

/* Hamburger — hidden on desktop, shown in mobile media query */
.hamburger {
  display: none;
  align-items: center; justify-content: center;
  min-width: 36px; min-height: 36px;
  font-size: 18px;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--r-sm); color: #E0F2FE;
  cursor: pointer; transition: var(--t);
}
.hamburger:hover { background: rgba(255,255,255,.16); }

/* Mobile drawer "Menü x" close header — injected by JS but only meant for the
   mobile sidebar drawer. Hidden on desktop; the mobile @media re-shows it. */
.sidebar-mobile-close { display: none; }

/* ── Status indicator chip (API / connection dot) ── */
.status-indicator {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  padding: 3px 10px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  color: rgba(255,255,255,.75);
  white-space: nowrap;
}
/* .status-dot base + state classes defined further below */

/* ── Who badge (logged-in user + role pill) ── */
.who-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  padding: 3px 10px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  color: rgba(255,255,255,.85);
  white-space: nowrap;
}

/* ── Light mode overrides for topbar widgets ──
   NOTE: .topbar's background is a fixed dark gradient in both themes (see
   .topbar above — it doesn't read any --surf/--text variables). These two
   widgets only ever appear inside .topbar-right, so giving them near-black
   text here made them unreadable against that permanently-dark bar. Removed
   the dark-text override; they now keep their light-on-dark default styling
   in both themes, matching .live-clock's fix below. */

/* ── Theme toggle ── */
.theme-toggle {
  width: 36px; height: 36px; padding: 0;
  font-size: 15px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; border-radius: var(--r-sm);
}
.topbar .theme-toggle {
  background: rgba(255,255,255,.09);
  border-color: rgba(255,255,255,.18);
  color: #E0F2FE;
  -webkit-backdrop-filter: blur(4px);backdrop-filter: blur(4px);
  transition: var(--t);
}
.topbar .theme-toggle:hover {
  background: rgba(255,255,255,.20);
  border-color: rgba(255,255,255,.40);
  color: #fff;
  transform: none;
  box-shadow: none;
}

/* ── Pills ── */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 13px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.09);
  -webkit-backdrop-filter: blur(8px);backdrop-filter: blur(8px);
  font-size: 12.5px; font-weight: 500; color: #E0F2FE;
  white-space: nowrap; letter-spacing: .01em;
}
.pill .muted { color: rgba(237,233,254,.60); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ── Status dot ── */
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(248,113,113,.8); flex-shrink: 0;
  transition: var(--t);
}
.status-dot.good {
  background: #34d399;
  box-shadow:
    0 0 0 3px rgba(5,150,105,.18),
    0 0 12px rgba(5,150,105,.70);
  animation: pulseDot 2.4s ease-in-out infinite;
}
@keyframes pulseDot {
  0%,100% { box-shadow: 0 0 0 3px rgba(5,150,105,.18), 0 0 12px rgba(5,150,105,.70); }
  50%     { box-shadow: 0 0 0 6px rgba(5,150,105,.08), 0 0 22px rgba(5,150,105,.90); }
}

/* ── Badges ── */
.badge {
  font-size: 10px; font-weight: 700; letter-spacing: .10em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(255,255,255,.14); color: #E0F2FE;
  border: 1px solid rgba(255,255,255,.22);
}
.badge.admin {
  background: rgba(52,211,153,.20);
  color: #6ee7b7; border-color: rgba(52,211,153,.30);
}
[data-theme="dark"] .badge        { background: rgba(103,232,249,.14); color: var(--primary-2); border-color: rgba(103,232,249,.22); }
[data-theme="dark"] .badge.admin  { background: rgba(52,211,153,.14);  color: var(--good);      border-color: rgba(52,211,153,.28); }

/* ── 4. BUTTONS ─────────────────────────────────────────────────────────── */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 20px; border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surf); color: var(--text);
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; overflow: hidden; transition: var(--t);
  letter-spacing: .01em; white-space: nowrap;
}
.btn:hover {
  border-color: var(--border-h);
  color: var(--primary);
  background: var(--surf-h);
  box-shadow: var(--shadow-xs);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0) !important; }

/* Primary – gradient with inner highlight */
.btn.primary {
  background: linear-gradient(150deg, #0E7490 0%, #0891B2 50%, #06B6D4 100%);
  border-color: rgba(8,145,178,.40); color: #fff;
  box-shadow: 0 2px 8px rgba(8,145,178,.30),
              0 1px 0 rgba(255,255,255,.15) inset;
}
.btn.primary::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(105deg,
    transparent 30%, rgba(255,255,255,.18) 50%, transparent 70%);
  background-size: 200% 100%;
  background-position: -100% 0;
  transition: background-position .5s var(--ease);
  border-radius: inherit;
}
.btn.primary:hover::after  { background-position: 200% 0; }
.btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(8,145,178,.45),
              0 1px 0 rgba(255,255,255,.20) inset;
  background: linear-gradient(150deg, #0369A1 0%, #0E7490 50%, #0891B2 100%);
  color: #fff;
}
.btn.primary:active {
  box-shadow: 0 2px 8px rgba(8,145,178,.30),
              0 1px 0 rgba(255,255,255,.10) inset;
}

.btn.ghost       { background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surf-h); box-shadow: none; transform: none; }
.btn.small       { padding: 6px 13px; font-size: 12px; border-radius: var(--r-xs); }
.btn.full        { width: 100%; }
.btn.danger {
  background: rgba(220,38,38,.05); color: var(--bad);
  border-color: rgba(220,38,38,.18);
}
.btn.danger:hover {
  background: rgba(220,38,38,.10); border-color: var(--bad);
  box-shadow: 0 2px 12px rgba(220,38,38,.12);
  color: var(--bad);
}
.btn:disabled { opacity: .40; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* Ripple */
.ripple {
  position: absolute; transform: translate(-50%,-50%) scale(0);
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(8,145,178,.12);
  animation: ripple .55s linear forwards; pointer-events: none;
}
@keyframes ripple { to { transform: translate(-50%,-50%) scale(1); opacity: 0; } }

[data-theme="dark"] .btn             { background: var(--surf-inset); }
[data-theme="dark"] .btn:hover       { background: var(--surf-raised); }
[data-theme="dark"] .btn.primary     { background: linear-gradient(150deg,#0369A1,#0891B2,#06B6D4); border-color: rgba(34,211,238,.30); }
[data-theme="dark"] .btn.primary:hover { background: linear-gradient(150deg,#075985,#0E7490,#0891B2); }
[data-theme="dark"] .btn.ghost       { background: transparent; }
[data-theme="dark"] .btn.ghost:hover { background: rgba(103,232,249,.07); border-color: var(--border-h); }
[data-theme="dark"] .btn.danger      { background: rgba(248,113,113,.07); border-color: rgba(248,113,113,.18); }
[data-theme="dark"] .btn.danger:hover{ background: rgba(248,113,113,.14); border-color: var(--bad); }

/* ── 5. LAYOUT ──────────────────────────────────────────────────────────── */
.wrap {
  display: flex; padding-top: var(--topbar-h);
  min-height: 100vh; position: relative; z-index: 2;
}

/* ── 6. SIDEBAR ─────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 50;
  transition: var(--t-slow);
}

/* Top aurora glow inside sidebar */
.sidebar::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 80px;
  background: linear-gradient(180deg,
    rgba(8,145,178,.08) 0%, transparent 100%);
  pointer-events: none; z-index: 0;
}

.sidebar-nav    { flex: 1; overflow-y: auto; padding: 20px 10px 10px; position: relative; z-index: 1; }
.sidebar-footer {
  flex-shrink: 0; padding: 12px 10px 20px;
  border-top: 1px solid var(--border);
  background: var(--sidebar-footer-bg);
  -webkit-backdrop-filter: blur(12px);backdrop-filter: blur(12px);
  position: relative; z-index: 1;
}
.sidebar-version {
  font-size: 11px; color: var(--muted); padding: 8px 10px 0;
  letter-spacing: .04em; font-weight: 500;
}
.sidebar-label {
  display: block;
  font-size: 9.5px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); padding: 0 10px 10px; opacity: .75;
}

.seg { display: flex; flex-direction: column; gap: 2px; }
.seg button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px;
  border-radius: var(--r-sm); border: 1px solid transparent;
  background: transparent; color: var(--muted);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; text-align: left; transition: var(--t);
  position: relative; overflow: hidden;
}
.seg button:hover {
  background: rgba(8,145,178,.08);
  border-color: var(--border);
  color: var(--primary);
  transform: translateX(2px);
}
/* Active state — gradient pill background */
.seg button.active {
  background: linear-gradient(105deg,
    rgba(8,145,178,.14) 0%, rgba(34,211,238,.10) 100%);
  border-color: rgba(8,145,178,.22);
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}
/* Glowing left accent */
.seg button.active::before {
  content: '';
  position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-2) 100%);
  box-shadow: 0 0 8px rgba(8,145,178,.60);
}

/* ── 7. MAIN AREA ────────────────────────────────────────────────────────── */
.main {
  flex: 1; margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  padding: 22px; min-width: 0;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}
.main.scroll {
  overflow-y: auto; height: auto;
  min-height: calc(100vh - var(--topbar-h));
}

/* ── 8. WORK AREA ─────────────────────────────────────────────────────── */
.work-area {
  display: grid; grid-template-columns: 1fr 310px;
  gap: 16px; flex: 1; min-height: 0;
}

.pane-left,
.pane-right {
  display: flex; flex-direction: column;
  background: var(--surf); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow);
  overflow-y: auto; min-height: 0;
}
.pane-left.scroll,
.pane-right.scroll {
  overflow-y: auto;
}

/* ── 9. TAB CONTAINER ────────────────────────────────────────────────────── */
.tab-container {
  display: flex; flex-direction: column;
  background: var(--surf); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow);
  overflow: hidden; min-height: 0;
  transition: box-shadow .3s var(--ease);
}
.tab-container:focus-within { box-shadow: var(--glow); }

.tab-bar {
  display: flex; gap: 2px;
  padding: 10px 12px 0;
  background: linear-gradient(180deg, var(--surf-raised) 0%, var(--surf) 100%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; overflow-x: auto;
}
.tab-bar::-webkit-scrollbar { height: 0; }

.tab-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; background: transparent;
  border: 1px solid transparent; border-bottom: 2px solid transparent;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--muted); white-space: nowrap; transition: var(--t);
  position: relative; bottom: -1px;
}
.tab-btn:hover  { color: var(--primary); background: rgba(8,145,178,.06); }
.tab-btn.active {
  background: var(--surf); border-color: var(--border);
  border-bottom-color: var(--surf); color: var(--primary); z-index: 1;
}
/* Glowing top accent line on active tab */
.tab-btn.active::before {
  content: '';
  position: absolute; top: 0; left: 10px; right: 10px; height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  border-radius: 0 0 var(--r-xs) var(--r-xs);
  box-shadow: 0 0 8px rgba(8,145,178,.50);
}
.tab-btn-icon { font-size: 15px; }
.tab-panes    { overflow: visible; }
.tab-pane     { display: none; }          /* pages use data-tab / switchTab to toggle */
.tab-pane.active { display: block; }

/* ── Pane header ── */
.pane-header {
  display: flex; align-items: center; gap: 18px;
  margin-bottom: 24px; padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.pane-icon-wrap {
  width: 60px; height: 60px; border-radius: var(--r); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 28px;
  background: linear-gradient(135deg,
    rgba(8,145,178,.10) 0%, rgba(34,211,238,.06) 100%);
  border: 1px solid rgba(8,145,178,.18);
  box-shadow: 0 2px 14px rgba(8,145,178,.12),
              0 1px 0 rgba(255,255,255,.50) inset;
}
.pane-title {
  font-size: 22px; font-weight: 800; margin: 0 0 4px;
  letter-spacing: -.03em;
  /* Gradient text */
  background: linear-gradient(135deg, var(--text) 40%, var(--primary) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.pane-sub {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .10em; color: var(--muted);
}
.pane-desc {
  font-size: 13.5px; line-height: 1.75; color: var(--muted);
  margin-bottom: 22px; padding: 14px 18px;
  background: linear-gradient(135deg,
    rgba(8,145,178,.04) 0%, rgba(34,211,238,.02) 100%);
  border: 1px solid rgba(8,145,178,.10);
  border-radius: var(--r-sm);
}
.pane-section-title {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .14em; color: var(--muted); margin-bottom: 12px;
}

/* List items with pill ✓ */
.pane-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.pane-list li {
  display: flex; align-items: flex-start; gap: 12px;
  font-size: 13.5px; line-height: 1.6; color: var(--text);
  padding: 11px 15px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--surf-inset);
  transition: var(--t);
}
.pane-list li:hover {
  border-color: rgba(8,145,178,.25);
  background: var(--surf);
  box-shadow: var(--shadow-sm);
  transform: translateX(4px);
}
.pane-list li::before {
  content: '✓';
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; width: 20px; height: 20px; margin-top: 1px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(8,145,178,.15), rgba(34,211,238,.10));
  border: 1px solid rgba(8,145,178,.18);
  font-size: 10px; font-weight: 900; color: var(--primary);
}
[data-theme="dark"] .pane-list li::before {
  background: linear-gradient(135deg, rgba(103,232,249,.15), rgba(103,232,249,.08));
  border-color: rgba(103,232,249,.20);
}

/* ── 10. NEWS PANEL ──────────────────────────────────────────────────────── */
.news-panel {
  display: flex; flex-direction: column;
  background: var(--surf); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow);
  overflow: hidden; min-height: 0;
}
.news-header {
  display: flex; align-items: center; gap: 9px;
  padding: 14px 18px;
  background: linear-gradient(135deg,
    var(--surf-raised) 0%, rgba(8,145,178,.04) 100%);
  border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 700; color: var(--text); flex-shrink: 0;
}
.news-header-icon { font-size: 18px; }
.news-count {
  margin-left: auto; font-size: 10px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
  background: var(--primary-glow); color: var(--primary);
  border: 1px solid rgba(8,145,178,.16);
}
.news-scroll {
  flex: 1; overflow-y: auto; padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
}

/* News items — colored left border based on tag type */
.news-item {
  flex-shrink: 0;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 12px 14px; background: var(--surf-inset);
  cursor: pointer; transition: var(--t);
  border-left-width: 3px;
}
.news-item:hover {
  border-color: rgba(8,145,178,.28);
  background: var(--surf);
  box-shadow: var(--shadow-sm);
  transform: translateX(2px) translateY(-1px);
}
/* Color-code left border by tag type using :has() */
.news-item:has(.tag-violet) { border-left-color: rgba(8,145,178,.55); }
.news-item:has(.tag-red)    { border-left-color: rgba(220,38,38,.55); }
.news-item:has(.tag-green)  { border-left-color: rgba(5,150,105,.55); }
.news-item:has(.tag-blue)   { border-left-color: rgba(37,99,235,.55); }
.news-item:has(.tag-amber)  { border-left-color: rgba(217,119,6,.55); }

.news-item-top  {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 6px; margin-bottom: 5px;
}
.news-item-title { font-size: 12.5px; font-weight: 700; color: var(--text); line-height: 1.4; }
.news-item-date  { font-size: 10px; color: var(--muted); white-space: nowrap; flex-shrink: 0; font-weight: 500; }
.news-item-text  { font-size: 12px; line-height: 1.65; color: var(--muted); margin-bottom: 8px; }

/* Tags */
.news-tag {
  display: inline-flex; align-items: center;
  font-size: 9.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .07em; padding: 2px 9px; border-radius: 999px;
  gap: 4px;
}
.tag-violet { background: rgba(8,145,178,.08); color: var(--primary);  border: 1px solid rgba(8,145,178,.18); }
.tag-red    { background: rgba(220,38,38,.08);  color: #dc2626;         border: 1px solid rgba(220,38,38,.18); }
.tag-green  { background: rgba(5,150,105,.08);  color: #059669;         border: 1px solid rgba(5,150,105,.18); }
.tag-blue   { background: rgba(37,99,235,.08);  color: #2563eb;         border: 1px solid rgba(37,99,235,.18); }
.tag-amber  { background: rgba(217,119,6,.08);  color: #d97706;         border: 1px solid rgba(217,119,6,.18); }

[data-theme="dark"] .tag-red    { color: var(--bad); }
[data-theme="dark"] .tag-green  { color: var(--good); }
[data-theme="dark"] .tag-blue   { color: #60a5fa; }
[data-theme="dark"] .tag-amber  { color: #fbbf24; }

/* ── 11. GENERIC CARD ────────────────────────────────────────────────────── */
.card {
  background: var(--surf); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow);
  overflow: hidden; margin-bottom: 16px;
  transition: box-shadow .25s var(--ease);
}
.card:hover { box-shadow: var(--shadow-lg); }

.card > h3 {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 15px 22px; border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg,
    var(--surf-raised) 0%, rgba(8,145,178,.03) 100%);
  font-size: 14px; font-weight: 700; color: var(--text);
}
.card > .body { padding: 22px; overflow-y: auto; }

/* ── 12. CHAT ────────────────────────────────────────────────────────────── */
.card.chatcard { display: flex; flex-direction: column; height: 100%; margin-bottom: 0; }
.chatlog {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 20px; display: flex; flex-direction: column; gap: 14px;
}
.bubble {
  max-width: 78%; padding: 12px 16px; border-radius: 16px;
  font-size: 14px; line-height: 1.70; white-space: pre-wrap; word-break: break-word;
  animation: bubbleIn .25s var(--ease-spring) both;
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
.bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #0369A1 0%, #0891B2 60%, #06B6D4 100%);
  color: #fff; border-radius: 16px 16px 4px 16px;
  box-shadow: 0 3px 14px rgba(8,145,178,.35);
}
.bubble.ai {
  align-self: flex-start;
  background: var(--surf-inset); border: 1px solid var(--border);
  color: var(--text); border-radius: 16px 16px 16px 4px;
  box-shadow: var(--shadow-sm);
}
.sources {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--muted);
}
.composer {
  flex-shrink: 0; padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surf-raised) 0%, var(--surf) 100%);
  display: flex; gap: 10px; align-items: flex-end;
}

/* ── 13. FORM ELEMENTS ───────────────────────────────────────────────────── */
textarea {
  width: 100%; padding: 11px 14px;
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--surf-inset); color: var(--text);
  font-family: inherit; font-size: 14px; outline: none;
  resize: vertical; min-height: 42px; max-height: 200px; line-height: 1.6;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
textarea::placeholder { color: var(--muted); }
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--surf);
}
input, select {
  width: 100%; padding: 11px 14px;
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--surf-inset); color: var(--text);
  font-family: inherit; font-size: 14px; outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
input::placeholder { color: var(--muted); }
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--surf);
}
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; padding: 0; }
input[type="file"]     { display: none; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 10.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .09em; color: var(--muted);
}
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 10px; font-weight: 500; }

/* ── 14. DROP ZONE ────────────────────────────────────────────────────────── */
.drop {
  border: 2px dashed var(--border); border-radius: var(--r);
  padding: 24px 20px; text-align: center; cursor: pointer;
  background: var(--surf-inset); transition: var(--t);
}
.drop:hover, .drop.dragover {
  border-color: var(--primary);
  background: rgba(8,145,178,.04);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

/* ── 15. LINK / DOC LIST ─────────────────────────────────────────────────── */
.link { color: var(--primary); cursor: pointer; font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }

.doclist { display: flex; flex-direction: column; gap: 5px; }
.docitem {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 15px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--surf-inset); transition: var(--t);
}
.docitem:hover {
  border-color: rgba(8,145,178,.25);
  background: var(--surf-h);
  box-shadow: var(--shadow-xs);
  transform: translateX(2px);
}
.docname { font-size: 13.5px; color: var(--text); font-weight: 500; flex: 1; }

/* ── 16. KPI BOXES ───────────────────────────────────────────────────────── */
.kpi { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.box {
  flex: 1; min-width: 100px; padding: 18px 20px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: linear-gradient(135deg,
    var(--surf-inset) 0%, rgba(8,145,178,.03) 100%);
  text-align: center; transition: var(--t);
}
.box:hover {
  box-shadow: var(--shadow-sm);
  border-color: rgba(8,145,178,.25);
  transform: translateY(-2px);
}
.num {
  font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.lbl {
  font-size: 10.5px; color: var(--muted); margin-top: 6px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
}

/* ── 17. TICKET DETAIL ───────────────────────────────────────────────────── */
.ticket-detail { display: flex; flex-direction: column; }
.trow {
  display: flex; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.trow:last-child { border-bottom: none; }
.tlabel { color: var(--muted); font-weight: 700; min-width: 108px; flex-shrink: 0; }
.tval   { color: var(--text); flex: 1; }

.answered-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: rgba(5,150,105,.08); color: #059669;
  border: 1px solid rgba(5,150,105,.20);
}
.open-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--primary-glow); color: var(--primary);
  border: 1px solid rgba(8,145,178,.22);
}
[data-theme="dark"] .answered-badge { background: rgba(52,211,153,.10); color: var(--good); border-color: rgba(52,211,153,.22); }

/* ── 18. NOTE / SLOT / SCHEDULE ─────────────────────────────────────────── */
.note {
  padding: 14px 18px; border-radius: var(--r-sm);
  border: 1px solid rgba(8,145,178,.16);
  background: linear-gradient(135deg,
    rgba(8,145,178,.04) 0%, rgba(34,211,238,.02) 100%);
  font-size: 13.5px; line-height: 1.70; color: var(--text);
}
.slot-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 10px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--surf-inset); min-height: 44px;
  max-height: 200px; overflow-y: auto;
}
.schedule-box {
  padding: 18px; border: 1px solid var(--border);
  border-radius: var(--r); background: rgba(8,145,178,.03);
  box-shadow: var(--shadow-xs);
}
.schedule-box-title {
  font-weight: 800; margin-bottom: 14px;
  font-size: 14px; letter-spacing: -.01em;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── 19. MODAL ───────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(10,5,40,.50);
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .28s var(--ease);
}
.modal.show { opacity: 1; pointer-events: all; }
.modal.show .panel { transform: translateY(0) scale(1); }

[data-theme="dark"] .modal { background: rgba(0,0,0,.75); }

.panel {
  position: relative; width: 100%; max-width: 470px;
  border-radius: var(--r-xl);
  background: var(--surf);
  /* Gradient border via padding-box / border-box */
  border: 1px solid var(--border);
  overflow: hidden;
  transform: translateY(28px) scale(.96);
  transition: transform .42s var(--ease-spring);
  box-shadow: var(--shadow-lg);
}
/* Animated rainbow shimmer on top of modal */
.panel-shimmer {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg,
    #0E7490, #06B6D4, #22d3ee, #34d399, #06B6D4, #0E7490);
  background-size: 300% 100%;
  animation: shimmerSlide 4s linear infinite;
}
@keyframes shimmerSlide {
  0%   { background-position: 100% 0; }
  100% { background-position: -200% 0; }
}

.head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg,
    var(--surf-raised) 0%, rgba(8,145,178,.03) 100%);
  position: relative; z-index: 1;
}
.head-title { font-weight: 800; font-size: 15px; color: var(--text); letter-spacing: -.01em; }
.body { padding: 24px; position: relative; z-index: 1; }

/* ── 20. PAGE CARD ───────────────────────────────────────────────────────── */
.page-card {
  background: var(--surf); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow);
  overflow: hidden; margin-bottom: 18px;
  transition: box-shadow .25s var(--ease);
}
.page-card:hover { box-shadow: var(--shadow-lg); }

.page-card-head {
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg,
    var(--surf-raised) 0%, rgba(8,145,178,.03) 100%);
  display: flex; align-items: center; gap: 12px;
  font-size: 15px; font-weight: 800; color: var(--text);
  letter-spacing: -.02em;
}
.page-card-head-icon { font-size: 20px; }
.page-card-body { padding: 24px; }

/* ── 21. SETTINGS ────────────────────────────────────────────────────────── */
.settings-section { margin-bottom: 28px; }
.settings-section:last-child { margin-bottom: 0; }
.settings-section-title {
  font-size: 9.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .14em; color: var(--muted);
  margin-bottom: 14px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Language / theme selector buttons */
.lang-options { display: flex; gap: 10px; flex-wrap: wrap; }
.lang-btn {
  flex: 1; min-width: 150px;
  display: flex; align-items: center; gap: 14px;
  padding: 15px 18px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surf-inset); color: var(--text);
  font-family: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: var(--t); text-align: left;
}
.lang-btn:hover  {
  border-color: rgba(8,145,178,.32);
  background: rgba(8,145,178,.05);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.lang-btn.active {
  border-color: var(--primary);
  background: linear-gradient(135deg,
    rgba(8,145,178,.09) 0%, rgba(34,211,238,.05) 100%);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.lang-flag  { font-size: 26px; flex-shrink: 0; }
.lang-label { flex: 1; }
.lang-name  { font-size: 15px; font-weight: 700; display: block; color: var(--text); }
.lang-sub   { font-size: 11px; color: var(--muted); }
.lang-check { font-size: 16px; color: var(--primary); flex-shrink: 0; }

/* ── 22. FEATURE GRID ────────────────────────────────────────────────────── */
.feature-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px;
}
.feature-card {
  padding: 18px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surf-inset); transition: var(--t);
}
.feature-card:hover {
  border-color: rgba(8,145,178,.26);
  background: var(--surf); box-shadow: var(--shadow);
  transform: translateY(-3px);
}
.feature-icon  { font-size: 26px; margin-bottom: 10px; }
.feature-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.feature-desc  { font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ── 23. INFO SECTIONS ───────────────────────────────────────────────────── */
.info-section { padding: 16px 0; border-bottom: 1px solid var(--border); }
.info-section:last-child { border-bottom: none; padding-bottom: 0; }
.info-section-title {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .12em; color: var(--muted); margin-bottom: 10px;
}
.info-section p { font-size: 13.5px; line-height: 1.80; color: var(--text); margin: 0 0 8px; }
.info-section p:last-child { margin-bottom: 0; }
.info-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.info-list li {
  font-size: 13px; color: var(--text); padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--r-xs);
  background: var(--surf-inset);
  display: flex; align-items: flex-start; gap: 9px; transition: var(--t);
}
.info-list li:hover { border-color: var(--border-h); background: var(--surf); }
.info-list li::before {
  content: '›'; color: var(--primary); font-weight: 900; font-size: 17px;
  flex-shrink: 0; line-height: 1.2;
}

/* ── 24. AI LANGUAGE TOGGLE ──────────────────────────────────────────────── */

/* Segmented DE / EN control used in chat composer and contact form */
.ai-lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surf-inset);
  flex-shrink: 0;
}
.ai-lang-btn {
  padding: 7px 13px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  border: none; border-right: 1px solid var(--border);
  background: transparent; color: var(--muted);
  cursor: pointer; font-family: inherit;
  transition: var(--t); white-space: nowrap;
}
.ai-lang-btn:last-child { border-right: none; }
.ai-lang-btn:hover { background: var(--surf-h); color: var(--primary); }
.ai-lang-btn.active {
  background: linear-gradient(135deg, #0E7490, #06B6D4);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,.15) inset;
}

/* Vertical stack: toggle on top, send button below — used in chat composer */
.composer-actions {
  display: flex; flex-direction: column;
  align-items: stretch; gap: 6px; flex-shrink: 0;
}

/* ── 25. SCROLLBAR ───────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(8,145,178,.15); border-radius: 999px;
  transition: background .2s;
}
::-webkit-scrollbar-thumb:hover { background: rgba(8,145,178,.35); }

[data-theme="dark"] ::-webkit-scrollbar-thumb       { background: rgba(103,232,249,.18); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(103,232,249,.40); }

/* ── 25. RESPONSIVE ──────────────────────────────────────────────────────── */
@media (max-width: 1100px) { .work-area { grid-template-columns: 1fr 280px; } }
@media (max-width: 900px)  { .work-area { grid-template-columns: 1fr; grid-template-rows: 1fr 260px; } }
@media (max-width: 768px)  {
  .sidebar { display: none; }
  .main    { margin-left: 0; padding: 12px; }
  .grid2   { grid-template-columns: 1fr; }
  .tab-btn span:not(.tab-btn-icon) { display: none; }
}

/* ══════════════════════════════════════════════════════════════════════════
   ADDITIONS: Scan overlay · Topbar center · Sidebar nav-icon · Chat bubbles
   Toast · Skeleton · §31 Effects · Responsive fixes
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Scan overlay ── */
.scan-overlay {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  contain: strict;
}
.scan-overlay::before {
  content: '';
  position: absolute; top: -60%; left: 0; right: 0; height: 60%;
  background: linear-gradient(180deg,
    transparent 0%, rgba(6,182,212,.018) 45%,
    rgba(6,182,212,.035) 50%, rgba(6,182,212,.018) 55%, transparent 100%);
  animation: vertScan 14s linear infinite;
}
@keyframes vertScan { from{top:-60%} to{top:160%} }
[data-theme="light"] .scan-overlay::before { opacity: .35; }

/* ── Topbar center section (clock + TLS badge) ── */
.topbar-center {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; pointer-events: none; min-width: 0; overflow: hidden;
}
.live-clock {
  font-family: var(--mono), monospace;
  font-size: 12px; font-weight: 600; letter-spacing: .08em;
  color: rgba(221,214,254,.90);
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: var(--r-sm);
}
.live-clock svg { flex-shrink: 0; }
.tls-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 9px; font-weight: 800; letter-spacing: .10em;
  text-transform: uppercase; color: #6ee7b7;
  padding: 3px 10px;
  background: rgba(16,185,129,.08);
  border: 1px solid rgba(16,185,129,.22);
  border-radius: 999px;
}
.tls-badge svg { width: 10px; height: 10px; flex-shrink: 0; }
/* .live-clock also only ever appears inside the permanently-dark .topbar —
   removed its light-theme dark-text override for the same reason as
   .status-indicator/.who-badge above; it keeps the light-on-dark default. */
[data-theme="light"] .tls-badge   { background:rgba(5,150,105,.07); border-color:rgba(5,150,105,.22); color:#059669; }

/* ── Sidebar nav-icon containers ── */
.nav-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex-shrink: 0;
}
.nav-icon svg { width: 18px; height: 18px; }

/* ── Thinking / typing dots (chat) ── */
.thinking-dots { display: inline-flex; gap: 4px; align-items: center; }
.thinking-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary-2); animation: dotBounce 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(2){animation-delay:.2s}
.thinking-dots span:nth-child(3){animation-delay:.4s}
@keyframes dotBounce {
  0%,80%,100%{transform:scale(1);opacity:.6}
  40%{transform:scale(1.4) translateY(-3px);opacity:1}
}

/* ── Toast notifications ── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 1000;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px;
  background: var(--surf-raised); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
  font-size: 13px; font-weight: 600; color: var(--text);
  min-width: 260px; max-width: 380px; pointer-events: all;
  animation: toastIn .35s var(--ease-spring) both;
}
.toast.toast-exit { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn  { from{opacity:0;transform:translateX(30px)} to{opacity:1;transform:none} }
@keyframes toastOut { from{opacity:1} to{opacity:0;transform:translateX(30px)} }
.toast-icon { font-size: 17px; flex-shrink: 0; }
.toast-msg  { flex: 1; }
.toast.success { border-left: 3px solid var(--good); }
.toast.error   { border-left: 3px solid var(--bad); }
.toast.info    { border-left: 3px solid var(--primary); }
.toast.warn    { border-left: 3px solid var(--warn); }

/* ── Skeleton loader ── */
.skeleton {
  background: linear-gradient(90deg,
    var(--surf-raised) 25%, rgba(103,232,249,.07) 50%, var(--surf-raised) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.8s ease-in-out infinite;
  border-radius: var(--r-xs);
}
@keyframes skeleton { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── §31 Effects ─────────────────────────────────────────────────────────── */

/* Matrix rain canvas */
#matrixCanvas {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 1; pointer-events: none; opacity: .13; contain: strict;
  transition: opacity 1.2s ease;
}
[data-theme="light"] #matrixCanvas { opacity: 0 !important; }

/* Entrance animations */
.anim-init { opacity: 0; transform: translateY(16px);
  transition: opacity .5s var(--ease), transform .5s var(--ease); }
.anim-init.anim-in { opacity: 1; transform: none; }

/* Holographic card shimmer */
.card,.page-card,.feature-card { --mx:50%; --my:50%; }
.card::after,.page-card::after,.feature-card::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(circle at var(--mx) var(--my),
    rgba(103,232,249,.09) 0%, rgba(34,211,238,.04) 30%, transparent 65%);
  opacity: 0; pointer-events: none; transition: opacity .35s var(--ease);
}
.card.holo::after,.page-card.holo::after,.feature-card.holo::after { opacity: 1; }

/* Status dot ping */
.status-dot { position: relative; }
.status-dot.online.ping::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 1.5px solid var(--good);
  animation: statusPing 1.1s var(--ease-out) forwards;
  pointer-events: none;
}
@keyframes statusPing { from{transform:scale(1);opacity:.9} to{transform:scale(2.8);opacity:0} }

/* Input focus pulse */
input:focus,textarea:focus,select:focus {
  animation: inputPulse 2.4s var(--ease) infinite;
}
@keyframes inputPulse {
  0%,100%{box-shadow:0 0 0 3px rgba(103,232,249,.20),0 0 18px rgba(103,232,249,.10)}
  50%    {box-shadow:0 0 0 4px rgba(103,232,249,.36),0 0 28px rgba(103,232,249,.18)}
}

/* Typing cursor */
.typing-cursor::after {
  content: '▋'; color: var(--primary-2);
  animation: cursorBlink .75s step-end infinite; margin-left: 1px;
}
@keyframes cursorBlink { 0%,100%{opacity:1} 50%{opacity:0} }

/* GPU hints */
.card,.page-card,.feature-card,.bubble,.news-item,.docitem,.lang-btn { will-change: transform; }
.modal { contain: layout style; }  /* tab-container removed — interfered with flex height */

/* Selection */
::selection { background: rgba(34,211,238,.28); color: var(--text); }

/* ══ RESPONSIVE — MOBILE FIRST ════════════════════════════════════════════ */

/* ── Sidebar overlay backdrop ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: var(--topbar-h); left: 0; right: 0; bottom: 0; /* start below topbar so hamburger stays usable */
  z-index: 499;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.sidebar-overlay.show { display: block; }

/* ── Tablet (≤ 1024px) ── */
@media (max-width: 1024px) {
  .topbar-center { display: none; }
  .kpi-grid { grid-template-columns: repeat(3,1fr) !important; }
}

/* ── Mobile (≤ 767px) ── */
@media (max-width: 767px) {
  :root { --topbar-h: 56px; }

  /* Topbar */
  .topbar {
    grid-template-columns: auto 1fr !important;
    padding: 0 10px;
  }
  .topbar-left  { grid-column: 1; gap: 6px; }
  .topbar-right { grid-column: 2; gap: 5px; }
  .live-clock   { display: none; }
  .topbar-center { display: none; }
  .who-badge    { display: none; }
  .status-indicator .muted { display: none; }
  .brand        { font-size: 13px !important; }
  .topbar .btn.small {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 12px;
  }
  .topbar #themeToggle,
  .topbar .theme-toggle {
    width: 36px;
    min-width: 36px;
    height: 36px;
    padding: 0;
  }
  .topbar .status-indicator {
    width: 28px;
    min-width: 28px;
    height: 22px;
    padding: 0;
    justify-content: center;
  }

  /* Hamburger — show on mobile, touch-friendly */
  .hamburger {
    display: inline-flex !important;
    align-items: center; justify-content: center;
    min-width: 40px; min-height: 40px;
    font-size: 19px;
  }

  /* Sidebar — slide-in drawer */
  .sidebar {
    position: fixed !important;
    top: var(--topbar-h); left: 0; bottom: 0;
    width: 260px; z-index: 500;
    display: flex !important;
    flex-direction: column;
    overflow-y: auto; overflow-x: hidden;
    transform: translateX(-110%);
    transition: transform .28s cubic-bezier(.4,0,.2,1),
                box-shadow .28s ease;
    border-right: 1px solid var(--border);
    box-shadow: none;
  }
  .sidebar.mob-open {
    transform: translateX(0) !important;
    box-shadow: 8px 0 40px rgba(0,0,0,.45);
  }
  .sidebar-mobile-close {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 52px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb,var(--surf) 72%,transparent);
    color: var(--text);
    font-weight: 800;
  }
  .sidebar-mobile-close button {
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    border-radius: 10px;
  }
  /* Make sure sidebar-collapsed on desktop doesn't interfere on mobile */
  .sidebar.sidebar-collapsed {
    transform: translateX(-110%);
  }
  .sidebar.sidebar-collapsed.mob-open {
    transform: translateX(0) !important;
  }

  /* Wrap and main layout */
  /* Remove stacking context from .wrap so sidebar (z-index:500) and overlay
     (z-index:499, appended to body) both compete in the root stacking context.
     Without this, overlay at 499 in body context beats wrap at 2 in body
     context, covering even the fixed sidebar inside wrap. */
  .wrap { display: block !important; z-index: auto !important; position: static !important; }
  .main {
    margin-left: 0 !important;
    padding: 12px !important;
    /* ALL pages scroll on mobile — not just .scroll ones */
    overflow-y: auto !important;
    height: auto !important;
    min-height: calc(100vh - var(--topbar-h));
    /* Remove fixed column layout */
    display: block !important;
    flex-direction: unset !important;
  }

  /* Inner work areas — stack vertically, allow scrolling */
  .work-area,
  .chat-layout,
  .tk-layout,
  .eg-workspace,
  .calendar-layout {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    flex-direction: column !important;
  }

  /* Chat-specific: unlock the nested flex overflow clamp */
  .chat-wrap {
    display: flex !important;
    flex-direction: column !important;
    overflow: visible !important;
    height: auto !important;
    min-height: 0;
  }
  .chat-main {
    display: flex !important;
    flex-direction: column !important;
    overflow: visible !important;
    height: auto !important;
    flex: none !important;
  }
  .chatlog {
    flex: none !important;
    min-height: 55vh;
    max-height: 70vh;
    overflow-y: auto !important;
    height: auto !important;
  }
  .chat-composer {
    flex-shrink: 0 !important;
    position: sticky;
    bottom: 0;
    background: var(--surf);
    z-index: 10;
  }

  /* Tickets-specific: stack list and detail */
  .tk-workspace {
    display: flex !important;
    flex-direction: column !important;
    overflow: visible !important;
    height: auto !important;
  }
  .tk-sidebar {
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border);
    overflow-y: auto !important;
    display: flex !important;
  }
  /* Full mobile master-detail: list shown by default; detail full-screen when a ticket is open */
  .tk-detail {
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    min-height: 50vh;
    display: none !important;
    flex-direction: column !important;
  }
  .tk-workspace.mobile-detail .tk-sidebar { display: none !important; }
  .tk-workspace.mobile-detail .tk-detail  { display: flex !important; }
  .tk-message-area {
    overflow: visible !important;
    height: auto !important;
  }
  .tk-reply-panel {
    position: static !important;
  }
  #tkDetailContent {
    overflow: visible !important;
    min-height: 0 !important;
  }

  /* Panes — natural height on mobile */
  .pane-left, .pane-right,
  .chat-pane, .chat-side,
  .eg-compose, .eg-sidebar {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    width: 100% !important;
    margin-bottom: 12px;
  }

  /* Right column always full-width */
  .right-col { width: 100%; }

  /* Touch targets */
  .btn, button, a.btn { min-height: 40px; }
  .nav-icon { width: 32px; height: 32px; }

  /* Grid overrides */
  .grid2 { grid-template-columns: 1fr !important; }
  .work-area { grid-template-columns: 1fr !important; }
  .kpi-grid { grid-template-columns: repeat(2,1fr) !important; }
  .qa-grid { grid-template-columns: repeat(3,1fr) !important; }

  /* Chat specific */
  .chat-area, .chat-messages {
    height: 50vh !important;
    min-height: 200px;
    overflow-y: auto !important;
  }
  .chat-input-row { flex-wrap: wrap !important; }
  .eg-body-textarea { height: 180px !important; }
  .eg-rewrite-bar  { flex-wrap: wrap !important; height: auto !important; }
  .eg-action-bar   { flex-wrap: wrap !important; height: auto !important; gap: 6px !important; }

  /* Tickets */
  .tk-grid, .ticket-grid { grid-template-columns: 1fr !important; }

  /* Tables — horizontal scroll */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Modals — full width */
  .modal .panel, .panel { max-width: 100% !important; border-radius: 12px 12px 0 0; }
  .modal {
    align-items: center !important;
    padding: 16px !important;
  }
  .modal .panel,
  .modal-inner {
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
  }

  /* Toast — bottom */
  .toast-container { right: 12px; left: 12px; bottom: 16px; }
  .toast { min-width: 0; width: 100%; }

  /* Tab labels */
  .tab-btn span:not(.tab-btn-icon) { display: inline !important; font-size: 11px; }
}

/* ── Small phones (≤ 480px) ── */
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr !important; }
  .qa-grid  { grid-template-columns: repeat(2,1fr) !important; }
  .welcome-banner { flex-direction: column; gap: 14px; }
  .welcome-badges { display: none; }   /* declutter on tiny screens */
  .health-strip   { gap: 6px; }
  .health-chip    { font-size: 11px; padding: 5px 10px; }

  /* Topbar even tighter on narrow phones */
  .topbar { padding: 0 8px; }
  .topbar-right { gap: 4px; }
  .status-indicator { display: none !important; }
  .theme-toggle { width: 30px; height: 30px; font-size: 13px; }

  /* Main padding tighter on very small screens */
  .main { padding: 8px !important; }

  /* Cards — remove side padding on tiny screens */
  .pane-left, .pane-right { border-radius: var(--r-sm); }

  /* Buttons full width in action bars on tiny screens */
  .tab-btn { padding: 7px 10px; font-size: 11px; }
  .btn.small { padding: 5px 10px; font-size: 11px; }

  /* Pane headers — stack title + actions vertically */
  .pane-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  .pane-actions {
    width: 100%;
    justify-content: flex-start;
  }

  /* KPI boxes — single column on smallest phones */
  .kpi-grid { grid-template-columns: 1fr !important; }

  /* Calendar layout — reduce padding */
  .calendar-layout { gap: 8px !important; }

  /* Email generator body textarea */
  .eg-body-textarea { height: 140px !important; }

  /* Settings page form rows */
  .settings-row { flex-direction: column !important; gap: 6px !important; }
  .settings-label { min-width: unset !important; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { animation-duration:.01ms !important; transition-duration:.01ms !important; }
  #matrixCanvas { display: none; }
  .anim-init    { opacity: 1; }
}

/* ══════════════════════════════════════════════════════════════════════════
   LIGHT MODE CONTRAST IMPROVEMENTS
   ══════════════════════════════════════════════════════════════════════════ */

[data-theme="light"] {
  --muted: #475569;  /* slightly darker for better contrast on light bg */
}

/* Input focus ring — visible in light mode */
[data-theme="light"] input:focus,
[data-theme="light"] textarea:focus,
[data-theme="light"] select:focus {
  animation: inputPulseLight 2.4s cubic-bezier(.4,0,.2,1) infinite;
}
@keyframes inputPulseLight {
  0%,100%{box-shadow:0 0 0 3px rgba(8,145,178,.22),0 0 14px rgba(8,145,178,.10)}
  50%    {box-shadow:0 0 0 4px rgba(8,145,178,.38),0 0 22px rgba(8,145,178,.16)}
}

/* Skeleton shimmer — visible in light mode */
[data-theme="light"] .skeleton {
  background: linear-gradient(90deg,
    #f1f5f9 25%, rgba(8,145,178,.10) 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton 1.8s ease-in-out infinite;
}

/* Text selection — readable in light mode */
[data-theme="light"] ::selection {
  background: rgba(8,145,178,.25);
  color: #0F172A;
}

/* Typing cursor — visible in light mode */
[data-theme="light"] .typing-cursor::after { color: var(--primary); }
[data-theme="light"] .type-cursor { background: var(--primary) !important; }

/* Scan overlay — hidden in light mode (removes distracting animation) */
[data-theme="light"] .scan-overlay { display: none; }

/* ── Keyboard focus visibility (a11y P1) ───────────────────────────────
   Visible focus ring for keyboard/AT users on every interactive element.
   :focus-visible only shows for keyboard navigation, not mouse clicks. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible,
[role="button"]:focus-visible,
summary:focus-visible {
  outline: 3px solid #0891B2;
  outline-offset: 2px;
  border-radius: 4px;
}
[data-theme="dark"] a:focus-visible,
[data-theme="dark"] button:focus-visible,
[data-theme="dark"] input:focus-visible,
[data-theme="dark"] textarea:focus-visible,
[data-theme="dark"] select:focus-visible,
[data-theme="dark"] [tabindex]:focus-visible,
[data-theme="dark"] [role="button"]:focus-visible {
  outline-color: #38BDF8;
}
:focus:not(:focus-visible) { outline: none; }

/* Active left-bar glow — softer in light mode */
[data-theme="light"] .seg button.active::before {
  box-shadow: 0 0 6px rgba(8,145,178,.40);
}

/* Topbar who-badge role pill — light readable override */
[data-theme="light"] .who-badge .badge {
  background: rgba(0,0,0,.08);
  color: rgba(0,0,0,.72);
  border-color: rgba(0,0,0,.14);
}
[data-theme="light"] .who-badge .badge.admin {
  background: rgba(5,150,105,.12);
  color: #059669;
  border-color: rgba(5,150,105,.25);
}

/* Muted text — ensure readable contrast */
[data-theme="light"] .muted { color: #475569; }
[data-theme="light"] .pane-desc { color: #475569; }
[data-theme="light"] .pane-sub  { color: #64748B; }
[data-theme="light"] .sidebar-label { color: #64748B; }

/* Dark mode: sidebar-label has opacity:.75 which makes it near-invisible — kill the opacity */
[data-theme="dark"] .sidebar-label { opacity: 1; color: #B0BCC8; }
/* Dark mode: pane descriptions and sub-labels need boosted contrast */
[data-theme="dark"] .pane-sub  { color: #B0BCC8; }
[data-theme="dark"] .pane-desc { color: #B0BCC8; }
[data-theme="dark"] .field-label { color: #B0BCC8; }

/* Health chip / tag labels */
[data-theme="light"] .health-label { color: #475569; }

/* KPI card label */
[data-theme="light"] .kpi-label { color: #475569; }

/* Holographic card shimmer — subtle in light mode */
[data-theme="light"] .card::after,
[data-theme="light"] .page-card::after,
[data-theme="light"] .feature-card::after {
  background: radial-gradient(circle at var(--mx) var(--my),
    rgba(8,145,178,.06) 0%, transparent 60%);
}

/* Lang toggle button */
.lang-toggle {
  font-size: 11px; font-weight: 800; letter-spacing: .06em;
  padding: 4px 9px !important; min-width: 36px;
}

/* ══════════════════════════════════════════════════════════════════════════
   LANG TOGGLE — visible on all screen sizes (topbar has enough room)
   ══════════════════════════════════════════════════════════════════════════ */
/* lang-toggle base styling already above; no extra display rules needed */


/* ── Skip-to-content link (a11y P2) ── */
.skip-link{position:absolute;left:-9999px;top:0;z-index:2000;background:#0891B2;color:#fff;padding:10px 16px;border-radius:0 0 8px 0;font-weight:600;text-decoration:none;}
.skip-link:focus{left:0;outline:3px solid #fff;outline-offset:-3px;}


/* ── Mobile touch targets (>=24px WCAG AA, comfortable tap) ───────────── */
@media (max-width: 767px) {
  input[type="checkbox"], input[type="radio"] { min-width: 24px; min-height: 24px; }
  select, input[type="date"], input[type="time"], input[type="number"] { min-height: 34px; }
  .site-footer a { display: inline-block; padding: 6px 4px; }
}
