/* ============================================
   LOMA — Dark Minimalist Dashboard v2
   Inspired by Linear, Vercel, Raycast
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-hover: #1a1a1a;
  --surface-active: #1e1e1e;
  --surface-raised: #181818;
  --border: #222;
  --border-subtle: #1a1a1a;
  --border-hover: #333;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-muted: rgba(99, 102, 241, 0.12);
  --accent-glow: rgba(99, 102, 241, 0.08);
  --success: #22c55e;
  --success-muted: rgba(34, 197, 94, 0.12);
  --error: #ef4444;
  --error-muted: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-muted: rgba(245, 158, 11, 0.12);
  --info: #3b82f6;
  --info-muted: rgba(59, 130, 246, 0.12);
  --cyan: #06b6d4;
  --cyan-muted: rgba(6, 182, 212, 0.12);
  --text: #e5e5e5;
  --text-secondary: #737373;
  --text-tertiary: #525252;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --radius-lg: 14px;
  --sidebar-collapsed: 56px;
  --sidebar-expanded: 200px;
  --transition: 0.15s ease;
  --transition-slow: 0.25s ease;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'SF Mono', 'Cascadia Code', 'Fira Code', ui-monospace, monospace;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.15);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.35), 0 4px 8px rgba(0,0,0,0.2);
  --shadow-glow-accent: 0 0 20px rgba(99, 102, 241, 0.15), 0 0 40px rgba(99, 102, 241, 0.05);
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover {
  color: var(--accent-hover);
}

/* --- Layout --- */
.layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar (fixed, always expanded) --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-expanded);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-header {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.sidebar-logo .logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  margin-right: 10px;
  flex-shrink: 0;
}
.sidebar-logo .logo-text {
  opacity: 1;
}

.sidebar-nav {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
  gap: 10px;
}
.sidebar-link:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.sidebar-link.active {
  background: var(--accent-muted);
  color: var(--accent-hover);
}

.sidebar-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}
.sidebar-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-label {
  font-size: 13px;
  font-weight: 500;
  opacity: 1;
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

/* --- Main Content --- */
.main {
  margin-left: var(--sidebar-expanded);
  flex: 1;
  min-height: 100vh;
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 40px;
}

/* --- Page Header --- */
.page-header {
  margin-bottom: 32px;
}
.page-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
}
.card:hover {
  border-color: var(--border-hover);
}

/* --- Stat Cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  box-shadow: var(--shadow-sm);
}
.stat-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.stat-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}
.stat-card--accent::before { background: var(--accent); }
.stat-card--success::before { background: var(--success); }
.stat-card--warning::before { background: var(--warning); }
.stat-card--error::before { background: var(--error); }
.stat-card--info::before { background: var(--info); }
.stat-card--cyan::before { background: var(--cyan); }

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.stat-icon--accent { background: var(--accent-muted); color: var(--accent); }
.stat-icon--success { background: var(--success-muted); color: var(--success); }
.stat-icon--warning { background: var(--warning-muted); color: var(--warning); }
.stat-icon--error { background: var(--error-muted); color: var(--error); }
.stat-icon--info { background: var(--info-muted); color: var(--info); }
.stat-icon--cyan { background: var(--cyan-muted); color: var(--cyan); }

.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

/* --- Pipeline Status Indicator --- */
.pipeline-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.pipeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pipeline-dot--active {
  background: var(--success);
  box-shadow: 0 0 8px var(--success), 0 0 16px rgba(34, 197, 94, 0.3);
  animation: pulse-green 2s infinite;
}
.pipeline-dot--idle {
  background: var(--text-tertiary);
}
@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.pipeline-status-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.pipeline-status-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

/* --- Last Run Summary --- */
.last-run-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}
.last-run-summary .run-type-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 9999px;
  background: var(--accent-muted);
  color: var(--accent-hover);
}
.last-run-info {
  flex: 1;
  display: flex;
  gap: 24px;
  font-size: 12px;
  color: var(--text-secondary);
}
.last-run-info strong {
  color: var(--text);
  font-weight: 600;
}

/* --- Tables --- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
.table-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.table-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  text-align: left;
  padding: 10px 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.015);
  white-space: nowrap;
}
tbody td {
  padding: 10px 20px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
  vertical-align: middle;
}
tbody tr:last-child td {
  border-bottom: none;
}
tbody tr {
  transition: background var(--transition);
}
tbody tr:hover {
  background: var(--surface-hover);
}
tbody tr:hover td {
  color: var(--text);
}

.cell-mono {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-secondary);
}
.cell-truncate {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-link {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
.cell-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}
.cell-number {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  font-size: 12px;
}

/* --- Status Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 18px;
  white-space: nowrap;
}
.badge--ready {
  background: var(--success-muted);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.2);
}
.badge--success,
.badge--published,
.badge--completed {
  background: var(--success-muted);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.2);
}
.badge--error,
.badge--failed {
  background: var(--error-muted);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.badge--unchecked,
.badge--pending {
  background: var(--warning-muted);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}
.badge--warning {
  background: var(--warning-muted);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}
.badge--done {
  background: var(--info-muted);
  color: var(--info);
  border: 1px solid rgba(59, 130, 246, 0.2);
}
.badge--running {
  background: var(--accent-muted);
  color: var(--accent-hover);
  border: 1px solid rgba(99, 102, 241, 0.2);
  animation: badge-pulse 2s infinite;
}
@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.badge--draft {
  background: rgba(115,115,115,0.12);
  color: var(--text-secondary);
  border: 1px solid rgba(115,115,115,0.15);
}
.badge--stopped {
  background: rgba(115,115,115,0.12);
  color: var(--text-secondary);
  border: 1px solid rgba(115,115,115,0.15);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  flex-shrink: 0;
}
.badge--ready .badge-dot { background: var(--success); }
.badge--success .badge-dot,
.badge--published .badge-dot,
.badge--completed .badge-dot { background: var(--success); }
.badge--error .badge-dot,
.badge--failed .badge-dot { background: var(--error); }
.badge--unchecked .badge-dot,
.badge--pending .badge-dot { background: var(--warning); }
.badge--warning .badge-dot { background: var(--warning); }
.badge--done .badge-dot { background: var(--info); }
.badge--running .badge-dot {
  background: var(--accent);
  animation: pulse-green 1.5s infinite;
}
.badge--draft .badge-dot { background: var(--text-tertiary); }
.badge--stopped .badge-dot { background: var(--text-tertiary); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1;
  text-decoration: none;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: var(--shadow-glow-accent);
  transform: translateY(-1px);
}
.btn--primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn--secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.btn--danger {
  background: var(--error-muted);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn--danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.35);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
}
.btn--ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn--sm {
  padding: 5px 10px;
  font-size: 12px;
}
.btn--lg {
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius);
}
.btn--xl {
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius);
}

.btn-icon {
  display: inline-flex;
  font-size: 14px;
  flex-shrink: 0;
}
.btn-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Filter Pills --- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  width: fit-content;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.filter-pill {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.filter-pill:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.filter-pill.active {
  color: var(--text);
  background: var(--surface-active);
  box-shadow: inset 0 0 0 1px var(--border);
}
.filter-pill .pill-count {
  font-size: 10px;
  font-weight: 600;
  background: rgba(255,255,255,0.06);
  padding: 1px 6px;
  border-radius: 9999px;
  font-variant-numeric: tabular-nums;
}

/* --- Search Input --- */
.search-box {
  position: relative;
  margin-bottom: 16px;
  max-width: 360px;
}
.search-box input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}
.search-box input::placeholder {
  color: var(--text-tertiary);
}
.search-box-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}
.search-box-icon svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
  text-decoration: none;
}
.pagination-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border);
}
.pagination-btn.active {
  background: var(--accent-muted);
  color: var(--accent-hover);
  border-color: rgba(99, 102, 241, 0.2);
  font-weight: 600;
}
.pagination-btn:disabled,
.pagination-btn.disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.pagination-info {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 0 8px;
}

/* --- Drop Zones --- */
.drop-zones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.drop-zone {
  border: 1px dashed #333;
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  background: var(--surface);
}
.drop-zone:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-muted);
  box-shadow: var(--shadow-glow-accent);
}
.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.drop-zone-icon {
  font-size: 24px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  display: block;
}
.drop-zone-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}
.drop-zone-hint {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* --- Action Cards --- */
.actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  box-shadow: var(--shadow-sm);
}
.action-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.action-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-bottom: 18px;
}
.action-card-icon--accent {
  background: var(--accent-muted);
  color: var(--accent);
}
.action-card-icon--success {
  background: var(--success-muted);
  color: var(--success);
}
.action-card-icon--warning {
  background: var(--warning-muted);
  color: var(--warning);
}

.action-card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}
.action-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
  flex: 1;
}
.action-card .btn {
  width: 100%;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
}

/* --- Progress --- */
.progress-section {
  margin-bottom: 24px;
}
.progress-section.hidden {
  display: none;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.progress-title {
  font-size: 14px;
  font-weight: 600;
}
.progress-meta {
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 16px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 3px;
  transition: width 0.5s ease;
  position: relative;
}
.progress-fill.animating::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-counters {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.progress-counter {
  font-size: 12px;
  color: var(--text-secondary);
}
.progress-counter strong {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.progress-eta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.progress-eta svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* --- Idle State (Run Page) --- */
.idle-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.idle-state-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--text-tertiary);
}
.idle-state-icon svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}
.idle-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.idle-state-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}
.idle-state-meta {
  display: inline-flex;
  gap: 20px;
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 10px 16px;
  background: rgba(255,255,255,0.02);
  border-radius: var(--radius-sm);
}
.idle-state-meta strong {
  color: var(--text-secondary);
  font-weight: 600;
}

/* --- Terminal / Log --- */
.log-box {
  background: #0c0c0c;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 360px;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.log-box::-webkit-scrollbar {
  width: 6px;
}
.log-box::-webkit-scrollbar-track {
  background: transparent;
}
.log-box::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}
.log-line {
  padding: 1px 0;
  white-space: pre-wrap;
  word-break: break-all;
}
.log-line--error {
  color: var(--error);
}
.log-line--success {
  color: var(--success);
}
.log-line--info {
  color: var(--accent-hover);
}

/* --- Export Page --- */
.export-hero {
  text-align: center;
  padding: 56px 20px 48px;
  margin-bottom: 32px;
  position: relative;
}
.export-hero::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.export-hero-number {
  font-size: 72px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
}
.export-hero-label {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: 500;
  position: relative;
}

.export-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 32px;
}

.export-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 40px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
  box-shadow: var(--shadow-sm);
}
.export-stat {
  text-align: center;
}
.export-stat-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.export-stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
  margin-top: 2px;
}

/* --- Domain Detail Header --- */
.detail-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.detail-title {
  font-size: 16px;
  font-weight: 600;
  font-family: var(--mono);
  margin-bottom: 16px;
  color: var(--text);
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.detail-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.detail-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  font-weight: 500;
}
.detail-value {
  font-size: 13px;
  color: var(--text);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-tertiary);
}
.empty-state-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.empty-state-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.empty-state-desc {
  font-size: 12px;
}

/* --- Forms --- */
form .form-row {
  margin-bottom: 16px;
}
form label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

/* --- Flash Messages --- */
.flash {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}
.flash--success {
  background: var(--success-muted);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.15);
}
.flash--error {
  background: var(--error-muted);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.15);
}
.flash--warning {
  background: var(--warning-muted);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.15);
}

/* --- Toast / Copy notification --- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 18px;
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* --- Loading skeleton --- */
@keyframes skeleton-loading {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface) 0px, var(--surface-hover) 100px, var(--surface) 200px);
  background-size: 200px 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-xs);
  height: 20px;
}

/* --- Utility --- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-secondary { color: var(--text-secondary); }
.text-mono { font-family: var(--mono); font-size: 12px; }
.text-sm { font-size: 12px; }
.text-center { text-align: center; }
.w-full { width: 100%; }

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in {
  animation: fadeIn 0.2s ease forwards;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in-up {
  animation: fadeInUp 0.3s ease forwards;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.spin {
  animation: spin 1s linear infinite;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-collapsed);
  }
  .main {
    margin-left: var(--sidebar-collapsed);
  }
  .sidebar-label, .sidebar-logo .logo-text {
    display: none;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .actions-grid {
    grid-template-columns: 1fr;
  }
  .drop-zones {
    grid-template-columns: 1fr;
  }
  .page {
    padding: 24px 16px;
  }
  .filter-bar {
    width: 100%;
    overflow-x: auto;
  }
  .export-hero-number {
    font-size: 48px;
  }
  .export-stats {
    flex-direction: column;
    gap: 16px;
  }
  .last-run-summary {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  .last-run-info {
    flex-wrap: wrap;
    gap: 12px;
  }
  .progress-counters {
    gap: 12px;
  }
  table {
    font-size: 12px;
  }
  thead th,
  tbody td {
    padding: 8px 12px;
  }
  .idle-state {
    padding: 32px 20px;
  }
  .pipeline-status {
    flex-wrap: wrap;
  }
  .search-box {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .stat-card {
    padding: 16px;
  }
  .stat-value {
    font-size: 22px;
  }
  .export-actions {
    flex-direction: column;
    align-items: center;
  }
  .pagination {
    flex-wrap: wrap;
  }
}

/* --- Topbar --- */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.topbar-logo:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.topbar-logo.active {
  background: var(--accent-muted);
  color: var(--accent);
}
.topbar-logo .logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 14px;
}
.topbar-logo .logo-text {
  font-size: 15px;
}
.topbar-dashboard-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-left: 4px;
}
.topbar-logo.active .topbar-dashboard-label {
  color: var(--accent);
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.topbar-username {
  color: var(--text);
  font-weight: 500;
}
.topbar-logout {
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.topbar-logout:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-hover);
}

/* --- Auth pages --- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
}
.auth-logo .logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 16px;
}
.auth-logo .logo-text {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.auth-title {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 6px;
}
.auth-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.5;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.auth-field > span {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.auth-field input,
.auth-field select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font: inherit;
  transition: border-color var(--transition), background var(--transition);
}
.auth-field input:focus,
.auth-field select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}
.auth-error {
  background: var(--error-muted);
  color: var(--error);
  border: 1px solid var(--error-muted);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}
.auth-submit {
  width: 100%;
  margin-top: 8px;
}

/* --- Alerts --- */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert--error {
  background: var(--error-muted);
  color: var(--error);
  border-color: var(--error-muted);
}
.alert--success {
  background: var(--success-muted);
  color: var(--success);
  border-color: var(--success-muted);
}

/* --- Extra badge variants --- */
.badge--primary {
  background: var(--accent-muted);
  color: var(--accent);
}
.badge--muted {
  background: var(--surface-active);
  color: var(--text-secondary);
}

/* --- Topbar stats inline --- */
.topbar {
  gap: 16px;
}
.topbar-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
.topbar-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  min-width: 70px;
  transition: border-color var(--transition), background var(--transition);
  color: var(--text);
  text-decoration: none;
}
.topbar-stat:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  color: var(--text);
}
.topbar-stat-value {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.1;
}
.topbar-stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: lowercase;
  letter-spacing: 0;
}
.topbar-stat--success .topbar-stat-value { color: var(--success); }
.topbar-stat--warning .topbar-stat-value { color: var(--warning); }

.topbar-task {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
  max-width: 380px;
}
.topbar-task-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
  flex-shrink: 0;
}
.topbar-task--active .topbar-task-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
  animation: pulse 1.6s ease-in-out infinite;
}
.topbar-task--active .topbar-task-text {
  color: var(--text);
}
.topbar-task-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@media (max-width: 1100px) {
  .topbar-task { display: none; }
}
@media (max-width: 900px) {
  .topbar-stats { display: none; }
}

/* --- Tabs --- */
.tab-link {
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  text-decoration: none;
  transition: all var(--transition);
}
.tab-link:hover {
  color: var(--text);
}
.tab-link.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- Sortable table --- */
.sortable-table th.sortable {
  position: relative;
}
.sortable-table th.sortable::after {
  content: '↕';
  margin-left: 6px;
  opacity: 0.3;
  font-size: 10px;
}
.sortable-table th.sort-asc::after {
  content: '↑';
  opacity: 1;
  color: var(--accent);
}
.sortable-table th.sort-desc::after {
  content: '↓';
  opacity: 1;
  color: var(--accent);
}


/* --- Sidebar collapsible --- */
.sidebar { transition: width 0.18s ease; }
.main { transition: margin-left 0.18s ease; }
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .logo-text,
.sidebar.collapsed .sidebar-toggle-label { display: none; }
.layout.sidebar-collapsed .main { margin-left: var(--sidebar-collapsed); }

.sidebar-header {
  position: relative;
}
.sidebar-toggle {
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  padding: 0;
  transition: all var(--transition);
}
.sidebar-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar-toggle:hover { background: var(--surface-hover); color: var(--text); }
.sidebar.collapsed .sidebar-header {
  justify-content: center;
}
.sidebar.collapsed .sidebar-logo { display: none; }
.sidebar.collapsed .sidebar-toggle { margin-left: 0; }

/* Allow horizontal scroll on raw tables in campaigns/users pages */
.sortable-table { display: table; }
.page > table.sortable-table,
.page > .table-scroll {
  display: block;
  overflow-x: auto;
  width: 100%;
}

/* --- Segmented toggle (campaign type 1-click) --- */
.seg-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: var(--accent);
  color: #fff;
}

/* --- API budget banner --- */
.api-budget-banner {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  color: #fff;
  padding: 14px 20px;
  border-radius: 8px;
  margin: 0 0 20px;
  font-size: 14px;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}
.api-budget-banner strong { font-weight: 700; }
.api-budget-banner a { color: #fff; }

/* --- Password input with show/hide toggle --- */
.pw-wrap {
  position: relative;
  display: block;
}
.pw-wrap input {
  width: 100%;
  padding-right: 38px;
  box-sizing: border-box;
}
.pw-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
}
.pw-toggle:hover { color: var(--text); background: var(--surface-hover); }

/* --- Wide pages (campaigns / users / domains) — full container width --- */
.page--wide {
  max-width: 100%;
  padding-left: 12px;
  padding-right: 12px;
}

/* Compact wide tables — squeeze padding so the whole table fits to the left
   edge without the horizontal slider (Pasha правки 15.05 / 17.05). */
.page--wide .table-scroll { overflow-x: auto; }
.sortable-table { width: 100%; table-layout: auto; }
.sortable-table thead th { padding: 8px 8px; font-size: 10px; }
.sortable-table tbody td { padding: 7px 8px; font-size: 12px; }
.sortable-table tbody td.cell-mono,
.sortable-table .cell-mono { font-size: 11px; }
.sortable-table .btn--sm {
  padding: 3px 6px;
  font-size: 11px;
  min-width: 0;
}

/* --- Dropdown menu --- */
.dropdown-wrap { position: relative; }
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 220px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  overflow: hidden;
}
.dropdown-menu.open { display: block; }
.dropdown-menu a {
  display: block;
  padding: 10px 14px;
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
}
.dropdown-menu a:hover { background: var(--surface-hover); }
/* per-column filter */
th.col-filtered { background: rgba(255,200,0,0.12); }
th.col-filtered button { color:var(--accent); border-color:var(--accent); }
