/* LabControl · mobile-first styles. Palette: cool plaster, ink, cobalt (articulating-paper blue). */
:root {
  --bg: #ECF0F8;
  --surface: #FFFFFF;
  --ink: #17252D;
  --muted: #5B6B75;
  --line: #D8DFEC;
  --accent: #3F5FB0;   /* фирменный синий клиники */
  --accent-dark: #344F96;
  --accent-ink: #FFFFFF;
  --accent-soft: #E5EAF7;
  --wait: #8A5A00;   --wait-bg: #FFF2CC;
  --ok: #17704A;     --ok-bg: #E1F3EA;
  --bad: #B3261E;    --bad-bg: #FCE6E4;
  --off: #66737C;    --off-bg: #E9EDF0;
  --radius: 12px;
  --tap: 46px;
  color-scheme: light;
  font: 400 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
/* фон клиники: голубой узор из зубов и инструментов (повторяется плиткой) */
html { background: #DCE9F7 url(brand/bg-pattern.jpg) repeat 0 0 / 300px 300px; }
body { background: transparent; min-height: 100vh; }
body { padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: linear-gradient(100deg, #3A58A8 0%, #4466B8 100%); color: #fff; border-bottom: 0;
  box-shadow: 0 2px 10px rgba(40, 60, 120, .18);
}
.top .brand { display: flex; align-items: center; gap: 9px; flex: none; color: #fff; text-decoration: none; }
.top .brand img { height: 34px; width: auto; display: block; }
.top .brand-name { display: none; line-height: 1.1; font-size: 13px; font-weight: 600; opacity: .95; }
.top .brand-name b { display: block; font-size: 15px; font-weight: 750; }
.top .back { background: rgba(255, 255, 255, .16); color: #fff !important; }
.top h1 { font-size: 19px; font-weight: 750; margin: 0; flex: 1; min-width: 0;
          white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.back { width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--bg); flex: none;
        font-size: 22px; line-height: 1; cursor: pointer; }

main { max-width: 760px; margin: 0 auto; padding: 14px 14px 24px; }

/* ---------- bottom nav ---------- */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(min-content, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
nav.tabs a {
  position: relative; display: flex; align-items: center; justify-content: center;
  height: 58px; padding: 0 3px; text-decoration: none; color: var(--muted); font-size: clamp(12px, 3.5vw, 14px); font-weight: 600;
  border-top: 3px solid transparent;
}
nav.tabs a.on { color: var(--accent); border-top-color: var(--accent); }
.badge { display: inline-block; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 5px;
         border-radius: 10px; background: var(--bad); color: #fff; font-size: 12px; line-height: 20px; text-align: center; }
.badge[hidden] { display: none; }
nav.tabs a .badge { position: absolute; top: 2px; left: calc(50% + 26px); margin: 0; min-width: 18px; height: 18px;
                    line-height: 18px; padding: 0 5px; font-size: 11px; }

/* ---------- blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 14px; margin-bottom: 10px; }
a.card { display: block; color: inherit; text-decoration: none; }
a.card:active { background: var(--accent-soft); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row.top-align { align-items: flex-start; }
.stack > * + * { margin-top: 6px; }
.title { font-weight: 700; font-size: 17px; }
.big { font-size: 26px; font-weight: 750; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 22px 2px 10px; }
h3 { font-size: 15px; margin: 14px 0 8px; }
.sep { height: 1px; background: var(--line); margin: 12px -14px; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 13px; font-weight: 650; white-space: nowrap; }
.pill.wait { color: var(--wait); background: var(--wait-bg); }
.pill.ok   { color: var(--ok);   background: var(--ok-bg); }
.pill.bad  { color: var(--bad);  background: var(--bad-bg); }
.pill.off  { color: var(--off);  background: var(--off-bg); }
.pill.info { color: var(--accent); background: var(--accent-soft); }

.note { border-left: 3px solid var(--bad); background: var(--bad-bg); padding: 8px 10px; border-radius: 6px; font-size: 14px; }
.note.info { border-left-color: var(--accent); background: var(--accent-soft); }
.note.warn { border-left-color: var(--wait); background: var(--wait-bg); }

/* ---------- forms ---------- */
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input.in, select.in, textarea.in {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
textarea.in { min-height: 76px; resize: vertical; }
.in:focus-visible, .btn:focus-visible, .tooth:focus-visible, nav.tabs a:focus-visible, a.card:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 12px;
         border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
       min-height: var(--tap); padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
       background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; text-decoration: none; }
.btn.wide { width: 100%; }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); font-weight: 600; }
.btn.ok { background: var(--ok); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn[disabled] { opacity: .55; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.actions .btn { flex: 1 1 auto; }

/* ---------- dental formula (FDI) ---------- */
.formula { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-radius: 10px; overflow: hidden;
           border: 1px solid var(--line); background: var(--surface); }
.quad { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; padding: 6px; }
.quad.q1, .quad.q4, .quad.q5, .quad.q8 { border-right: 2px solid var(--ink); }
.quad.q1, .quad.q2, .quad.q5, .quad.q6 { border-bottom: 2px solid var(--ink); }
.quad.short { grid-template-columns: repeat(5, 1fr); }
.tooth { min-width: 0; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 8px 8px 12px 12px;
         background: #FBFCFD; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; cursor: pointer; }
.tooth.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tooth[disabled] { opacity: .3; cursor: default; }
@media (max-width: 520px) {
  .formula { grid-template-columns: 1fr; }
  .quad.q1, .quad.q4, .quad.q5, .quad.q8 { border-right: 0; }
  .quad { border-bottom: 1px solid var(--line); }
  .quad.q4, .quad.q8 { border-bottom: 0; }
  .quad::before { content: attr(data-label); grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
}

/* teeth of one item, as chips */
.teeth { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
        min-width: 54px; min-height: 50px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 10px 10px 16px 16px;
        background: #FBFCFD; cursor: pointer; line-height: 1.15; }
.chip b { font-size: 16px; font-variant-numeric: tabular-nums; }
.chip small { font-size: 11px; color: var(--muted); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on small { color: #DCE7F7; }
.chip.done { box-shadow: inset 0 -3px 0 var(--ok); }
.chip.static { cursor: default; }

/* ---------- lists ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.stage { display: grid; grid-template-columns: 28px 1fr; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.stage:first-child { border-top: 0; }
.stage .pos { width: 26px; height: 26px; border-radius: 50%; background: var(--bg); display: grid; place-items: center;
              font-size: 13px; font-weight: 700; }
.stage.completed .pos { background: var(--ok); color: #fff; }
.stage.active .pos { background: var(--accent); color: #fff; }
.stage.cancelled { opacity: .55; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 8px 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; }
.month { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.month b { font-size: 17px; text-transform: capitalize; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.t td.r, table.t th.r { text-align: right; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }

/* ---------- sheet (bottom panel for forms) ---------- */
.veil { position: fixed; inset: 0; background: rgba(15, 25, 32, .45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; background: var(--surface);
         border-radius: 16px 16px 0 0; padding: 16px 16px calc(18px + env(safe-area-inset-bottom, 0px)); }
.sheet h2 { margin: 0 0 14px; font-size: 18px; }
@media (min-width: 700px) { .veil { align-items: center; } .sheet { border-radius: 16px; } }

.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
         z-index: 30; max-width: calc(100% - 28px); padding: 11px 16px; border-radius: 10px; background: var(--ink); color: #fff;
         font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.toast.bad { background: var(--bad); }

/* ---------- login ---------- */
.login { max-width: 400px; margin: 0 auto; padding: 12vh 22px 32px; }
.login .mark { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.login .mark img { height: 64px; width: auto; flex: none; }
.login .mark .co { line-height: 1.15; color: var(--accent); font-size: 15px; font-weight: 600; }
.login .mark .co b { display: block; font-size: 22px; letter-spacing: -.01em; }
.login .mark .co small { display: block; margin-top: 4px; color: var(--muted); font-weight: 500; font-size: 13px; }
.login { background: rgba(255, 255, 255, .72); border-radius: 18px; margin-top: 8vh; padding-top: 28px;
  box-shadow: 0 8px 30px rgba(40, 60, 120, .10); }
.login .mark svg { flex: none; }
.login .mark b { font-size: 24px; letter-spacing: -.02em; }
.spin { text-align: center; color: var(--muted); padding: 40px; }

@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: up .18s ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
}

/* ---------- my pay ---------- */
.pay-hero { background: var(--accent); border-color: var(--accent); color: #fff; padding: 16px; }
.pay-label { font-size: 15px; font-weight: 600; color: #D5E3F6; }
.pay-sum { font-size: 36px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0 2px; }
.pay-sub { font-size: 14px; color: #D5E3F6; margin-top: 4px; }
.pay-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; font-size: 14px; font-weight: 600; }
.pay-line a { color: #fff; }
.pay-foot { font-size: 13px; color: #C4D7F1; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.18); }
.pay-foot + .pay-foot { border-top: 0; padding-top: 0; margin-top: 4px; }
.pay-row + .pay-row { margin-top: 14px; }
.bar { height: 6px; margin-top: 8px; border-radius: 3px; background: var(--bg); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.pay-total { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.seg.full { display: flex; width: 100%; margin-bottom: 4px; }
.seg.full button { flex: 1 1 auto; padding: 9px 4px; font-size: 14px; white-space: nowrap; }
@media (max-width: 380px) { .seg.full button { font-size: 13px; padding: 9px 2px; } }
.seg .cnt { display: inline-block; margin-left: 4px; font-size: 12px; opacity: .8; }
.day { display: flex; justify-content: space-between; gap: 8px; margin: 16px 2px 6px; font-size: 14px; font-weight: 650; color: var(--muted); }
.entry .calc { margin-top: 8px; align-items: flex-end; }
.entry .row > b:first-child { min-width: 0; }
.entry > .row:first-child > .num, .entry .calc > .pill { flex: none; }
.entry .calc > div { flex: 1 1 auto; min-width: 0; }
.entry.rejected { border-color: #F0B9B4; }

/* ---------- phones (QR) and first steps ---------- */
.qr { width: 220px; max-width: 70vw; margin: 4px auto 8px; }
.qr svg { display: block; width: 100%; height: auto; border-radius: 8px; }
.qr-url { text-align: center; font-weight: 700; font-size: 17px; margin-bottom: 10px; word-break: break-all; }
ol.steps { margin: 10px 0 12px; padding-left: 22px; }
ol.steps li { margin-bottom: 8px; }
button.card.linkcard { width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.first-steps { border-color: var(--accent); }
.first-steps .step { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 0; border: 0; border-top: 1px solid var(--line);
  background: none; text-align: left; font: inherit; color: inherit; text-decoration: none; cursor: pointer; }
.first-steps .row + .step { margin-top: 8px; }
.first-steps .n { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; }
.first-steps .step.done .n { background: var(--ok); }
.first-steps .step.done b { color: var(--muted); text-decoration: line-through; }
.first-steps .stack > * { display: block; }

/* ---------- team board ---------- */
main.wide { max-width: 1280px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 6px; }
@media (min-width: 760px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; color: inherit; text-decoration: none; }
.tile-v { font-size: 28px; font-weight: 800; line-height: 1.1; }
.tile-l { font-size: 14px; color: var(--muted); margin-top: 2px; }
.tile.wait .tile-v { color: var(--wait); }
.tile.bad { border-color: #F0B9B4; background: var(--bad-bg); }
.tile.bad .tile-v { color: var(--bad); }
a.tile:active { background: var(--accent-soft); }
.board { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 900px) { .board { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); align-items: start; } }
.board .card { margin-bottom: 0; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.person .sub { margin: 14px 0 2px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.task-row { display: block; padding: 9px 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.card > .task-row:first-child { border-top: 0; padding-top: 0; }
.task-row .small { margin-top: 3px; }
.task-row > div:last-child .pill { margin-top: 5px; }
.works { margin-top: 10px; }
.works summary { color: var(--accent); font-weight: 600; font-size: 14px; padding: 4px 0; }

/* ---------- big screens (the lab computer): menu on top instead of the bottom bar ---------- */
@media (min-width: 900px) {
  #app { display: flex; flex-direction: column; min-height: 100vh; }
  body { padding-bottom: 0; }
  .top { order: 0; position: static; padding-left: 24px; gap: 14px; }
  .top .brand-name { display: block; padding-right: 14px; margin-right: 4px; border-right: 1px solid rgba(255, 255, 255, .35); }
  .top .brand img { height: 40px; }
  nav.tabs { background: rgba(255, 255, 255, .9); }
  nav.tabs { order: 1; position: sticky; top: 0; bottom: auto; grid-auto-columns: minmax(120px, max-content);
    justify-content: start; padding: 0 12px; border-top: 0; border-bottom: 1px solid var(--line); }
  nav.tabs a { height: 48px; padding: 0 18px; border-top: 0; border-bottom: 3px solid transparent; font-size: 15px; }
  nav.tabs a.on { border-bottom-color: var(--accent); }
  nav.tabs a .badge { position: static; margin-left: 6px; }
  main { order: 2; width: 100%; padding-top: 18px; }
  .toast { bottom: 24px; }
}

/* ---------- output report + printing ---------- */
.t tr.sum td { border-top: 2px solid var(--line); }
details.lines { margin-top: 10px; }
details.lines > summary { color: var(--accent); font-weight: 600; font-size: 14px; padding: 4px 0; }
.print-only { display: none; }
@media print {
  .top, nav.tabs, .no-print, .toast, .veil { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; padding: 0; }
  main { max-width: none; padding: 0; }
  .card { break-inside: avoid; border: 1px solid #bbb; box-shadow: none; }
}
.t td.num, .big, .title.num { white-space: nowrap; }
.big { flex: none; }

/* ---------- order statuses, executors, doctors ---------- */
.chip { display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.k-fitting:not(.on) { border-color: #E9C46A; } .chip.k-done:not(.on) { border-color: #9CD3B0; } .chip.k-hold:not(.on) { border-color: #F0B9B4; }
.chip.big { min-height: 46px; font-size: 16px; padding: 0 16px; }
.ws-chips { margin: 0 0 12px; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.ws-chips .chip { flex: none; white-space: nowrap; }
@media (min-width: 760px) { .ws-chips { flex-wrap: wrap; } }
.ws-pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.ws-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.ws-line .btn { margin-left: auto; }
.current { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.current .pill { margin-left: 2px; }
@media (min-width: 900px) { .orders-list > div { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 10px; align-items: start; }
  .orders-list .card { margin-bottom: 0; } }
.ex-table { padding: 4px 14px; }
.ex-row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "stage state" "who pay" "due act"; gap: 2px 10px;
  padding: 10px 0; border-top: 1px solid var(--line); align-items: start; }
.ex-row:first-child, .ex-head + .ex-row { border-top: 0; }
.ex-head { display: none; }
.ex-stage { grid-area: stage; } .ex-who { grid-area: who; } .ex-due { grid-area: due; } .ex-pay { grid-area: pay; text-align: right; }
.ex-state { grid-area: state; text-align: right; } .ex-act { grid-area: act; text-align: right; } .ex-act .btn { margin: 0; }
.ex-row.overdue .ex-due { color: var(--bad); font-weight: 700; }
@media (min-width: 760px) {
  .ex-row { grid-template-columns: 1.3fr 1.5fr .8fr .9fr 1fr auto; grid-template-areas: "stage who due pay state act"; align-items: center; }
  .ex-head { display: grid; font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
  .ex-l { display: none; }
}
.history summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.history .row { padding: 6px 0; border-top: 1px solid var(--line); }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; padding: 10px 0; border: 0;
  border-top: 1px solid var(--line); background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.card > .list-row:first-child { border-top: 0; }
.list-row.off { opacity: .55; }
.linklike { border: 0; background: none; padding: 0; font: inherit; cursor: pointer; text-align: left; }
.actions.tight { margin: 0; gap: 4px; flex-wrap: nowrap; }
label.check { display: flex; align-items: center; gap: 8px; margin: 8px 0 14px; }
.newdoc { border-left: 3px solid var(--accent); padding-left: 10px; margin-bottom: 8px; }

.hist-row { padding: 8px 0; border-top: 1px solid var(--line); }
.history summary + .hist-row { border-top: 0; }
.hist-what { font-size: 15px; }
.hist-what .old { text-decoration: line-through; color: var(--muted); }
.hist-who { margin-top: 2px; }

.entry-mini { padding: 8px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.entry-mini .btn { margin-left: 6px; }

.unit-line { display: grid; grid-template-columns: 1fr 84px auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.unit-line .btn { margin: 0; }
.seg.full a { flex: 1 1 auto; text-align: center; padding: 9px 4px; font-size: 14px; white-space: nowrap; text-decoration: none; color: var(--muted); font-weight: 600; }
.seg.full a.on { background: var(--accent); color: #fff; }
.units-line { display: block; margin: 8px 0 2px; color: inherit; text-decoration: none; }
.warn-text { color: #8a5a00; }
/* ---------- order QR label ---------- */
.qr-label { display: flex; flex-direction: column; align-items: center; text-align: center; }
.qr-label .qr { width: 200px; margin: 0 auto 6px; }
.qr-label-text { line-height: 1.35; }
.qr-label-text b { font-size: 20px; }
.print-area { display: none; }
@media print {
  body.printing-qr > *:not(.print-area) { display: none !important; }
  body.printing-qr .print-area { display: flex; flex-wrap: wrap; gap: 6mm; align-items: flex-start; }
  .print-area .qr-label { break-inside: avoid; border: 0.3mm dashed #999; padding: 3mm; color: #000; }
  .print-area.small .qr-label { width: 50mm; }
  .print-area.small .qr { width: 40mm; max-width: none; margin-bottom: 1mm; }
  .print-area.small .qr-label-text { font-size: 9pt; }
  .print-area.small .qr-label-text b { font-size: 12pt; }
  .print-area.big .qr-label { width: 90mm; }
  .print-area.big .qr { width: 75mm; max-width: none; }
  .print-area.big .qr-label-text { font-size: 13pt; }
  .print-area.big .qr-label-text b { font-size: 18pt; }
  .print-area .qr svg { border-radius: 0; }
  .print-area .qr-label-text .small, .print-area .qr-label-text div { font-size: inherit; }
}
.danger-link { color: var(--bad); font-size: 13px; margin-left: 6px; }
@media print { html, body { background: #fff !important; } }
/* branch switch in the header */
.branch-switch { flex: none; border: 1px solid rgba(255, 255, 255, .45); background: rgba(255, 255, 255, .14); color: #fff;
  border-radius: 999px; padding: 6px 11px; font: inherit; font-size: 13px; font-weight: 650; cursor: pointer; white-space: nowrap;
  max-width: 42vw; overflow: hidden; text-overflow: ellipsis; }
.branch-switch.on { background: #fff; color: var(--accent); border-color: #fff; }
/* ---------- printed order (A4) ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body.printing-qr .print-area.order-sheet { display: block; color: #000; font-size: 10.5pt; line-height: 1.35; }
  .order-sheet .ps-head { display: flex; align-items: center; gap: 6mm; border-bottom: 0.5mm solid #3F5FB0; padding-bottom: 4mm; margin-bottom: 4mm; }
  .order-sheet .ps-brand { display: flex; align-items: center; gap: 3mm; color: #3F5FB0; font-size: 9pt; }
  .order-sheet .ps-brand img { height: 14mm; }
  .order-sheet .ps-brand b { font-size: 11pt; }
  .order-sheet .ps-title { flex: 1; text-align: center; }
  .order-sheet .ps-num { font-size: 18pt; font-weight: 800; }
  .order-sheet .ps-qr .qr { width: 26mm; max-width: none; margin: 0; }
  .order-sheet .ps-qr .qr svg { border-radius: 0; }
  .order-sheet .ps-kv { display: grid; grid-template-columns: 32mm 1fr 32mm 1fr; gap: 1.5mm 4mm; margin: 0 0 4mm; }
  .order-sheet .ps-kv dt { color: #555; }
  .order-sheet .ps-kv dd { margin: 0; font-weight: 600; }
  .order-sheet h2 { font-size: 12pt; margin: 5mm 0 2mm; }
  .order-sheet .ps-item { break-inside: avoid; margin-bottom: 4mm; }
  .order-sheet .ps-item-head { margin-bottom: 1.5mm; }
  .order-sheet table { width: 100%; border-collapse: collapse; }
  .order-sheet th, .order-sheet td { border: 0.25mm solid #999; padding: 1.5mm 2mm; text-align: left; vertical-align: top; }
  .order-sheet th { background: #EEF2FA; font-size: 9pt; }
  .order-sheet td:nth-child(1) { width: 7mm; }
  .order-sheet td:nth-child(4), .order-sheet td:nth-child(5) { width: 22mm; }
  .order-sheet td:nth-child(6) { width: 25mm; }
  .order-sheet .ps-muted { color: #666; font-size: 8.5pt; }
  .order-sheet .ps-note { margin: 1mm 0; }
  .order-sheet .ps-foot { margin-top: 6mm; color: #777; font-size: 8pt; text-align: right; }
}
.staff-group { margin: 18px 2px 8px; }
.staff-group:first-child { margin-top: 4px; }
.branch-tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 650; white-space: nowrap; }
.bad-text { color: var(--bad); font-weight: 650; }
/* ---------- doctor remarks and photos ---------- */
.remark { padding: 10px 0; border-bottom: 1px solid var(--line); }
.remark:last-child { border-bottom: 0; }
.remark.ok b { color: #1c7a43; }
.remark-text { margin: 6px 0; white-space: pre-wrap; }
.photo-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.photo-thumb { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; background: #eef2fa; }
.photo-big { width: 100%; height: auto; border-radius: 12px; }
.stage-picks { display: grid; gap: 6px; margin-bottom: 12px; }
.stage-pick { text-align: left; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); font: inherit; cursor: pointer; }
.stage-pick.on { border-color: var(--accent); background: var(--accent-soft); }
.stage-list { display: grid; gap: 6px; margin-top: 8px; }
/* 3.24: status colours */
.f-label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 38px; height: 38px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; font: inherit; position: relative; overflow: hidden; }
.swatch.on { box-shadow: 0 0 0 3px var(--accent); }
.swatch.none { background: #fff; font-size: 11px; font-weight: 650; color: var(--muted); }
.swatch.pick { background: conic-gradient(#D64545, #E0B000, #2E9E5B, #2A9FD6, #8E5CC9, #E05297, #D64545); color: #fff; font-weight: 700; font-size: 18px; }
.swatch.pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
/* 3.25: overdue on top of «Сводка» */
button.tile { width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.late-card { border-color: #F0B9B4; box-shadow: inset 4px 0 0 var(--bad); }
.late-row + .late-row { border-top: 1px solid var(--line); }
#late { scroll-margin-top: 80px; }
/* 3.26: chats, months chart, ceramics table */
.chat-btn { position: relative; flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  color: #fff; background: rgba(255, 255, 255, .14); text-decoration: none; }
.chat-btn .chat-ico { display: grid; place-items: center; }
.chat-btn .badge { position: absolute; top: -4px; right: -6px; margin: 0; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; font-size: 11px;
  box-shadow: 0 0 0 2px #4466B8; }
.chat-list { padding: 0; overflow: hidden; }
.chat-row { display: flex; gap: 12px; padding: 12px 14px; text-decoration: none; color: inherit; align-items: flex-start; }
.chat-row + .chat-row { border-top: 1px solid var(--line); }
.chat-row.unread .chat-title, .chat-row.unread .chat-last { font-weight: 700; color: var(--text, #1B2430); }
.chat-ava { flex: none; width: 42px; height: 42px; border-radius: 50%; background: #E3E9F7; color: var(--accent); font-weight: 750;
  display: grid; place-items: center; font-size: 15px; }
.chat-ava.order { background: var(--accent); color: #fff; }
.chat-main { flex: 1; min-width: 0; }
.chat-main .row { gap: 8px; }
.chat-title, .chat-sub, .chat-last { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chat-last { color: var(--muted); flex: 1; }
.badge-num { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.pick-list { margin-top: 10px; max-height: 60vh; overflow: auto; }
.pick-row { display: flex; gap: 12px; align-items: center; padding: 9px 2px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--line); }
.chat-head { margin: -4px 0 8px; }
.chat-msgs { display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; padding-bottom: 8px; min-height: calc(100vh - 290px); }
textarea.in.chat-in { min-height: 46px; height: 46px; }
.chat-day { align-self: center; font-size: 12px; color: var(--muted); background: rgba(255, 255, 255, .85); border-radius: 10px; padding: 2px 10px; margin: 6px 0; }
.msg { max-width: 82%; align-self: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 7px 11px 5px;
  box-shadow: 0 1px 2px rgba(30, 50, 100, .06); }
.msg.doc { border-color: #F3C79A; background: #FFF8EF; }
.msg.mine { align-self: flex-end; background: var(--accent); border-color: var(--accent); color: #fff; border-radius: 16px 16px 4px 16px; }
.msg-from { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 1px; }
.msg.doc .msg-from { color: #B5651D; }
.msg-body { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; font-size: 15px; line-height: 1.35; }
.msg-time { font-size: 11px; opacity: .65; text-align: right; margin-top: 2px; }
.chat-compose { position: sticky; bottom: calc(58px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 8px; align-items: flex-end;
  padding: 8px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); z-index: 3; }
.doctor-shell .chat-compose { bottom: env(safe-area-inset-bottom, 0px); }
.chat-in { flex: 1; resize: none; min-height: 44px; max-height: 140px; border-radius: 22px; padding: 11px 16px; line-height: 1.3; }
.chat-send { flex: none; width: 46px; height: 46px; border-radius: 50%; padding: 0; font-size: 19px; }
@media (min-width: 900px) { .chat-compose { bottom: 0; } }
.trend .seg a { padding: 6px 10px; font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; }
.trend .seg a.on { background: var(--accent); color: #fff; }
.trend .row { flex-wrap: wrap; gap: 8px; }
.trend-svg { width: 100%; height: auto; display: block; margin-top: 6px; overflow: visible; }
.trend-svg .base { stroke: var(--line); stroke-width: 1; }
.trend-svg .val { font-size: 11px; font-weight: 700; fill: #1B2430; }
.trend-svg .mon { font-size: 11px; fill: #6B7686; }
.trend-svg .mon.now { font-weight: 700; fill: #1B2430; }
.trend-svg .bar { cursor: pointer; outline: none; }
.trend-svg .bar:not(.on) rect[fill^="#"] { opacity: .82; }
.legend { display: flex; gap: 14px; margin-top: 6px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; }
.trend-detail { margin: 4px 0 6px; min-height: 20px; }
table.t tr.sub-row td { color: var(--muted); font-size: 13px; padding-top: 2px; }
table.t tr.total-row td { border-bottom: 0; }
/* 3.27: quick full-arch choice */
.presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.presets .chip { padding: 6px 11px; font-size: 14px; }
/* 3.28: the day summary on top of the first screen */
.day-digest { border-color: #F3D9A4; background: linear-gradient(180deg, #FFF9EC, #fff); }
.day-digest .row { margin-bottom: 6px; }
.dd-line { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; color: inherit; text-decoration: none; border-top: 1px solid var(--line); }
.dd-line b { font-size: 18px; }
.dd-line.bad b { color: var(--bad); }
.dd-line.wait b { color: var(--wait); }
/* 3.31: work is handed in for all teeth of the item */
.teeth-all { padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; line-height: 1.4; }
/* 3.35: «Сводка» — people and lists fold up */
details.fold > summary { list-style: none; cursor: pointer; position: relative; padding-right: 26px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: '▾'; position: absolute; right: 2px; top: 2px; font-size: 16px; color: var(--muted); transition: transform .15s; }
details.fold[open] > summary::after { transform: rotate(180deg); }
details.fold[open] > summary { margin-bottom: 8px; }
.fold-title { font-size: 17px; font-weight: 750; }
.fold-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.fold-badges .pill { font-size: 12px; }
details.person:not([open]) { padding-bottom: 12px; }
/* 3.39: yellow notices fold into one line */
.note-mini { font-size: 13px; color: #8a5a00; background: var(--wait-bg); border-radius: 999px; padding: 4px 12px; display: inline-block; margin: 2px 0 6px; }
.note-toggle { font-size: 13px; white-space: nowrap; }
/* 3.40: the accounting report as a page (print / save as PDF) */
@media print {
  .report-sheet h2 { font-size: 12pt; margin: 6mm 0 2mm; color: #000; }
  .report-sheet table.rt { width: 100%; border-collapse: collapse; font-size: 10pt; }
  .report-sheet .rt th { text-align: left; border-bottom: 0.4mm solid #3F5FB0; padding: 1.5mm 2mm; font-size: 9pt; color: #333; }
  .report-sheet .rt td { border-bottom: 0.2mm solid #ccc; padding: 1.3mm 2mm; vertical-align: top; }
  .report-sheet .rt .r { text-align: right; white-space: nowrap; }
  .report-sheet .rt tr { break-inside: avoid; }
  .report-sheet .rt-sub td { background: #eef2fb; font-weight: 600; }
  .report-sheet .rt-total td { border-top: 0.5mm solid #000; font-weight: 800; font-size: 11pt; }
  .report-sheet .rt-light td { color: #555; font-size: 9pt; }
}
/* 3.41: stage comments */
.stage-note { margin-top: 2px; }
.stage-note span { background: #FFF6DD; border-radius: 6px; padding: 1px 6px; color: #5b4300; }

/* 3.42 · calendar of due dates */
a.card.cal-link, .card.cal-link { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 10px 0 6px; }
.cal-wd { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; }
.cal-wd.we { color: var(--bad); }
.cal-day { position: relative; min-height: 58px; padding: 4px 2px 3px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; gap: 1px; cursor: pointer; }
.cal-day.out { opacity: .45; }
.cal-n { font-size: 12px; color: var(--muted); align-self: flex-start; padding-left: 3px; }
.cal-u { font-size: 16px; font-weight: 700; line-height: 1.1; }
.cal-o { font-size: 10px; color: var(--muted); }
.cal-day.some { background: var(--accent-soft); }
.cal-day.high { background: var(--wait-bg); }
.cal-day.over { background: var(--bad-bg); }
.cal-day.over .cal-u { color: var(--bad); }
.cal-day.done { background: var(--ok-bg); }
.cal-day.done .cal-u { color: var(--ok); }
.cal-day.late { border: 2px solid var(--bad); }
.cal-day.today .cal-n { color: var(--accent); font-weight: 700; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day.sel { outline: 3px solid var(--accent); outline-offset: 1px; z-index: 1; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 4px 2px 6px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend .sw { width: 14px; height: 14px; border-radius: 4px; border: 1px solid #9AA8B8; display: inline-block; }
.cal-legend .sw.some { background: var(--accent-soft); } .cal-legend .sw.high { background: var(--wait-bg); }
.cal-legend .sw.over { background: var(--bad-bg); } .cal-legend .sw.done { background: var(--ok-bg); }
.cal-legend .sw.late { background: var(--surface); border: 2px solid var(--bad); }
@media (min-width: 700px) { .cal-day { min-height: 72px; } .cal-u { font-size: 19px; } }
