/* TaroLune Dashboard — тёмная тема, фиолетово-золотая.
   Мобильный вид первичен: смотреть будут с телефона.

   Оформление держится того же языка, что и публичный лендинг: живой
   градиентный фон, стеклянные поверхности, антиква в заголовках и крупных
   числах. Но дозировка другая — это рабочий инструмент, а не витрина:
   фон спокойнее, движение короче, плотность таблиц не тронута. Числа должны
   читаться с первого взгляда, а не «производить впечатление».

   Имена классов не менялись ни одного: шаблоны продолжают работать как есть. */

:root {
  color-scheme: dark;

  --bg:          #0b0715;
  --surface-1:   #161022;   /* карточки и фон графиков — на нём валидирована палитра */
  --surface-2:   #1e1731;
  --surface-3:   #2a2042;
  --line:        rgba(255,255,255,.10);
  --line-soft:   rgba(255,255,255,.06);
  --line-hi:     rgba(255,255,255,.15);

  --text-1:      #f4f1fb;
  --text-2:      #bcb2d8;
  --text-3:      #8e84ac;

  --accent:      #9b8cf0;   /* фиолет — одиночные ряды и активные состояния */
  --accent-dim:  #6f5fd0;
  --gold:        #eac678;   /* золото — деньги и акценты бренда */
  --gold-dim:    #c9963c;

  --good:        #4ec99a;
  --warn:        #e0a83a;
  --bad:         #e66767;

  --glass:       rgba(255,255,255,.042);
  --glass-hi:    rgba(255,255,255,.07);

  --radius:      16px;
  --radius-sm:   10px;
  --gap:         14px;
  --maxw:        1240px;

  --serif:       ui-serif, "Iowan Old Style", "Apple Garamond", Georgia, "Times New Roman", serif;
  --ease:        cubic-bezier(.25,.46,.45,.94);
  --ease-out:    cubic-bezier(.22,1,.36,1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-1);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

/* Живой фон. Два пятна, очень медленно и с малой амплитудой: в рабочем
   интерфейсе фон не должен притягивать взгляд от цифр. Через ::before/::after
   на body — чтобы не трогать разметку шаблонов. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-image:
    radial-gradient(900px 520px at 10% -10%, rgba(155,140,240,.20), transparent 62%),
    radial-gradient(760px 460px at 94% 2%,  rgba(234,198,120,.09), transparent 60%),
    radial-gradient(680px 520px at 60% 108%, rgba(111,95,208,.13), transparent 64%);
  animation: bgdrift 34s ease-in-out infinite;
}
body::after {   /* зерно: убирает полосы на градиенте и добавляет «материал» */
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes bgdrift {
  0%, 100% { transform: translate3d(0,0,0)   scale(1); }
  50%      { transform: translate3d(0,-1.6%,0) scale(1.04); }
}

a { color: var(--accent); text-decoration: none; transition: color .16s var(--ease); }
a:hover { text-decoration: underline; }

/* --- Шапка ---------------------------------------------------------------- */
.top {
  position: sticky; top: 0; z-index: 40;
  background: rgba(11,7,21,.74);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: var(--maxw); margin: 0 auto;
  padding: 11px 14px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.brand {
  font: 700 17px/1.2 var(--serif); letter-spacing: -.01em;
  color: var(--text-1); white-space: nowrap;
}
.brand span { color: var(--gold); }
.brand small {
  display: block; font: 400 11px/1.3 -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-3); letter-spacing: .07em; text-transform: uppercase; margin-top: 1px;
}
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-3); }

nav.tabs {
  max-width: var(--maxw); margin: 0 auto;
  padding: 0 8px 8px;
  display: flex; gap: 4px; overflow-x: auto;
  scrollbar-width: none;
}
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a {
  padding: 7px 14px; border-radius: 999px; white-space: nowrap;
  color: var(--text-2); font-size: 14px; border: 1px solid transparent;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}
nav.tabs a:hover { background: var(--glass-hi); color: var(--text-1); text-decoration: none; }
nav.tabs a.on {
  background: var(--surface-3); color: var(--text-1);
  border-color: rgba(155,140,240,.42);
}
/* Счётчик непросмотренных заявок — чтобы очередь не терялась во вкладках. */
nav.tabs a .cnt {
  display: inline-block; min-width: 17px; padding: 0 5px; margin-left: 3px;
  border-radius: 999px; background: linear-gradient(135deg, #f0d296, var(--gold-dim)); color: #1c1405;
  font-size: 11.5px; line-height: 17px; text-align: center; font-weight: 700;
}

/* --- Каркас --------------------------------------------------------------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 20px 14px 60px; }
h1 { font: 700 24px/1.2 var(--serif); margin: 0 0 4px; letter-spacing: -.015em; }
h2 { font-size: 16px; margin: 28px 0 10px; font-weight: 600; color: var(--text-1); letter-spacing: -.005em; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 600; color: var(--text-2); }
.sub { color: var(--text-3); font-size: 13px; margin: 0 0 16px; }

.card {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.card + .card { margin-top: var(--gap); }

.grid { display: grid; gap: var(--gap); align-items: start; }
.g2 { grid-template-columns: 1fr; }
@media (min-width: 780px) { .g2 { grid-template-columns: 1fr 1fr; } }

/* --- Плитки с числами ------------------------------------------------------ */
.tiles {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
}
/* На широком экране фиксируем 4 колонки: auto-fit давал 7 плиток в ряд
   и одну сиротой во втором — выглядит как сбой вёрстки, а не как сетка. */
@media (min-width: 900px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 15px;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.tile:hover { border-color: var(--line-hi); background: var(--glass-hi); }
.tile .k { font-size: 12px; color: var(--text-3); margin-bottom: 5px; letter-spacing: .01em; }
.tile .v { font: 650 26px/1.15 var(--serif); letter-spacing: -.02em;
             font-variant-numeric: tabular-nums;
             white-space: nowrap; }   /* число и ⭐ не должны разъезжаться на две строки */
.tile .v.sm { font-size: 20px; }
.tile .x { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.tile.gold { border-color: rgba(234,198,120,.34); }
.tile.gold .v { color: var(--gold); }
.tile.acc .v { color: var(--accent); }

.hero {
  background: linear-gradient(150deg, rgba(155,140,240,.17), rgba(234,198,120,.06));
  border: 1px solid rgba(155,140,240,.32);
}
.hero .v { font-size: 34px; }

/* --- Воронка --------------------------------------------------------------- */
.funnel { display: grid; gap: 8px; }
.fstep { display: grid; grid-template-columns: 1fr; gap: 4px; }
.fstep .lbl { display: flex; justify-content: space-between; font-size: 13px; gap: 10px; }
.fstep .lbl b { font-weight: 600; }
.fstep .lbl .p { color: var(--text-3); font-variant-numeric: tabular-nums; }
.fbar { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.fbar i {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--gold-dim));
}
.fdrop { font-size: 12px; color: var(--text-3); padding-left: 2px; }

/* --- Таблицы ---------------------------------------------------------------
   Стекло здесь намеренно не используется: липкая первая колонка обязана иметь
   непрозрачный фон, иначе при горизонтальной прокрутке под неё «просвечивают»
   соседние цифры и таблица читается как сломанная. */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -17px; padding: 0 17px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
th, td { padding: 10px 10px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface-1); }
thead th {
  color: var(--text-3); font-weight: 500; font-size: 12px;
  border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: .05em;
}
thead th a { color: inherit; }
thead th a.on { color: var(--accent); }
tbody tr { border-bottom: 1px solid var(--line-soft); }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:hover td:first-child { background: var(--surface-2); }
td.num, th.num { font-variant-numeric: tabular-nums; }
tfoot td { border-top: 1px solid var(--line); font-weight: 600; color: var(--text-2); }
.muted { color: var(--text-3); }
.gold { color: var(--gold); }
.good { color: var(--good); }
.bad { color: var(--bad); }

/* --- Формы ----------------------------------------------------------------- */
label { display: block; font-size: 12.5px; color: var(--text-3); margin: 0 0 5px; }
input, select, textarea, button {
  font: inherit; color: var(--text-1);
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px; width: 100%;
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-dim); outline-offset: 1px; border-color: var(--accent-dim);
}
.field { margin-bottom: 12px; }
.row { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .row.c2 { grid-template-columns: 1fr 1fr; } .row.c3 { grid-template-columns: 1fr 1fr 1fr; } }

button, .btn {
  width: auto; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  background: var(--glass-hi); border-color: var(--line);
  padding: 10px 16px; font-size: 14px; border-radius: 999px;
  transition: transform .16s var(--ease), background .16s var(--ease),
              border-color .16s var(--ease), box-shadow .18s var(--ease);
}
button:hover, .btn:hover {
  background: rgba(255,255,255,.11); border-color: var(--line-hi);
  transform: translateY(-1px); text-decoration: none;
}
button:active, .btn:active { transform: translateY(0); }
button.primary, .btn.primary {
  background: linear-gradient(135deg, #f0d296, var(--gold-dim));
  border-color: transparent; color: #1c1405; font-weight: 600;
  box-shadow: 0 3px 14px -5px rgba(234,198,120,.5);
}
button.primary:hover, .btn.primary:hover {
  background: linear-gradient(135deg, #f5dcaa, #d5a248);
  box-shadow: 0 7px 20px -6px rgba(234,198,120,.6);
}
button.ghost { background: transparent; }
button.ghost:hover { background: var(--glass-hi); }
button.danger { border-color: rgba(230,103,103,.45); color: var(--bad); background: transparent; }
button.danger:hover { background: rgba(230,103,103,.11); border-color: rgba(230,103,103,.6); }
.inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline > * { width: auto; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 14px; }
label.check input { width: auto; }

/* --- Период ---------------------------------------------------------------- */
.period { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.chips { display: flex; gap: 4px; background: var(--glass); border: 1px solid var(--line);
         border-radius: 999px; padding: 3px;
         -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.chips a { padding: 6px 13px; border-radius: 999px; font-size: 13px; color: var(--text-2);
           transition: background .16s var(--ease), color .16s var(--ease); }
.chips a.on { background: var(--surface-3); color: var(--text-1); }
.chips a:hover { text-decoration: none; color: var(--text-1); }
.period form { display: flex; gap: 6px; align-items: center; }
.period input[type=date] { width: auto; padding: 7px 10px; font-size: 13px; }

/* --- Графики --------------------------------------------------------------- */
.chart { position: relative; height: 260px; }
.chart-sm { height: 200px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-bottom: 10px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: baseline; }

/* --- Мелочи ---------------------------------------------------------------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; border: 1px solid var(--line); color: var(--text-2);
  background: var(--glass); white-space: nowrap;
}
.badge.on { border-color: rgba(78,201,154,.42); color: var(--good); }
.badge.off { border-color: rgba(230,103,103,.42); color: var(--bad); }
.badge.gold { border-color: rgba(234,198,120,.42); color: var(--gold); }

.note {
  background: var(--glass); border: 1px solid var(--line);
  border-left: 3px solid var(--accent-dim);
  border-radius: var(--radius-sm); padding: 12px 14px;
  color: var(--text-2); font-size: 13px; margin: 14px 0;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.note.warn { border-left-color: var(--warn); }
.note.bad { border-left-color: var(--bad); }
.note code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.copy {
  display: flex; gap: 8px; align-items: center;
  background: var(--glass); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 11px;
}
.copy code {
  flex: 1; overflow-x: auto; white-space: nowrap; font-size: 13px; color: var(--gold);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.copy button { padding: 7px 13px; font-size: 13px; }

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--text-3); font-size: 13px; }
dl.kv dd { margin: 0; text-align: right; }

.login-wrap { max-width: 390px; margin: 12vh auto; padding: 0 16px; }
.login-wrap .card { padding: 26px; }
.login-wrap .brand { font-size: 25px; text-align: center; display: block; margin-bottom: 4px; }
.login-wrap .sub { text-align: center; }

.err { color: var(--bad); font-size: 13.5px; margin: 0 0 12px; }
.ok { color: var(--good); font-size: 13.5px; margin: 0 0 12px; }
.qr { background: #fff; border-radius: var(--radius-sm); padding: 8px; width: 168px; height: 168px; }
.qr img { width: 100%; height: 100%; display: block; }
.pager { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
.foot { color: var(--text-3); font-size: 12px; text-align: center; margin-top: 34px; }

/* --- Антифрод -------------------------------------------------------------- */
.risk { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.risk b { font-variant-numeric: tabular-nums; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok      { background: var(--good); }
.dot.watch   { background: var(--warn); }
.dot.suspect { background: #e0813a; }
.dot.bad     { background: var(--bad); }
.risk.ok b      { color: var(--good); }
.risk.watch b   { color: var(--warn); }
.risk.suspect b { color: #e0813a; }
.risk.bad b     { color: var(--bad); }

/* Полоска правила: заполнение показывает, насколько правило сработало. */
.rule { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.rule:last-child { border-bottom: 0; }
.rule .top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
             position: static; background: none; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
.rule .nm { font-size: 14px; }
.rule .vl { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.rule .bar { height: 5px; border-radius: 999px; background: var(--surface-3); margin: 7px 0 6px; overflow: hidden; }
.rule .bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.rule.hot .bar i { background: var(--bad); }
.rule .ex { font-size: 12.5px; color: var(--text-3); line-height: 1.45; }
.rule .why { font-size: 12px; color: var(--text-2); }

.money-split { display: grid; gap: 6px; font-size: 13.5px; }
.money-split div { display: flex; justify-content: space-between; gap: 12px; }
.money-split .sep { border-top: 1px solid var(--line); padding-top: 7px; margin-top: 3px; font-weight: 600; }
.money-split .neg { color: var(--text-3); }

/* --- Уважение к системным настройкам --------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}
