/* Мост — оформление мини-приложения. Токены повторяют design/tokens.css. */
:root {
  --bg: #F3F5F8;
  --card: #FFFFFF;
  --field: #F3F5F8;
  --ink: #0F1B2D;
  --ink-2: #55607A;
  --line: #D5DBE3;
  --line-strong: #C3CBD6;
  --accent: #0B7A8C;
  --accent-ink: #075E6C;
  --accent-soft: #DDF0F3;
  --warn: #D9730D;
  --warn-ink: #9A4A07;
  --warn-soft: #FFF1E3;
  --r-sm: 12px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 24px;
  --font-display: 'Jost', 'Golos Text', system-ui, sans-serif;
  --font-text: 'Golos Text', system-ui, sans-serif;
  --nav-h: 68px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.4 var(--font-text); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .55; cursor: default; }
a { color: var(--accent-ink); }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.boot, .loading { padding: 48px 20px; text-align: center; color: var(--ink-2); }
.boot { font: 500 32px var(--font-display); color: var(--ink); padding-top: 30vh; }

/* ---------- каркас: на телефоне меню снизу, на планшете — слева ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.main { padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; }
.nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex; gap: 4px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line); }
.nav .logo, .nav .who { display: none; }
.tab { flex: 1 1 0; min-width: 0; min-height: 54px; border: 0; border-radius: var(--r-md); background: none; color: var(--ink-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 500; }
.tab[aria-current="page"] { background: var(--ink); color: #fff; }
.tab .badge { position: absolute; }

@media (min-width: 900px) {
  .shell { display: flex; }
  .nav { position: sticky; top: 0; bottom: auto; right: auto; height: 100vh; width: 100px; flex: none; flex-direction: column; align-items: center;
    padding: 20px 10px; border-top: 0; border-right: 1px solid var(--line); gap: 6px; }
  .nav .logo { display: flex; width: 52px; height: 52px; border-radius: 16px; background: var(--accent); color: #fff; align-items: center; justify-content: center; margin-bottom: 12px; flex: none; }
  .nav .who { display: block; margin-top: auto; width: 80px; padding: 8px 4px; border: 0; border-radius: var(--r-sm); background: var(--field); font-size: 11.5px; line-height: 1.25; text-align: center; overflow-wrap: anywhere; }
  .tab { flex: none; width: 80px; min-height: 62px; }
  .main { flex: 1 1 0; min-width: 0; padding: 28px 28px 40px; margin: 0; }
}

/* ---------- заголовки и общие блоки ---------- */
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.head h1 { font: 500 28px/1.1 var(--font-display); letter-spacing: -0.3px; }
.head .sub { margin-top: 3px; font-size: 13.5px; color: var(--ink-2); }
.back { width: 44px; height: 44px; flex: none; border: 0; border-radius: var(--r-md); background: var(--card); display: flex; align-items: center; justify-content: center; }
h2.group { margin: 18px 0 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.grow { flex: 1 1 0; min-width: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.num { font-family: var(--font-display); font-weight: 500; }
.big { font: 500 40px/1.1 var(--font-display); letter-spacing: -0.5px; }
.big small { font: 500 28px var(--font-text); }
.empty { padding: 28px 16px; border-radius: var(--r-lg); background: var(--card); color: var(--ink-2); text-align: center; }
.cols { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }   /* minmax(0, …): широкое содержимое не распирает страницу */
@media (min-width: 900px) { .cols { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } }

.card { background: var(--card); border-radius: var(--r-lg); padding: 16px; }
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.card.warn { background: var(--warn-soft); }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 4px 0; }
.kv > :first-child { color: var(--ink-2); }
.kv > :last-child { font-weight: 500; text-align: right; }
.hr { height: 1px; background: #E3E8EE; margin: 10px 0; }

/* ---------- кнопки, чипы, поля ---------- */
.btn { min-height: 48px; padding: 0 16px; border: 0; border-radius: var(--r-md); background: var(--ink); color: #fff; font-size: 15px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.accent { background: var(--accent); }
.btn.line { background: var(--card); color: var(--ink); border: 1.5px solid var(--line-strong); font-weight: 500; }
.btn.soft { background: var(--field); color: var(--ink); font-weight: 500; }
.btn.danger { background: var(--card); color: var(--warn-ink); border: 1.5px solid #E9C7A6; font-weight: 500; }
.btn.block { width: 100%; }
.btn.two { flex-direction: column; align-items: flex-start; gap: 1px; min-height: 52px; padding: 6px 14px; text-align: left; }
.btn.two small { font-size: 12px; font-weight: 400; color: var(--ink-2); }
.chip { min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--card); color: var(--ink); font-size: 14px; font-weight: 500; }
.chip.in { background: var(--field); }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; font-weight: 600; }
.tag { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; background: var(--field); font-size: 12.5px; white-space: nowrap; }
.tag.accent { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.tag.warn { background: var(--warn-soft); color: var(--warn-ink); font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
.field input, .field select, .field textarea, .input { min-height: 48px; width: 100%; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: var(--r-md); background: var(--card); color: var(--ink); font-size: 16px; }
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--accent); }
.grid2 { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- наряд в списке ---------- */
.order { width: 100%; border: 0; text-align: left; display: grid; gap: 10px 14px; padding: 14px 16px; border-radius: var(--r-lg); background: var(--card); color: var(--ink);
  grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "no due" "what what" "state state" "go go"; cursor: pointer; }
.order .no { grid-area: no; font: 500 16px var(--font-display); color: var(--ink-2); white-space: nowrap; }
.order .what { grid-area: what; min-width: 0; }
.order .title { font-size: 15.5px; font-weight: 600; overflow-wrap: anywhere; }
.order .sub { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.order .state { grid-area: state; display: flex; flex-direction: column; gap: 6px; }
.order .due { grid-area: due; text-align: right; font-size: 14px; font-weight: 500; white-space: nowrap; }
.order .due .small { display: inline; margin-left: 8px; }
.order .go { grid-area: go; }
.steps { display: flex; gap: 4px; }
.steps i { flex: 1 1 0; height: 6px; border-radius: 3px; background: var(--line); }
.steps i.on { background: var(--accent); }
.steps i.bad { background: var(--warn); }
.state .label { font-size: 13px; font-weight: 500; }
.state .label.accent { color: var(--accent-ink); font-weight: 600; }
.state .label.warn { color: var(--warn-ink); font-weight: 600; }
@media (min-width: 900px) {
  .order { grid-template-columns: 68px minmax(0, 1fr) 230px 110px auto; grid-template-areas: "no what state due go"; align-items: center; }
  .order .due { text-align: left; }
  .order .due .small { display: block; margin-left: 0; }
}

/* ---------- карточка наряда ---------- */
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.fact { padding: 10px 12px; border-radius: var(--r-md); background: var(--field); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fact span { font-size: 12px; color: var(--ink-2); }
.fact b { font: 500 17px var(--font-display); overflow-wrap: anywhere; }
.name { font: 500 24px/1.15 var(--font-display); letter-spacing: -0.2px; overflow-wrap: anywhere; }
.timeline { display: flex; flex-direction: column; }
.timeline .st { display: flex; gap: 12px; min-height: 40px; }
.timeline .mark { width: 24px; flex: none; display: flex; flex-direction: column; align-items: center; }
.timeline .dot { width: 24px; height: 24px; border-radius: 999px; border: 2px solid var(--line-strong); background: var(--card); display: flex; align-items: center; justify-content: center; color: #fff; }
.timeline .bar { flex: 1 1 0; width: 2px; background: var(--line); }
.timeline .st.done .dot { background: var(--accent); border-color: var(--accent); }
.timeline .st.done .bar { background: var(--accent); }
.timeline .st.now .dot { border-color: var(--ink); }
.timeline .st.now .dot::after { content: ""; width: 10px; height: 10px; border-radius: 999px; background: var(--ink); }
.timeline .st:last-child .bar { display: none; }
.timeline .txt { padding-bottom: 12px; font-size: 15px; font-weight: 500; }
.timeline .st.now .txt { font-weight: 600; }
.timeline .txt small { display: block; font-size: 12.5px; font-weight: 400; color: var(--ink-2); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumbs button { border: 0; padding: 0; border-radius: var(--r-sm); overflow: hidden; aspect-ratio: 1; background: var(--field); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.history { font-size: 13.5px; }
.history li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid #E3E8EE; }
.history li:first-child { border-top: 0; }
.history ul { list-style: none; margin: 0; padding: 0; }
.history time { color: var(--ink-2); white-space: nowrap; font-size: 12.5px; }
.msgs { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 86%; align-self: flex-start; padding: 9px 12px; border-radius: 4px 16px 16px 16px; background: var(--field); font-size: 14.5px; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; border-radius: 16px 4px 16px 16px; background: var(--accent-soft); }
.msg small { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 2px; }
.send { display: flex; gap: 8px; margin-top: 10px; }
.send .input { border: 0; background: var(--field); border-radius: 16px; }
.send .btn { width: 48px; padding: 0; border-radius: 16px; flex: none; }

/* ---------- новый наряд: зубная формула ---------- */
/* челюсть — две половины по восемь зубов; не помещаются в ряд — встают друг под другом, зубы сжимаются под ширину */
.jaw { display: flex; flex-wrap: wrap; gap: 6px 0; max-width: 930px; }
.quad { display: flex; align-items: center; flex: 1 1 372px; min-width: 0; }
.tooth { flex: 1 1 0; min-width: 0; max-width: 44px; height: 44px; padding: 0; border: 0; border-radius: 10px; background: var(--field); font: 500 15px var(--font-display); }
.tooth[aria-pressed="true"] { background: var(--accent); color: #fff; }
.join { width: 14px; height: 44px; flex: none; padding: 0; border: 0; background: none; display: flex; align-items: center; justify-content: center; }
.join i { width: 10px; height: 10px; border-radius: 999px; border: 2px solid #8792A6; background: var(--card); }
.join[aria-pressed="true"] i { border-color: var(--accent); background: var(--accent); }
.join:disabled { opacity: 0; }
@media (max-width: 480px) { .join { width: 11px; } .tooth { font-size: 14px; border-radius: 9px; } }
.wrap > select.input { flex: 1 1 100%; }
.shade { width: 52px; min-height: 44px; padding: 0; border: 0; border-radius: var(--r-sm); background: var(--field); font: 500 16px var(--font-display); }
.shade[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------- окно снизу, просмотр файлов, всплывающее сообщение ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(15, 27, 45, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); border-radius: var(--r-xl) var(--r-xl) 0 0; background: var(--card);
  display: flex; flex-direction: column; gap: 14px; }
.sheet h2 { font: 500 22px/1.2 var(--font-display); }
@media (min-width: 640px) { .scrim { align-items: center; } .sheet { border-radius: var(--r-xl); } }
.viewer { position: fixed; inset: 0; z-index: 50; background: #0F1B2D; display: flex; flex-direction: column; }
.viewer .bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; color: #fff; font-size: 14px; }
.viewer .bar .btn { min-height: 44px; background: rgba(255, 255, 255, .14); }
.viewer iframe, .viewer .pic { flex: 1 1 0; min-height: 0; width: 100%; border: 0; background: #fff; }
.viewer .pic { background: #0F1B2D; display: flex; align-items: center; justify-content: center; }
.viewer .pic img { max-width: 100%; max-height: 100%; }
#toast { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); max-width: min(92vw, 460px);
  padding: 12px 16px; border-radius: var(--r-md); background: var(--ink); color: #fff; font-size: 14.5px; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.on { opacity: 1; }
#toast.bad { background: var(--warn-ink); }

/* ---------- прайс и ставки ---------- */
.price { display: grid; gap: 10px; }
.price .rates { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.price .field input { min-height: 44px; }
.bar-load { height: 6px; border-radius: 3px; background: #E3E8EE; overflow: hidden; }
.bar-load i { display: block; height: 6px; border-radius: 3px; background: var(--accent); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* на телефоне действия по наряду — сразу под шапкой, а не в самом низу */
.cols .side { order: -1; }
@media (min-width: 900px) { .cols .side { order: 0; } }

.linkish { border: 0; background: none; padding: 6px 0; margin: -3px 0; color: inherit; font: inherit; text-align: left; }
.linkish.edit { margin-left: 10px; color: var(--accent-ink); text-decoration: underline; font-weight: 500; }
.handover > summary { cursor: pointer; padding: 10px 0; font-size: 14px; font-weight: 500; }
.handover > summary small { display: block; font-size: 12.5px; font-weight: 400; color: var(--ink-2); }
.handover[open] > summary { margin-bottom: 6px; }
.viewer .bar { gap: 8px; }
/* прайс для одной клиники: работа — общая цена — особая цена */
.pline { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid #E3E8EE; }
.pline:first-of-type { border-top: 0; }
.pline input { min-height: 44px; width: 100%; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: var(--r-md); background: var(--card); font-size: 16px; }
.pline input:focus { outline: none; border-color: var(--accent); }
.card.off { opacity: .6; }
.code { font: 500 30px var(--font-display); letter-spacing: 3px; }

/* ---------- админка владельцев сервиса ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.kpi { padding: 14px; border-radius: var(--r-lg); background: var(--card); min-width: 0; }
.kpi.warn { background: var(--warn-soft); }
.kpi .l { font-size: 11.5px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--ink-2); }
.kpi .v { margin-top: 4px; font: 500 28px/1.15 var(--font-display); overflow-wrap: anywhere; }
.kpi .s { margin-top: 2px; font-size: 12.5px; color: var(--ink-2); }
.days { display: flex; align-items: flex-end; gap: 6px; height: 132px; }
.days .d { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--ink-2); }
.days .bars { flex: 1 1 0; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.days .bars i { width: 42%; min-height: 2px; border-radius: 3px 3px 0 0; }
.days .in, .dot.in { background: var(--ink); }
.days .out, .dot.out { background: var(--accent); }
.dot { width: 10px; height: 10px; border-radius: 999px; flex: none; }
.dot.out { margin-left: 10px; }
details.card > summary { list-style: none; cursor: pointer; }
details.card > summary::-webkit-details-marker { display: none; }
