/* Расчётные листы. Лист оформлен как кассовый чек: перфорация, пунктирные выводки,
   двойная черта под итогом. Всё остальное намеренно тихое. */

:root {
  --chalk: #e6eaee;
  --paper: #fdfdfb;
  --ink: #19232e;
  --muted: #5a6773;
  --line: #c9d1d8;
  --leader: #9aa6b1;
  --accent: #17457a;
  --accent-ink: #ffffff;
  --plus: #1b6b43;
  --minus: #b3261e;
  --field: #ffffff;
  --shadow: rgba(25, 35, 46, 0.16);
  --edge: rgba(25, 35, 46, 0.1);
  --focus: #2f7fd6;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --chalk: #12181f;
    --paper: #1b232c;
    --ink: #e8edf2;
    --muted: #93a0ad;
    --line: #35414d;
    --leader: #5b6875;
    --accent: #8bb7ee;
    --accent-ink: #0d1722;
    --plus: #5bc68a;
    --minus: #f2877f;
    --field: #1b232c;
    --shadow: rgba(0, 0, 0, 0.45);
    --edge: rgba(255, 255, 255, 0.06);
    --focus: #8bb7ee;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--chalk);
  color: var(--ink);
  font: 400 16px/1.45 var(--font);
  font-variant-numeric: lining-nums;
}

h1, h2, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.noscript { padding: 24px; }

/* ---------- бренд ---------- */
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand__mark { width: 22px; height: 22px; color: var(--accent); flex: none; }
.brand__name { font-weight: 650; letter-spacing: -0.005em; }
.brand--big .brand__mark { width: 30px; height: 30px; }
.brand--big .brand__name { font-size: 22px; }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px;
  border: 1.5px solid transparent; border-radius: 10px;
  font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background-color .12s, border-color .12s, opacity .12s;
}
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn--primary:disabled { opacity: .4; cursor: not-allowed; }
.btn--quiet { background: transparent; color: var(--muted); border-color: var(--line); min-height: 40px; padding: 0 14px; font-weight: 500; }
.btn--quiet:hover { color: var(--ink); border-color: var(--leader); }
.btn--danger { background: transparent; color: var(--minus); border-color: var(--minus); min-height: 38px; padding: 0 14px; font-weight: 600; }
.btn--danger-armed { background: var(--minus); color: var(--paper); }
.btn--wide { width: 100%; }

.link-btn {
  background: none; border: 0; padding: 8px 4px; cursor: pointer;
  color: var(--accent); font-weight: 600; font-size: 14px;
}

.field { display: block; margin: 0 0 16px; padding: 0; border: 0; min-width: 0; }
.field__label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; color: var(--muted); padding: 0; }
.field__row { display: flex; align-items: center; gap: 8px; background: var(--field); border: 1.5px solid var(--line); border-radius: 10px; padding-right: 8px; }
.field__row:focus-within { border-color: var(--focus); }
.field__row input { border: 0; background: transparent; flex: 1; min-width: 0; outline: none; padding: 0 0 0 14px; min-height: 46px; }
input[type="text"], input[type="password"], input[type="search"], .select {
  width: 100%; min-height: 46px; padding: 0 14px;
  background: var(--field); border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 16px; /* меньше 16px iOS увеличивает страницу при фокусе */
}
.field__row input[type="password"], .field__row input[type="text"] { border: 0; }
input:focus-visible, .select:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent); }
.field__row input:focus-visible { box-shadow: none; }

.msg { font-size: 14.5px; margin: 0 0 14px; }
.msg--error { color: var(--minus); }

/* ---------- вход ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login__card {
  width: 100%; max-width: 380px; padding: 28px 24px 24px;
  background: var(--paper); border-radius: 16px; box-shadow: 0 1px 0 var(--edge), 0 12px 32px var(--shadow);
}
.login__card .brand { margin-bottom: 24px; }
.login__note { margin: -8px 0 16px; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 12%, transparent); font-size: 14.5px; }

/* ---------- каркас ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 20px; padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--chalk) 90%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar .btn--quiet { margin-left: auto; }
.tabs { display: none; gap: 4px; }
.tabs__link {
  padding: 8px 14px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600;
}
.tabs__link:hover { color: var(--ink); }
.tabs__link[aria-current="page"] { color: var(--ink); background: var(--paper); box-shadow: 0 0 0 1px var(--line); }

.main { max-width: 1000px; margin: 0 auto; padding: 24px 16px calc(96px + env(safe-area-inset-bottom)); }
.view__title { font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -0.015em; margin-bottom: 18px; }
.section-title { font-size: 18px; font-weight: 650; margin: 36px 0 12px; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: 1fr 1fr;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--paper); border-top: 1px solid var(--line);
}
.dock__link {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 0 8px; min-height: 56px; color: var(--muted); text-decoration: none; font-size: 12.5px; font-weight: 600;
}
.dock__link svg { width: 24px; height: 24px; }
.dock__link[aria-current="page"] { color: var(--accent); }

@media (min-width: 720px) {
  .tabs { display: flex; }
  .dock { display: none; }
  .main { padding: 36px 24px 64px; }
  .view__title { font-size: 30px; }
}

/* ---------- поиск ---------- */
.search { margin-bottom: 8px; }
.search__input { min-height: 56px; font-size: 18px; border-radius: 12px; padding: 0 18px; }
.status { min-height: 1.5em; margin: 10px 2px 18px; color: var(--muted); font-size: 15px; }
.status--empty { color: var(--ink); }

.results { display: grid; gap: 36px; }
.person__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 14px; }
.person__name { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }
.person__tab { color: var(--muted); font-variant-numeric: tabular-nums; }
.tickets { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); align-items: start; }

/* ---------- расчётный лист-чек ---------- */
.ticket-wrap {
  filter: drop-shadow(0 1px 0 var(--edge)) drop-shadow(0 8px 12px var(--shadow));
  animation: print .5s cubic-bezier(.2, .7, .2, 1) backwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}
.ticket {
  --r: 5px; --step: 14px;
  background: var(--paper);
  padding: 26px 20px 30px;
  -webkit-mask:
    radial-gradient(circle at 50% 0, #0000 var(--r), #000 calc(var(--r) + .5px)) top / var(--step) 51% repeat-x,
    radial-gradient(circle at 50% 100%, #0000 var(--r), #000 calc(var(--r) + .5px)) bottom / var(--step) 51% repeat-x;
  mask:
    radial-gradient(circle at 50% 0, #0000 var(--r), #000 calc(var(--r) + .5px)) top / var(--step) 51% repeat-x,
    radial-gradient(circle at 50% 100%, #0000 var(--r), #000 calc(var(--r) + .5px)) bottom / var(--step) 51% repeat-x;
}
.ticket__period { font-size: 17px; font-weight: 700; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1.5px dashed var(--line); }
.ticket__group { margin-top: 16px; }
.ticket__group-title { font-size: 14px; font-weight: 650; color: var(--muted); margin-bottom: 4px; }

.line { display: flex; align-items: baseline; gap: 6px; padding: 3px 0; }
.line__label { flex: 0 1 auto; }
.line__dots { flex: 1 1 14px; min-width: 14px; border-bottom: 2px dotted var(--leader); transform: translateY(-4px); }
.line__value { flex: none; text-align: right; font-variant-numeric: tabular-nums lining-nums; font-weight: 600; white-space: nowrap; }
.line--plus .line__value { color: var(--plus); }
.line--minus .line__value { color: var(--minus); }

.ticket__total { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 20px; padding-top: 14px; border-top: 1.5px dashed var(--line); }
.ticket__total-label { font-weight: 700; }
.ticket__total-value {
  font-size: 28px; line-height: 1.15; font-weight: 750; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums lining-nums; white-space: nowrap;
  border-bottom: 5px double var(--ink); padding-bottom: 2px;
}

@keyframes print {
  from { clip-path: inset(0 0 100% 0); transform: translateY(-10px); }
  to   { clip-path: inset(-20px -20px -20px -20px); transform: none; }
}

/* ---------- загрузка ---------- */
.panel { background: var(--paper); border-radius: 14px; padding: 20px; box-shadow: 0 1px 0 var(--edge), 0 6px 20px var(--shadow); }
.period { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.period .field--short { grid-column: auto; }
.period .seg { grid-column: 1 / -1; }
@media (min-width: 720px) {
  .period { grid-template-columns: 120px 1fr 1.3fr; }
  .period .seg { grid-column: auto; }
}
.select { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; }

.seg__row { display: grid; grid-template-columns: 1fr 1fr; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--field); }
.seg__input { position: absolute; opacity: 0; pointer-events: none; }
.seg__opt { display: grid; place-items: center; min-height: 43px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg__input:checked + .seg__opt { background: var(--accent); color: var(--accent-ink); }
.seg__input:focus-visible + .seg__opt { outline: 3px solid var(--focus); outline-offset: -3px; }

.drop { position: relative; margin: 4px 0 10px; }
.drop__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop__label {
  display: flex; align-items: center; justify-content: center; gap: 12px; text-align: left;
  min-height: 96px; padding: 16px; border: 2px dashed var(--leader); border-radius: 12px; color: var(--muted);
  transition: border-color .12s, background-color .12s;
}
.drop__icon { width: 26px; height: 26px; flex: none; }
.drop__input:focus-visible + .drop__label { outline: 3px solid var(--focus); outline-offset: 2px; }
.drop.is-over .drop__label, .drop__label:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.drop.has-file .drop__label { border-style: solid; border-color: var(--accent); color: var(--ink); font-weight: 600; }
.hint { font-size: 14px; color: var(--muted); margin-bottom: 18px; max-width: 62ch; }
#up-submit { min-width: 200px; }
@media (max-width: 719px) { #up-submit { width: 100%; } }

.result { margin-top: 16px; padding: 16px 18px; border-radius: 12px; background: var(--paper); border-left: 5px solid var(--plus); box-shadow: 0 1px 0 var(--edge); }
.result--error { border-left-color: var(--minus); }
.result__title { font-weight: 700; margin-bottom: 4px; }
.result__list { margin: 8px 0 0; padding-left: 20px; }
.result__list li + li { margin-top: 3px; }
.result__stats { display: flex; flex-wrap: wrap; gap: 4px 24px; margin-top: 6px; color: var(--muted); font-variant-numeric: tabular-nums; }

.periods { display: grid; gap: 8px; }
.period-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 16px; background: var(--paper); border-radius: 12px; box-shadow: 0 1px 0 var(--edge); }
.period-row__main { flex: 1; min-width: 0; }
.period-row__label { font-weight: 650; }
.period-row__meta { color: var(--muted); font-size: 14px; }
.periods__empty { color: var(--muted); padding: 4px 2px; }

@media (prefers-reduced-motion: reduce) {
  .ticket-wrap { animation: none; }
  * { transition: none !important; }
}

@media print {
  .bar, .dock, .search, .status { display: none !important; }
  body { background: #fff; }
  .ticket-wrap { filter: none; animation: none; break-inside: avoid; }
}
