/* ============================================================
   Voltaxion Ops Admin — dark unicorn-tech palette
   ============================================================ */

:root {
  --bg: #0a0612;
  --bg-elev: #120a22;
  --bg-card: #16102a;
  --bg-card-2: #1d1638;
  --border: #2a1f4a;
  --border-strong: #3a2d68;
  --text: #e8e3f5;
  --text-mute: #9b8fc0;
  --text-dim: #6b5d8f;
  --accent: #a855f7;
  --accent-2: #06b6d4;
  --accent-3: #ec4899;
  --neon: linear-gradient(135deg, #a855f7 0%, #06b6d4 60%, #ec4899 100%);
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --info: #3b82f6;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}
code, .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.92em; }

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

/* ============ App shell ============ */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "top top"
    "side main";
  min-height: 100vh;
}
.topbar {
  grid-area: top;
  background: linear-gradient(90deg, #0a0612 0%, #160a2c 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.tb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.3px;
}
.tb-logo {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--neon);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  box-shadow: 0 0 14px rgba(168,85,247,0.5);
}
.tb-sub {
  font-size: 11px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  padding: 3px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
}
.tb-spacer { flex: 1; }
.tb-search {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  color: var(--text);
  width: 280px;
  font-size: 13px;
}
.tb-search:focus { outline: none; border-color: var(--accent); }
.tb-user {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.tb-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--neon);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 11px;
}
.tb-user-name { font-size: 12px; font-weight: 600; }
.tb-user-role { font-size: 10px; color: var(--text-mute); }

/* ============ Sidebar ============ */
.sidebar {
  grid-area: side;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  overflow-y: auto;
}
.nav-section { margin-bottom: 18px; }
.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-dim);
  padding: 0 10px 8px;
}
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-mute);
  font-weight: 500;
  cursor: pointer;
  gap: 10px;
  margin-bottom: 2px;
  font-size: 13px;
}
.nav-item:hover { background: var(--bg-card); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(168,85,247,0.18), rgba(168,85,247,0.04));
  color: var(--text);
  border-left: 2px solid var(--accent);
  padding-left: 8px;
}
.nav-icon { width: 16px; text-align: center; opacity: 0.9; }
.nav-badge {
  background: var(--accent-3);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.nav-badge.warn { background: var(--warn); }
.nav-badge.ok { background: var(--ok); }
.nav-badge.muted { background: var(--border-strong); color: var(--text-mute); }

/* ============ Main ============ */
.main {
  grid-area: main;
  padding: 24px 32px 40px;
  overflow-y: auto;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  gap: 20px;
  flex-wrap: wrap;
}
.page-head h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.page-head .sub {
  color: var(--text-mute);
  font-size: 13px;
}
.page-head-right { display: flex; gap: 10px; align-items: center; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}
.btn:hover { border-color: var(--accent); }
.btn-primary {
  background: var(--neon);
  border-color: transparent;
  color: white;
  box-shadow: 0 0 18px rgba(168,85,247,0.35);
}
.btn-primary:hover { box-shadow: 0 0 26px rgba(168,85,247,0.55); }
.btn-ghost { background: transparent; }
.btn-danger { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.4); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-mute);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
}
.icon-btn:hover { color: var(--accent); }

/* ============ Pills / chips ============ */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-card-2);
  color: var(--text-mute);
  border: 1px solid var(--border);
}
.pill-live { color: var(--ok); border-color: rgba(34,197,94,0.4); background: rgba(34,197,94,0.08); }
.pill-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity: 0.5; } }

.pill-ok { color: var(--ok); border-color: rgba(34,197,94,0.4); background: rgba(34,197,94,0.08); }
.pill-warn { color: var(--warn); border-color: rgba(245,158,11,0.4); background: rgba(245,158,11,0.08); }
.pill-err { color: #fca5a5; border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.08); }
.pill-info { color: #93c5fd; border-color: rgba(59,130,246,0.4); background: rgba(59,130,246,0.08); }
.pill-accent { color: #d8b4fe; border-color: rgba(168,85,247,0.5); background: rgba(168,85,247,0.12); }

/* state pills (orders) */
.state {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.state-lock { background: rgba(168,85,247,0.15); color: #d8b4fe; }
.state-quoted { background: rgba(59,130,246,0.15); color: #93c5fd; }
.state-confirmed { background: rgba(6,182,212,0.15); color: #67e8f9; }
.state-allocated { background: rgba(236,72,153,0.15); color: #f9a8d4; }
.state-shipped { background: rgba(245,158,11,0.15); color: #fcd34d; }
.state-delivered { background: rgba(34,197,94,0.15); color: #86efac; }
.state-closed { background: rgba(107,93,143,0.15); color: var(--text-mute); }
.state-disputed { background: rgba(239,68,68,0.15); color: #fca5a5; }
.state-cancelled { background: rgba(107,93,143,0.12); color: var(--text-dim); text-decoration: line-through; }

/* tiers */
.tier-T0 { background: rgba(107,93,143,0.15); color: var(--text-mute); padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: 11px; }
.tier-T1 { background: rgba(59,130,246,0.15); color: #93c5fd; padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: 11px; }
.tier-T2 { background: rgba(168,85,247,0.15); color: #d8b4fe; padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: 11px; }
.tier-T3 { background: var(--neon); color: white; padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: 11px; }

/* ============ Cards / KPIs ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--border-strong); }
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 700; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.kpi::after {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 60px; height: 60px;
  background: radial-gradient(circle at top right, rgba(168,85,247,0.15), transparent 70%);
  pointer-events: none;
}
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  font-family: 'JetBrains Mono', monospace;
}
.kpi-delta {
  font-size: 11px;
  margin-top: 6px;
  font-weight: 600;
}
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--err); }
.kpi-delta.flat { color: var(--text-mute); }

/* dashboard grid */
.dash-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.dash-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
@media (max-width: 1100px) {
  .dash-grid, .dash-grid-3 { grid-template-columns: 1fr; }
}

/* activity feed */
.feed { list-style: none; padding: 0; margin: 0; }
.feed-item {
  display: flex; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.feed-item:last-child { border-bottom: none; }
.feed-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
  flex-shrink: 0;
}
.feed-dot.ok { background: var(--ok); }
.feed-dot.warn { background: var(--warn); }
.feed-dot.err { background: var(--err); }
.feed-text { flex: 1; font-size: 13px; }
.feed-time { color: var(--text-dim); font-size: 11px; margin-top: 2px; font-family: 'JetBrains Mono', monospace; }

/* queue widget */
.queue-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.queue-row:last-child { border-bottom: none; }
.queue-row a { color: var(--text); font-weight: 500; }
.queue-row a:hover { color: var(--accent); }

/* ============ Tables ============ */
.tbl-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl thead {
  background: var(--bg-card-2);
  border-bottom: 1px solid var(--border);
}
.tbl th {
  text-align: left;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-mute);
}
.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background 0.1s; }
.tbl tbody tr:hover { background: rgba(168,85,247,0.04); cursor: pointer; }
.tbl .num { font-family: 'JetBrains Mono', monospace; text-align: right; }
.tbl .pos { color: var(--ok); }
.tbl .neg { color: var(--err); }

.tbl-toolbar {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 14px;
  background: var(--bg-card-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tbl-toolbar input, .tbl-toolbar select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.tbl-toolbar input { min-width: 200px; }
.tbl-toolbar .filter-spacer { flex: 1; }

.tab-row {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mute);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.tab .tab-count {
  background: var(--bg-card-2);
  color: var(--text-mute);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.tab.active .tab-count { background: var(--accent); color: white; }

/* ============ Modal ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(5,2,15,0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
}
.modal-overlay.open { display: block; }
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 880px;
  max-height: 88vh;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  z-index: 101;
  display: none;
  flex-direction: column;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), 0 0 50px rgba(168,85,247,0.15);
}
.modal.open { display: flex; }
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  background: var(--bg-card-2);
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 22px;
  margin-bottom: 18px;
}
.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 4px;
}
.field-value { font-size: 13px; font-weight: 500; }

/* state pipeline */
.pipeline {
  display: flex; gap: 4px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.pipe-step {
  flex: 1;
  min-width: 80px;
  padding: 8px 6px;
  text-align: center;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  background: var(--bg-card-2);
  color: var(--text-dim);
  border-radius: 5px;
  border: 1px solid var(--border);
}
.pipe-step.done { background: rgba(34,197,94,0.1); color: #86efac; border-color: rgba(34,197,94,0.3); }
.pipe-step.current { background: var(--neon); color: white; border-color: transparent; box-shadow: 0 0 15px rgba(168,85,247,0.4); }

/* ============ Login page ============ */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at top, rgba(168,85,247,0.15), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(6,182,212,0.1), transparent 50%),
    var(--bg);
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 36px 38px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5), 0 0 60px rgba(168,85,247,0.1);
}
.login-brand {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px;
}
.login-logo {
  width: 44px; height: 44px;
  border-radius: 11px;
  background: var(--neon);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 0 22px rgba(168,85,247,0.45);
}
.login-title { font-size: 17px; font-weight: 800; }
.login-sub { font-size: 12px; color: var(--text-mute); }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label {
  display: flex; flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.login-form input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.login-form input:focus { outline: none; border-color: var(--accent); }
.login-err {
  color: var(--err);
  font-size: 12px;
  text-align: center;
  min-height: 14px;
}
.login-foot {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-mute);
}
.login-foot-row { padding: 3px 0; }
.login-foot-row.muted { color: var(--text-dim); }

.muted { color: var(--text-mute); }
.dim { color: var(--text-dim); }
.bold { font-weight: 700; }
.right { text-align: right; }
.center { text-align: center; }
.mb-12 { margin-bottom: 12px; }
.mb-18 { margin-bottom: 18px; }

.empty {
  padding: 40px;
  text-align: center;
  color: var(--text-dim);
}

/* responsive */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "top" "main"; }
  .sidebar { display: none; }
  .main { padding: 16px; }
}
