/* Касса клиники — оформление.
   Белый фон, тёмный текст. Никаких серых подложек: страница светлая,
   разделение — тонкими линиями и воздухом, а не заливкой.
   Mobile-first: админы заполняют смену чаще с телефона, поэтому базовые
   размеры рассчитаны на палец, а широкий экран получает вторую колонку
   через медиазапрос, а не наоборот. */

:root {
    --bg: #ffffff;
    --line: #e6e8eb;
    --line-soft: #f0f2f4;
    --text: #16181d;
    --muted: #737a85;
    --accent: #1f5eff;
    --accent-soft: #eef3ff;
    --ok: #0f7a3d;
    --ok-soft: #eaf7ef;
    --warn: #9a5b00;
    --warn-soft: #fff6e6;
    --err: #c02626;
    --err-soft: #fdeeee;
    --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    margin: 0;
    font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ── шапка ── */
header {
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    padding: 14px 16px 0;
    position: sticky; top: 0; z-index: 20;
}
.hdr { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.hdr .brand { font-weight: 700; font-size: 19px; letter-spacing: -.2px; }
.hdr .who { color: var(--muted); font-size: 13px; margin-left: auto; }
nav { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 12px; }
nav a {
    padding: 9px 14px; text-decoration: none; color: var(--muted);
    font-size: 15px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
nav a:hover { color: var(--text); }
nav a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

main { padding: 20px 16px 40px; max-width: 880px; margin: 0 auto; }

.card {
    background: var(--bg); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.card h2 {
    margin: 0 0 16px; font-size: 16px; font-weight: 600;
    display: flex; align-items: center; gap: 10px;
}
.card h2 .num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 7px;
    background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700;
}

/* ── поля ── */
label { display: block; margin-bottom: 15px; }
label .cap {
    display: block; font-size: 13px; color: var(--muted);
    margin-bottom: 6px; font-weight: 500;
}

input, select, textarea {
    width: 100%; padding: 13px 14px;
    font-size: 17px;               /* меньше 17px — iOS зумит страницу при фокусе */
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--bg); color: var(--text); font-family: inherit;
    transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 94, 255, .10);
}
input[readonly] { background: var(--line-soft); color: var(--muted); border-color: var(--line-soft); }
input::placeholder { color: #b3b8c0; }
textarea { min-height: 82px; resize: vertical; }
select { appearance: none; background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23737a85' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }

/* Суммы — моноширинные и по правому краю: видно разряды, легче сверять */
input.money { text-align: right; font-variant-numeric: tabular-nums; letter-spacing: .2px; }

/* ── строки расходов: название = сумма ── */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row-item { display: flex; gap: 8px; align-items: center; }
.row-item .t { flex: 1 1 auto; min-width: 0; }
.row-item .a { flex: 0 0 116px; }
.row-item .rm {
    flex: 0 0 auto; width: 42px; height: 48px; border: 1px solid var(--line);
    background: var(--bg); border-radius: 10px; color: var(--muted);
    font-size: 22px; line-height: 1; cursor: pointer;
}
.row-item .rm:hover { color: var(--err); border-color: var(--err); }
.add-row {
    margin-top: 8px; padding: 12px 16px; border: 1px dashed var(--line);
    background: var(--bg); border-radius: 10px; color: var(--accent);
    font-size: 15px; font-weight: 500; cursor: pointer; width: 100%;
}
.add-row:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ── итоги ── */
.totals { display: flex; flex-direction: column; gap: 12px; }
.tot { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.tot .lbl { color: var(--muted); font-size: 15px; }
.tot .val { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tot.big .val { font-size: 28px; letter-spacing: -.5px; }
.tot.big .lbl { font-size: 16px; color: var(--text); font-weight: 600; }

/* ── нижняя панель ──────────────────────────────────────────────────
   Итог и кнопки приклеены к низу экрана: сумма видна, пока заполняешь,
   а «Сохранить» не надо искать в конце длинной формы. */
.bottom-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--bg); border-top: 1px solid var(--line);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, .06);
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.bb-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bb-sum { display: flex; align-items: baseline; gap: 8px; margin-right: auto; }
.bb-sum .lbl { font-size: 14px; color: var(--muted); }
.bb-sum .val {
    font-size: 22px; font-weight: 700; letter-spacing: -.3px;
    font-variant-numeric: tabular-nums;
}
.bb-btns { display: flex; gap: 8px; flex: 1 1 100%; }
.bb-btns .btn { flex: 1 1 0; padding: 14px 12px; }
.bb-hint {
    font-size: 12px; line-height: 1.4; color: var(--muted);
    margin-top: 8px; display: flex; flex-direction: column; gap: 3px;
}
.bb-hint b { font-weight: 600; color: var(--text); }
.bb-hint .bb-warn { color: var(--warn); }
.bb-hint .bb-warn b { color: var(--warn); }
/* Чтобы панель не накрывала последнюю карточку формы */
body:has(.bottom-bar) main { padding-bottom: 190px; }

/* ── кнопки ── */
.btn {
    display: inline-block; padding: 14px 22px; border-radius: 10px;
    border: 1px solid transparent; font-size: 16px; font-weight: 600;
    cursor: pointer; text-decoration: none; text-align: center; font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1a52e0; }
.btn-ghost { background: var(--bg); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-wide { width: 100%; }
.actions { display: flex; flex-direction: column; gap: 10px; }

/* ── подсказки и статусы ── */
.hint { font-size: 13px; color: var(--muted); margin: -8px 0 15px; }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-err  { background: var(--err-soft);  color: var(--err); }
.alert-ok   { background: var(--ok-soft);   color: var(--ok); }

.badge { display: inline-block; padding: 4px 10px; border-radius: 20px;
         font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-draft     { background: var(--line-soft); color: var(--muted); }
.badge-submitted { background: var(--accent-soft); color: var(--accent); }
.badge-verified  { background: var(--ok-soft); color: var(--ok); }

/* ── список смен ── */
.shift-card { display: block; text-decoration: none; color: inherit; transition: border-color .12s; }
.shift-card:hover { border-color: var(--accent); }
.shift-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.shift-date { font-weight: 600; font-size: 16px; }
.shift-branch { color: var(--muted); font-size: 13px; margin-top: 2px; }
.shift-nums {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 10px 18px; margin-top: 14px; padding-top: 14px;
    border-top: 1px solid var(--line-soft); font-size: 14px;
}
.shift-nums .n { display: flex; justify-content: space-between; gap: 8px; }
.shift-nums .n span:first-child { color: var(--muted); }
.shift-nums .n span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line-soft); }
th { color: var(--muted); font-weight: 600; font-size: 12px;
     text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.discrepancy { color: var(--err); font-weight: 600; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* ── инструкция ── */
.step { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0;
        border-bottom: 1px solid var(--line-soft); line-height: 1.55; }
.step:last-child { border-bottom: none; padding-bottom: 0; }
.step:first-of-type { padding-top: 0; }
.step-n {
    flex: 0 0 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent);
    font-size: 14px; font-weight: 700;
}
.card p { line-height: 1.6; margin: 0 0 14px; }
.card p:last-child { margin-bottom: 0; }
code {
    background: var(--line-soft); border-radius: 5px; padding: 2px 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em;
}
ul.dont { margin: 0; padding-left: 20px; line-height: 1.65; }
ul.dont li { margin-bottom: 8px; }
ul.dont li:last-child { margin-bottom: 0; }

/* ── печать: инструкция на стену ── */
@media print {
    header, nav, .btn { display: none; }
    .card { border: none; padding: 0 0 14px; margin: 0 0 10px;
            border-bottom: 1px solid #ddd; break-inside: avoid; }
    main { padding: 0; }
}

/* ── широкий экран ── */
@media (min-width: 720px) {
    main { padding: 28px 24px 60px; }
    .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
    .grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
    .actions { flex-direction: row; }
    .btn-wide { width: auto; }
    .shift-nums { grid-template-columns: repeat(4, 1fr); }
    .row-item .a { flex: 0 0 160px; }
    .card { padding: 22px; }

    /* На широком экране панель компактнее: кнопки по размеру текста,
       подсказки в одну строку рядом. */
    .bottom-bar { padding: 12px 24px; }
    .bb-btns { flex: 0 0 auto; }
    .bb-btns .btn { flex: 0 0 auto; min-width: 150px; }
    .bb-hint { flex-direction: row; gap: 18px; margin-top: 6px; }
    body:has(.bottom-bar) main { padding-bottom: 140px; }
}
