/* ═══════════════════════════════════════════════════════════════════
   AutoPanel — Style System v2
   Theme: Dark-first with warm light mode
   Fonts: Outfit (UI) · IBM Plex Mono (data) · Heebo (Hebrew)
   i18n: RTL-ready via logical properties
══════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Global hidden utility */
.hidden { display: none !important; }

/* ─── CSS Variables ──────────────────────────────────────────── */
:root {
  /* ── Dark mode (default) ─────────────── */
  --bg:             #0a0a0a;
  --surface:        #141414;
  --surface-hover:  #1a1a1a;
  --surface-active: #1e1e1e;
  --text:           #e8e6e0;
  --text-secondary: #a3a3a3;
  --text-muted:     #737373;
  --text-faint:     #525252;
  --border:         #262626;
  --border-strong:  #404040;

  /* Accent */
  --accent:         #f59e0b;
  --accent-hover:   #d97706;
  --accent-bg:      rgba(245,158,11,0.10);

  /* Chrome (topbar) */
  --topbar-bg:      #050505;

  /* Inverse (active/selected/primary buttons) */
  --inv-bg:         #e8e6e0;
  --inv-text:       #0a0a0a;

  /* Dividers */
  --divider:        #262626;

  /* Errors */
  --error-tint:     rgba(239,68,68,0.08);
  --error-border:   rgba(239,68,68,0.20);

  /* Shadows */
  --shadow-sm:      0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg:      0 8px 32px rgba(0,0,0,0.5);
  --shadow-card:    0 1px 3px rgba(0,0,0,0.24);

  /* Status colours */
  --clr-running:    #22c55e;
  --clr-idle:       #6b7280;
  --clr-stopping:   #f59e0b;
  --clr-stopped:    #6b7280;
  --clr-error:      #ef4444;
  --clr-completed:  #22c55e;
  --clr-partial:    #f59e0b;
  --clr-pending:    #6b7280;
  --clr-progress:   #3b82f6;
  --clr-canceled:   #ef4444;
  --clr-failed:     #ef4444;

  /* Badge colours (dark) */
  --badge-running-bg:    rgba(34,197,94,0.12);
  --badge-running-text:  #4ade80;
  --badge-stopping-bg:   rgba(245,158,11,0.12);
  --badge-stopping-text: #fbbf24;
  --badge-idle-bg:       rgba(107,114,128,0.12);
  --badge-idle-text:     #9ca3af;
  --badge-error-bg:      rgba(239,68,68,0.12);
  --badge-error-text:    #f87171;
  --badge-completed-bg:  rgba(34,197,94,0.12);
  --badge-completed-text:#4ade80;
  --badge-partial-bg:    rgba(245,158,11,0.12);
  --badge-partial-text:  #fbbf24;
  --badge-pending-bg:    rgba(107,114,128,0.12);
  --badge-pending-text:  #9ca3af;
  --badge-processing-bg: rgba(59,130,246,0.12);
  --badge-processing-text:#60a5fa;
  --badge-canceled-bg:   rgba(239,68,68,0.12);
  --badge-canceled-text: #f87171;

  /* Log level badge colours */
  --log-info-bg:       rgba(107,114,128,0.12);
  --log-info-text:     #9ca3af;
  --log-success-bg:    rgba(34,197,94,0.12);
  --log-success-text:  #4ade80;
  --log-warning-bg:    rgba(245,158,11,0.12);
  --log-warning-text:  #fbbf24;
  --log-error-bg:      rgba(239,68,68,0.12);
  --log-error-text:    #f87171;

  /* Log row text */
  --log-success-row: #22c55e;
  --log-warning-row: #f59e0b;
  --log-error-row:   #ef4444;

  /* Layout */
  --topbar-h:       56px;
  --sidebar-w:      224px;
  --radius:         8px;
  --radius-sm:      6px;
  --radius-xs:      4px;

  /* Type */
  --font-head:  'Inter', 'Heebo', sans-serif;
  --font-body:  'Inter', 'Heebo', sans-serif;
  --font-mono:  'IBM Plex Mono', monospace;

  /* Transitions */
  --duration:   0.2s;
  --ease:       cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Light Mode ────────────────────────────────────────────── */
body.light-mode {
  --bg:             #f5f4f0;
  --surface:        #ffffff;
  --surface-hover:  #fafaf8;
  --surface-active: #f0efeb;
  --text:           #171717;
  --text-secondary: #525252;
  --text-muted:     #737373;
  --text-faint:     #a3a3a3;
  --border:         #e5e5e5;
  --border-strong:  #d4d4d4;
  --accent:         #d97706;
  --accent-hover:   #b45309;
  --accent-bg:      rgba(217,119,6,0.08);
  --topbar-bg:      #0d0d0d;
  --inv-bg:         #171717;
  --inv-text:       #ffffff;
  --divider:        #e5e5e5;
  --error-tint:     #fef2f2;
  --error-border:   #fecaca;
  --shadow-sm:      0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:      0 8px 32px rgba(0,0,0,0.12);
  --shadow-card:    0 1px 3px rgba(0,0,0,0.06);

  --clr-running:    #16a34a;
  --clr-stopping:   #d97706;
  --clr-stopped:    #374151;
  --clr-error:      #dc2626;
  --clr-completed:  #16a34a;
  --clr-partial:    #d97706;
  --clr-canceled:   #dc2626;
  --clr-failed:     #dc2626;

  --badge-running-bg:    #dcfce7;
  --badge-running-text:  #15803d;
  --badge-stopping-bg:   #fef3c7;
  --badge-stopping-text: #92400e;
  --badge-idle-bg:       #f3f4f6;
  --badge-idle-text:     #374151;
  --badge-error-bg:      #fee2e2;
  --badge-error-text:    #dc2626;
  --badge-completed-bg:  #dcfce7;
  --badge-completed-text:#15803d;
  --badge-partial-bg:    #fef3c7;
  --badge-partial-text:  #92400e;
  --badge-pending-bg:    #f3f4f6;
  --badge-pending-text:  #374151;
  --badge-processing-bg: #dbeafe;
  --badge-processing-text:#1d4ed8;
  --badge-canceled-bg:   #fee2e2;
  --badge-canceled-text: #dc2626;

  --log-info-bg:       #f3f4f6;
  --log-info-text:     #374151;
  --log-success-bg:    #dcfce7;
  --log-success-text:  #15803d;
  --log-warning-bg:    #fef3c7;
  --log-warning-text:  #92400e;
  --log-error-bg:      #fee2e2;
  --log-error-text:    #dc2626;

  --log-success-row: #15803d;
  --log-warning-row: #b45309;
  --log-error-row:   #dc2626;
}

/* ─── Base ───────────────────────────────────────────────────── */
html, body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─────────────────────────────────────────────────────────────────
   TOP BAR
───────────────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  inset-inline-start: 0;
  inset-inline-end: 0;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.topbar-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-mark {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.5px;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  user-select: none;
}

.brand-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.3px;
  color: #fff;
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 1px;
  align-self: center;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-clock {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 3px 10px;
  user-select: none;
  white-space: nowrap;
}

.balance-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.balance-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius-xs);
  padding: 3px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.balance-chip .chip-name {
  color: rgba(255,255,255,0.35);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.balance-chip .chip-amount {
  color: #fff;
  font-weight: 500;
}

.balance-chip.low .chip-amount { color: #fbbf24; }

/* WS indicator */
.ws-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  font-family: var(--font-mono);
}

.ws-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #374151;
  transition: background var(--duration) var(--ease);
}
.ws-indicator.connected .ws-dot { background: var(--clr-running); }
.ws-indicator.connected .ws-label { color: rgba(255,255,255,0.7); }
.ws-indicator.disconnected .ws-dot { background: var(--clr-error); }

/* Topbar icon buttons */
.topbar-icon-btn,
.logout-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.6);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--duration) var(--ease);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  padding: 0;
}
.topbar-icon-btn:hover { background: rgba(255,255,255,0.08); color: #fff; border-color: rgba(255,255,255,0.22); }
.logout-btn:hover { background: rgba(220,38,38,0.6); color: #fff; border-color: transparent; }

.lang-toggle-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.6);
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--duration) var(--ease);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.lang-toggle-btn:hover { background: rgba(255,255,255,0.08); color: #fff; border-color: rgba(255,255,255,0.22); }

/* ─────────────────────────────────────────────────────────────────
   LAYOUT
───────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  height: 100vh;
  padding-top: var(--topbar-h);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  padding: 16px 0;
  flex-shrink: 0;
  overflow-y: auto;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
}

.nav-section { padding: 0 12px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  text-align: start;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--duration) var(--ease);
  position: relative;
  margin-bottom: 2px;
}

.nav-item svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--inv-bg);
  color: var(--inv-text);
  font-weight: 600;
}

.nav-badge {
  margin-inline-start: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  line-height: 1.4;
}

.running-badge {
  background: var(--clr-running);
  color: #fff;
  display: none;
}
.running-badge.visible { display: inline; }

/* Main content */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 36px;
  position: relative;
}

/* ─────────────────────────────────────────────────────────────────
   SECTIONS
───────────────────────────────────────────────────────────────── */
.section { max-width: 1200px; margin: 0 auto; }
.section.hidden { display: none; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--divider);
}

.section-title {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}

.section-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.sub-title {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.mt-lg { margin-top: 40px; }

/* ─────────────────────────────────────────────────────────────────
   STAT CARDS
───────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 20px;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.stat-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.stat-card::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--border-strong);
}

.stat-card.accent-running::before { background: var(--clr-running); }
.stat-card.accent-ok::before      { background: var(--clr-completed); }
.stat-card.accent-warn::before    { background: var(--clr-partial); }
.stat-card.accent-err::before     { background: var(--clr-error); }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-head);
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  letter-spacing: -1px;
}

/* ─────────────────────────────────────────────────────────────────
   FILTER ROW
───────────────────────────────────────────────────────────────── */
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--duration) var(--ease);
}

.filter-btn.active {
  background: var(--inv-bg);
  color: var(--inv-text);
  border-color: transparent;
}

.filter-btn:hover:not(.active) { border-color: var(--border-strong); color: var(--text); }

.select-sm {
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12.5px;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease);
}
.select-sm:focus { border-color: var(--accent); }

/* ─────────────────────────────────────────────────────────────────
   AUTOMATION CARDS (dashboard active list)
───────────────────────────────────────────────────────────────── */
.auto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.auto-mini-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.auto-mini-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }

.auto-mini-card::before {
  content: '';
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  inset-inline-end: 0;
  height: 3px;
}

.auto-mini-card.status-running::before   { background: var(--clr-running); }
.auto-mini-card.status-stopping::before  { background: var(--clr-stopping); }
.auto-mini-card.status-error::before     { background: var(--clr-error); }
.auto-mini-card.status-idle::before      { background: var(--border-strong); }
.auto-mini-card.status-stopped::before   { background: var(--text-faint); }

.mini-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.mini-card-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  line-height: 1.3;
}

.mini-card-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 2px;
}

.mini-card-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.mini-stat { display: flex; flex-direction: column; }
.mini-stat-val { font-family: var(--font-mono); font-weight: 500; color: var(--text); }
.mini-stat-key { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ─────────────────────────────────────────────────────────────────
   AUTOMATION CARD LIST (full view)
───────────────────────────────────────────────────────────────── */
.auto-card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auto-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.auto-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }

.auto-card-top {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  gap: 16px;
}

.auto-card-indicator {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.auto-card-indicator.status-running  { background: var(--clr-running); animation: pulse 2s infinite; }
.auto-card-indicator.status-stopping { background: var(--clr-stopping); }
.auto-card-indicator.status-idle     { background: var(--text-faint); }
.auto-card-indicator.status-stopped  { background: var(--text-faint); }
.auto-card-indicator.status-error    { background: var(--clr-error); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.auto-card-info { flex: 1; min-width: 0; }

.auto-card-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auto-card-detail {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.auto-card-counters {
  display: flex;
  gap: 20px;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.counter-item { display: flex; flex-direction: column; align-items: center; }
.counter-val  { font-family: var(--font-mono); font-weight: 600; font-size: 16px; color: var(--text); }
.counter-key  { font-size: 9px; text-transform: uppercase; letter-spacing: 0.6px; }

.auto-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.auto-card-bottom {
  padding: 12px 20px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.auto-card-bottom span b { color: var(--text); }

.auto-card.status-error .auto-card-bottom {
  background: var(--error-tint);
  color: var(--clr-error);
}

/* ─────────────────────────────────────────────────────────────────
   STATUS BADGE
───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.badge-running    { background: var(--badge-running-bg);    color: var(--badge-running-text); }
.badge-stopping   { background: var(--badge-stopping-bg);   color: var(--badge-stopping-text); }
.badge-idle,
.badge-stopped    { background: var(--badge-idle-bg);       color: var(--badge-idle-text); }
.badge-error      { background: var(--badge-error-bg);      color: var(--badge-error-text); }
.badge-Completed  { background: var(--badge-completed-bg);  color: var(--badge-completed-text); }
.badge-Partial    { background: var(--badge-partial-bg);    color: var(--badge-partial-text); }
.badge-Pending    { background: var(--badge-pending-bg);    color: var(--badge-pending-text); }
.badge-Processing,
.badge-In\.progress { background: var(--badge-processing-bg); color: var(--badge-processing-text); }
.badge-Canceled   { background: var(--badge-canceled-bg);   color: var(--badge-canceled-text); }
.badge-Failed     { background: var(--badge-canceled-bg);   color: var(--badge-canceled-text); }

/* ─────────────────────────────────────────────────────────────────
   PANEL CARDS
───────────────────────────────────────────────────────────────── */
.panel-card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  box-shadow: var(--shadow-card);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.panel-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }

.panel-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-card-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.panel-card-url {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
  word-break: break-all;
}

.panel-balance {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin: 12px 0 8px;
}

.panel-balance.low { color: var(--clr-error); }
.panel-balance-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
  margin-bottom: 14px;
}

.panel-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ─────────────────────────────────────────────────────────────────
   DATA TABLE
───────────────────────────────────────────────────────────────── */
.table-wrap, .log-table-wrap {
  width: 100%;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.log-table-wrap.fullheight { max-height: calc(100vh - 240px); overflow-y: auto; }

.data-table, .log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.data-table th, .log-table th {
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  padding: 12px 14px;
  text-align: start;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table td, .log-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tr:last-child td,
.log-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td,
.log-table tr:hover td { background: var(--surface-hover); }

.mono-cell {
  font-family: var(--font-mono);
  font-size: 11px;
}

.empty-td {
  text-align: center;
  color: var(--text-faint);
  padding: 32px !important;
  font-style: italic;
}

/* Log level colours */
.log-row-success td:nth-child(2) { color: var(--log-success-row); }
.log-row-warning td:nth-child(2) { color: var(--log-warning-row); }
.log-row-error   td:nth-child(2) { color: var(--log-error-row); }

.log-level-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
}

.log-level-badge.info    { background: var(--log-info-bg);    color: var(--log-info-text); }
.log-level-badge.success { background: var(--log-success-bg); color: var(--log-success-text); }
.log-level-badge.warning { background: var(--log-warning-bg); color: var(--log-warning-text); }
.log-level-badge.error   { background: var(--log-error-bg);   color: var(--log-error-text); }

.pagination-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 0 4px;
}

.page-info {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* ─────────────────────────────────────────────────────────────────
   BUTTONS
───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--inv-bg);
  color: var(--inv-text);
  border-color: transparent;
}
.btn-primary:hover:not(:disabled) { opacity: 0.85; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text); background: var(--surface-hover); }

.btn-success {
  background: var(--clr-running);
  color: #fff;
  border-color: var(--clr-running);
}
.btn-success:hover:not(:disabled) { background: #15803d; }

.btn-danger {
  background: transparent;
  color: var(--clr-error);
  border-color: var(--clr-error);
}
.btn-danger:hover:not(:disabled) { background: var(--error-tint); }

.btn-warn {
  background: var(--clr-stopping);
  color: #fff;
  border-color: var(--clr-stopping);
}
.btn-warn:hover:not(:disabled) { background: #b45309; }

.btn-sm { padding: 5px 12px; font-size: 12px; }

.text-danger { color: var(--clr-error); }

/* ─────────────────────────────────────────────────────────────────
   FORMS
───────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  margin-bottom: 14px;
}
.form-group:last-child { margin-bottom: 0; }

.form-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.req { color: var(--clr-error); }
.hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-size: 11px;
  color: var(--text-faint);
}

.form-input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
  width: 100%;
}

.form-input.mono { font-family: var(--font-mono); font-size: 12px; }

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.form-input::placeholder { color: var(--text-faint); }

.form-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.form-row .form-group { min-width: 140px; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ─────────────────────────────────────────────────────────────────
   SERVICE SELECT + INFO CARD
───────────────────────────────────────────────────────────────── */
.service-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.service-select-wrap select { flex: 1; }

.svc-id-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.svc-id-row input { flex: 1; min-width: 0; }
.svc-id-row .btn { flex-shrink: 0; white-space: nowrap; }

.service-loading {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
}
.service-loading.hidden { display: none; }

.service-info-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-top: 6px;
  animation: fadeSlideIn 0.25s ease;
}

.service-info-card.hidden { display: none; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sic-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.sic-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.sic-cat {
  font-size: 11px;
  color: var(--text-faint);
  background: var(--border);
  padding: 1px 8px;
  border-radius: 10px;
}

.sic-stats {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.sic-stat { display: flex; flex-direction: column; gap: 2px; }
.sic-key { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-faint); }
.sic-val { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--text); }

/* ─────────────────────────────────────────────────────────────────
   MODAL
───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: backdropIn 0.2s ease;
}

@keyframes backdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-backdrop.hidden { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px;
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal.modal-wide { max-width: 640px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: all var(--duration) var(--ease);
}
.modal-close:hover { background: var(--bg); color: var(--text); }

/* ─────────────────────────────────────────────────────────────────
   TOAST NOTIFICATIONS
───────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.toast {
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-body);
  max-width: 360px;
  animation: toastIn 0.3s ease;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
}

.toast.toast-success { background: var(--clr-running); color: #fff; }
.toast.toast-warning { background: var(--clr-stopping); color: #fff; }
.toast.toast-error   { background: var(--clr-error); color: #fff; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─────────────────────────────────────────────────────────────────
   ALERT BANNER (LOW BALANCE)
───────────────────────────────────────────────────────────────── */
.alert-banner {
  position: fixed;
  top: var(--topbar-h);
  inset-inline-start: var(--sidebar-w);
  inset-inline-end: 0;
  background: #fef3c7;
  border-bottom: 2px solid var(--clr-stopping);
  color: #92400e;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
  z-index: 90;
}

.alert-banner.hidden { display: none; }
.alert-icon { font-size: 18px; }
.alert-banner button {
  margin-inline-start: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #92400e;
  padding: 2px 8px;
}

/* ─────────────────────────────────────────────────────────────────
   EMPTY STATE
───────────────────────────────────────────────────────────────── */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13.5px;
  font-style: italic;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ─────────────────────────────────────────────────────────────────
   SPINNER
───────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────────────────────────────────────────────────────────
   SCROLLBAR
───────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ─── Text Selection ─────────────────────────────────────────── */
::selection {
  background: rgba(245, 158, 11, 0.22);
  color: var(--text);
}

/* ─── Select / Dropdown Theming ──────────────────────────────── */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  /* Custom chevron — neutral grey works in both modes */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23737373' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-inline-end: 28px;
  cursor: pointer;
}

/* Dropdown popup — override system colours */
select option,
select optgroup {
  background-color: #1a1a1a;
  color: #e8e6e0;
}

body.light-mode select option,
body.light-mode select optgroup {
  background-color: #ffffff;
  color: #171717;
}

select optgroup {
  font-weight: 600;
  font-style: normal;
}

/* .form-input and .select-sm use the 'background' shorthand which resets
   background-image — restore the chevron with higher specificity */
select.form-input,
select.select-sm {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23737373' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-inline-end: 28px;
}

/* ─── Number Input Spinners ──────────────────────────────────── */
input[type='number']::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type='number'] { -moz-appearance: textfield; }

/* ─── Autofill Override ──────────────────────────────────────── */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset;
  box-shadow: 0 0 0 1000px var(--bg) inset;
  transition: background-color 9999s ease-in-out 0s;
}

/* ─── Search Input Cancel Button ────────────────────────────── */
input[type='search']::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  height: 14px;
  width: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath fill='%23737373' d='M7 5.586L2.707 1.293 1.293 2.707 5.586 7l-4.293 4.293 1.414 1.414L7 8.414l4.293 4.293 1.414-1.414L8.414 7l4.293-4.293L11.293 1.293z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  cursor: pointer;
}

/* ─── Focus-visible ring (keyboard nav) ─────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─────────────────────────────────────────────────────────────────
   LOGIN OVERLAY
───────────────────────────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.login-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.3px;
  color: var(--text);
}

.login-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 28px;
}

.login-form .form-group { margin-bottom: 16px; }

.login-btn {
  width: 100%;
  margin-top: 8px;
  padding: 11px;
  font-size: 14px;
}

.login-error {
  background: var(--error-tint);
  border: 1px solid var(--error-border);
  color: var(--clr-error);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

/* ─────────────────────────────────────────────────────────────────
   HAMBURGER
───────────────────────────────────────────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all 0.25s ease;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile sidebar backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-backdrop.visible { display: block; }

/* ─────────────────────────────────────────────────────────────────
   SPEND ANALYTICS
───────────────────────────────────────────────────────────────── */
.spend-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 32px;
}

.spend-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.spend-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }

.spend-card-total {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.spend-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.spend-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}

/* ─────────────────────────────────────────────────────────────────
   AUTOMATION LINK
───────────────────────────────────────────────────────────────── */
.auto-link {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
  transition: color var(--duration) var(--ease);
}
.auto-link:hover { text-decoration: underline; color: var(--accent-hover); }

/* ─────────────────────────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────────────────────────── */

/* Tablet */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .balance-list { display: none; }
}

/* Mobile */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  .hamburger { display: flex; }

  .brand-tag { display: none; }

  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    inset-inline-start: 0;
    height: calc(100dvh - var(--topbar-h));
    z-index: 95;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.2);
  }

  /* RTL sidebar slides from right */
  html[dir="rtl"] .sidebar {
    transform: translateX(100%);
  }

  .sidebar.open { transform: translateX(0) !important; }

  .content {
    margin-inline-start: 0 !important;
    padding: 16px;
  }

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  .auto-card-counters { display: none; }

  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .modal {
    width: 100vw;
    max-width: 100%;
    max-height: 92dvh;
    overflow-y: auto;
    padding: 24px 20px;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .modal-backdrop { padding: 0; align-items: flex-end; }

  .section-header { flex-wrap: wrap; gap: 8px; }
  .section-header .btn { font-size: 12px; padding: 6px 12px; }

  .form-row { flex-direction: column; gap: 0; }

  .spend-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Small phones */
@media (max-width: 480px) {
  .topbar { padding: 0 14px; }
  .brand-name { font-size: 15px; }
  .brand-mark { font-size: 14px; padding: 2px 5px; }

  .content { padding: 12px; }

  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 14px 12px; }
  .stat-value { font-size: 26px; }

  .ws-label { display: none; }

  .section-title { font-size: 18px; }

  .spend-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .spend-value { font-size: 16px; }

  .lang-toggle-btn { padding: 0 8px; font-size: 11px; }
}

/* ─────────────────────────────────────────────────────────────────
   BULK CREATE
───────────────────────────────────────────────────────────────── */
.bulk-links-area {
  min-height: 180px;
  resize: vertical;
  font-size: 12.5px;
  line-height: 1.7;
  tab-size: 2;
}

.bulk-links-count {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
}

.bulk-progress {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 12px;
}

.bulk-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.25s var(--ease);
}

.bulk-status {
  max-height: 160px;
  overflow-y: auto;
  font-size: 12px;
  font-family: var(--font-mono);
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 12px;
  scroll-behavior: smooth;
}

.bulk-row {
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bulk-row.ok {
  background: var(--badge-completed-bg);
  color: var(--badge-completed-text);
}

.bulk-row.err {
  background: var(--badge-error-bg);
  color: var(--badge-error-text);
}

/* ─────────────────────────────────────────────────────────────────
   RTL ADJUSTMENTS
───────────────────────────────────────────────────────────────── */
html[dir="rtl"] .auto-card-bottom { direction: rtl; }
html[dir="rtl"] .pagination-row { direction: rtl; }
html[dir="rtl"] .filter-row { direction: rtl; }
