/* XSHOP admin panel — тёмная тема, палитра согласно data-viz гайду */
:root {
  color-scheme: dark;
  --surface-0: #0d0d0d;      /* page plane */
  --surface-1: #17171a;      /* sidebar / cards */
  --surface-2: #1f2024;      /* card hover / inputs */
  --surface-3: #26272c;      /* elevated (modals) */
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);

  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;

  --series-1: #3987e5;  /* blue */
  --series-2: #d95926;  /* orange */
  --series-3: #199e70;  /* aqua */
  --series-4: #c98500;  /* yellow */
  --series-5: #d55181;  /* magenta */
  --series-6: #008300;  /* green */
  --series-7: #9085e9;  /* violet */
  --series-8: #e66767;  /* red */

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --accent: var(--series-1);
  --accent-soft: rgba(57,135,229,0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--surface-0);
  color: var(--text-primary);
  font-size: 14px;
}
a { color: var(--series-1); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.brand { padding: 8px 12px 20px; font-weight: 700; font-size: 18px; letter-spacing: 0.5px; }
.brand span { color: var(--series-1); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); cursor: pointer; font-weight: 500;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active { background: var(--accent-soft); color: var(--text-primary); }
.nav-item .badge {
  margin-left: auto; background: var(--status-critical); color: #fff;
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px;
}
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }

.main { padding: 28px 36px 60px; max-width: 1280px; }
.view { display: none; }
.view.active { display: block; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-header h1 { font-size: 22px; margin: 0; }
.page-header .sub { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ---------- cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1000px) {
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.card h2, .card h3 { margin-top: 0; }

.stat-tile { display: flex; flex-direction: column; gap: 6px; }
.stat-tile .label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-tile .value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-tile .delta { font-size: 12px; color: var(--text-secondary); }
.stat-tile .value.warn { color: var(--status-warning); }
.stat-tile .value.critical { color: var(--status-critical); }
.stat-tile .value.good { color: var(--status-good); }

/* ---------- table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.pill.good { background: rgba(12,163,12,0.15); color: var(--status-good); }
.pill.warning { background: rgba(250,178,25,0.15); color: var(--status-warning); }
.pill.critical { background: rgba(208,59,59,0.15); color: var(--status-critical); }
.pill.neutral { background: var(--surface-2); color: var(--text-secondary); }

/* ---------- forms ---------- */
input[type=text], input[type=password], input[type=number], input[type=search], textarea, select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-primary);
}
textarea { resize: vertical; min-height: 70px; }
label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; }
.field { margin-bottom: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: none;
  background: var(--accent); color: #04122a; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.secondary { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border-strong); }
.btn.danger { background: var(--status-critical); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 12.5px; }

.search-box { position: relative; max-width: 320px; width: 100%; }

/* ---------- tabs (segmented control) ---------- */
.segmented { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.segmented button { border: none; background: none; padding: 7px 14px; border-radius: 6px; color: var(--text-secondary); cursor: pointer; font-weight: 500; }
.segmented button.active { background: var(--surface-3); color: var(--text-primary); }

/* ---------- modal / slide-over ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: none; align-items: stretch; justify-content: flex-end; z-index: 50;
}
.overlay.open { display: flex; }
.drawer {
  width: min(560px, 100%); background: var(--surface-1); border-left: 1px solid var(--border);
  overflow-y: auto; padding: 24px 28px 60px;
}
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.drawer-header h2 { margin: 0 0 4px; }
.close-btn { background: none; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; line-height: 1; }

.chat-log { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; padding: 12px; background: var(--surface-0); border-radius: var(--radius-sm); margin-bottom: 12px; }
.chat-msg { max-width: 80%; padding: 8px 12px; border-radius: 10px; font-size: 13px; }
.chat-msg.in { background: var(--surface-2); align-self: flex-start; }
.chat-msg.out { background: var(--accent-soft); align-self: flex-end; }
.chat-msg .meta { font-size: 10px; color: var(--text-muted); margin-top: 3px; }

.tag-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--border-strong); padding: 3px 10px; border-radius: 20px; font-size: 12px; margin: 2px 4px 2px 0; }

.toast-container { position: fixed; top: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface-3); border: 1px solid var(--border-strong); padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,0.4); }
.toast.error { border-color: var(--status-critical); }
.toast.success { border-color: var(--status-good); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }

/* ---------- login page ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 340px; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p { color: var(--text-muted); font-size: 13px; margin-top: 0; margin-bottom: 20px; }
