:root {
  --bg: #0A0F1C;
  --bg-elevated: #0F1626;
  --surface: #131A2B;
  --surface-2: #1A2238;
  --border: #1F2940;
  --border-strong: #2B3654;
  --text: #E8ECF4;
  --text-dim: #8893AF;
  --text-muted: #5C6885;
  --silver: #C0C7D4;
  --silver-bright: #E2E8F0;
  --accent: #4A9EFF;
  --accent-dim: #2563EB;
  --success: #4ADE80;
  --warning: #FBB040;
  --danger: #FF5C5C;
  --gold: #D4A857;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  --radius: 10px;
  --radius-sm: 6px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(74,158,255,0.06), transparent 50%),
    radial-gradient(900px 500px at -10% 100%, rgba(192,199,212,0.04), transparent 50%),
    var(--bg);
}

#app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

/* ============== SIDEBAR ============== */
.sidebar {
  background: linear-gradient(180deg, #0C1322 0%, #0A0F1C 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--silver-bright);
  background: linear-gradient(135deg, rgba(192,199,212,0.15), rgba(192,199,212,0.05));
  border: 1px solid rgba(192,199,212,0.2);
  border-radius: 8px;
}
.brand-mark svg { width: 22px; height: 22px; }

.brand-name {
  font-weight: 700;
  letter-spacing: 0.15em;
  font-size: 13px;
  color: var(--silver-bright);
}
.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.nav {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  padding: 14px 10px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  font-weight: 500;
  font-size: 13.5px;
  text-decoration: none;
  transition: background 120ms, color 120ms;
}
.nav-link:hover {
  background: rgba(255,255,255,0.03);
  color: var(--text);
}
.nav-link.active {
  background: linear-gradient(90deg, rgba(74,158,255,0.12), rgba(74,158,255,0.02));
  color: var(--silver-bright);
  border: 1px solid rgba(74,158,255,0.25);
  padding: 8px 9px;
}
.nav-icon {
  font-size: 13px;
  width: 16px;
  text-align: center;
  color: var(--silver);
}

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

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3A4567, #1F2940);
  color: var(--silver-bright);
  font-weight: 600;
  font-size: 12px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
}
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--text-muted); }

.env-tag {
  margin-top: 10px;
  font-size: 10px;
  text-align: center;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  padding: 6px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}

/* ============== TOPBAR ============== */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(10,15,28,0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.search {
  flex: 1;
  max-width: 480px;
}
.search input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
}
.search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-2);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(74,222,128,0.08);
  border: 1px solid rgba(74,222,128,0.2);
  color: #86EFAC;
  font-size: 12px;
  border-radius: 100px;
  font-weight: 500;
}
.status-dot {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success);
}

.btn-icon {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 100px;
  border: 2px solid var(--bg);
}

/* ============== VIEW ============== */
.view {
  flex: 1;
  padding: 28px;
  overflow-y: auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  gap: 20px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--silver-bright);
  letter-spacing: -0.01em;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.page-actions { display: flex; gap: 10px; }

/* ============== BUTTONS ============== */
.btn {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 120ms;
}
.btn:hover { background: var(--surface-2); border-color: var(--silver); }
.btn-primary {
  background: linear-gradient(135deg, #4A9EFF, #2563EB);
  border-color: #2563EB;
  color: white;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #5BA9FF, #3070EE);
  border-color: #3070EE;
}
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }

/* ============== CARDS ============== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}
.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ============== KPI GRID ============== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.kpi {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--silver);
}
.kpi.success::before { background: var(--success); }
.kpi.warning::before { background: var(--warning); }
.kpi.accent::before { background: var(--accent); }
.kpi.gold::before { background: var(--gold); }

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--silver-bright);
  margin: 8px 0 4px;
  letter-spacing: -0.02em;
}
.kpi-delta {
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta.flat { color: var(--text-muted); }

/* ============== GRIDS ============== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
.grid-main-side { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .grid-main-side { grid-template-columns: 1fr; }
}

/* ============== TABLES ============== */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tbody tr:hover { background: rgba(255,255,255,0.015); }
tbody tr:last-child td { border-bottom: none; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono, .mono { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }

/* ============== BADGES / TAGS ============== */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.tag.success { background: rgba(74,222,128,0.1); color: #86EFAC; border-color: rgba(74,222,128,0.25); }
.tag.warning { background: rgba(251,176,64,0.1); color: #FCD34D; border-color: rgba(251,176,64,0.25); }
.tag.danger { background: rgba(255,92,92,0.1); color: #FCA5A5; border-color: rgba(255,92,92,0.25); }
.tag.accent { background: rgba(74,158,255,0.1); color: #93C5FD; border-color: rgba(74,158,255,0.25); }
.tag.silver { background: rgba(192,199,212,0.08); color: var(--silver-bright); border-color: rgba(192,199,212,0.2); }
.tag.gold { background: rgba(212,168,87,0.1); color: #FCD34D; border-color: rgba(212,168,87,0.3); }

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

/* ============== PROGRESS ============== */
.progress {
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 100px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #6FB8FF);
  border-radius: 100px;
}
.progress-bar.success { background: linear-gradient(90deg, #22C55E, var(--success)); }
.progress-bar.warning { background: linear-gradient(90deg, #F59E0B, var(--warning)); }

/* ============== LISTS ============== */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title {
  font-weight: 500;
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 2px;
}
.list-item-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============== AVATARS / THUMBNAILS ============== */
.thumb {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--surface-2), var(--bg-elevated));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: var(--silver);
  font-size: 14px;
  flex-shrink: 0;
}
.thumb.lg { width: 48px; height: 48px; font-size: 18px; }

/* ============== CHART ============== */
.chart-area {
  height: 220px;
  position: relative;
  margin-top: 12px;
}
.chart-area svg { width: 100%; height: 100%; }
.chart-axis { stroke: var(--border); stroke-width: 1; }
.chart-line { stroke: var(--accent); stroke-width: 2; fill: none; }
.chart-fill { fill: url(#chartGradient); opacity: 0.4; }
.chart-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2,4; opacity: 0.5; }
.chart-label { fill: var(--text-muted); font-size: 10px; font-family: 'JetBrains Mono', monospace; }

/* ============== TABS ============== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--silver-bright);
  border-bottom-color: var(--accent);
}

/* ============== MODAL/DRAWER ============== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
}
.drawer-backdrop.open { display: block; }
.drawer {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: 560px;
  max-width: 100vw;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  z-index: 101;
  transform: translateX(100%);
  transition: transform 240ms ease;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.drawer-title { font-weight: 700; font-size: 16px; color: var(--silver-bright); }
.drawer-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.drawer-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
}

/* ============== FORMS ============== */
.field { margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field-input, .field-select, .field-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
}
.field-textarea { min-height: 80px; resize: vertical; }
.field-input:focus, .field-select:focus, .field-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ============== UTIL ============== */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: 8px; }
.gap-md { gap: 14px; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.bright { color: var(--silver-bright); }
.mb-sm { margin-bottom: 10px; }
.mb-md { margin-bottom: 18px; }
.mt-md { margin-top: 18px; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.bold { font-weight: 600; }
.right { text-align: right; }
.center { text-align: center; }
.uppercase { text-transform: uppercase; letter-spacing: 0.08em; }

/* ============== DIVIDER ============== */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ============== TOASTS ============== */
.toasts {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 12px 16px 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  animation: toastIn 200ms ease;
}
.toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px currentColor;
  flex-shrink: 0;
}
.toast-warning .toast-dot { background: var(--warning); }
.toast-danger .toast-dot  { background: var(--danger); }
.toast-accent .toast-dot  { background: var(--accent); }
@keyframes toastIn {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ============== KANBAN PIPELINE ============== */
.pipeline {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.pipeline-col {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pipeline-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.pipeline-card {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
  transition: border-color 120ms, transform 120ms;
}
.pipeline-card:hover { border-color: var(--silver); transform: translateY(-1px); }

/* ============== EMPTY STATES ============== */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: #3A4567; }
