/* === Tarkov-Bot — Light Minimal Design Tokens === */
:root {
  /* Surfaces — clean off-whites */
  --bg-0: #fafbfa;        /* page bg */
  --bg-1: #ffffff;        /* panel */
  --bg-2: #f4f6f5;        /* card alt */
  --bg-3: #eaedeb;        /* hover / raised */
  --bg-4: #d8dcda;        /* border-strong */

  --line: #ececec;        /* hairlines */
  --line-2: #dcdfdd;

  /* Foreground */
  --fg-0: #1a1d1c;        /* primary text */
  --fg-1: #4a514f;        /* secondary */
  --fg-2: #7a807e;        /* tertiary / labels */
  --fg-3: #b6bab8;        /* disabled */

  /* Accent — soft sage green (primary) */
  --amber: #5a9b7e;
  --amber-2: #4a8a6e;
  --amber-dim: #b3d4c3;
  --amber-bg: rgba(90, 155, 126, 0.10);

  /* Status / secondary accents */
  --green: #5a9b7e;
  --green-dim: #b3d4c3;
  --green-bg: rgba(90, 155, 126, 0.10);

  --blue: #6b8fb8;
  --blue-bg: rgba(107, 143, 184, 0.10);

  --red: #c47a7a;
  --red-bg: rgba(196, 122, 122, 0.10);

  --yellow: #d4b056;

  /* Typography */
  --ff-sans: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ff-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ff-display: "Inter Tight", "Helvetica Neue", sans-serif;

  /* Density */
  --pad: 16px;
  --pad-sm: 10px;
  --pad-lg: 24px;
  --row-h: 44px;
  --radius: 6px;
  --radius-lg: 10px;
}

[data-density="compact"] {
  --pad: 12px;
  --pad-sm: 8px;
  --pad-lg: 18px;
  --row-h: 36px;
}
[data-density="comfortable"] {
  --pad: 22px;
  --pad-sm: 14px;
  --pad-lg: 32px;
  --row-h: 52px;
}

* { box-sizing: border-box; }

html { scrollbar-gutter: stable; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: var(--ff-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

#root { min-height: 100vh; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

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

/* ===== Reusable element classes ===== */
.mono { font-family: var(--ff-mono); font-feature-settings: "tnum"; }
.label {
  font-family: var(--ff-sans);
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--fg-2);
  font-weight: 500;
}
.num {
  font-family: var(--ff-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.panel {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
}

.divider {
  height: 1px;
  background: var(--line);
  width: 100%;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  color: var(--fg-0);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  transition: all 120ms ease;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-2); border-color: var(--bg-4); }
.btn-primary {
  background: var(--amber);
  color: #ffffff;
  border-color: var(--amber);
  font-weight: 500;
}
.btn-primary:hover { background: var(--amber-2); border-color: var(--amber-2); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--fg-1);
}
.btn-ghost:hover { background: var(--bg-2); color: var(--fg-0); }
.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  justify-content: center;
}
.btn-danger {
  background: transparent;
  border-color: var(--red);
  color: var(--red);
}
.btn-danger:hover { background: var(--red-bg); }

/* Inputs */
.input, .select {
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  color: var(--fg-0);
  padding: 8px 12px;
  font-size: 13px;
  border-radius: var(--radius);
  outline: none;
  transition: border-color 120ms ease;
  width: 100%;
}
.input:focus, .select:focus { border-color: var(--amber); }
.input::placeholder { color: var(--fg-3); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  font-family: var(--ff-sans);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--fg-1);
  background: var(--bg-1);
  white-space: nowrap;
  font-weight: 500;
}
.badge-amber { color: var(--amber-2); border-color: var(--amber-dim); background: var(--amber-bg); }
.badge-green { color: var(--green); border-color: var(--green-dim); background: var(--green-bg); }
.badge-red { color: var(--red); border-color: rgba(196, 122, 122, 0.35); background: var(--red-bg); }
.badge-blue { color: var(--blue); border-color: rgba(107, 143, 184, 0.35); background: var(--blue-bg); }

/* Status dot */
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--fg-3);
  display: inline-block;
}
.dot-online { background: var(--green); }
.dot-offline { background: var(--fg-3); }
.dot-blocked { background: var(--red); }

/* KPI + tables */
.kpi-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad-lg) var(--pad);
  position: relative;
  overflow: hidden;
}
.kpi-label {
  font-family: var(--ff-sans);
  font-size: 12px;
  color: var(--fg-2);
  margin-bottom: 12px;
  font-weight: 500;
}
.kpi-value {
  font-family: var(--ff-sans);
  font-variant-numeric: tabular-nums;
  font-size: 28px;
  font-weight: 500;
  color: var(--fg-0);
  letter-spacing: -0.02em;
  line-height: 1;
}
.kpi-delta {
  font-family: var(--ff-sans);
  font-size: 12px;
  line-height: 1.2;
  color: var(--fg-2);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.kpi-delta svg { position: relative; top: 1px; }
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }

/* Table */
.tb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tb-table thead th {
  text-align: left;
  font-family: var(--ff-sans);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg-2);
  font-weight: 500;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.tb-table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  color: var(--fg-0);
  vertical-align: middle;
}
.tb-table tbody tr:hover { background: var(--bg-2); }
.tb-table tbody tr:last-child td { border-bottom: none; }

/* Grid variant — visible cell borders + zebra rows for spreadsheet-style editing */
.tb-table.tb-grid {
  border-collapse: separate;
  border-spacing: 0;
}
.tb-table.tb-grid thead th {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line-2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.tb-table.tb-grid thead th:last-child { border-right: none; }
.tb-table.tb-grid tbody td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.tb-table.tb-grid tbody td:last-child { border-right: none; }
.tb-table.tb-grid tbody tr:nth-child(even) td { background: var(--bg-0); }
.tb-table.tb-grid tbody tr:hover td { background: var(--bg-3); }
.tb-table.tb-grid tbody tr:last-child td { border-bottom: none; }

/* Section header */
.section-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-h h2 {
  font-size: 14px;
  font-family: var(--ff-sans);
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--fg-0);
  font-weight: 500;
  margin: 0;
}

/* Page heading */
h1.page-title {
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--fg-0);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  padding: 12px 18px;
  font-family: var(--ff-sans);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg-2);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 120ms ease;
  font-weight: 500;
}
.tab:hover { color: var(--fg-0); }
.tab.active {
  color: var(--fg-0);
  border-bottom-color: var(--amber);
}

/* Pill tabs (for sub-segments) */
.seg {
  display: inline-flex;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2px;
}
.seg button {
  padding: 6px 12px;
  font-family: var(--ff-sans);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg-2);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  font-weight: 500;
}
.seg button.active {
  background: var(--bg-1);
  color: var(--fg-0);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.seg button:hover:not(.active) { color: var(--fg-0); }

/* Toggle */
.toggle {
  width: 34px; height: 20px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: all 120ms ease;
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 1px; left: 1px;
  width: 16px; height: 16px;
  background: #ffffff;
  border-radius: 50%;
  transition: all 150ms ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.toggle.on { background: var(--amber); border-color: var(--amber); }
.toggle.on::after { left: 15px; background: #fff; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 25, 22, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  width: 560px;
  max-width: calc(100vw - 32px);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(20, 25, 22, 0.15);
}
.modal-h {
  padding: var(--pad) var(--pad-lg);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body { padding: var(--pad-lg); }
.modal-foot {
  padding: var(--pad) var(--pad-lg);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px; right: 20px;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  padding: 12px 16px;
  border-radius: var(--radius);
  z-index: 200;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 200ms ease;
  box-shadow: 0 8px 24px rgba(20, 25, 22, 0.10);
}
@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
}

/* Utility */
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; }
.gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.flex-1 { flex: 1; }
.muted { color: var(--fg-2); }
.fg-1 { color: var(--fg-1); }
.amber { color: var(--amber); }
.green { color: var(--green); }
.red { color: var(--red); }

/* Sparkline area */
.spark { display: block; width: 100%; }

/* Sidebar */
.sb-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  color: var(--fg-1);
  font-size: 13px;
  text-decoration: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 120ms ease;
  font-weight: 500;
}
.sb-link:hover { color: var(--fg-0); background: var(--bg-2); }
.sb-link.active {
  color: var(--fg-0);
  background: var(--bg-2);
}
.sb-link.active svg { color: var(--amber); }
.sb-link svg { flex-shrink: 0; color: var(--fg-2); }
.sb-section-label {
  padding: 18px 12px 6px;
  font-family: var(--ff-sans);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg-3);
  font-weight: 500;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--fg-2);
}
.empty-icon {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-3);
}

/* Skeleton */
@keyframes skel {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}
.skel {
  background: linear-gradient(90deg, var(--bg-2) 0, var(--bg-3) 50%, var(--bg-2) 100%);
  background-size: 200px 100%;
  animation: skel 1.4s linear infinite;
  border-radius: var(--radius);
}

/* Dark mode override */
[data-theme="dark"] {
  --bg-0: #0f1311;
  --bg-1: #161a18;
  --bg-2: #1c211e;
  --bg-3: #242a26;
  --bg-4: #313832;
  --line: #242a26;
  --line-2: #313832;
  --fg-0: #e4e8e6;
  --fg-1: #a8aeab;
  --fg-2: #767c79;
  --fg-3: #4a4f4c;
  --amber: #7fbf9e;
  --amber-2: #93cdaf;
  --amber-dim: #345040;
  --amber-bg: rgba(127, 191, 158, 0.12);
  --green: #7fbf9e;
  --green-dim: #345040;
  --green-bg: rgba(127, 191, 158, 0.12);
  --blue: #8eaecb;
  --red: #d49494;
}
