/* Исходящие: кухонные чеки на стальной раздаче.
   Компания — чек на термобумаге, очередь — лента чеков. Красный — только то, что пора сделать. */
:root {
  --steel: #5f6b70;
  --steel-deep: #4f5a5f;
  --steel-line: #74828a;
  --paper: #f2f4f1;
  --paper-shade: #e3e7e3;
  --ink: #1d2730;
  --ink-soft: #55616b;
  --ink-faint: #8a959c;
  --rule: #c3cac6;
  --red: #c4302b;
  --wa: #168a4b;
  --tg: #1f78bf;
  --max: #5d43d6;
  --ok: #2f7a50;
  --display: 'Oswald', 'Arial Narrow', sans-serif;
  --text: 'Golos Text', system-ui, sans-serif;
  --tick: 7px; /* шаг перфорации */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --steel: #343c40; --steel-deep: #2a3134; --steel-line: #4a565c; --paper: #e6e9e5; --paper-shade: #d4d9d4; }
}
:root[data-theme="dark"] { --steel: #343c40; --steel-deep: #2a3134; --steel-line: #4a565c; --paper: #e6e9e5; --paper-shade: #d4d9d4; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--steel);
  color: var(--ink);
  font: 400 16px/1.5 var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid #ffd66b; outline-offset: 2px; border-radius: 6px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- чек ---------- */
/* Зубцы оторванного чека вырезаны маской в самом листе, поэтому тень даёт обёртка через drop-shadow. */
.ticket {
  position: relative;
  background: var(--paper);
  padding: 22px 18px 24px;
  --hole: radial-gradient(circle at 50% 0, transparent 4.5px, #000 5px);
  --hole-b: radial-gradient(circle at 50% 100%, transparent 4.5px, #000 5px);
  -webkit-mask: var(--hole) top / 13px 51% repeat-x, var(--hole-b) bottom / 13px 51% repeat-x;
  mask: var(--hole) top / 13px 51% repeat-x, var(--hole-b) bottom / 13px 51% repeat-x;
}
.t-item, .detail > .ticket-wrap, .login-wrap { filter: drop-shadow(0 8px 14px rgba(0,0,0,.28)); }

/* ---------- вход ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 32px 16px; }
.login-wrap { width: min(380px, 100%); }
.login-ticket { padding: 34px 26px 32px; }
.login-title { font: 600 40px/1 var(--display); margin: 0 0 6px; letter-spacing: .01em; }
.login-sub { margin: 0 0 22px; color: var(--ink-soft); }
.login-hint { margin: 14px 0 0; font-size: 14px; color: var(--ink-soft); }

/* ---------- шапка ---------- */
.app { min-height: 100dvh; padding-bottom: 96px; }
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--steel-deep);
  color: var(--paper);
  border-bottom: 1px solid var(--steel-line);
}
.top-title { font: 600 24px/1 var(--display); letter-spacing: .01em; margin-right: auto; }
.meter { display: flex; align-items: center; gap: 8px; }
.meter-n { font: 600 30px/1 var(--display); font-variant-numeric: tabular-nums; }
.meter-of { font-size: 12px; line-height: 1.2; color: #c9d1d4; }
.meter.over .meter-n { color: #ff8f86; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 12px; background: transparent; color: var(--paper); cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.08); }

/* ---------- вкладки ---------- */
.tabs {
  position: sticky; top: calc(65px + env(safe-area-inset-top)); z-index: 15;
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 10px 16px; background: var(--steel);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; display: inline-flex; align-items: baseline; gap: 7px;
  padding: 8px 13px; border: 1px solid var(--steel-line); border-radius: 999px;
  background: transparent; color: #dfe5e7; cursor: pointer; white-space: nowrap; font-size: 15px;
}
.tab b { font: 600 15px/1 var(--display); font-variant-numeric: tabular-nums; }
.tab[aria-selected="true"] { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.tab.urgent b { color: #ff9b93; }
.tab.urgent[aria-selected="true"] b { color: var(--red); }

/* ---------- полоса подготовки ---------- */
.jobbar {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center;
  margin: 2px 16px 6px; padding: 12px 14px; border-radius: 12px;
  background: var(--steel-deep); color: var(--paper);
}
.job-text { font-size: 14px; min-width: 0; }
.job-text b { margin-right: 8px; }
.job-text span { color: #c9d1d4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.job-track { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: var(--steel-line); overflow: hidden; }
.job-fill { height: 100%; width: 0; background: var(--paper); transition: width .4s ease; }
.jobbar .btn-quiet { color: var(--paper); border-color: var(--steel-line); }

/* ---------- раскладка ---------- */
.layout { padding: 6px 16px 0; }
.rail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 14px; color: #dfe5e7; font-size: 14px; }
.rail-head .btn { flex: none; }
.tickets { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; }
.empty { color: #dfe5e7; text-align: center; padding: 48px 16px; max-width: 34ch; margin: 0 auto; }
.empty b { display: block; font: 600 22px/1.2 var(--display); color: var(--paper); margin-bottom: 6px; }

@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; gap: 28px; align-items: start; max-width: 1180px; margin: 0 auto; }
  .rail { position: sticky; top: 130px; max-height: calc(100dvh - 140px); overflow-y: auto; padding: 10px 6px 30px 2px; }
  .detail { position: sticky; top: 130px; max-height: calc(100dvh - 140px); overflow-y: auto; padding: 10px 6px 30px; }
  .detail[hidden] { display: block !important; visibility: hidden; }
  .tabs, .jobbar { max-width: 1180px; margin-left: auto; margin-right: auto; }
  .add-btn { right: max(24px, calc(50% - 566px)); }
}

/* ---------- чек в ленте ---------- */
.t-item { cursor: pointer; }
.t-item .ticket { padding: 18px 16px 20px; transition: transform .15s ease; }
.t-item:hover .ticket { transform: translateY(-1px); }
.t-item.active .ticket { background: #fff8dc; }
.t-name { font: 500 22px/1.15 var(--display); margin: 0; overflow-wrap: anywhere; }
.t-city { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-soft); }
.t-state { margin: 6px 0 0; font-size: 13.5px; color: var(--ink-soft); }
.t-state.due { color: var(--red); font-weight: 600; }
.t-state.err { color: var(--red); }
.t-idea { margin: 8px 0 0; padding-top: 8px; border-top: 1px dashed var(--rule); font-size: 14.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.t-ch { display: flex; gap: 6px; margin-top: 10px; }
.chip { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; color: #fff; }
.chip.wa { background: var(--wa); } .chip.tg { background: var(--tg); } .chip.max { background: var(--max); }
.chip.none { background: transparent; color: var(--ink-faint); border: 1px dashed var(--rule); font-weight: 500; }

/* ---------- открытый чек ---------- */
.detail { padding-bottom: 30px; }
.detail .ticket { padding: 26px 22px 30px; }
.d-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; color: #dfe5e7; font-size: 14px; }
.d-nav .grow { flex: 1; }
.d-nav .icon-btn { width: 40px; height: 40px; color: #eef2f3; }
.d-nav .icon-btn:disabled { opacity: .35; cursor: default; }
.d-name { font: 600 32px/1.08 var(--display); margin: 0; overflow-wrap: anywhere; }
.d-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0 0; font-size: 14px; color: var(--ink-soft); }
.d-meta a { color: var(--ink); text-decoration-color: var(--rule); text-underline-offset: 3px; overflow-wrap: anywhere; }
.d-sec { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--rule); }
.d-sec h3 { font: 500 13px/1.3 var(--text); color: var(--ink-soft); margin: 0 0 8px; }
.d-sec p { margin: 0; }
.d-sec ul { margin: 8px 0 0; padding-left: 18px; color: var(--ink-soft); font-size: 14.5px; }
.d-idea { font-weight: 500; }
.d-alert { margin-top: 14px; padding: 10px 12px; border-left: 3px solid var(--red); background: #fbe9e7; font-size: 14.5px; }
.msg {
  width: 100%; min-height: 150px; resize: vertical;
  padding: 14px 15px; border: 1px solid var(--rule); border-radius: 10px;
  background: #fff; color: var(--ink); line-height: 1.55; font-size: 16px;
}
.msg-note { margin: 6px 0 0; font-size: 13px; color: var(--ink-soft); min-height: 1.3em; }
.send { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.send a, .send span {
  display: grid; place-items: center; min-height: 52px; padding: 6px 8px;
  border-radius: 12px; text-decoration: none; font-weight: 600; font-size: 15px; text-align: center;
}
.send a { color: #fff; }
.send a.wa { background: var(--wa); } .send a.tg { background: var(--tg); } .send a.max { background: var(--max); }
.send a:active { transform: translateY(1px); }
.send span { color: var(--ink-faint); border: 1px dashed var(--rule); font-weight: 500; font-size: 13.5px; line-height: 1.25; }
.confirm {
  margin-top: 12px; padding: 14px; border-radius: 12px; background: var(--ink); color: var(--paper);
  display: grid; gap: 10px;
}
.confirm p { margin: 0; font-size: 15px; }
.confirm div { display: flex; gap: 8px; }
.confirm .btn { flex: 1; }
.confirm .btn-ink { background: var(--paper); color: var(--ink); }
.confirm .btn-quiet { color: var(--paper); border-color: #4b5862; }
.contacts { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.contacts .field { margin: 0; }
.history { list-style: none; margin: 0; padding: 0; font-size: 14px; color: var(--ink-soft); display: grid; gap: 6px; }
.history time { font-variant-numeric: tabular-nums; color: var(--ink); margin-right: 8px; }
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.d-actions .spacer { flex: 1; }

@media (max-width: 899px) {
  .detail:not([hidden]) {
    position: fixed; inset: 0; z-index: 40; overflow-y: auto; overscroll-behavior: contain;
    background: var(--steel); padding: calc(12px + env(safe-area-inset-top)) 14px calc(32px + env(safe-area-inset-bottom));
    animation: slide-in .22s ease-out;
  }
  .contacts { grid-template-columns: 1fr; }
  .d-name { font-size: 28px; }
}
@keyframes slide-in { from { transform: translateX(28px); opacity: 0; } }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  cursor: pointer; font-weight: 600; font-size: 15px; text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover:not(:disabled) { background: #2c3a46; }
.btn-red { background: var(--red); color: #fff; }
.btn-quiet { background: transparent; border-color: var(--rule); color: var(--ink); }
.btn-quiet:hover:not(:disabled) { background: rgba(0,0,0,.04); }
.btn-small { min-height: 38px; padding: 0 13px; font-size: 14px; font-weight: 500; }
.rail-head .btn-ink { background: var(--paper); color: var(--ink); }
.field { display: grid; gap: 6px; margin-bottom: 14px; font-size: 14px; color: var(--ink-soft); }
.field input, .field textarea, .sheet textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--rule); border-radius: 10px; background: #fff; color: var(--ink); font-size: 16px;
}
.field textarea, .sheet textarea { resize: vertical; line-height: 1.5; }
.form-error { min-height: 1.4em; margin: 4px 0 10px; color: var(--red); font-size: 14px; }
.hint { color: var(--ink-soft); font-size: 14px; margin: 0 0 12px; }

/* ---------- кнопка «Добавить» ---------- */
.add-btn {
  position: fixed; z-index: 30; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: 8px; min-height: 54px; padding: 0 20px 0 16px;
  border: 0; border-radius: 16px; background: var(--paper); color: var(--ink);
  font-weight: 600; font-size: 15px; cursor: pointer; box-shadow: 0 12px 28px -12px rgba(0,0,0,.6);
}

/* ---------- листы ---------- */
.sheet {
  width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 0; border-radius: 16px; background: var(--paper); color: var(--ink);
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.6);
}
.sheet::backdrop { background: rgba(28,35,40,.6); }
.sheet-body { padding: 22px 20px 20px; }
.sheet h2 { font: 600 28px/1.1 var(--display); margin: 0 0 10px; }
.sheet h3 { font: 500 14px/1.3 var(--text); color: var(--ink-soft); margin: 20px 0 10px; padding-top: 14px; border-top: 1px dashed var(--rule); }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.test-result { font-size: 14px; }
.test-result.ok { color: var(--ok); } .test-result.bad { color: var(--red); }
.fold { margin: 12px 0; border-top: 1px dashed var(--rule); padding-top: 10px; }
.fold summary { cursor: pointer; font-weight: 500; padding: 4px 0; }
.fold[open] summary { margin-bottom: 8px; }
.prompt { white-space: pre-wrap; font: 400 13.5px/1.5 var(--text); background: #fff; border: 1px solid var(--rule); border-radius: 10px; padding: 12px; margin: 0 0 10px; }
@media (max-width: 560px) {
  .sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 92dvh; }
  .two { grid-template-columns: 1fr; }
}

/* ---------- уведомление ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  width: max-content; max-width: min(420px, calc(100% - 32px)); padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: var(--paper); font-size: 15px; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
