/* ==========================================================================
   Zaldak Panel — dedicated stylesheet for /panel pages.
   The public landing page uses styles.css and is untouched by this file.
   ========================================================================== */

:root {
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  --bg: #07080d;
  --bg-2: #0b0d15;
  --surface: rgba(255, 255, 255, 0.028);
  --surface-2: rgba(255, 255, 255, 0.05);
  --surface-3: rgba(255, 255, 255, 0.085);
  --field: rgba(6, 8, 14, 0.72);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --line-3: rgba(255, 255, 255, 0.22);

  --text: #e9edf5;
  --text-2: #c2c9d8;
  --muted: #98a2b8;
  --faint: #66708a;

  --accent: #8b9cff;
  --accent-2: #5ee1ff;
  --accent-ink: #070b22;
  --accent-soft: rgba(139, 156, 255, 0.14);
  --accent-ring: rgba(139, 156, 255, 0.28);

  --ok: #3ddc97;
  --ok-soft: rgba(61, 220, 151, 0.14);
  --warn: #ffb547;
  --danger: #ff5c7a;
  --danger-soft: rgba(255, 92, 122, 0.14);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 6px 20px rgba(0, 0, 0, 0.3);
  --sidebar-w: 264px;
  --topbar-h: 68px;
}

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

html { -webkit-text-size-adjust: 100%; }

body.panel,
body.panel-login {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 600px at -10% -10%, rgba(139, 156, 255, 0.13), transparent 60%),
    radial-gradient(900px 520px at 110% 10%, rgba(94, 225, 255, 0.08), transparent 55%),
    radial-gradient(800px 500px at 50% 120%, rgba(139, 156, 255, 0.06), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
small { font-size: 12px; color: var(--muted); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

[hidden] { display: none !important; }

.ico { width: 18px; height: 18px; flex: none; }
.ico-sm { width: 15px; height: 15px; flex: none; }

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015));
  border-right: 1px solid var(--line);
  backdrop-filter: blur(12px);
  overflow-y: auto;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 8px 16px;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 36px; height: 36px;
  border-radius: 11px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 17px; letter-spacing: -0.02em;
  color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 22px rgba(139, 156, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.brand-text { display: grid; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: 0.01em; }
.brand-sub { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.nav-label {
  padding: 8px 12px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item .ico { color: var(--muted); transition: color 0.15s ease; }
.nav-item:hover .ico { color: var(--text-2); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--text);
}
.nav-item.active .ico { color: var(--accent); }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -14px; top: 9px; bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.nav-item .nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-3);
  padding: 2px 7px;
  border-radius: 999px;
}

.sidebar-spacer { flex: 1; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.sidebar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-3);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  color: var(--text-2);
  flex: none;
}
.sidebar-user-text { display: grid; line-height: 1.2; min-width: 0; }
.sidebar-user-text strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-text span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-actions { display: grid; gap: 6px; margin-top: 8px; }
.sidebar-actions form { margin: 0; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--topbar-h);
  padding: 12px 28px;
  background: rgba(7, 8, 13, 0.72);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar-title { display: grid; line-height: 1.2; min-width: 0; }
.topbar-title h1 { font-size: 19px; font-weight: 700; }
.topbar-title p { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
  animation: pulse 2.2s ease-in-out infinite;
}
.live-pill strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.menu-btn { display: none; }

.content {
  width: 100%;
  max-width: 1180px;
  padding: 24px 28px 40px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
  align-content: start;
}

.scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 35;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.005em;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:hover { background: var(--surface-3); border-color: var(--line-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }
.btn .ico { width: 16px; height: 16px; }

.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  box-shadow: 0 8px 22px rgba(139, 156, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-primary:hover { filter: brightness(1.05); border-color: transparent; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }

.btn-danger-ghost { background: transparent; border-color: var(--line); color: var(--text-2); }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: rgba(255, 92, 122, 0.35); color: #ffd3dc; }

.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: var(--radius-xs); }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }

.btn.is-busy { pointer-events: none; opacity: 0.75; }

/* --------------------------------------------------------------------------
   Cards / layout primitives
   -------------------------------------------------------------------------- */

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--shadow-sm);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px 0;
}
.card-head-text { display: grid; gap: 2px; min-width: 0; }
.card-title { font-size: 15px; font-weight: 650; }
.card-hint { font-size: 12.5px; color: var(--muted); }
.card-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.card-body { padding: 16px 18px 18px; display: grid; gap: 14px; }
.card-body-tight { padding: 8px 18px 14px; }

.card-section { display: grid; gap: 12px; }
.card-section + .card-section { padding-top: 14px; border-top: 1px solid var(--line); }
.section-title {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; }
.span-2 { grid-column: span 2; }

.stack { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat {
  position: relative;
  padding: 16px 18px;
  display: grid;
  gap: 6px;
  overflow: hidden;
}
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 7px; }
.stat-label .ico { width: 14px; height: 14px; color: var(--faint); }
.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stat-sub { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-accent::after {
  content: "";
  position: absolute; right: -30px; top: -30px;
  width: 110px; height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 156, 255, 0.22), transparent 70%);
  pointer-events: none;
}

/* Chart */
.chart-card .card-head { align-items: center; }
.chart-wrap { position: relative; padding: 6px 4px 0; }
#views-chart {
  display: block;
  width: 100%;
  height: 250px;
  border-radius: var(--radius-sm);
  cursor: crosshair;
  touch-action: pan-y;
}
.chart-tooltip {
  position: absolute;
  left: 0; top: 0;
  z-index: 3;
  min-width: 128px;
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: rgba(13, 15, 22, 0.97);
  box-shadow: var(--shadow);
  transform: translate(-50%, calc(-100% - 14px));
  pointer-events: none;
  white-space: nowrap;
}
.chart-tooltip.is-below { transform: translate(-50%, 16px); }
.chart-tooltip::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -5px;
  width: 8px; height: 8px;
  transform: translateX(-50%) rotate(45deg);
  background: rgba(13, 15, 22, 0.97);
  border-right: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-2);
}
.chart-tooltip.is-below::after { bottom: auto; top: -5px; transform: translateX(-50%) rotate(-135deg); }
.chart-tooltip-label { font-size: 11.5px; color: var(--muted); }
.chart-tooltip-value { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.chart-tooltip-note { margin-top: 2px; font-size: 11px; color: var(--warn); }
.chart-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 13px; color: var(--faint);
  pointer-events: none;
}
.chart-foot {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px 8px 2px;
  font-size: 12px; color: var(--muted);
}
.chart-legend { display: inline-flex; align-items: center; gap: 0; }
.legend-swatch {
  width: 10px; height: 10px; border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: inline-block; margin-right: 7px; vertical-align: -1px;
}
.legend-swatch-est { background: transparent; border: 2px solid var(--accent); box-sizing: border-box; }
.chart-peak { margin-left: auto; color: var(--text-2); font-variant-numeric: tabular-nums; }

.segmented-sm { padding: 2px; }
.segmented .seg-btn {
  flex: 1; min-width: 0;
  height: 28px; padding: 0 12px;
  border: 0; border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.segmented .seg-btn:hover { color: var(--text-2); }
.segmented .seg-btn.is-active {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 8px rgba(0, 0, 0, 0.35);
}
.segmented .seg-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

/* --------------------------------------------------------------------------
   Form controls
   -------------------------------------------------------------------------- */

.field { display: grid; gap: 6px; min-width: 0; }
.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.01em;
}
.field-hint { font-size: 12px; color: var(--faint); line-height: 1.4; }

.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.input::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
  background: rgba(6, 8, 14, 0.9);
}
.input[readonly] { color: var(--muted); cursor: default; }

.textarea {
  height: auto;
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2398a2b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
.select option { background: #11141c; color: var(--text); }

.input-mono { font-family: var(--mono); font-size: 13px; }

/* Input with prefix (e.g. "@") */
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input-prefix {
  position: absolute; left: 12px;
  font-size: 13.5px; color: var(--faint); pointer-events: none;
  font-family: var(--mono);
}
.input-group .input { padding-left: 28px; }

/* Switch */
.switch {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease;
  min-width: 0;
}
.switch:hover { background: var(--surface-2); border-color: var(--line-2); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative;
  flex: none;
  width: 38px; height: 22px;
  margin-top: 1px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.switch input:checked + .switch-track {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 0 0 1px rgba(139, 156, 255, 0.25), 0 4px 14px rgba(139, 156, 255, 0.3);
}
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--accent-ring); }
.switch-text { display: grid; gap: 1px; min-width: 0; }
.switch-label { font-size: 13.5px; font-weight: 550; color: var(--text); }
.switch-hint { font-size: 12px; color: var(--muted); line-height: 1.4; }

.switch-danger input:checked + .switch-track {
  background: linear-gradient(135deg, #ff5c7a, #ff9a5c);
  box-shadow: 0 0 0 1px rgba(255, 92, 122, 0.3), 0 4px 14px rgba(255, 92, 122, 0.3);
}

.switch-compact { padding: 8px 10px; }

/* Segmented control (radio group) */
.segmented {
  display: flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--field);
}
.segmented label { flex: 1; min-width: 0; position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented span {
  display: flex; align-items: center; justify-content: center;
  height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 13px; font-weight: 550;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.segmented label:hover span { color: var(--text-2); }
.segmented input:checked + span {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 8px rgba(0, 0, 0, 0.35);
}
.segmented input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-ring); }

/* Range */
.range-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.range-out {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-3);
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 44px;
  text-align: center;
}
input[type="range"] {
  --fill: 0%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  margin: 8px 0 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) var(--fill), rgba(255, 255, 255, 0.12) var(--fill), rgba(255, 255, 255, 0.12) 100%);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--bg-2);
  box-shadow: 0 0 0 1px var(--line-3), 0 3px 10px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--bg-2);
  box-shadow: 0 0 0 1px var(--line-3), 0 3px 10px rgba(0, 0, 0, 0.45);
}
input[type="range"]::-moz-range-track { background: transparent; }
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.08); }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-ring); }

/* Color field */
.color-field { display: flex; align-items: center; gap: 8px; }
.color-swatch {
  position: relative;
  flex: none;
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  overflow: hidden;
  cursor: pointer;
  background-color: #1a1d26;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.09) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.09) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.09) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.09) 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.color-swatch:hover { border-color: var(--line-3); }
.color-swatch-fill { position: absolute; inset: 0; }
.color-swatch input[type="color"] {
  position: absolute; inset: -4px;
  width: calc(100% + 8px); height: calc(100% + 8px);
  opacity: 0; cursor: pointer; border: 0; padding: 0;
}
.color-field .input { font-family: var(--mono); font-size: 13px; }

/* File drop */
.file-drop {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  min-height: 74px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-3);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.file-drop:hover { border-color: var(--accent); background: var(--surface-2); }
.file-drop.is-over { border-color: var(--accent-2); background: var(--accent-soft); border-style: solid; }
.file-drop.has-file { border-style: solid; border-color: rgba(61, 220, 151, 0.5); background: var(--ok-soft); }
.file-drop input[type="file"] { position: absolute; opacity: 0; width: 0; height: 0; }
.file-drop-preview {
  flex: none;
  width: 52px; height: 52px;
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  color: var(--muted);
}
.file-drop-preview img, .file-drop-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-drop-preview .ico { width: 20px; height: 20px; }
.file-drop-preview.is-font { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-2); }
.file-drop-text { display: grid; gap: 2px; min-width: 0; }
.file-drop-title { font-size: 13.5px; font-weight: 600; }
.file-drop-title em { font-style: normal; color: var(--accent-2); }
.file-drop-meta, .file-drop-name {
  font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-drop.has-file .file-drop-name { color: var(--ok); }

/* Asset chips (read-only summary) */
.asset-chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.asset-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-width: 0;
}
.asset-chip-preview {
  flex: none; width: 40px; height: 40px;
  border-radius: 8px; overflow: hidden;
  background: var(--surface-3); border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--muted);
}
.asset-chip-preview img, .asset-chip-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.asset-chip-preview .ico { width: 18px; height: 18px; }
.asset-chip-text { display: grid; gap: 1px; min-width: 0; }
.asset-chip-text strong { font-size: 12.5px; }
.asset-chip-text span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-chip-text span.is-empty { color: var(--faint); font-style: italic; }

/* Badge rows */
.badge-list { display: grid; gap: 8px; }
.badge-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.badge-row-icon {
  width: 34px; height: 34px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(139, 156, 255, 0.35), rgba(94, 225, 255, 0.25));
  border: 1px solid var(--line-2);
  font-size: 12px; font-weight: 700;
  overflow: hidden;
}
.badge-row-icon img { width: 100%; height: 100%; object-fit: cover; }
.badge-row-text { display: grid; gap: 1px; min-width: 0; flex: 1; }
.badge-row-text strong { font-size: 13.5px; }
.badge-row-text span { font-size: 12px; color: var(--muted); }
.badge-row .switch { padding: 0; border: 0; background: transparent; }
.badge-row .switch:hover { background: transparent; }

/* --------------------------------------------------------------------------
   Links tab
   -------------------------------------------------------------------------- */

.links-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--muted);
}
.links-toolbar .kbd {
  font-family: var(--mono); font-size: 11px;
  padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text-2);
}

.platform-links-list { display: grid; gap: 10px; }

.platform-link-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.018));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}
.platform-link-item.is-enabled { border-color: rgba(139, 156, 255, 0.3); }
.platform-link-item.dragging {
  opacity: 0.55;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-ring);
  transform: scale(0.995);
}

.link-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 8px;
  min-width: 0;
}
.drag-handle {
  flex: none;
  width: 28px; height: 36px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--faint);
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.drag-handle:hover { background: var(--surface-2); color: var(--text-2); }
.drag-handle:active { cursor: grabbing; }
.drag-handle .ico { width: 16px; height: 16px; }

.link-index {
  flex: none;
  width: 22px; height: 22px;
  border-radius: 6px;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--muted);
  background: var(--surface-3);
}

.link-avatar {
  flex: none;
  width: 38px; height: 38px;
  border-radius: 10px;
  overflow: hidden;
  display: grid; place-items: center;
  background: var(--surface-3);
  border: 1px solid var(--line);
  font-weight: 700; font-size: 13px; color: var(--text-2);
}
.link-avatar img { width: 26px; height: 26px; object-fit: contain; }

.link-title { display: grid; gap: 1px; min-width: 0; flex: 1; }
.link-title strong { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-title span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-title span.is-empty { color: var(--faint); font-style: italic; }

.link-head .switch { padding: 6px 10px; }
.link-head .switch .switch-label { font-size: 12.5px; color: var(--text-2); }

.link-collapse {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.15s ease, color 0.15s ease, transform 0.2s ease;
}
.link-collapse:hover { background: var(--surface-2); color: var(--text); }
.link-collapse .ico { transition: transform 0.2s ease; }
.platform-link-item.is-collapsed .link-collapse .ico { transform: rotate(-90deg); }

.link-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
  padding: 4px 14px 14px;
  border-top: 1px solid var(--line);
  margin-top: 0;
  padding-top: 14px;
}
.platform-link-item.is-collapsed .link-body { display: none; }

.icon-size-control { display: grid; gap: 6px; }
.icon-size-row { display: inline-flex; align-items: center; gap: 6px; }
.icon-size-btn {
  width: 34px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-size: 16px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.icon-size-btn:hover { background: var(--surface-3); border-color: var(--line-3); }
.icon-size-input {
  width: 68px !important;
  height: 36px;
  text-align: center;
  font-family: var(--mono);
  -moz-appearance: textfield;
}
.icon-size-input::-webkit-outer-spin-button,
.icon-size-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.icon-size-value { font-size: 12px; color: var(--muted); font-family: var(--mono); min-width: 40px; }

/* --------------------------------------------------------------------------
   Logs tab
   -------------------------------------------------------------------------- */

.logs-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search {
  position: relative;
  flex: 1 1 260px;
  max-width: 420px;
}
.search .ico {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--faint);
  pointer-events: none;
}
.search .input { padding-left: 36px; height: 38px; }
.logs-count { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.logs-count strong { color: var(--text-2); font-weight: 600; }

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: min(64vh, 720px);
  background: rgba(0, 0, 0, 0.18);
}
.logs-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
.logs-table th {
  position: sticky; top: 0; z-index: 1;
  text-align: left;
  padding: 10px 12px;
  font-size: 11px; font-weight: 650;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
  background: rgba(13, 15, 22, 0.98);
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
.logs-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--text-2);
  white-space: nowrap;
}
.logs-table tbody tr:hover td { background: var(--surface-2); }
.logs-table tbody tr:last-child td { border-bottom: 0; }
.logs-table .mono { font-family: var(--mono); font-size: 12px; color: var(--text); }
.logs-table .cell-time { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.logs-table .cell-ua { max-width: 340px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.logs-table .cell-isp { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.logs-table .cell-loc { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.logs-table .cell-actions { text-align: right; }
.logs-table .cell-actions .btn + .btn { margin-left: 6px; }
.logs-table .cell-empty { text-align: center; padding: 28px; color: var(--faint); }

.path-pill {
  display: inline-block;
  font-family: var(--mono); font-size: 11.5px;
  padding: 2px 7px; border-radius: 6px;
  background: var(--surface-3); color: var(--text-2);
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}

/* Person / bot verdict */
.th-sub { font-weight: 500; color: var(--faint); text-transform: none; letter-spacing: 0; }

.logs-legend {
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  font-size: 12px; color: var(--muted);
}
.logs-legend > span { display: inline-flex; align-items: center; gap: 7px; }

.vbadge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 650;
  border: 1px solid var(--line);
  white-space: nowrap;
  cursor: help;
}
.vbadge::before {
  content: ""; flex: none;
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.v-human { background: var(--ok-soft); color: #8ff0c4; border-color: rgba(61, 220, 151, 0.32); }
.v-bot { background: rgba(255, 92, 122, 0.12); color: #ffaebd; border-color: rgba(255, 92, 122, 0.3); }
.v-unknown { background: var(--surface-3); color: var(--muted); }

/* --------------------------------------------------------------------------
   Save bar, toasts, misc
   -------------------------------------------------------------------------- */

.save-bar {
  position: sticky;
  bottom: 14px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  background: rgba(11, 13, 21, 0.86);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.save-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.save-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); transition: background 0.2s ease; }
.save-status .status-dirty { display: none; }
body.is-dirty .save-status .dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(255, 181, 71, 0.18); }
body.is-dirty .save-status .status-clean { display: none; }
body.is-dirty .save-status .status-dirty { display: inline; color: var(--text-2); }
.save-bar .btn-primary { margin-left: auto; }
body.is-dirty .btn-save { animation: glow 1.6s ease-in-out infinite; }

.toast-stack {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 100;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 12px 11px 14px;
  border-radius: 12px;
  border: 1px solid rgba(61, 220, 151, 0.35);
  background: rgba(14, 22, 20, 0.96);
  color: #dcfff0;
  box-shadow: var(--shadow);
  font-size: 13.5px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.toast.is-in { opacity: 1; transform: none; }
.toast.is-out { opacity: 0; transform: translateX(12px); }
.toast .ico { color: var(--ok); margin-top: 1px; }
.toast-text { flex: 1; min-width: 0; }
.toast-close {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 7px;
  border: 0; background: transparent;
  color: inherit; opacity: 0.6; cursor: pointer;
  display: grid; place-items: center;
}
.toast-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.08); }
.toast-close .ico { width: 14px; height: 14px; color: inherit; margin: 0; }

.toast-error { border-color: rgba(255, 92, 122, 0.4); background: rgba(26, 14, 18, 0.96); color: #ffe1e7; }
.toast-error .ico { color: var(--danger); }

.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12.5px; color: var(--muted);
}
.callout .ico { color: var(--accent); margin-top: 1px; }
.callout-warn { border-color: rgba(255, 181, 71, 0.3); background: rgba(255, 181, 71, 0.06); }
.callout-warn .ico { color: var(--warn); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2);
  border: 1px solid var(--line);
}
.chip-ok { background: var(--ok-soft); color: #bff5dc; border-color: rgba(61, 220, 151, 0.3); }
.chip-warn { background: rgba(255, 181, 71, 0.14); color: #ffe1b0; border-color: rgba(255, 181, 71, 0.3); }

/* --------------------------------------------------------------------------
   Login page
   -------------------------------------------------------------------------- */

body.panel-login { display: grid; place-items: center; padding: 24px; }

.login-card {
  width: min(400px, 100%);
  padding: 30px 28px 26px;
  border-radius: 20px;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.025));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), var(--shadow);
  backdrop-filter: blur(16px);
  display: grid;
  gap: 18px;
  animation: rise 0.4s ease;
}
.login-brand { display: grid; justify-items: center; gap: 12px; text-align: center; }
.login-brand .brand-mark { width: 52px; height: 52px; border-radius: 16px; font-size: 24px; }
.login-brand h1 { font-size: 21px; font-weight: 700; }
.login-brand p { font-size: 13px; color: var(--muted); }

.login-form { display: grid; gap: 14px; }
.password-wrap { position: relative; }
.password-wrap .input { padding-right: 44px; }
.password-toggle {
  position: absolute; right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 30px; height: 30px;
  border-radius: 7px; border: 0;
  background: transparent; color: var(--muted);
  cursor: pointer; display: grid; place-items: center;
}
.password-toggle:hover { background: var(--surface-3); color: var(--text); }
.password-toggle .ico { width: 16px; height: 16px; }
.password-toggle .ico-off { display: none; }
.password-toggle.is-visible .ico-on { display: none; }
.password-toggle.is-visible .ico-off { display: block; }

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid rgba(255, 92, 122, 0.35);
  background: var(--danger-soft);
  color: #ffd9e0;
}
.alert .ico { color: var(--danger); margin-top: 1px; }

.login-foot { text-align: center; font-size: 12.5px; color: var(--muted); }
.login-foot a { color: var(--text-2); }

.cf-turnstile { display: flex; justify-content: center; }

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--ok-soft); }
  50% { box-shadow: 0 0 0 6px rgba(61, 220, 151, 0.06); }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 8px 22px rgba(139, 156, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
  50% { box-shadow: 0 8px 30px rgba(139, 156, 255, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
}

.content > * { animation: rise 0.35s ease both; }
.content > *:nth-child(2) { animation-delay: 0.04s; }
.content > *:nth-child(3) { animation-delay: 0.08s; }
.content > *:nth-child(4) { animation-delay: 0.12s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .asset-chips { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(300px, 86vw);
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: var(--shadow);
    background: #0c0e16;
    z-index: 50;
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; }
  body.nav-open { overflow: hidden; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .topbar-title h1 { font-size: 17px; }
  .topbar-title p { display: none; }
  .live-pill span { display: none; }
  .content { padding: 16px 16px 32px; }
}

@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4, .link-body { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 13px 14px; gap: 4px; }
  .stat-value { font-size: 22px; }
  .stat-sub { white-space: normal; line-height: 1.3; }
  .span-2 { grid-column: auto; }
  .card-head, .card-body { padding-left: 14px; padding-right: 14px; }
  .chart-card .card-head { flex-wrap: wrap; row-gap: 10px; }
  .chart-card .card-head-actions { margin-left: 0; width: 100%; }
  .chart-card .segmented { width: 100%; }
  .chart-wrap { padding: 4px 0 0; }
  #views-chart { height: 210px; }
  .chart-foot { gap: 6px 14px; padding-left: 4px; padding-right: 4px; }
  .chart-peak { margin-left: 0; width: 100%; }
  .link-head { flex-wrap: wrap; }
  .link-head .switch { order: 5; width: 100%; margin-top: 4px; }
  .save-bar { bottom: 8px; flex-wrap: wrap; }
  .topbar-actions .btn-text { display: none; }
  .topbar-actions .btn { padding: 0 10px; }
}
