/* =====================================================================
   Elorium Design System — production CSS
   Извлечён из дизайн-системы (Claude Design handoff) + дополнен.
   Чёрный фон · янтарный акцент · острые углы · просторно · dark+light.

   Структура:
   1. Tokens (dark по умолчанию + light)
   2. Base / reset
   3. Utilities (layout, text, spacing)
   4. Buttons
   5. Forms (input, select, segmented, toggle, checkbox)
   6. Badges & statuses
   7. Card / section heading
   8. KPI / stat cards
   9. Data table + pagination
   10. Slide-over panel
   11. Modal / dialog / bottom-sheet
   12. Toast / popover
   13. Tabs
   14. Plan cards / list rows / progress ring (miniapp)
   15. Admin shell (.admin)  + Miniapp shell (.app)
   16. Empty / loading states
   17. Ambient glow
   ===================================================================== */

/* ── 1. Tokens ───────────────────────────────────────────────────── */

:root {
  --accent-h: 70;

  --font-sans: "Geist", -apple-system, system-ui, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;

  /* radius (острые) */
  --r-xs: 3px; --r-sm: 6px; --r: 8px; --r-lg: 10px; --r-xl: 12px; --r-full: 999px;

  /* spacing (просторно, база 4) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px; --sp-5: 20px;
  --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px; --sp-16: 64px;

  /* sizing */
  --sidebar-w: 248px;
  --topbar-h: 64px;
  --row-h: 52px;

  /* motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 120ms;
  --t: 200ms;

  /* z-index */
  --z-sticky: 20; --z-dropdown: 100; --z-scrim: 200; --z-modal: 300; --z-toast: 400; --z-popover: 500;
}

/* DARK (default) */
:root, [data-theme="dark"] {
  --accent:       #F59E0B;
  --accent-hover: oklch(0.81 0.15 72);
  --accent-fg:    #1F1604;
  --accent-soft:  oklch(0.76 0.16 70 / 0.15);
  --accent-line:  oklch(0.76 0.16 70 / 0.40);

  --bg:        #0B0B0D;
  --bg-sunken: #08080A;
  --bg-elev:   #141416;
  --bg-elev-2: #1B1B1E;
  --bg-hover:  #222226;

  --border:        #242428;
  --border-soft:   #1B1B1F;
  --border-strong: #34343A;

  --fg:        #F5F5F6;
  --fg-muted:  #ABABB2;
  --fg-subtle: #7E7E86;
  --fg-faint:  #5F5F66;

  --positive: #34C77B; --positive-soft: oklch(0.74 0.15 150 / 0.14);
  --warning:  #E8C53A; --warning-soft:  oklch(0.83 0.14 90 / 0.14);
  --danger:   #F25555; --danger-soft:   oklch(0.66 0.20 25 / 0.14);
  --info:     #5B9BF2; --info-soft:     oklch(0.70 0.13 240 / 0.14);
  --neutral-soft: oklch(0.73 0.006 285 / 0.14);

  --on-positive: #06140C;
  --on-danger:   #FFFFFF;

  --glow-c: oklch(0.76 0.16 70 / 0.08);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow:    0 6px 20px -6px rgba(0,0,0,0.5);
  --shadow-lg: 0 20px 50px -12px rgba(0,0,0,0.6);
  color-scheme: dark;
}

/* LIGHT */
[data-theme="light"] {
  --accent:       #E08600;
  --accent-hover: oklch(0.64 0.15 65);
  --accent-fg:    #1F1604;
  --accent-soft:  oklch(0.70 0.15 65 / 0.13);
  --accent-line:  oklch(0.70 0.15 65 / 0.35);

  --bg:        #FAFAFA;
  --bg-sunken: #F2F2F4;
  --bg-elev:   #FFFFFF;
  --bg-elev-2: #F4F4F5;
  --bg-hover:  #EDEDEF;

  --border:        #E4E4E7;
  --border-soft:   #EFEFF1;
  --border-strong: #D1D1D6;

  --fg:        #1A1A1E;
  --fg-muted:  #5C5C64;
  --fg-subtle: #77777F;
  --fg-faint:  #A2A2A9;

  --positive: oklch(0.55 0.14 150); --positive-soft: oklch(0.55 0.14 150 / 0.12);
  --warning:  oklch(0.62 0.13 85);  --warning-soft:  oklch(0.62 0.13 85 / 0.12);
  --danger:   oklch(0.56 0.21 25);  --danger-soft:   oklch(0.56 0.21 25 / 0.10);
  --info:     oklch(0.55 0.16 240); --info-soft:     oklch(0.55 0.16 240 / 0.10);
  --neutral-soft: oklch(0.45 0.008 285 / 0.10);

  --on-positive: #FFFFFF;
  --on-danger:   #FFFFFF;

  --glow-c: oklch(0.70 0.15 65 / 0.06);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow:    0 6px 20px -6px rgba(0,0,0,0.10);
  --shadow-lg: 0 20px 50px -12px rgba(0,0,0,0.18);
  color-scheme: light;
}

/* ── 2. Base / reset ─────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
html, body, #root { height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
::selection { background: var(--accent-soft); color: var(--fg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-full); border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: padding-box; }

/* Typography roles */
.t-display { font-size: 30px; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.t-h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.t-h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }
.t-h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.t-body { font-size: 14.5px; font-weight: 400; line-height: 1.55; }
.t-small { font-size: 13.5px; }
.t-caption { font-size: 12.5px; color: var(--fg-muted); }
.t-label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-subtle); }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }

/* ── 3. Utilities ────────────────────────────────────────────────── */

.row { display: flex; align-items: center; gap: var(--sp-2); }
.col { display: flex; flex-direction: column; }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.center { display: flex; align-items: center; justify-content: center; }
.muted { color: var(--fg-muted); }
.subtle { color: var(--fg-subtle); }
.faint { color: var(--fg-faint); }
.accent-t { color: var(--accent); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 4. Buttons ──────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 18px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--bg-elev-2); color: var(--fg);
  font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap;
  cursor: pointer; user-select: none; flex-shrink: 0;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), filter var(--t-fast), transform var(--t-fast);
}
.btn:hover { background: var(--bg-hover); border-color: var(--fg-faint); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 17px; height: 17px; flex-shrink: 0; }

.btn-sm { height: 32px; padding: 0 14px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; font-weight: 600; }
.btn-lg svg { width: 19px; height: 19px; }
.btn-block { display: flex; width: 100%; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-icon.btn-lg { width: 48px; }

.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: transparent; }
.btn-lg.btn-primary { box-shadow: 0 4px 16px -4px var(--accent-line); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-muted); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--fg); border-color: transparent; }

.btn-confirm { background: var(--positive); color: var(--on-positive); border-color: transparent; font-weight: 600; }
.btn-confirm:hover { filter: brightness(1.08); border-color: transparent; background: var(--positive); }

.btn-danger { background: var(--danger); color: var(--on-danger); border-color: transparent; font-weight: 600; }
.btn-danger:hover { filter: brightness(1.08); border-color: transparent; background: var(--danger); }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); font-weight: 600; }
.btn-danger-soft:hover { background: transparent; }

/* Кнопка-строка (miniapp): иконка+текст слева, значение справа */
.btn-row { justify-content: space-between; gap: 12px; text-align: left; }
.btn-row .lead { display: flex; align-items: center; gap: 11px; min-width: 0; }
.btn-row .lead svg { width: 20px; height: 20px; }
.btn-row .trail { font-weight: 500; opacity: 0.9; }

/* ── 5. Forms ────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-subtle); }
.field-hint { font-size: 12px; color: var(--fg-faint); }

.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 14px;
  background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--fg); font-size: 14px; outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--fg-faint); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { height: auto; min-height: 110px; padding: 12px 14px; resize: vertical; line-height: 1.55; font-family: var(--font-mono); font-size: 13px; }
.select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237E7E86' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input-search { position: relative; }
.input-search > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--fg-faint); pointer-events: none; }
.input-search .input { padding-left: 38px; }

/* Segmented control / tabs-inline */
.segment { display: inline-flex; padding: 3px; gap: 3px; background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: var(--r-sm); width: fit-content; }
.segment button, .segment .seg { padding: 7px 14px; border-radius: var(--r-xs); font-size: 13px; font-weight: 500; color: var(--fg-muted); transition: background var(--t-fast), color var(--t-fast); }
.segment button:hover { color: var(--fg); }
.segment button.active, .segment .seg.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Toggle */
.toggle { position: relative; width: 42px; height: 24px; border-radius: var(--r-full); background: var(--bg-hover); border: 1px solid var(--border-strong); cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast); flex-shrink: 0; }
.toggle::after { content: ""; position: absolute; top: 1px; left: 1px; width: 20px; height: 20px; border-radius: var(--r-full); background: var(--fg-subtle); transition: transform var(--t) var(--ease), background var(--t-fast); }
.toggle.on { background: var(--accent); border-color: transparent; }
.toggle.on::after { transform: translateX(18px); background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.4); }

/* Checkbox */
.checkbox { appearance: none; width: 18px; height: 18px; border: 1px solid var(--border-strong); border-radius: var(--r-xs); background: var(--bg-sunken); cursor: pointer; position: relative; flex-shrink: 0; }
.checkbox:checked { background: var(--accent); border-color: var(--accent); }
.checkbox:checked::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px; border: solid var(--accent-fg); border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* ── 6. Badges & statuses ────────────────────────────────────────── */

.badge { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: var(--r-sm); font-size: 12.5px; font-weight: 600; line-height: 1; white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: var(--r-full); background: currentColor; }
.badge.positive { background: var(--positive-soft); color: var(--positive); }
.badge.warning  { background: var(--warning-soft);  color: var(--warning); }
.badge.danger   { background: var(--danger-soft);   color: var(--danger); }
.badge.info     { background: var(--info-soft);     color: var(--info); }
.badge.accent   { background: var(--accent-soft);   color: var(--accent); border: 1px solid var(--accent-line); }
.badge.neutral  { background: var(--bg-elev-2);     color: var(--fg-muted); border: 1px solid var(--border); }
.badge.pill { border-radius: var(--r-full); }
.badge.sm { padding: 4px 9px; font-size: 11.5px; }

/* Count / counter pill */
.badge-count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--r-full); background: var(--danger); color: #fff; font-size: 12px; font-weight: 600; font-family: var(--font-mono); }
.badge-count.warning { background: var(--warning-soft); color: var(--warning); }
.badge-count.accent  { background: var(--accent-soft); color: var(--accent); }

/* ── 7. Card / section heading ───────────────────────────────────── */

.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r); padding: var(--sp-5) var(--sp-6); }
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.card-sub { font-size: 12.5px; color: var(--fg-subtle); }

.section-h { display: flex; align-items: center; gap: 12px; margin: var(--sp-6) 0 var(--sp-4); }
.section-h h3 { font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-subtle); }
.section-h .rule { flex: 1; height: 1px; background: var(--border-soft); }
.section-eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }

/* ── 8. KPI / stat cards ─────────────────────────────────────────── */

.stat-grid { display: grid; gap: var(--sp-5); }
.stat-grid.c4 { grid-template-columns: repeat(4, 1fr); }
.stat-grid.c3 { grid-template-columns: repeat(3, 1fr); }
.stat-grid.c2 { grid-template-columns: repeat(2, 1fr); }
.stat { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r); padding: 22px 24px; box-shadow: var(--shadow-sm); transition: border-color var(--t-fast), transform var(--t-fast); }
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { border-color: var(--accent-line); transform: translateY(-2px); }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.stat-label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-subtle); }
.stat-value { font-family: var(--font-mono); font-size: 28px; font-weight: 600; letter-spacing: -0.01em; font-feature-settings: "tnum"; line-height: 1.1; }
.stat-sub { font-size: 12.5px; color: var(--fg-subtle); margin-top: 8px; }
.delta { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: var(--r-sm); font-size: 12px; font-weight: 600; }
.delta.up { background: var(--positive-soft); color: var(--positive); }
.delta.down { background: var(--danger-soft); color: var(--danger); }

/* ── 9. Data table ───────────────────────────────────────────────── */

.table-shell { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-sm); }
.table-head { display: flex; align-items: center; justify-content: space-between; height: var(--topbar-h); padding: 0 24px; border-bottom: 1px solid var(--border-soft); }
.table-head .title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.table-toolbar { display: flex; align-items: center; gap: var(--sp-2); padding: 14px 24px; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.table-toolbar .input-search { flex: 1; min-width: 220px; max-width: 380px; }
.table-scroll { overflow-x: auto; }

table.t { width: 100%; border-collapse: separate; border-spacing: 0; }
.t th { text-align: left; height: 40px; padding: 0 24px; background: var(--bg-elev-2); border-bottom: 1px solid var(--border-soft); font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-subtle); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.t th.right { text-align: right; }
.t th.sortable { cursor: pointer; }
.t th.sortable:hover { color: var(--fg); }
.t td { height: var(--row-h); padding: 0 24px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; vertical-align: middle; font-size: 14px; }
.t tbody tr:last-child td { border-bottom: none; }
.t tr.clickable { cursor: pointer; transition: background var(--t-fast); }
.t tr.clickable:hover td { background: var(--bg-hover); }
.t tr.selected td { background: var(--accent-soft); }
.t .num { font-family: var(--font-mono); font-size: 13.5px; text-align: right; font-feature-settings: "tnum"; }
.t .cell-muted { color: var(--fg-muted); }
.t .cell-date { font-family: var(--font-mono); font-size: 12.5px; color: var(--fg-subtle); }

/* Аватар-инициалы в строке */
.avatar { width: 30px; height: 30px; border-radius: var(--r-full); display: inline-flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 600; flex-shrink: 0; background: var(--accent-soft); color: var(--accent); }
.avatar.info { background: var(--info-soft); color: var(--info); }
.avatar.danger { background: var(--danger-soft); color: var(--danger); }
.avatar.positive { background: var(--positive-soft); color: var(--positive); }
.user-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 14px 24px; border-top: 1px solid var(--border-soft); font-size: 12.5px; color: var(--fg-muted); }
.pages { display: flex; gap: 4px; }
.page-btn { min-width: 30px; height: 30px; padding: 0 8px; border-radius: var(--r-sm); color: var(--fg-muted); font-family: var(--font-mono); font-size: 12.5px; display: inline-flex; align-items: center; justify-content: center; transition: background var(--t-fast), color var(--t-fast); }
.page-btn:hover { background: var(--bg-hover); color: var(--fg); }
.page-btn.active { background: var(--accent-soft); color: var(--accent); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── 10. Slide-over panel ────────────────────────────────────────── */

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: var(--z-scrim); animation: elx-fade var(--t-fast) ease-out; }
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--bg-elev); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: calc(var(--z-scrim) + 1); display: flex; flex-direction: column; animation: elx-slide-in var(--t) var(--ease); }
.panel-head { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 24px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0; }
.panel-head h2 { font-size: 16px; font-weight: 600; }
.panel-head .meta { font-family: var(--font-mono); font-size: 12px; color: var(--fg-faint); }
.panel-body { flex: 1; overflow-y: auto; }
.panel-sec { padding: 20px 24px; border-bottom: 1px solid var(--border-soft); }
.panel-sec:last-child { border-bottom: none; }
.panel-sec-title { font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-subtle); margin-bottom: 14px; }
.panel-foot { display: flex; gap: var(--sp-2); padding: 16px 24px; border-top: 1px solid var(--border-soft); flex-shrink: 0; background: var(--bg-sunken); }

/* key-value rows */
.kv { display: flex; flex-direction: column; gap: 12px; }
.kv-row { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; }
.kv-row .k { color: var(--fg-muted); }
.kv-row .v { font-weight: 500; text-align: right; }

/* ── 11. Modal / dialog / bottom-sheet ───────────────────────────── */

.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: var(--z-modal); display: grid; place-items: center; padding: 20px; animation: elx-fade var(--t-fast); }
.modal { width: 100%; max-width: 440px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-6); box-shadow: var(--shadow-lg); animation: elx-pop var(--t) var(--ease); }
.modal h3 { font-size: 17px; margin-bottom: 8px; }
.modal p { font-size: 14px; color: var(--fg-muted); margin-bottom: var(--sp-5); }
.modal-acts { display: flex; gap: var(--sp-2); justify-content: flex-end; }

.sheet-scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: var(--z-modal); display: flex; align-items: flex-end; justify-content: center; animation: elx-fade var(--t-fast); }
.sheet { width: 100%; max-width: 460px; background: var(--bg-elev); border: 1px solid var(--border); border-bottom: 0; border-radius: var(--r-xl) var(--r-xl) 0 0; padding: var(--sp-5) var(--sp-4) calc(var(--sp-6) + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); animation: elx-sheet-up var(--t) var(--ease); }
.sheet .grip { width: 36px; height: 4px; border-radius: var(--r-full); background: var(--border-strong); margin: 0 auto 18px; }

/* ── 12. Toast / popover ─────────────────────────────────────────── */

.toast-tray { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: var(--z-toast); }
.toast { display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 380px; padding: 12px 14px; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--r); box-shadow: var(--shadow); font-size: 13.5px; animation: elx-toast-in var(--t) var(--ease); }
.toast.success { border-color: var(--positive); }
.toast.error { border-color: var(--danger); }

.popover { position: fixed; z-index: var(--z-popover); min-width: 200px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px; box-shadow: var(--shadow-lg); animation: elx-pop var(--t-fast) var(--ease); }

/* ── 13. Tabs ────────────────────────────────────────────────────── */

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg-sunken); border: 1px solid var(--border-soft); border-radius: var(--r); }
.tabs button { flex: 1; height: 36px; border-radius: var(--r-sm); font-size: 13.5px; font-weight: 500; color: var(--fg-muted); transition: background var(--t-fast), color var(--t-fast); }
.tabs button:hover { color: var(--fg); }
.tabs button.active { background: var(--bg-elev); color: var(--fg); box-shadow: var(--shadow-sm); }

/* ── 14. Miniapp: plan cards / list rows / progress ring ─────────── */

.plan { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 18px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r); cursor: pointer; transition: border-color var(--t-fast); }
.plan:hover { border-color: var(--border-strong); }
.plan.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.plan .pl-dur { font-size: 15px; font-weight: 600; }
.plan .pl-desc { font-size: 12.5px; color: var(--fg-subtle); margin-top: 2px; }
.plan .pl-price { font-family: var(--font-mono); font-size: 20px; font-weight: 600; text-align: right; font-feature-settings: "tnum"; }
.plan .pl-old { font-size: 12.5px; color: var(--fg-faint); text-decoration: line-through; text-align: right; }
.plan .pl-rib { position: absolute; top: -9px; left: 16px; padding: 2px 8px; border-radius: var(--r-full); background: var(--accent); color: var(--accent-fg); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }

.row-item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r); }
.row-item + .row-item { margin-top: 8px; }
.row-ico { width: 38px; height: 38px; border-radius: var(--r-sm); background: var(--bg-elev-2); display: grid; place-items: center; color: var(--fg-muted); flex-shrink: 0; }
.row-ico svg { width: 19px; height: 19px; }
.row-main { min-width: 0; flex: 1; }
.row-title { font-size: 14px; font-weight: 500; }
.row-meta { font-size: 12.5px; color: var(--fg-subtle); }
.row-right { text-align: right; flex-shrink: 0; }

.ring { position: relative; width: clamp(180px, 52vw, 220px); aspect-ratio: 1; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .ring-bg { fill: none; stroke: var(--bg-elev-2); stroke-width: 12; }
.ring .ring-fg { fill: none; stroke: var(--accent); stroke-width: 12; stroke-linecap: round; }
.ring-c { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.ring-c .big { font-size: clamp(24px, 7vw, 30px); font-weight: 700; letter-spacing: -0.02em; }
.ring-c .small { font-size: 12.5px; color: var(--fg-subtle); }

/* ── 15. Shells ──────────────────────────────────────────────────── */

/* Admin */
.admin { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; }
.sidebar { display: flex; flex-direction: column; background: var(--bg-sunken); border-right: 1px solid var(--border-soft); overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; height: var(--topbar-h); padding: 0 22px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0; }
.sidebar-brand .logo { width: 26px; height: 26px; border-radius: var(--r-sm); background: var(--accent); box-shadow: 0 0 0 1px var(--accent-line), 0 4px 14px -4px var(--accent); flex-shrink: 0; }
.sidebar-brand .name { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }
.sidebar-nav { padding: 18px 14px; display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-faint); padding: 8px 12px 6px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: var(--r-sm); color: var(--fg-muted); font-size: 13.5px; cursor: pointer; transition: background var(--t-fast), color var(--t-fast); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); color: var(--fg); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav-item .count { margin-left: auto; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px; border-top: 1px solid var(--border-soft); }

.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); height: var(--topbar-h); padding: 0 32px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0; position: sticky; top: 0; z-index: var(--z-sticky); background: color-mix(in oklch, var(--bg) 80%, transparent); backdrop-filter: blur(12px); }
.topbar h1 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.content { flex: 1; overflow-y: auto; padding: var(--sp-6) 32px; }

/* Miniapp — фикс. высота, без скролла страницы */
.app { display: flex; flex-direction: column; height: 100dvh; max-width: 460px; margin: 0 auto; padding: var(--sp-5) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom)); gap: var(--sp-4); overflow: hidden; }
.app-scroll { flex: 1; overflow-y: auto; min-height: 0; }

/* ── 16. Empty / loading ─────────────────────────────────────────── */

.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 56px 20px; color: var(--fg-faint); text-align: center; }
.empty svg { width: 34px; height: 34px; opacity: 0.6; }
.empty .t1 { font-size: 14px; color: var(--fg-subtle); }

.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: elx-spin 0.7s linear infinite; }
.skeleton { background: linear-gradient(90deg, var(--bg-elev) 25%, var(--bg-elev-2) 50%, var(--bg-elev) 75%); background-size: 200% 100%; border-radius: var(--r-sm); animation: elx-shimmer 1.4s infinite; }

/* ── 17. Ambient glow ────────────────────────────────────────────── */

.glow { position: fixed; top: -260px; left: 50%; transform: translateX(-50%); width: 1100px; height: 600px; background: radial-gradient(ellipse at center, var(--glow-c), transparent 70%); filter: blur(80px); pointer-events: none; z-index: 0; }

/* ── 18. Extended admin detail components ────────────────────────── */

/* Banner (info / warning / danger / accent) */
.banner { display: flex; align-items: flex-start; gap: 12px; padding: 13px 15px; border-radius: var(--r); border: 1px solid var(--border); background: var(--bg-elev-2); }
.banner > svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; color: var(--fg-muted); }
.banner .bn-main { flex: 1; min-width: 0; }
.banner .bn-title { font-size: 13.5px; font-weight: 600; color: var(--fg); }
.banner .bn-sub { font-size: 12.5px; color: var(--fg-muted); margin-top: 2px; }
.banner .bn-acts { display: flex; gap: 8px; flex-shrink: 0; align-self: center; }
.banner.info    { background: var(--info-soft);    border-color: transparent; }
.banner.info > svg { color: var(--info); }
.banner.warning { background: var(--warning-soft); border-color: transparent; }
.banner.warning > svg { color: var(--warning); }
.banner.danger  { background: var(--danger-soft);  border-color: transparent; }
.banner.danger > svg { color: var(--danger); }
.banner.accent  { background: var(--accent-soft);  border-color: var(--accent-line); }
.banner.accent > svg { color: var(--accent); }

/* Chip (slug, тип, провайдер) */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: var(--r-full); background: var(--bg-elev-2); border: 1px solid var(--border); font-size: 11.5px; font-weight: 600; color: var(--fg-muted); white-space: nowrap; }
.chip.mono { font-family: var(--font-mono); font-weight: 500; }
.chip.accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.chip.info { background: var(--info-soft); border-color: transparent; color: var(--info); }

/* Copyable value + clickable link id */
.copyable { cursor: pointer; transition: color var(--t-fast); display: inline-flex; align-items: center; gap: 6px; }
.copyable:hover { color: var(--accent); }
.copyable svg { width: 13px; height: 13px; opacity: 0; transition: opacity var(--t-fast); }
.copyable:hover svg { opacity: 0.8; }
.link { color: var(--accent); cursor: pointer; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* Inline-editable cell */
.editable { cursor: pointer; border-bottom: 1px dashed var(--border-strong); transition: border-color var(--t-fast), color var(--t-fast); }
.editable:hover { border-color: var(--accent); color: var(--accent); }
.edit-inline { display: inline-flex; align-items: center; gap: 6px; }
.edit-inline .input { height: 32px; width: 92px; font-size: 13px; }

/* Event log / journal */
.log { display: flex; flex-direction: column; border: 1px solid var(--border-soft); border-radius: var(--r); overflow: hidden; }
.log-item { display: flex; gap: 14px; align-items: baseline; padding: 9px 14px; }
.log-item:nth-child(odd) { background: var(--bg-sunken); }
.log-item .log-time { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-faint); flex-shrink: 0; width: 142px; }
.log-item .log-msg { font-size: 13px; color: var(--fg); line-height: 1.4; }
.log-item .log-msg.code { font-family: var(--font-mono); font-size: 12px; color: var(--fg-subtle); }
.log-item .lg-tag { display: inline-block; width: 6px; height: 6px; border-radius: var(--r-full); background: var(--fg-faint); margin-right: 7px; vertical-align: middle; }
.log-item .lg-tag.positive { background: var(--positive); }
.log-item .lg-tag.danger { background: var(--danger); }
.log-item .lg-tag.accent { background: var(--accent); }
.log-item .lg-tag.info { background: var(--info); }

/* List rows (promocodes, generic key rows) */
.list-rows { display: flex; flex-direction: column; border: 1px solid var(--border-soft); border-radius: var(--r); overflow: hidden; }
.list-rows > .lr { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.list-rows > .lr + .lr { border-top: 1px solid var(--border-soft); }
.list-rows > .lr .lr-date { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--fg-faint); flex-shrink: 0; }

/* Popover action menu (anchored in panel head) */
.pop-anchor { position: relative; }
.pop-card { position: absolute; top: calc(100% + 6px); right: 0; z-index: var(--z-popover); min-width: 232px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 7px; box-shadow: var(--shadow-lg); animation: elx-pop var(--t-fast) var(--ease); }
.popmenu { display: flex; flex-direction: column; gap: 1px; }
.popmenu-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); font-size: 13.5px; color: var(--fg-muted); cursor: pointer; transition: background var(--t-fast), color var(--t-fast); white-space: nowrap; }
.popmenu-item:hover { background: var(--bg-hover); color: var(--fg); }
.popmenu-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.popmenu-item.danger { color: var(--danger); }
.popmenu-item.danger:hover { background: var(--danger-soft); }
.popmenu-sep { height: 1px; background: var(--border-soft); margin: 5px 4px; }

/* Panel sub-header (Telegram ID + регистрация и т.п.) */
.panel-subhead { display: flex; align-items: center; gap: 18px; padding: 11px 24px; border-bottom: 1px solid var(--border-soft); background: var(--bg-sunken); flex-shrink: 0; flex-wrap: wrap; }
.panel-subhead .ph-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--fg-muted); }
.panel-subhead .ph-item .ph-k { color: var(--fg-faint); }

/* Summary cell-grid (Сводка) */
.cells { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.cells.c2 { grid-template-columns: 1fr 1fr; }
.cell { background: var(--bg-sunken); border: 1px solid var(--border-soft); border-radius: var(--r); padding: 13px 15px; }
.cell .cl-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--fg-subtle); margin-bottom: 8px; }
.cell .cl-value { font-family: var(--font-mono); font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.cell .cl-value.ed { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; transition: color var(--t-fast); }
.cell .cl-value.ed svg { width: 13px; height: 13px; opacity: 0.45; transition: opacity var(--t-fast); }
.cell .cl-value.ed:hover { color: var(--accent); }
.cell .cl-value.ed:hover svg { opacity: 1; }
.cell .cl-value.pos { color: var(--positive); }
.cell .cl-value.neg { color: var(--danger); }
.cell .cl-sub { font-size: 11.5px; color: var(--fg-faint); margin-top: 4px; }

/* Compact table inside panels */
.t.compact th { height: 34px; padding: 0 16px; }
.t.compact td { height: 42px; padding: 0 16px; font-size: 13px; }

/* Quick-add date buttons */
.quick-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.quick-btn { height: 28px; padding: 0 11px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--bg-elev-2); color: var(--fg-muted); font-size: 12px; font-weight: 600; font-family: var(--font-mono); cursor: pointer; transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast); }
.quick-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }

/* Referral / id chips row */
.id-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.id-chip { display: inline-flex; align-items: center; height: 28px; padding: 0 11px; border-radius: var(--r-sm); background: var(--bg-elev-2); border: 1px solid var(--border); font-family: var(--font-mono); font-size: 12.5px; color: var(--accent); cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast); }
.id-chip:hover { border-color: var(--accent-line); background: var(--accent-soft); }

/* Chart legend */
.legend { display: flex; gap: 16px; flex-wrap: wrap; }
.legend .lg { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--fg-muted); }
.legend .lg .sw { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

/* Interactive charts (hover day → highlight + tooltip) */
.chart-plot { position: relative; width: 100%; }
.chart-line { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.chart-cols { position: absolute; inset: 0; display: flex; }
.chart-col { flex: 1; position: relative; display: flex; flex-direction: column; justify-content: flex-end; padding: 0 2px; cursor: pointer; }
.chart-col .bar { width: 100%; border-radius: var(--r-xs) var(--r-xs) 0 0; transition: opacity var(--t-fast), filter var(--t-fast); }
.chart-cols:hover .bar { opacity: 0.32; }
.chart-col:hover .bar { opacity: 1; filter: brightness(1.12); }
.chart-col .stack { width: 100%; display: flex; flex-direction: column; justify-content: flex-end; transition: opacity var(--t-fast); }
.chart-cols:hover .stack { opacity: 0.32; }
.chart-col:hover .stack { opacity: 1; }
.chart-col .guide { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--border-strong); opacity: 0; transform: translateX(-50%); transition: opacity var(--t-fast); pointer-events: none; }
.chart-col:hover .guide { opacity: 1; }
.chart-col .dot { position: absolute; left: 50%; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg-elev); transform: translate(-50%, -50%); opacity: 0; transition: opacity var(--t-fast); pointer-events: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.chart-col:hover .dot { opacity: 1; }
.chart-tip { position: absolute; left: 50%; bottom: calc(100% + 9px); transform: translateX(-50%); background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 11px; box-shadow: var(--shadow-lg); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--t-fast); z-index: 6; }
.chart-col:hover .chart-tip { opacity: 1; }
.chart-tip::after { content: ""; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--bg-elev); }
.chart-tip .ct-date { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-faint); margin-bottom: 4px; }
.chart-tip .ct-row { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--fg-muted); }
.chart-tip .ct-row + .ct-row { margin-top: 3px; }
.chart-tip .ct-sw { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.chart-tip .ct-val { font-family: var(--font-mono); font-weight: 600; color: var(--fg); margin-left: auto; padding-left: 10px; }

/* ── Keyframes ───────────────────────────────────────────────────── */
@keyframes elx-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes elx-slide-in { from { transform: translateX(24px); opacity: 0.6; } to { transform: translateX(0); opacity: 1; } }
@keyframes elx-pop { from { transform: scale(0.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes elx-sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes elx-toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes elx-spin { to { transform: rotate(360deg); } }
@keyframes elx-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── Admin → mobile ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .admin { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 248px; z-index: 250; transform: translateX(-100%); transition: transform var(--t) var(--ease); }
  .admin.menu-open .sidebar { transform: translateX(0); }
  .content { padding: var(--sp-4); }
  .topbar { padding: 0 16px; }
  .stat-grid.c4 { grid-template-columns: 1fr 1fr; }
  .stat-grid.c3 { grid-template-columns: 1fr; }
}
