/* refstat — design system v2 (Emil-inspired: калм, точный, деньги видны) */

/* ==================================================================
   Tokens
   ================================================================== */
:root {
  /* surfaces */
  --bg:         #0b0d10;
  --bg-elev-1:  #12151a;   /* nav, first panel */
  --bg-elev-2:  #171b21;   /* panels on top */
  --bg-elev-3:  #1e232b;   /* hover row */
  --hairline:   rgba(255,255,255,0.06);
  --border:     rgba(255,255,255,0.09);
  --border-strong: rgba(255,255,255,0.14);

  /* text */
  --text:       #e8ebef;
  --text-2:     #b6bcc6;
  --text-3:     #7a828e;
  --text-4:     #565c66;

  /* semantic */
  --pos:        #4ade80;      /* revenue/profit */
  --pos-bg:     rgba(74,222,128,0.10);
  --pos-border: rgba(74,222,128,0.28);
  --neg:        #f87171;
  --neg-bg:     rgba(248,113,113,0.09);
  --neg-border: rgba(248,113,113,0.28);
  --warn:       #fbbf24;
  --warn-bg:    rgba(251,191,36,0.09);
  --warn-border: rgba(251,191,36,0.28);
  --info:       #60a5fa;
  --info-bg:    rgba(96,165,250,0.10);
  --info-border: rgba(96,165,250,0.30);

  /* brand accent */
  --accent:     #7aa2ff;
  --accent-2:   #5b8dff;
  --accent-fg:  #0b0d10;

  /* spacing scale (4px base) */
  --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;

  /* radii */
  --r-1: 4px; --r-2: 6px; --r-3: 8px; --r-4: 10px; --r-5: 14px;

  /* type */
  --font: ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI",
          "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* motion */
  --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --dur-fast: 140ms;
  --dur-med:  220ms;

  /* shadows */
  --shadow-1: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-2: 0 4px 12px rgba(0,0,0,0.35), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-focus: 0 0 0 3px rgba(122,162,255,0.28);
}

/* ==================================================================
   Reset
   ================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: #a4beff; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
hr { border: 0; border-top: 1px solid var(--hairline); margin: var(--sp-4) 0; }
code { font-family: var(--font-mono); font-size: 12px; }

/* tabular numerals globally for money/tables/inputs — critical for alignment */
.num, .tbl td, .stat-val, .field input[type="number"],
.badge, dl.kv dd, .kv-strong {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ==================================================================
   Layout
   ================================================================== */
.wrap { max-width: 1240px; margin: 0 auto; padding: var(--sp-8) var(--sp-6) var(--sp-12); }
.foot {
  text-align: center; color: var(--text-4);
  padding: var(--sp-8) var(--sp-4); font-size: 12px;
}

/* ==================================================================
   Nav
   ================================================================== */
.topnav {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-6);
  background: color-mix(in srgb, var(--bg-elev-1) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}
.topnav .brand {
  font-weight: 600; font-size: 14px; letter-spacing: -0.01em;
  color: var(--text);
  padding: 6px 10px; margin-right: var(--sp-2);
  border-radius: var(--r-2);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  border: 1px solid var(--border);
}
.topnav .brand:hover { text-decoration: none; }
.topnav nav {
  display: flex; gap: var(--sp-1);
}
.topnav nav a {
  color: var(--text-2); font-size: 13px;
  padding: 6px 10px; border-radius: var(--r-2);
  transition: color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
.topnav nav a:hover {
  color: var(--text); background: rgba(255,255,255,0.04);
  text-decoration: none;
}
.topnav nav a.active {
  color: var(--text);
  background: rgba(255,255,255,0.06);
  box-shadow: inset 0 -1px 0 var(--text-3);
}
.topnav .actions { margin-left: auto; display: flex; gap: var(--sp-2); }

/* ==================================================================
   Flash messages
   ================================================================== */
.flashes {
  max-width: 1240px; margin: var(--sp-4) auto 0;
  padding: 0 var(--sp-6);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.flash {
  padding: 10px 14px;
  border-radius: var(--r-3);
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  animation: flash-in 260ms var(--ease-out);
}
.flash::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; flex: none;
}
.flash-ok    { border-color: var(--pos-border); background: color-mix(in srgb, var(--pos-bg) 60%, var(--bg-elev-2)); }
.flash-ok::before { background: var(--pos); }
.flash-error { border-color: var(--neg-border); background: color-mix(in srgb, var(--neg-bg) 60%, var(--bg-elev-2)); }
.flash-error::before { background: var(--neg); }
.flash-warn  { border-color: var(--warn-border); background: color-mix(in srgb, var(--warn-bg) 60%, var(--bg-elev-2)); }
.flash-warn::before { background: var(--warn); }
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ==================================================================
   Typography
   ================================================================== */
h1 { font-size: 22px; margin: 0 0 var(--sp-4); font-weight: 600; letter-spacing: -0.015em; }
h2 { font-size: 13px; margin: 0 0 var(--sp-3); font-weight: 600;
     color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.muted { color: var(--text-3); }
.dim   { color: var(--text-4); }
.pos   { color: var(--pos); }
.neg   { color: var(--neg); }
.warn  { color: var(--warn); }

/* Section title — a soft rail between blocks */
.section-title {
  font-size: 11px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em;
  margin: var(--sp-6) 0 var(--sp-3);
  display: flex; align-items: center; gap: 10px;
}
.section-title:first-child { margin-top: 0; }
.section-title::after {
  content: ""; flex: 1; height: 1px; background: var(--hairline);
}

.head-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap;
}
.head-row h1 { margin: 0; }
.head-row .head-actions { display: flex; gap: var(--sp-2); }

/* ==================================================================
   Panel
   ================================================================== */
.panel {
  background: linear-gradient(180deg, var(--bg-elev-2), var(--bg-elev-1));
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
  box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset, var(--shadow-1);
}
.panel + .panel { margin-top: var(--sp-4); }
.panel h2:first-child { margin-top: -4px; }

/* grid layouts */
.grid { display: grid; gap: var(--sp-3); }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .grid.two { grid-template-columns: 1fr; } }

/* ==================================================================
   Stats — deliberate hierarchy
   ================================================================== */
.stats-money {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
@media (max-width: 1100px) {
  .stats-money { grid-template-columns: 1fr 1fr; }
  .stats-money .stat-hero { grid-column: 1 / -1; }
}
.stats-money .stat-hero {
  grid-row: span 2;
}
.stats-accounts {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
@media (max-width: 900px) { .stats-accounts { grid-template-columns: repeat(2, 1fr); } }

.stat {
  background: linear-gradient(180deg, var(--bg-elev-2), var(--bg-elev-1));
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-1);
  transition: border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
  box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset, var(--shadow-1);
}
.stat:hover { border-color: var(--border-strong); }
.stat-lbl {
  color: var(--text-3); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600;
}
.stat-val {
  font-size: 20px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--text); line-height: 1.15;
}
.stat-sub { color: var(--text-4); font-size: 11px; margin-top: 2px; }

.stat.subtle .stat-val { color: var(--text-2); }
.stat.warn { border-color: var(--warn-border); background: color-mix(in srgb, var(--warn-bg) 50%, var(--bg-elev-1)); }
.stat.warn .stat-val { color: var(--warn); }
.stat.neg  .stat-val { color: var(--neg); }

/* HERO stat — the "how much I earned" card */
.stat-hero {
  position: relative; overflow: hidden;
  padding: var(--sp-6);
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(74,222,128,0.12), transparent 60%),
    radial-gradient(80% 60% at 100% 100%, rgba(74,222,128,0.06), transparent 60%),
    linear-gradient(180deg, var(--bg-elev-2), var(--bg-elev-1));
  border: 1px solid var(--pos-border);
  border-radius: var(--r-4);
  display: flex; flex-direction: column; gap: var(--sp-3);
  justify-content: space-between;
}
.stat-hero::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(50% 60% at 0% 0%, rgba(74,222,128,0.06), transparent 70%);
  pointer-events: none;
}
.stat-hero > * { position: relative; z-index: 1; }
.stat-hero.neg .stat-val, .stat-hero.neg .stat-lbl { color: var(--neg); }
.stat-hero .stat-lbl { color: var(--pos); opacity: 0.9; }
.stat-hero .stat-val {
  font-size: 44px; font-weight: 700; letter-spacing: -0.03em;
  color: var(--pos);
  line-height: 1;
}
.stat-hero .stat-formula {
  font-size: 12px; color: var(--text-3);
  display: inline-flex; gap: 8px; align-items: center;
  align-self: flex-start;
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
  padding: 6px 12px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
}
.stat-hero .stat-formula .val { color: var(--text-2); font-weight: 500; }
.stat-hero .stat-formula .op {
  color: var(--text-4);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1;
}

/* ==================================================================
   Tables
   ================================================================== */
.tbl-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  overflow: hidden;
  background: var(--bg-elev-1);
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl thead th {
  color: var(--text-3);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  padding: 10px 14px;
  background: var(--bg-elev-1);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl tbody td {
  padding: 12px 14px;
  border-top: 1px solid var(--hairline);
  vertical-align: middle;
}
.tbl tbody tr:first-child td { border-top: 0; }
.tbl tbody tr {
  transition: background var(--dur-fast) var(--ease-out);
}
.tbl tbody tr:hover { background: var(--bg-elev-3); }
.tbl .num { text-align: right; }
.tbl .actions-col { width: 1%; text-align: right; white-space: nowrap; }
.tbl .cell-primary { font-weight: 500; }
.tbl .cell-sub { color: var(--text-4); font-size: 11px; margin-top: 2px; }

/* Row-as-link — remove separate "открыть" cells */
.tbl tbody tr.linked { cursor: pointer; }
.tbl tbody tr.linked td:first-child a {
  color: var(--text);
  font-weight: 500;
}
.tbl tbody tr.linked:hover td:first-child a { color: var(--accent); }
.tbl tbody tr.linked:active { transform: translateY(1px); }

/* Subtle left-edge accent on hover, à la Linear */
.tbl tbody tr.linked {
  position: relative;
}
.tbl tbody tr.linked::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--accent); opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.tbl tbody tr.linked:hover::after { opacity: 1; }

.empty {
  padding: var(--sp-8) var(--sp-6);
  text-align: center;
  color: var(--text-3);
  border: 1px dashed var(--border);
  border-radius: var(--r-3);
  font-size: 13px;
  background: var(--bg-elev-1);
}
.empty a { text-decoration: underline; text-underline-offset: 3px; }

/* ==================================================================
   Badges & filter chips
   ================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-2);
  white-space: nowrap;
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.9;
}
.b-registered { color: var(--info);  border-color: var(--info-border); background: var(--info-bg); }
.b-assigned   { color: var(--pos);   border-color: var(--pos-border);  background: var(--pos-bg); }
.b-closed     { color: var(--text-3);border-color: var(--border);      background: var(--bg-elev-2); }
.b-dropped    { color: var(--neg);   border-color: var(--neg-border);  background: var(--neg-bg); }
.b-banned     { color: var(--neg);   border-color: var(--neg);         background: var(--neg-bg); text-decoration: line-through; }
.b-active     { color: var(--pos);   border-color: var(--pos-border);  background: var(--pos-bg); }
.b-completed  { color: var(--text-3);border-color: var(--border);      background: var(--bg-elev-2); }

.filters { display: flex; gap: 6px; margin-bottom: var(--sp-4); flex-wrap: wrap; }
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  color: var(--text-2);
  transition: color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.chip:hover { color: var(--text); border-color: var(--border-strong); text-decoration: none; }
.chip.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ==================================================================
   Buttons
   ================================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border-radius: var(--r-2);
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 13px; font-weight: 500;
  cursor: pointer; text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
  user-select: none;
}
.btn:hover { background: var(--bg-elev-3); border-color: var(--border-strong); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:active { transform: scale(0.97); }

.btn.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn.primary:hover { background: #fff; border-color: #fff; }

.btn.pos {
  background: var(--pos-bg);
  color: var(--pos);
  border-color: var(--pos-border);
}
.btn.pos:hover { background: color-mix(in srgb, var(--pos-bg) 70%, var(--pos)); color: #0b0d10; }

.btn.danger {
  background: transparent;
  color: var(--neg);
  border-color: var(--neg-border);
}
.btn.danger:hover { background: var(--neg-bg); border-color: var(--neg); }

.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.big   { padding: 10px 18px; font-size: 14px; }
.btn.icon  { padding: 6px 8px; }

/* legacy compat: .btn.ok maps to positive */
.btn.ok { background: var(--pos-bg); color: var(--pos); border-color: var(--pos-border); }
.btn.ok:hover { background: color-mix(in srgb, var(--pos-bg) 70%, var(--pos)); color: #0b0d10; }

/* ==================================================================
   Forms
   ================================================================== */
.form { display: flex; flex-direction: column; gap: var(--sp-3); }
.form.inline { display: block; }
.row { display: flex; gap: var(--sp-3); align-items: flex-end; flex-wrap: wrap; }
.row.two > .field { flex: 1 1 280px; }
.row.three > .field { flex: 1 1 200px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 180px; }
.field.grow { flex: 1; }
.field label {
  font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600;
  display: flex; align-items: center; gap: 4px;
}
.field .req { color: var(--neg); font-weight: 700; }
.field input,
.field textarea,
.field select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  padding: 9px 11px;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
.field input::placeholder { color: var(--text-4); }
.field input:hover:not(:disabled),
.field textarea:hover:not(:disabled) {
  border-color: var(--border-strong);
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.field input:disabled {
  color: var(--text-3); background: var(--bg-elev-2);
  cursor: not-allowed;
}
.field small {
  font-size: 11px; color: var(--text-4); line-height: 1.5;
}

/* ==================================================================
   Definition list (key/value)
   ================================================================== */
dl.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 20px;
  margin: 0 0 var(--sp-4);
}
dl.kv dt {
  color: var(--text-3); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600;
  padding-top: 2px;
}
dl.kv dd { margin: 0; color: var(--text); }

/* ==================================================================
   Progress bar (orders / 100)
   ================================================================== */
.progress {
  display: flex; align-items: center; gap: 10px;
  min-width: 140px;
}
.progress-track {
  flex: 1; height: 6px;
  background: var(--bg-elev-3);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pos), #6ee7a7);
  border-radius: 999px;
  transition: width 400ms var(--ease-out);
}
.progress-fill.complete { background: linear-gradient(90deg, var(--accent), #a4beff); }
.progress-text {
  font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--text-2);
  white-space: nowrap;
  min-width: 60px;
}
.progress-text b { color: var(--text); font-weight: 600; }

/* Danger zone — visually separated actions */
.danger-zone {
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px dashed var(--hairline);
  display: flex; gap: var(--sp-2);
  flex-wrap: wrap;
  align-items: center;
}

/* ==================================================================
   Segmented control (свитч на 2–4 состояния)
   ================================================================== */
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  gap: 2px;
  position: relative;
}
.segmented input[type="radio"] {
  position: absolute; opacity: 0; pointer-events: none;
}
.segmented label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-2);
  font-size: 12px; font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
  user-select: none;
  white-space: nowrap;
}
.segmented label:hover { color: var(--text-2); }
.segmented input:checked + label {
  background: var(--bg-elev-3);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset, var(--shadow-1);
}
.segmented input:focus-visible + label {
  box-shadow: var(--shadow-focus);
}

/* Per-state accents */
.segmented input[value="pending"]:checked + label     { color: var(--warn); background: color-mix(in srgb, var(--warn-bg) 40%, var(--bg-elev-3)); }
.segmented input[value="registered"]:checked + label  { color: var(--pos);  background: color-mix(in srgb, var(--pos-bg)  40%, var(--bg-elev-3)); }
.segmented input[value="refused"]:checked + label     { color: var(--neg);  background: color-mix(in srgb, var(--neg-bg)  40%, var(--bg-elev-3)); }

.segmented label::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-4);
  transition: background var(--dur-fast) var(--ease-out);
  flex: none;
}
.segmented input[value="pending"]:checked + label::before    { background: var(--warn); }
.segmented input[value="registered"]:checked + label::before { background: var(--pos);  }
.segmented input[value="refused"]:checked + label::before    { background: var(--neg);  }

/* When segmented is inside a form, submit on change */
.segmented[data-auto-submit="true"] { }

/* Additional reg badges (colors reuse the same palette) */
.b-pending    { color: var(--warn); border-color: var(--warn-border); background: var(--warn-bg); }
.b-hot        { color: #fb923c;     border-color: rgba(251,146,60,.35); background: rgba(251,146,60,.10); }
.b-refused    { color: var(--neg);  border-color: var(--neg-border);  background: var(--neg-bg); }
/* .b-registered already exists for status; matches semantic */

/* Reg summary chips на дашборде */
.reg-summary {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin: 0 0 var(--sp-4);
}
.reg-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  font-size: 12px; font-weight: 500;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-2);
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
}
.reg-chip.b-info    { color: var(--info); border-color: var(--info-border); background: var(--info-bg); }
.reg-chip.b-registered { color: var(--pos);  border-color: var(--pos-border);  background: var(--pos-bg); }
.reg-chip.b-hot     { color: #fb923c;     border-color: rgba(251,146,60,.35); background: rgba(251,146,60,.10); }
.reg-chip.b-pending { color: var(--warn); border-color: var(--warn-border); background: var(--warn-bg); }
.reg-chip.b-refused { color: var(--neg);  border-color: var(--neg-border);  background: var(--neg-bg); }

/* Селфи-превью */
.selfie-preview {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}
.selfie-preview img {
  width: 90px; height: 90px;
  object-fit: cover;
  border-radius: var(--r-3);
  border: 1px solid var(--border);
  transition: transform var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
  display: block;
}
.selfie-preview a:hover img {
  transform: scale(1.03);
  border-color: var(--border-strong);
}
.selfie-remove {
  font-size: 12px; color: var(--text-3);
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer;
  text-transform: none; letter-spacing: 0;
}
.selfie-remove input { accent-color: var(--neg); }

/* file input polish */
input[type="file"] {
  background: var(--bg);
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  padding: 8px 11px;
  font-size: 13px;
}
input[type="file"]::file-selector-button {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  padding: 4px 12px;
  font: inherit;
  font-size: 12px;
  margin-right: 10px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
input[type="file"]::file-selector-button:hover {
  background: var(--bg-elev-3);
}

/* ==================================================================
   Money display in tables
   ================================================================== */
.money { font-variant-numeric: tabular-nums; }
.money-pos { color: var(--pos); }
.money-neg { color: var(--neg); }
.money-strong { color: var(--text); font-weight: 500; }

/* ==================================================================
   Entrance
   ================================================================== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.stats-money > *, .stats-accounts > * {
  animation: fadeUp 380ms var(--ease-out) both;
}
.stats-money > *:nth-child(1) { animation-delay: 0ms; }
.stats-money > *:nth-child(2) { animation-delay: 40ms; }
.stats-money > *:nth-child(3) { animation-delay: 80ms; }
.stats-money > *:nth-child(4) { animation-delay: 120ms; }
.stats-money > *:nth-child(5) { animation-delay: 160ms; }
.stats-money > *:nth-child(6) { animation-delay: 200ms; }
.stats-money > *:nth-child(7) { animation-delay: 240ms; }
.stats-accounts > *:nth-child(1) { animation-delay: 80ms; }
.stats-accounts > *:nth-child(2) { animation-delay: 110ms; }
.stats-accounts > *:nth-child(3) { animation-delay: 140ms; }
.stats-accounts > *:nth-child(4) { animation-delay: 170ms; }
.stats-accounts > *:nth-child(5) { animation-delay: 200ms; }

.tbl-wrap {
  animation: fadeUp 380ms var(--ease-out) both;
  animation-delay: 60ms;
}
.panel {
  animation: fadeUp 380ms var(--ease-out) both;
}
.section-title {
  animation: fadeUp 380ms var(--ease-out) both;
}

/* ==================================================================
   Reduced motion
   ================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ==================================================================
   Hover only on real pointer devices
   ================================================================== */
@media (hover: none) {
  .btn:hover, .chip:hover, a:hover, .tbl tbody tr:hover {
    background: initial;
  }
}

/* Экономика: снятие курьера, правка суммы, статус «отвязан» */
.segmented { flex-wrap: wrap; max-width: 100%; }
.segmented input[value="hot"]:checked + label { color: #fb923c; background: color-mix(in srgb, rgba(251,146,60,.10) 40%, var(--bg-elev-3)); }
.segmented input[value="hot"]:checked + label::before { background: #fb923c; }
.b-unlinked { color: var(--text-3); border-color: var(--border); background: var(--bg-elev-2); }
.drop-box > summary { list-style: none; cursor: pointer; display: inline-flex; }
.drop-box > summary::-webkit-details-marker { display: none; }
.drop-box[open] { flex-basis: 100%; }
.payout-edit { display: inline-flex; gap: 4px; align-items: center; justify-content: flex-end; }
.payout-edit input {
  width: 96px; padding: 4px 8px; text-align: right;
  font: inherit; font-size: 13px; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-2);
}
.field .segmented label { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 500; color: var(--text-3); }
.field .segmented input:checked + label { color: var(--text); }

/* Потенциал на 100 заказов */
.stats-potential {
  display: grid; gap: var(--sp-3); margin-bottom: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.stat.pos-card { border-color: var(--pos-border); background: color-mix(in srgb, var(--pos-bg) 50%, var(--bg-elev-1)); }
.stat.pos-card .stat-val { color: var(--pos); }
.potential-details { margin-bottom: var(--sp-5); }
.potential-details > summary {
  cursor: pointer; font-size: 12px; color: var(--text-3);
  margin-bottom: var(--sp-3); user-select: none;
}
.potential-details > summary:hover { color: var(--text-2); }

/* Страница синка */
.sync-status {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  flex-wrap: wrap; padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4);
  border: 1px solid var(--border); border-radius: var(--r-3); background: var(--bg-elev-1);
}
.sync-status-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sync-status-text b { font-size: 14px; font-weight: 600; }
.sync-status-text b::before { content: "●"; margin-right: 8px; }
.sync-status-text span { font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }
.sync-status-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.sync-ok    { border-color: var(--pos-border);  background: color-mix(in srgb, var(--pos-bg) 45%, var(--bg-elev-1)); }
.sync-ok b  { color: var(--pos); }
.sync-stale { border-color: var(--warn-border); background: color-mix(in srgb, var(--warn-bg) 45%, var(--bg-elev-1)); }
.sync-stale b { color: var(--warn); }
.sync-error { border-color: var(--neg-border);  background: color-mix(in srgb, var(--neg-bg) 45%, var(--bg-elev-1)); }
.sync-error b { color: var(--neg); }
.sync-off b { color: var(--text-3); }
.sync-changes, .sync-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.sync-history li { display: flex; gap: 10px; flex-wrap: wrap; overflow-wrap: anywhere; }
.sync-missing {
  font-size: 12px; padding: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-3);
  border: 1px solid var(--warn-border); border-radius: var(--r-2);
  background: color-mix(in srgb, var(--warn-bg) 40%, var(--bg-elev-1));
}
.sync-missing b { color: var(--warn); font-weight: 600; }
.sync-settings > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sync-settings > summary::-webkit-details-marker { display: none; }
.sync-settings > summary::before { content: "▸"; color: var(--text-4); }
.sync-settings[open] > summary::before { content: "▾"; }
.sync-settings > summary .dim { font-size: 12px; }
.sync-howto { margin-top: var(--sp-3); font-size: 12px; }
.sync-howto > summary { cursor: pointer; color: var(--text-3); }
.sync-howto ol { margin: var(--sp-2) 0 0; padding-left: 1.2em; line-height: 1.8; }

/* Предупреждение о синке на дашборде */
.sync-alert {
  display: flex; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4); font-size: 13px;
  border: 1px solid var(--neg-border); border-radius: var(--r-3); color: var(--neg);
  background: color-mix(in srgb, var(--neg-bg) 45%, var(--bg-elev-1));
}
.sync-alert:hover { text-decoration: none; border-color: var(--neg); }
.sync-alert.sync-stale, .sync-alert.sync-off { color: var(--warn); border-color: var(--warn-border); background: color-mix(in srgb, var(--warn-bg) 45%, var(--bg-elev-1)); }
.sync-alert span { font-weight: 600; }

/* Проверка перед «зарегистрирован» */
.segmented input:disabled + label { opacity: .4; cursor: not-allowed; }
.segmented input:disabled + label:hover { color: var(--text-3); }
.reg-hint { display: block; margin-top: 6px; font-size: 12px; }

/* оборот по дням */
.turnover-days .bar-col { width: 30%; min-width: 80px; }
.day-bar { height: 8px; border-radius: var(--r-1); background: var(--hairline); overflow: hidden; }
.day-bar { display: flex; }
.day-bar > span { display: block; flex: none; height: 100%; background: var(--pos); opacity: 0.75; border-radius: var(--r-1); }
.day-bar > span.dispute { background: var(--info); }
.dispute-sub { color: var(--info); }
.dispute-sub a { color: inherit; }
@media (max-width: 640px) {
  .turnover-days .bar-col { display: none; }
}

/* ставки по скорости (templates/_tiers.html) */
.tier-steps { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.tier-step { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border, #333); white-space: nowrap; }
.tier-step.cur { border-color: var(--pos, #3fb950); color: var(--pos, #3fb950); font-weight: 600; }
.tier-step.passed { opacity: .45; text-decoration: line-through; }
.tier-edit summary { cursor: pointer; font-size: 12px; display: inline; }
