/* =========================================================================
   Бонусы D-Electro — мини-приложение.
   ВСЕ цвета, шрифты, радиусы и размеры — в переменных ниже (одно место).
   База — токены приложения Дейтон «Единое окно» (DESIGN.md): светлая/тёмная темы
   через data-theme на <html>. От сайта — логотип, Oswald в заголовках и крупной сумме,
   мотив молнии.
   ========================================================================= */
:root {
  color-scheme: light;
  /* цвета — светлая тема */
  --bg: #efeee9;
  --bg-elevated: #ffffff;
  --bg-sunken: #e8e6de;
  --bg-hover: rgba(28, 27, 23, 0.045);
  --bg-active: #f6f0d4;
  --text: #1c1b17;
  --text-secondary: #5e5b53;
  --text-tertiary: #8a867b;
  --border: #e4e0d6;
  --border-strong: #d3cec2;
  --brand: #f5c400;
  --brand-hover: #ffd22a;
  --brand-border: #e0b400;
  --brand-ink: #1a1a1a;
  --brand-soft: #fff4c2;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --ok: #1f7a45;
  --warn: #8a5a00;
  --warn-bg: #fff6e4;
  --warn-border: #f0e0bc;
  --shadow: 0 12px 32px rgba(28, 27, 23, 0.12);
  /* фирменная плашка «готово к выдаче» (как тёмная панель входа приложения) */
  --hero-bg: linear-gradient(180deg, #171717 0%, #0c0c0c 100%);
  --hero-glow: rgba(245, 196, 0, 0.16);
  --hero-text: #f6f4ee;
  --hero-muted: #9c978c;
  --hero-amount: var(--brand);
  /* шрифты */
  --font: "Roboto", "Segoe UI", Arial, sans-serif;
  --head: "Oswald", "Arial Narrow", "Roboto", sans-serif;
  --fs: 14px;
  --lh: 1.4;
  /* радиусы и размеры */
  --r-btn: 7px;
  --r-field: 8px;
  --r-card: 12px;
  --r-chip: 999px;
  --h-btn: 30px;
  --h-big: 42px;
  --icon: 18px;
  --top: 2px;
  --gap: 10px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121212;
  --bg-elevated: #1c1c1c;
  --bg-sunken: #262626;
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-active: #2c2818;
  --text: #f4f2ea;
  --text-secondary: #c4c0b4;
  --text-tertiary: #8f8b80;
  --border: #2d2d2d;
  --border-strong: #3c3c3c;
  --brand-ink: #161616;
  --brand-soft: #3a320c;
  --danger: #ff9b8e;
  --danger-soft: #3d201c;
  --ok: #7dcea0;
  --warn: #e6c36a;
  --warn-bg: #2a2416;
  --warn-border: #4d4124;
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  --hero-bg: linear-gradient(180deg, #1d1d1d 0%, #0c0c0c 100%);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 400 var(--fs)/var(--lh) var(--font); -webkit-font-smoothing: antialiased; padding-bottom: 32px; }
::selection { background: var(--brand); color: var(--brand-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.topline { height: var(--top); background: var(--brand); }
.head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 10px; background: var(--bg-elevated);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.logo { height: 34px; width: auto; display: block; }
:root[data-theme="dark"] .logo-light, :root:not([data-theme="dark"]) .logo-dark { display: none; }
.head-text { flex: 1; min-width: 0; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--text-tertiary); }
.who { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: var(--r-chip); background: var(--brand-soft);
  color: var(--text); border: 1px solid var(--warn-border); white-space: nowrap; }
.chip:empty { display: none; }

main { padding: 12px; max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--gap); }

h2.section { font-family: var(--head); font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  font-size: 15px; margin: 10px 2px 0; color: var(--text); display: flex; align-items: center; gap: 8px; }
h2.section::before { content: ""; width: 9px; height: 14px; background: var(--brand);
  clip-path: polygon(60% 0, 0 58%, 42% 58%, 30% 100%, 100% 38%, 56% 38%); }

.card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-card); padding: 12px 14px; }
.card.tight { padding: 0; overflow: hidden; }

/* «Готово к выдаче» */
.hero { position: relative; overflow: hidden; border-radius: var(--r-card); padding: 16px 16px 14px; color: var(--hero-text);
  background: radial-gradient(120% 90% at 100% 0%, var(--hero-glow) 0%, transparent 60%), var(--hero-bg); }
.hero::after { content: ""; position: absolute; right: -10px; top: -6px; width: 110px; height: 150px; opacity: .14;
  background: var(--brand); clip-path: polygon(60% 0, 0 58%, 42% 58%, 30% 100%, 100% 38%, 56% 38%); }
.hero .label { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--hero-muted); }
.hero .amount { font-family: var(--head); font-weight: 700; font-size: 44px; line-height: 1.05; color: var(--hero-amount);
  margin: 4px 0 2px; letter-spacing: .01em; }
.hero .sub { color: var(--hero-muted); font-size: 12.5px; position: relative; z-index: 1; }
.hero .debt { color: #ffb0a6; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.stat .k { font-size: 12px; color: var(--text-tertiary); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 20px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }

.row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; }
.row.click { cursor: pointer; }
.row.click:hover { background: var(--bg-hover); }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 500; }
.row .s { font-size: 12px; color: var(--text-tertiary); }
.row .num { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.row .num small { display: block; font-weight: 400; font-size: 11.5px; color: var(--text-tertiary); }

.pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: var(--r-chip); white-space: nowrap; }
.pill.frozen { background: var(--bg-sunken); color: var(--text-secondary); }
.pill.ready { background: var(--brand-soft); color: var(--text); }
.pill.storno { background: var(--danger-soft); color: var(--danger); text-decoration: line-through; }
.pill.ok { background: transparent; color: var(--ok); border: 1px solid currentColor; }

.ico { width: var(--icon); height: var(--icon); flex: none; }
.ico.sm { width: 15px; height: 15px; }

/* сегмент вкладок (как theme-switch приложения) */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--bg-sunken); border-radius: 9px; }
.tabs button { flex: 1 0 30%; height: var(--h-btn); border: 0; background: transparent; border-radius: var(--r-btn);
  font-size: 12.5px; font-weight: 500; color: var(--text-secondary); padding: 0 10px; display: flex; align-items: center;
  justify-content: center; gap: 6px; cursor: pointer; }
.tabs button.on { background: var(--bg-elevated); color: var(--text); font-weight: 700; box-shadow: 0 1px 2px rgba(28, 27, 23, .12); }

/* кнопки */
.btn { height: var(--h-btn); padding: 0 10px; border-radius: var(--r-btn); border: 1px solid var(--border-strong);
  background: var(--bg-elevated); font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
  justify-content: center; cursor: pointer; }
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--brand); border-color: var(--brand-border); color: var(--brand-ink); font-weight: 700; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; height: var(--h-big); font-size: 15px; font-weight: 700; border-radius: var(--r-field); }
.btn:disabled { opacity: .45; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { flex: 1; }

/* поля */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.field input, .field select, .field textarea { height: var(--h-big); padding: 0 12px; border-radius: var(--r-field);
  border: 1px solid var(--border-strong); background: var(--bg-elevated); }
.field textarea { height: auto; min-height: 68px; padding: 8px 12px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--brand); border-color: transparent; }
.field .hint { font-size: 11.5px; color: var(--text-tertiary); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.search { position: relative; }
.search .ico { position: absolute; left: 12px; top: 12px; color: var(--text-tertiary); }
.search input { width: 100%; padding-left: 38px; }

.note { padding: 10px 12px; border-radius: var(--r-field); background: var(--warn-bg); border: 1px solid var(--warn-border);
  color: var(--warn); font-size: 13px; display: flex; gap: 8px; }
.note.err { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.empty { text-align: center; color: var(--text-tertiary); padding: 28px 10px; }
.muted { color: var(--text-tertiary); font-size: 12px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-secondary); background: none; border: 0;
  padding: 0; cursor: pointer; font-weight: 500; }

table.rep { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.rep th { text-align: left; font-weight: 700; color: var(--text-tertiary); font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.rep td { padding: 8px 10px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
table.rep td.n, table.rep th.n { text-align: right; white-space: nowrap; }
table.rep tr.total td { font-weight: 700; border-bottom: 0; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #1a1a1a; color: #fff;
  padding: 10px 14px; border-radius: var(--r-field); box-shadow: var(--shadow); font-weight: 500; z-index: 20; max-width: 90vw; }
:root[data-theme="dark"] .toast { background: var(--brand); color: #161616; }

/* ---- управление карточкой: удаление, слияние, операции ---- */
.pill.gone { background: var(--danger-soft); color: var(--danger); }
.actions { flex-wrap: wrap; }
.note + .card, .back + .note { margin-top: 8px; }
details.entries > summary { cursor: pointer; list-style: none; padding: 10px 12px; margin: 0; }
details.entries > summary::-webkit-details-marker { display: none; }
details.entries > summary::after { content: " ▾"; color: var(--text-secondary); }
details.entries[open] > summary::after { content: " ▴"; }
.merge-side { border-left: 4px solid var(--border); margin-bottom: 8px; }
.merge-side.keep { border-left-color: var(--ok); }
.merge-side.dup { border-left-color: var(--brand); }
.merge-side .k, .card > .k { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.merge-side .s, .card > .s { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
