/* ==========================================================================
   Смены — стили. Токены как у остальных сайтов SellerDock (тил-акцент,
   Manrope/Inter, цифры моноширинным с табличными цифрами), плюс два цвета смен:
   янтарный — день, индиго — ночь.
   ========================================================================== */

:root {
  --bg: #F3F5F7;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --border: #E1E5EA;
  --border-strong: #C9D0D8;
  --text-primary: #12161C;
  --text-secondary: #5E6878;
  --text-muted: #98A2B3;

  --accent: #0E6E62;
  --accent-hover: #0B5A50;
  --accent-soft: #E4F1EE;
  --on-accent: #FFFFFF;

  --danger: #B3392C;
  --danger-soft: #FBEAE7;
  --warning: #8A5A00;
  --warning-soft: #FDF3DC;
  --success: #1F7A4D;
  --success-soft: #E6F4EC;

  --day: #8A5A00;
  --day-soft: #FCEFD2;
  --night: #3D3A8C;
  --night-soft: #E7E6FA;

  --radius: 8px;
  --radius-lg: 14px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-modal: 0 8px 24px rgba(16, 24, 40, 0.18), 0 2px 6px rgba(16, 24, 40, 0.08);

  --font-display: 'Manrope', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171C;
    --surface: #1C2027;
    --surface-2: #23272F;
    --border: #2E333C;
    --border-strong: #3E4550;
    --text-primary: #E7EAEF;
    --text-secondary: #A3ACBA;
    --text-muted: #6B7280;

    --accent: #1BB6A0;
    --accent-hover: #17957F;
    --accent-soft: #123832;
    --on-accent: #0B1714;

    --danger: #F08A7E;
    --danger-soft: #3A1E1B;
    --warning: #F2C46B;
    --warning-soft: #3A2E14;
    --success: #6BD39C;
    --success-soft: #16301F;

    --day: #F2C46B;
    --day-soft: #3A2E14;
    --night: #B3AEF5;
    --night-soft: #25234A;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* hidden должен побеждать display у классов (иначе модалки видны сразу). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
a { color: var(--accent); }

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-secondary); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* ---------------- кнопки и поля ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; color: var(--text-primary);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }

.input, select.input, textarea.input {
  height: 36px; padding: 0 10px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); width: 100%;
}
textarea.input { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 12px; color: var(--text-secondary); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.hint { font-size: 12px; color: var(--text-secondary); margin: -6px 0 12px; }
.hint.warn { color: var(--warning); }
.error-text { color: var(--danger); font-size: 13px; margin: 8px 0 0; }

.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }

/* ---------------- вход ---------------- */

.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 28px 24px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800;
}
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 20px; }
.login-sub { color: var(--text-secondary); margin: 12px 0 20px; }

/* ---------------- кабинет владельца ---------------- */

.app-head {
  position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 10px 20px; flex-wrap: wrap;
}
.tabs { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.tab {
  border: 0; background: transparent; padding: 8px 12px; border-radius: var(--radius); cursor: pointer;
  color: var(--text-secondary); font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { background: var(--surface-2); color: var(--text-primary); }
.tab.active { background: var(--accent-soft); color: var(--accent); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff;
  font-size: 12px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600;
}

main.page { padding: 20px; max-width: 1500px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { font-family: var(--font-display); font-size: 20px; margin: 0 12px 0 0; }
.spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 0 12px; height: 34px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); padding: 16px 18px; margin-bottom: 14px;
}
.card h2 { font-family: var(--font-display); font-size: 16px; margin: 0 0 12px; }
.banner {
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; background: var(--warning-soft);
  color: var(--warning); display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.banner.info { background: var(--accent-soft); color: var(--accent); }
.banner.danger { background: var(--danger-soft); color: var(--danger); }
.empty { text-align: center; padding: 40px 16px; color: var(--text-secondary); }
.empty b { display: block; color: var(--text-primary); font-size: 16px; margin-bottom: 4px; }

/* таблицы */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
table.grid { border-collapse: collapse; width: 100%; }
table.grid th, table.grid td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: middle; }
table.grid th { font-size: 12px; font-weight: 500; color: var(--text-secondary); background: var(--surface-2); white-space: nowrap; }
table.grid td.r, table.grid th.r { text-align: right; }
table.grid td.num { white-space: nowrap; }
table.grid td.c, table.grid th.c { text-align: center; }
table.grid tr.total td { font-weight: 600; background: var(--surface-2); }
table.grid tr.clickable { cursor: pointer; }
table.grid tr.clickable:hover td { background: var(--surface-2); }
table.grid tr.inactive td { color: var(--text-muted); }

/* табель */
table.ts { border-collapse: separate; border-spacing: 0; width: 100%; }
table.ts th, table.ts td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0; text-align: center; height: 40px; }
table.ts th { font-size: 11px; font-weight: 500; color: var(--text-secondary); background: var(--surface-2); padding: 4px 2px; line-height: 1.2; }
table.ts th.today { color: var(--accent); background: var(--accent-soft); }
table.ts th.weekend { color: var(--danger); }
table.ts td.name, table.ts th.name {
  text-align: left; padding: 4px 10px; position: sticky; left: 0; background: var(--surface); z-index: 2; min-width: 170px;
}
table.ts th.name { background: var(--surface-2); }
table.ts td.name .pos { font-size: 11px; color: var(--text-muted); }
table.ts td.cell { cursor: pointer; min-width: 44px; }
table.ts td.cell:hover { background: var(--surface-2); }
table.ts td.cell.today { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
table.ts td.sum { padding: 0 8px; text-align: right; font-family: var(--font-mono); font-size: 13px; white-space: nowrap; }
table.ts tr.foot td { background: var(--surface-2); font-size: 12px; color: var(--text-secondary); }
table.ts tr.foot td.name { background: var(--surface-2); }
table.ts input.kg {
  width: 52px; height: 28px; border: 1px solid var(--border); border-radius: 6px; text-align: center;
  background: var(--surface); font-family: var(--font-mono); font-size: 12px; padding: 0 2px;
}
.kgpp.low { color: var(--danger); font-weight: 600; }

.chip {
  display: inline-flex; align-items: center; justify-content: center; position: relative;
  width: 22px; height: 22px; border-radius: 6px; font-weight: 700; font-size: 12px; margin: 1px;
}
.chip.day { background: var(--day-soft); color: var(--day); }
.chip.night { background: var(--night-soft); color: var(--night); }
.chip.flag { box-shadow: 0 0 0 2px var(--danger); }
.chip.unpaid { text-decoration: line-through; opacity: 0.55; }
.chip.partial::after { content: "½"; position: absolute; right: -5px; bottom: -6px; font-size: 10px; color: var(--text-secondary); }
.chip.live::before {
  content: ""; position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--success); box-shadow: 0 0 0 2px var(--surface);
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin: 10px 0 0; align-items: center; }
.legend .chip { width: 18px; height: 18px; font-size: 10px; }

/* пометки */
.flags { list-style: none; padding: 0; margin: 6px 0; }
.flags li { padding: 3px 0 3px 22px; position: relative; font-size: 13px; }
.flags li::before { content: "!"; position: absolute; left: 0; top: 4px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--danger-soft); color: var(--danger); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.flags li.done { color: var(--text-secondary); }
.flags li.done::before { content: "✓"; background: var(--success-soft); color: var(--success); }

/* очередь решений */
.review-item { display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; align-items: start; }
.review-item + .review-item { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.review-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.who { font-weight: 600; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); }
.tag.day { background: var(--day-soft); color: var(--day); border-color: transparent; }
.tag.night { background: var(--night-soft); color: var(--night); border-color: transparent; }
.tag.ok { background: var(--success-soft); color: var(--success); border-color: transparent; }
.tag.warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.tag.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* метрики */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; }
.kpi .l { font-size: 12px; color: var(--text-secondary); }
.kpi .v { font-family: var(--font-mono); font-size: 20px; font-weight: 600; margin-top: 2px; }

/* модалки */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(16, 24, 40, 0.45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 560px; background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal); padding: 20px 22px;
}
.modal.wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-head h2 { font-family: var(--font-display); font-size: 18px; margin: 0; flex: 1; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }
.shift-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.shift-card h3 { margin: 0 0 6px; font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 3px 10px; font-size: 13px; margin: 6px 0; }
.kv .k { color: var(--text-secondary); }
.pay-options { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.pay-options label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.pay-options input[type="number"] { width: 120px; height: 30px; }
details.edit summary { cursor: pointer; color: var(--accent); font-size: 13px; margin: 6px 0; }
.qr-box svg { width: 180px; height: 180px; background: #fff; border-radius: 8px; padding: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200;
  background: var(--text-primary); color: var(--bg); padding: 10px 16px; border-radius: var(--radius); box-shadow: var(--shadow-modal);
  max-width: calc(100% - 32px);
}
.toast.err { background: var(--danger); color: #fff; }

@media (max-width: 720px) {
  .app-head { padding: 8px 12px; }
  main.page { padding: 12px; }
  .review-item { grid-template-columns: 1fr; }
  .review-actions { justify-content: flex-start; }
}

/* ---------------- страница рабочего ---------------- */

.wk { max-width: 460px; margin: 0 auto; padding: 16px 16px 40px; }
.wk-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.wk-name { font-family: var(--font-display); font-weight: 800; font-size: 18px; }
.wk-status { text-align: center; padding: 22px 18px; }
.wk-status .state { font-size: 15px; color: var(--text-secondary); margin-bottom: 4px; }
.wk-status .big { font-family: var(--font-display); font-size: 26px; font-weight: 800; margin-bottom: 18px; }
.wk-btn {
  width: 100%; min-height: 72px; border-radius: 16px; border: 0; cursor: pointer;
  font-family: var(--font-display); font-weight: 800; font-size: 22px;
}
.wk-btn.in { background: var(--accent); color: var(--on-accent); }
.wk-btn.out { background: var(--surface); color: var(--danger); border: 2px solid var(--danger); }
.wk-btn:disabled { opacity: 0.6; cursor: progress; }
.wk-note { font-size: 13px; color: var(--text-secondary); margin-top: 12px; }
.wk-ask { font-size: 16px !important; color: var(--text-primary) !important; font-weight: 600; text-align: left; }
.wk-pieces { height: 60px; font-size: 26px; text-align: center; margin-bottom: 4px; }
#piecesForm { text-align: left; }
.wk-list { list-style: none; margin: 0; padding: 0; }
.wk-list li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.wk-list li:last-child { border-bottom: 0; }
.wk-list li .num, .wk-total .num { white-space: nowrap; flex-shrink: 0; }
.wk-total { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.wk-total.main { font-weight: 700; font-size: 17px; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; }
.wk-foot { text-align: center; margin-top: 20px; }
.wk-foot button { border: 0; background: transparent; color: var(--text-muted); text-decoration: underline; cursor: pointer; font-size: 13px; }

/* ---------------- печать QR ---------------- */

.qr-page { max-width: 640px; margin: 0 auto; padding: 32px 24px; text-align: center; }
.qr-page h1 { font-family: var(--font-display); font-size: 36px; margin: 0 0 8px; }
.qr-page .qr svg { width: 340px; height: 340px; background: #fff; }
.qr-page ol { text-align: left; font-size: 18px; line-height: 1.6; max-width: 480px; margin: 20px auto; }
.qr-page .url { font-family: var(--font-mono); font-size: 16px; }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; color: #000; }
}
