:root {
  --primary: #1832C4;
  --primary-hover: #0f23a1;
  --sidebar-bg: #1e1e2d;
  --sidebar-hover: #2a2a3d;
  --sidebar-active: #1832C4;
  --header-bg: #ffffff;
  --body-bg: #f5f5f9;
  --text: #212529;
  --text-light: #6c757d;
  --text-white: #ffffff;
  --border: #e0e0e0;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 10px;
  --sidebar-width: 260px;
  --header-height: 56px;
  --font: 'Segoe UI', 'Noto Sans Georgian', system-ui, sans-serif;
}

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

html, body { height: 100%; font-family: var(--font); background: var(--body-bg); color: var(--text); }

/* Layout */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--text-white);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  transition: transform 0.3s ease;
  z-index: 100;
}

.sidebar-header {
  padding: 18px 16px;
  font-size: 1.1rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header .logo {
  width: 28px;
  height: 28px;
  background: var(--primary);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.plugin-nav {
  padding: 8px 0;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.75);
  font-size: 0.9rem;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  text-align: left;
}

.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }

.nav-icon { font-size: 1.1rem; width: 24px; text-align: center; flex-shrink: 0; }
.nav-img { width: 26px; height: 26px; display: block; margin: 0 auto; filter: brightness(0) invert(1); opacity: 0.85; }
.nav-label { line-height: 1.3; }

/* Main area */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.header {
  height: var(--header-height);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}

#sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
}

#header-title {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#plugin-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
#sidebar-overlay.visible { display: block; }

/* Sidebar footer */
.sidebar-footer {
  padding: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-footer button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  text-align: left;
}

.sidebar-footer button:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

/* Mobile */
@media (max-width: 768px) {
  #sidebar-toggle { display: block; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  #plugin-content { padding: 16px; }
}

/* Plugin error */
.plugin-error {
  padding: 20px;
  background: #fff3f3;
  border: 1px solid #ffc0c0;
  border-radius: var(--radius);
  color: #c00;
}

/* Theme toggle */
#theme-toggle {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
  margin-left: auto;
  line-height: 1;
}
#theme-toggle:hover { background: rgba(0,0,0,0.05); }

/* ─── Dark Theme ─── */
[data-theme="dark"] {
  --body-bg: #121220;
  --header-bg: #1a1a2e;
  --text: #e0e0e0;
  --text-light: #999;
  --border: #2a2a3e;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
}
[data-theme="dark"] .header { background: #1a1a2e; color: #e0e0e0; }
[data-theme="dark"] #sidebar-toggle { color: #e0e0e0; }
[data-theme="dark"] #header-title { color: #e0e0e0; }
[data-theme="dark"] #plugin-content { background: #121220; }
[data-theme="dark"] #theme-toggle { color: #e0e0e0; }
[data-theme="dark"] #theme-toggle:hover { background: rgba(255,255,255,0.08); }

/* Dark overrides for common inline patterns in plugins */
[data-theme="dark"] #plugin-content [style*="background:#fff"] { background: #1e1e2e !important; }
[data-theme="dark"] #plugin-content [style*="background: #fff"] { background: #1e1e2e !important; }
[data-theme="dark"] #plugin-content [style*="background:#f5f5f9"] { background: #222236 !important; }
[data-theme="dark"] #plugin-content [style*="background: #f5f5f9"] { background: #222236 !important; }
[data-theme="dark"] #plugin-content [style*="background:#f5f7fb"] { background: #1e1e30 !important; }
[data-theme="dark"] #plugin-content [style*="background:#fafbff"] { background: #1a1a2e !important; }
[data-theme="dark"] #plugin-content [style*="background:#f0f4ff"] { background: #1a1a3e !important; }
[data-theme="dark"] #plugin-content [style*="background:#f0f0f0"] { background: #2a2a3e !important; }
[data-theme="dark"] #plugin-content [style*="background:#f5f5f5"] { background: #2a2a3e !important; }
[data-theme="dark"] #plugin-content [style*="background:#f8f9ff"] { background: #1a1a30 !important; }
[data-theme="dark"] #plugin-content [style*="background:#f8f9fa"] { background: #2a2a3e !important; }
[data-theme="dark"] #plugin-content [style*="background:#f0f0f5"] { background: #2a2a3e !important; }
[data-theme="dark"] #plugin-content [style*="background:#e8edf5"] { background: #1a1a30 !important; }
[data-theme="dark"] #plugin-content [style*="background:#f8f8f8"] { background: #2a2a3e !important; }
[data-theme="dark"] #plugin-content [style*="background:#fff3f3"] { background: #2e1a1a !important; }
[data-theme="dark"] #plugin-content [style*="color:#333"] { color: #ddd !important; }
[data-theme="dark"] #plugin-content [style*="color:#888"] { color: #999 !important; }
[data-theme="dark"] #plugin-content [style*="color:#666"] { color: #aaa !important; }
[data-theme="dark"] #plugin-content [style*="color:#222"] { color: #ddd !important; }
[data-theme="dark"] #plugin-content [style*="color:#555"] { color: #bbb !important; }
[data-theme="dark"] #plugin-content [style*="color:#777"] { color: #aaa !important; }
[data-theme="dark"] #plugin-content [style*="color: #333"] { color: #ddd !important; }
[data-theme="dark"] #plugin-content [style*="color: #888"] { color: #999 !important; }
[data-theme="dark"] #plugin-content [style*="color: #666"] { color: #aaa !important; }
[data-theme="dark"] #plugin-content [style*="color: #222"] { color: #ddd !important; }
[data-theme="dark"] #plugin-content [style*="color: #555"] { color: #bbb !important; }
[data-theme="dark"] #plugin-content [style*="color: #777"] { color: #aaa !important; }
[data-theme="dark"] #plugin-content [style*="color:#c00"] { color: #ff6b6b !important; }
[data-theme="dark"] #plugin-content [style*="border-color:#d0d0d0"] { border-color: #444 !important; }
[data-theme="dark"] #plugin-content [style*="border:1px solid #e0e0e0"] { border-color: #3a3a4a !important; }
[data-theme="dark"] #plugin-content [style*="border: 1px solid #e0e0e0"] { border-color: #3a3a4a !important; }
[data-theme="dark"] #plugin-content [style*="border:2px solid #ddd"] { border-color: #444 !important; }
[data-theme="dark"] #plugin-content [style*="border-bottom:1px solid #e0e0e0"] { border-bottom-color: #3a3a4a !important; }
[data-theme="dark"] #plugin-content [style*="border-bottom:2px solid #e0e0e0"] { border-bottom-color: #3a3a4a !important; }
[data-theme="dark"] #plugin-content [style*="border-top:1px solid #e8e8e8"] { border-top-color: #3a3a4a !important; }
[data-theme="dark"] #plugin-content [style*="border-top:1px solid #e0e0e0"] { border-top-color: #3a3a4a !important; }
[data-theme="dark"] #plugin-content [style*="border:2px solid #e0e0e0"] { border-color: #444 !important; }
[data-theme="dark"] #plugin-content [style*="box-shadow:0 2px 12px rgba(0,0,0,0.08)"] { box-shadow: 0 2px 12px rgba(0,0,0,0.4) !important; }
[data-theme="dark"] #plugin-content [style*="box-shadow:0 2px 12px rgba(0, 0, 0, 0.08)"] { box-shadow: 0 2px 12px rgba(0,0,0,0.4) !important; }
[data-theme="dark"] #plugin-content [style*="background:rgba(0,0,0,0.05)"] { background: rgba(255,255,255,0.05) !important; }
[data-theme="dark"] #plugin-content [style*="box-shadow:0 2px 8px rgba(0,0,0,0.1)"] { box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important; }

/* Dark theme for selects/inputs in plugins */
[data-theme="dark"] #plugin-content select, 
[data-theme="dark"] #plugin-content input[type="text"],
[data-theme="dark"] #plugin-content input[type="number"],
[data-theme="dark"] #plugin-content input[type="email"],
[data-theme="dark"] #plugin-content input[type="url"],
[data-theme="dark"] #plugin-content textarea {
  background: #1e1e2e !important;
  color: #e0e0e0 !important;
  border-color: #444 !important;
}
[data-theme="dark"] #plugin-content button {
  border-color: #444 !important;
  color: #e0e0e0 !important;
}
[data-theme="dark"] #plugin-content button[style*="background:#1832C4"],
[data-theme="dark"] #plugin-content button[style*="background: #1832C4"] {
  color: #fff !important;
}

/* Additional colors */
[data-theme="dark"] #plugin-content [style*="color:#aaa"] { color: #aaa !important; }
[data-theme="dark"] #plugin-content [style*="color:#bbb"] { color: #bbb !important; }
[data-theme="dark"] #plugin-content [style*="color:#ccc"] { color: #aaa !important; }
[data-theme="dark"] #plugin-content [style*="color:#ddd"] { color: #ccc !important; }
[data-theme="dark"] #plugin-content [style*="color:#e53935"] { color: #ff8a80 !important; }

/* Additional backgrounds */
[data-theme="dark"] #plugin-content [style*="background:#f9f9fc"] { background: #1e1e30 !important; }
[data-theme="dark"] #plugin-content [style*="background:#f9fafb"] { background: #1e1e30 !important; }
[data-theme="dark"] #plugin-content [style*="background:#e8fce8"] { background: #1a2e1a !important; }
[data-theme="dark"] #plugin-content [style*="background:#fff3e0"] { background: #2e2a1a !important; }
[data-theme="dark"] #plugin-content [style*="background:#fce8e8"] { background: #2e1a1a !important; }
[data-theme="dark"] #plugin-content [style*="background:#fff8e1"] { background: #2e2a1a !important; }
[data-theme="dark"] #plugin-content [style*="background:#e8f5e9"] { background: #1a2e1a !important; }
[data-theme="dark"] #plugin-content [style*="background:#e8e8f0"] { background: #2a2a3e !important; }
[data-theme="dark"] #plugin-content [style*="background:#e0e0e0"] { background: #3a3a4a !important; }

/* Additional borders */
[data-theme="dark"] #plugin-content [style*="border:1px solid #d0d0d0"] { border-color: #555 !important; }
[data-theme="dark"] #plugin-content [style*="border: 1px solid #d0d0d0"] { border-color: #555 !important; }
[data-theme="dark"] #plugin-content [style*="border:1px solid #ddd"] { border-color: #555 !important; }
[data-theme="dark"] #plugin-content [style*="border: 1px solid #ddd"] { border-color: #555 !important; }
[data-theme="dark"] #plugin-content [style*="border:1px solid #ccc"] { border-color: #555 !important; }
[data-theme="dark"] #plugin-content [style*="border: 1px solid #ccc"] { border-color: #555 !important; }
[data-theme="dark"] #plugin-content [style*="border:2px dashed #ddd"] { border-color: #555 !important; }
[data-theme="dark"] #plugin-content [style*="background:#1e1e1e"] { background: #1e1e1e !important; }

/* http-codes category cards */
[data-theme="dark"] #plugin-content [style*="background:#e3f2fd"] { background: #1a2a4a !important; }
[data-theme="dark"] #plugin-content [style*="background:#e8f5e9"] { background: #1a3a1a !important; }
[data-theme="dark"] #plugin-content [style*="background:#fff8e1"] { background: #3a3a1a !important; }
[data-theme="dark"] #plugin-content [style*="background:#fce4ec"] { background: #3a1a2a !important; }
[data-theme="dark"] #plugin-content [style*="background:#efebe9"] { background: #2e2a2a !important; }
[data-theme="dark"] #plugin-content [style*="background:#bbdefb"] { background: #1a2a5a !important; }
[data-theme="dark"] #plugin-content [style*="background:#c8e6c9"] { background: #1a3a2a !important; }
[data-theme="dark"] #plugin-content [style*="background:#fff9c4"] { background: #3a3a1a !important; }
[data-theme="dark"] #plugin-content [style*="background:#ffcdd2"] { background: #4a1a1a !important; }
[data-theme="dark"] #plugin-content [style*="background:#d7ccc8"] { background: #3a2a2a !important; }
[data-theme="dark"] #plugin-content [style*="color:#1565c0"] { color: #64b5f6 !important; }
[data-theme="dark"] #plugin-content [style*="color:#2e7d32"] { color: #81c784 !important; }
[data-theme="dark"] #plugin-content [style*="color:#e65100"] { color: #ff8a65 !important; }
[data-theme="dark"] #plugin-content [style*="color:#c62828"] { color: #ef9a9a !important; }
[data-theme="dark"] #plugin-content [style*="color:#bf360c"] { color: #ffab91 !important; }
[data-theme="dark"] #plugin-content [style*="color:#f57f17"] { color: #ffd54f !important; }

/* SVG dark mode — voltage divider */
[data-theme="dark"] #plugin-content svg[viewBox="0 0 180 160"] line { stroke: #888 !important; }
[data-theme="dark"] #plugin-content svg[viewBox="0 0 180 160"] rect { fill: #2a2a3a !important; stroke: #4a6cf7 !important; }
[data-theme="dark"] #plugin-content svg[viewBox="0 0 180 160"] text { fill: #aaa !important; }
[data-theme="dark"] #plugin-content svg[viewBox="0 0 180 160"] text[fill="#1832C4"] { fill: #7b9aff !important; }

/* SVG dark mode — resistor-calc */
[data-theme="dark"] #plugin-content svg[viewBox="0 0 690 130"] line { stroke: #666 !important; }
[data-theme="dark"] #plugin-content svg[viewBox="0 0 690 130"] text { fill: #999 !important; }

/* status code category filter buttons */
[data-theme="dark"] #plugin-content button[style*="color:#1565c0"] { color: #64b5f6 !important; background: #1a2a5a !important; }
[data-theme="dark"] #plugin-content button[style*="color:#2e7d32"] { color: #81c784 !important; background: #1a3a2a !important; }
[data-theme="dark"] #plugin-content button[style*="color:#f57f17"] { color: #ffd54f !important; background: #3a3a1a !important; }
[data-theme="dark"] #plugin-content button[style*="color:#c62828"] { color: #ef9a9a !important; background: #4a1a1a !important; }
[data-theme="dark"] #plugin-content button[style*="color:#bf360c"] { color: #ffab91 !important; background: #3a2a1a !important; }

/* QR code — type buttons */
[data-theme="dark"] .qr-type { color: #bbb !important; border-color: #555 !important; background: #1e1e30 !important; }
[data-theme="dark"] .qr-type[style*="background:#eef1ff"] { background: #1a2a5a !important; border-color: #4a6cf7 !important; color: #7b9aff !important; }

/* Markdown editor — tabs */
[data-theme="dark"] .md-tabs { border-bottom-color: #333 !important; }
[data-theme="dark"] .md-tab.active { color: #3b82f6 !important; position: relative !important; }
[data-theme="dark"] .md-tab.active::after {
  content: '' !important;
  position: absolute !important;
  bottom: 0 !important;
  left: 4px !important;
  right: 4px !important;
  height: 2px !important;
  background: #3b82f6 !important;
  border-radius: 2px 2px 0 0 !important;
}
[data-theme="dark"] .md-tab { color: #888 !important; }
[data-theme="dark"] .md-footer button.secondary { background: #2a2a3e !important; color: #e0e0e0 !important; }
[data-theme="dark"] .md-footer button.secondary:hover { background: #3a3a4e !important; }
[data-theme="dark"] .md-footer select { background: #1e1e2e !important; color: #e0e0e0 !important; border-color: #444 !important; }

/* ipcalc — summary box brighter */
[data-theme="dark"] #ip-summary { background: #1e2a4a !important; }

/* ufw — chip and select dark mode */
[data-theme="dark"] .ufw-chip {
  background: #2a2a3e !important;
  border-color: #444 !important;
  color: #e0e0e0 !important;
}
[data-theme="dark"] .ufw-chip select {
  background: transparent !important;
  color: inherit !important;
}
[data-theme="dark"] .ufw-chip:first-child { background: #1832C4 !important; border-color: #1832C4 !important; }
[data-theme="dark"] .ufw-chip select option { background: #2a2a3e !important; color: #e0e0e0 !important; }

/* http-codes — card text bolder */
[data-theme="dark"] #hc-grid > div > div { font-weight: 600 !important; }
[data-theme="dark"] #hc-grid > div > div[style*="font-weight:700"] { font-weight: 700 !important; }

/* ufw — explain box, input, preset buttons dark override */
[data-theme="dark"] #ufw-explain { background: #1a1a30 !important; color: #d0d0d0 !important; }
[data-theme="dark"] .ufw-preset { background: #222236 !important; color: #e0e0e0 !important; border-color: #444 !important; }
[data-theme="dark"] .ufw-preset:hover { background: #2a2a4e !important; }
[data-theme="dark"] #ufw-history { border-top-color: #333 !important; }
[data-theme="dark"] .ufw-hist-item { border-bottom-color: #333 !important; }
[data-theme="dark"] .ufw-hist-item:hover { background: #2a2a4e !important; }

/* bash-prompt-generator — dark mode (inline rgb() format) */
[data-theme="dark"] #bp-elements button {
  background: #222236 !important;
  color: #e0e0e0 !important;
  border-color: #555 !important;
}
[data-theme="dark"] #bp-elements button[style*="background: rgb(238, 241, 255)"],
[data-theme="dark"] #bp-elements button[style*="background:rgb(238,241,255)"] {
  background: #1a2a5a !important;
  color: #7b9aff !important;
  border-color: #4a6cf7 !important;
}
[data-theme="dark"] #bp-selected {
  background: #1e1e30 !important;
  border-color: #444 !important;
}
[data-theme="dark"] #bp-selected > div {
  background: #2a2a3e !important;
  border-color: #444 !important;
  color: #e0e0e0 !important;
}
[data-theme="dark"] #bp-selected > div[style*="background: rgb(221, 227, 255)"],
[data-theme="dark"] #bp-selected > div[style*="background:rgb(221,227,255)"] {
  background: #1a2a5a !important;
  border-color: #4a6cf7 !important;
}
[data-theme="dark"] #bp-selected > div span[style*="color: rgb(204, 0, 0)"],
[data-theme="dark"] #bp-selected > div span[style*="color:rgb(204,0,0)"] {
  color: #ff6b6b !important;
}
[data-theme="dark"] #bp-props { background: #1e1e30 !important; }
[data-theme="dark"] #bp-props > div[style*="color:#aaa"],
[data-theme="dark"] #bp-props > div[style*="color: rgb(170, 170, 170)"],
[data-theme="dark"] #bp-props > div[style*="color:rgb(170,170,170)"] {
  color: #888 !important;
}
[data-theme="dark"] #bp-output { border-color: #444 !important; }

/* raid — disk row dark mode (rgb format from style.cssText) */
[data-theme="dark"] #rd-drives > div { background: #2a2a3e !important; }
[data-theme="dark"] #rd-drives > div span[style*="color:#666"],
[data-theme="dark"] #rd-drives > div span[style*="color: rgb(102, 102, 102)"] { color: #aaa !important; }
