:root {
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-panel: #f1f5f9;
  --bg-elevated: #eef2f6;
  --bg-hover: #e9edf2;
  --border-dim: #e2e8f0;
  --border-mid: #cbd5e1;
  --border-bright: #94a3b8;
  --accent-cyan: #0d9488;
  --accent-cyan-dim: rgba(13,148,136,0.08);
  --accent-cyan-glow: rgba(13,148,136,0.2);
  --accent-green: #15803d;
  --accent-green-dim: rgba(21,128,61,0.08);
  --accent-amber: #b45309;
  --accent-amber-dim: rgba(180,83,9,0.08);
  --accent-red: #dc2626;
  --accent-red-dim: rgba(220,38,38,0.08);
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --font-display: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'IBM Plex Mono', monospace;
  --radius: 6px;
  --radius-lg: 10px;
  --transition-fast: 0.15s ease;
}

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

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-dim);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.header-brand { display: flex; align-items: center; gap: 14px; }
.brand-icon {
  width: 36px; height: 36px;
  border: 1.5px solid var(--accent-cyan);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  background: white;
}
.brand-name { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; }
.brand-sub { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); text-transform: uppercase; }
.header-meta { display: flex; align-items: center; gap: 20px; }
.status-pill {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px;
  background: var(--bg-panel); border: 1px solid var(--border-dim);
  border-radius: 20px; padding: 4px 12px;
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-green); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

/* Main */
.main { padding: 28px 32px 60px; max-width: 1600px; margin: 0 auto; }

/* Stats Bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent-color, var(--accent-cyan));
}
.stat-label { font-family: var(--font-mono); font-size: 10px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; }
.stat-value { font-size: 32px; font-weight: 600; letter-spacing: -0.5px; }
.stat-sub { font-family: var(--font-mono); font-size: 10px; color: var(--text-secondary); }

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--bg-surface);
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-dim);
}
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-label { font-size: 0.7rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-muted); font-family: var(--font-mono); }
.filter-select, .filter-search-input {
  background: var(--bg-panel);
  border: 1px solid var(--border-dim);
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
}
.filter-search-input { min-width: 200px; }
.filter-select:focus, .filter-search-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px var(--accent-cyan-dim);
}
#clear-filters {
  background: var(--bg-panel);
  border: 1px solid var(--border-dim);
  padding: 8px 16px;
  border-radius: var(--radius);
}
#clear-filters:hover { background: var(--bg-hover); }

/* Tabs */
.tabs-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.tabs-header {
  display: flex;
  border-bottom: 1px solid var(--border-dim);
  background: var(--bg-panel);
}
.tab-btn {
  flex: 1;
  padding: 14px 24px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border-dim);
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.tab-btn:last-child { border-right: none; }
.tab-btn .tab-count {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-dim);
  border-radius: 12px;
  padding: 1px 7px;
}
.tab-btn.active { color: var(--accent-cyan); background: var(--bg-surface); }
.tab-btn.active::after {
  content: '';
  position: absolute; bottom: -1px; left: 0; right: 0; height: 2px;
  background: var(--accent-cyan);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Toolbar & Table */
.toolbar {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-dim);
  flex-wrap: wrap;
  gap: 16px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}
.btn-primary { background: var(--accent-cyan); color: white; }
.btn-primary:hover { background: #0f766e; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-mid); }
.btn-ghost:hover { background: var(--bg-elevated); }

.table-wrapper { overflow-x: auto; }
.cx-table { width: 100%; border-collapse: collapse; min-width: 1200px; }
.cx-table th {
  padding: 11px 14px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  border-right: 1px solid var(--border-dim);
  background: var(--bg-panel);
}
.cx-table td {
  padding: 8px 10px;
  border-right: 1px solid var(--border-dim);
  vertical-align: middle;
}
.cell-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 13px;
}
.cell-input:focus {
  border-color: var(--accent-cyan);
  background: var(--bg-elevated);
  outline: none;
}
select.cell-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2364748b'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}
.del-btn {
  width: 28px; height: 28px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
}
.del-btn:hover { background: var(--accent-red-dim); border-color: var(--accent-red); color: var(--accent-red); }
.bottom-bar {
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border-dim);
  background: var(--bg-panel);
}
.row-count { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  padding: 32px;
  width: 480px;
  max-width: 90vw;
}
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.modal-sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-label { font-family: var(--font-mono); font-size: 10px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; margin-bottom: 6px; display: block; }
.form-input {
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.form-input:focus { border-color: var(--accent-cyan); outline: none; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }
.modal-info {
  background: var(--accent-cyan-dim);
  border: 1px solid rgba(13,148,136,0.2);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 10px;
  margin-bottom: 20px;
}

/* Toast */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  background: var(--bg-surface);
  border-left: 3px solid var(--accent-cyan);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.toast.success { border-left-color: var(--accent-green); }
.toast.error { border-left-color: var(--accent-red); }

/* Empty state */
.empty-state { padding: 64px 24px; text-align: center; color: var(--text-muted); }

/* Responsive */
@media (max-width: 768px) {
  .main { padding: 20px 16px 40px; }
  .header { padding: 0 16px; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-group { width: 100%; }
  .filter-select, .filter-search-input { flex: 1; }
  #clear-filters { width: 100%; justify-content: center; }
}