﻿:root {
  --green: #5C8763;
  --green-dark: #476B4E;
  --cream: #EDF2E9;
  --card: #FFFFFF;
  --text: #26312A;
  --muted: #6B7885;
  --faint: #9AA6B2;
  --line: #DDE5DA;
  --warn: #C99A5B;
  --danger: #B4544E;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

.screen { min-height: 100vh; }
[hidden] { display: none !important; }

.login {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 18px 40px;
  gap: 22px;
}

.brand { text-align: center; }
.brand h1 { margin: 8px 0 2px; font-size: 30px; letter-spacing: .5px; }
.logo { width: 64px; height: 64px; border-radius: 16px; }

.muted { color: var(--muted); font-size: 14px; }
.faint { color: var(--faint); font-size: 13px; }
.error { color: var(--danger); font-size: 14px; margin: 4px 0 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.login .card { display: flex; flex-direction: column; gap: 12px; max-width: 420px; width: 100%; margin: 0 auto; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 12px;
  font: inherit;
  color: var(--text);
  background: #FBFCFA;
}

input:focus, textarea:focus { outline: 2px solid rgba(92,135,99,.35); border-color: var(--green); }

button {
  font: inherit;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 11px 14px;
  cursor: pointer;
}

button:active { transform: scale(.99); }
button.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
button.primary:active { background: var(--green-dark); }
button.ghost { background: transparent; }
button.link { border: none; background: none; color: var(--green); padding: 4px; }
button.danger { color: var(--danger); border-color: #E7C9C6; }
button:disabled { opacity: .5; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(237,242,233,.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar-title strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title span { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon { width: 40px; height: 40px; padding: 0; font-size: 20px; line-height: 1; border-radius: 12px; }

main { padding: 12px 12px 28px; display: flex; flex-direction: column; gap: 10px; }

.order-card { display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.order-top { display: flex; align-items: center; gap: 8px; }
.order-num { font-weight: 700; color: var(--muted); font-size: 13px; }
.order-patient { font-size: 17px; font-weight: 600; flex: 1; min-width: 0; }
.order-work { color: var(--muted); font-size: 14px; }
.order-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--faint); font-size: 13px; }

.badge {
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: #EEF2EC;
  color: var(--muted);
  white-space: nowrap;
}
.badge.new { background: #E7EEF6; color: #3E5E7E; }
.badge.taken { background: #E6EEF7; color: #35597A; }
.badge.in_lab { background: #F3ECDD; color: #8A6A3A; }
.badge.in_clinic { background: #E3EFE2; color: #3F6B45; }
.badge.accepted { background: #DFF0E1; color: #2F6B39; }
.badge.declined { background: #F5E3E2; color: #8F4A45; }
.badge.cancelled { background: #F5E3E2; color: #8F4A45; }

.swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(0,0,0,.12); display: inline-block; }

.section-title { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 8px 2px 0; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.info-grid div { display: flex; flex-direction: column; gap: 2px; }
.info-grid span:first-child { font-size: 12px; color: var(--faint); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.files { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.file {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: #E3E9E1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
}
.file img { width: 100%; height: 100%; object-fit: cover; }
.file .name { padding: 6px; font-size: 11px; color: var(--muted); text-align: center; word-break: break-word; }

.chat { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.msg { max-width: 84%; padding: 9px 12px; border-radius: 14px; background: #fff; border: 1px solid var(--line); font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.msg.mine { align-self: flex-end; background: #E3EFE2; border-color: #CFE0CC; }
.msg.system { align-self: center; background: transparent; border: none; color: var(--faint); font-size: 12px; padding: 2px; }
.msg time { display: block; font-size: 10px; color: var(--faint); margin-top: 4px; }
.msg-file { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.msg-photo { max-width: 220px; max-height: 220px; border-radius: 10px; object-fit: cover; }
.msg-file-link { background: transparent; border: none; padding: 0; color: var(--green-dark); font-size: 13px; text-align: left; }

.composer { position: sticky; bottom: 0; background: rgba(237,242,233,.96); padding: 8px 0 0; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { resize: none; max-height: 120px; min-height: 44px; }
.composer .send { width: 52px; height: 44px; padding: 0; font-size: 18px; }
.composer .icon { height: 44px; width: 44px; font-size: 18px; }

.empty { text-align: center; color: var(--faint); padding: 30px 10px; }

.install {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 13px;
}
.install span { flex: 1; color: var(--muted); }
.install button { padding: 7px 10px; font-size: 13px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #26312A;
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  max-width: 90vw;
  z-index: 50;
}

@media (min-width: 720px) {
  main { max-width: 760px; margin: 0 auto; width: 100%; }
  .files { grid-template-columns: repeat(4, 1fr); }
}

/* --- Телефон: учёт «чёлки» и нижней полосы --- */
@supports (padding: max(0px)) {
  .topbar { padding-top: max(10px, env(safe-area-inset-top)); }
  main { padding-bottom: max(28px, env(safe-area-inset-bottom)); }
  .composer { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}

/* --- Браузер на большом экране --- */
@media (min-width: 900px) {
  body { font-size: 17px; }

  .topbar {
    padding-left: max(24px, calc((100% - 940px) / 2));
    padding-right: max(24px, calc((100% - 940px) / 2));
    padding-top: 14px;
    padding-bottom: 14px;
  }

  main {
    max-width: 940px;
    padding: 24px 24px 48px;
    gap: 12px;
  }

  .install {
    max-width: 940px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 14px;
    padding: 12px 16px;
    font-size: 14px;
  }

  .login { padding: 48px 24px 64px; gap: 28px; }
  .login .card { max-width: 440px; padding: 24px; }
  .brand h1 { font-size: 32px; }

  .order-card { transition: border-color .15s ease, box-shadow .15s ease; }
  .order-card:hover {
    border-color: rgba(92, 135, 99, .55);
    box-shadow: 0 2px 12px rgba(38, 49, 42, .07);
  }

  button { transition: border-color .15s ease, background .15s ease; }
  button:hover { border-color: rgba(92, 135, 99, .55); }
  button.primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
  .icon:hover { background: rgba(92, 135, 99, .08); }

  .files { grid-template-columns: repeat(5, 1fr); }
  .msg { max-width: 70%; }
  .composer { padding-bottom: 12px; }
}

/* --- выбор входа: клиника или лаборатория --- */
.role-switch {
  display: flex;
  gap: 6px;
  padding: 5px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
}
.role-btn {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  color: var(--muted);
}
.role-btn.on {
  background: rgba(92, 135, 99, .12);
  color: var(--green-dark);
  font-weight: 600;
}

/* --- чат: двухпанельный вид, страница не растягивается --- */
.shell { display: block; }

#view.order-view {
  height: 100%;
  padding: 0;
  overflow: hidden;
}

.chat-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(237, 242, 233, .9);
}

.chat-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-title strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title span { font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 4px; }

.chat-pane .composer {
  position: static;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--card);
}

.drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
  background: var(--card);
  border-left: 1px solid var(--line);
  transform: translateX(102%);
  transition: transform .2s ease;
  z-index: 20;
}

.drawer.open { transform: none; }

.drawer-head { display: flex; align-items: center; gap: 8px; }
.drawer-head strong { flex: 1; font-size: 15px; }

.chat-empty { padding: 24px 14px; color: var(--faint); text-align: center; }

.rail { display: flex; flex-direction: column; gap: 8px; padding: 12px; }

@media (min-width: 900px) {
  .shell {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    height: calc(100vh - 70px);
    align-items: stretch;
  }

  .rail {
    overflow-y: auto;
    border-right: 1px solid var(--line);
    padding: 14px;
  }

  #view.order-view { height: 100%; }

  .chat-scroll { padding: 16px 18px 6px; }
  .chat-pane .composer { padding: 12px 16px; }
}

/* карточка заказа в узкой левой колонке */
.rail .order-card { padding: 10px 12px; gap: 4px; }
.rail .order-top { flex-wrap: wrap; row-gap: 4px; }
.rail .order-num { order: 1; }
.rail .order-top .badge { order: 2; margin-left: auto; }
.rail .order-patient { order: 3; flex: 1 1 100%; font-size: 15px; line-height: 1.3; }
.rail .order-work { font-size: 13px; }
.rail .order-meta { font-size: 12px; gap: 6px; }

.files .empty { grid-column: 1 / -1; }

/* --- иконки Salix (маска, цвет берётся из currentColor) --- */
.ico {
  display: inline-block;
  width: 22px;
  height: 22px;
  background-color: currentColor;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
  flex: none;
}

.ico-back { -webkit-mask-image: url("icons/ui_back.png"); mask-image: url("icons/ui_back.png"); }
.ico-refresh { -webkit-mask-image: url("icons/ui_refresh.png"); mask-image: url("icons/ui_refresh.png"); }
.ico-close { -webkit-mask-image: url("icons/ui_close.png"); mask-image: url("icons/ui_close.png"); }
.ico-photo { -webkit-mask-image: url("icons/ui_photo.png"); mask-image: url("icons/ui_photo.png"); }
.ico-plus { -webkit-mask-image: url("icons/ui_plus.png"); mask-image: url("icons/ui_plus.png"); }
.ico-check { -webkit-mask-image: url("icons/ui_check.png"); mask-image: url("icons/ui_check.png"); }

.ico-send {
  -webkit-mask-image: url("icons/ui_chevron.png");
  mask-image: url("icons/ui_chevron.png");
  width: 24px;
  height: 24px;
  transform: rotate(-90deg);
}

.icon { display: inline-flex; align-items: center; justify-content: center; color: var(--green-dark); }
button.primary .ico { color: #fff; }



/* --- статусы и история в заказ-наряде --- */
.status-track {
  display: flex;
  gap: 6px;
  margin: 2px 0 6px;
}

.status-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  line-height: 1.2;
  color: var(--faint);
  text-align: center;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #DDE5DA;
}

.status-step.done { color: var(--green-dark); }
.status-step.done .status-dot { background: var(--green); }
.status-step.current .status-dot { box-shadow: 0 0 0 3px rgba(92, 135, 99, .2); }
.status-step.current { font-weight: 600; }

.history { display: flex; flex-direction: column; gap: 6px; }
.history-row { display: flex; gap: 8px; font-size: 13px; align-items: baseline; }
.history-time { color: var(--faint); white-space: nowrap; font-size: 12px; }

.ico-attach { -webkit-mask-image: url("icons/ui_attach.png"); mask-image: url("icons/ui_attach.png"); }

.ico-attach { width: 32px; height: 32px; }


/* --- разделы кабинета --- */
.tabs {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(237, 242, 233, .94);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  white-space: nowrap;
}

.tab.on {
  background: #fff;
  border-color: var(--line);
  color: var(--green-dark);
  font-weight: 600;
}

.tab .ico { width: 20px; height: 20px; }

.ico-orders { -webkit-mask-image: url("icons/ui_orders.png"); mask-image: url("icons/ui_orders.png"); }
.ico-person { -webkit-mask-image: url("icons/ui_person.png"); mask-image: url("icons/ui_person.png"); }
.ico-calendar { -webkit-mask-image: url("icons/ui_calendar.png"); mask-image: url("icons/ui_calendar.png"); }
.ico-clock { -webkit-mask-image: url("icons/ui_clock.png"); mask-image: url("icons/ui_clock.png"); }
.ico-check { -webkit-mask-image: url("icons/ui_check.png"); mask-image: url("icons/ui_check.png"); }

.shell.wide { grid-template-columns: minmax(0, 1fr); }

.patient-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.patient-face {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(92, 135, 99, .12);
  color: var(--green-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex: none;
}

.patient-main { flex: 1; min-width: 0; }
.patient-name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.patient-meta { font-size: 13px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.case-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.case-row:last-child { border-bottom: none; }
.case-sum { color: var(--green-dark); font-weight: 600; white-space: nowrap; }

.day-title { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 14px 2px 6px; }
.appt { display: flex; gap: 10px; align-items: baseline; }
.appt-time { font-weight: 700; color: var(--green-dark); min-width: 48px; }
.appt-body { flex: 1; min-width: 0; }
.appt-note { font-size: 13px; color: var(--faint); }

/* --- раскладка: шапка, вкладки, содержимое --- */
#app.screen {
  display: flex;
  flex-direction: column;
  height: var(--vvh, 100dvh);
}

#app .install, #app .tabs { flex: none; }

#app .shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#view {
  flex: 1 1 auto;
  min-height: 0;
}

#view.order-view { height: 100%; }

@media (min-width: 900px) {
  #app .shell {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    height: auto;
  }

  #app .shell.wide { grid-template-columns: minmax(0, 1fr); }

  #view { overflow-y: auto; }
}

.patient-name {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- форма пациента --- */
.add-patient {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border-style: dashed;
  color: var(--green-dark);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(38, 49, 42, .35);
}

.modal-card {
  width: min(460px, 100%);
  max-height: 90dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
}

.modal-card strong { font-size: 17px; }

.modal-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.modal-card .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.modal-card .actions .primary { flex: 1 1 140px; }

.appt-card { cursor: pointer; }
.appt-card:hover { border-color: rgba(92, 135, 99, .5); }

.ico-warehouse { -webkit-mask-image: url("icons/ui_warehouse.png"); mask-image: url("icons/ui_warehouse.png"); }

.stock-row { display: flex; align-items: center; gap: 10px; }
.stock-main { flex: 1; min-width: 0; }
.stock-name { font-size: 15px; font-weight: 600; }
.stock-meta { font-size: 13px; color: var(--faint); }
.stock-qty { font-weight: 700; color: var(--green-dark); white-space: nowrap; }
.stock-qty.low { color: var(--danger); }
.stock-actions { display: flex; gap: 6px; }
.stock-actions button { padding: 6px 10px; font-size: 13px; }

.cal-counts { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.cal-count { padding: 6px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: 13px; }
.cal-count b { color: var(--green-dark); }

.stock-card { cursor: pointer; }
.stock-card:hover { border-color: rgba(92, 135, 99, .5); }
.history-row { align-items: baseline; }

.ico-sliders { -webkit-mask-image: url("icons/ui_sliders.png"); mask-image: url("icons/ui_sliders.png"); }

.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) { .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.stat-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--green-dark); line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--faint); margin-top: 4px; }

.bar-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 6px; }
.bar-name { width: 120px; color: var(--muted); }
.bar-track { flex: 1; height: 8px; background: #E7EDE4; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--green); }
.bar-value { width: 34px; text-align: right; color: var(--muted); }

.case-item { cursor: pointer; }
.case-item:hover { color: var(--green-dark); }

.ico-gear { -webkit-mask-image: url("icons/ui_gear.png"); mask-image: url("icons/ui_gear.png"); }
.setting-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.setting-row + .setting-row { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.setting-title { font-weight: 600; font-size: 15px; }
.setting-note { font-size: 13px; color: var(--faint); }
.totp-secret { font-family: ui-monospace, Consolas, monospace; font-size: 15px; letter-spacing: .04em; background: #F4F7F2; border-radius: 10px; padding: 10px; word-break: break-all; }
/* С„РёР»СЊС‚СЂС‹ РёСЃС‚РѕСЂРёРё СЃРєР»Р°РґР° */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.filters select {
  height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

/* С‡РµРє-Р»РёСЃС‚ РїР»Р°РЅР° Р»РµС‡РµРЅРёСЏ */
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.check-row:last-child { border-bottom: none; }
.check-row input {
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
  accent-color: var(--green);
  flex: none;
}
.check-main { flex: 1; min-width: 0; }
.check-title { font-size: 15px; }
.check-row.done .check-title { text-decoration: line-through; color: var(--faint); }

.check-row { flex-direction: row; }

/* СЃРѕС…СЂР°РЅРµРЅРёРµ РїР°СЂРѕР»СЏ РЅР° СѓСЃС‚СЂРѕР№СЃС‚РІРµ */
.remember {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}
.remember input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
  flex: none;
}

/* --- С‚РµР»РµС„РѕРЅ: РЅР° РІРµСЃСЊ СЌРєСЂР°РЅ, Р±РµР· Р»РёС€РЅРµРіРѕ РїСЂРѕРєСЂСѓС‚Р° СЃС‚СЂР°РЅРёС†С‹ --- */
html, body { height: 100%; }

body.app-open {
  overflow: hidden;
  overscroll-behavior: none;
}

#app.screen { overflow: hidden; }

#view { overflow-y: auto; }
#view.order-view { overflow: hidden; }

@media (max-width: 899px) {
  .topbar { padding: 8px 10px; }
  .topbar-title strong { font-size: 15px; }

  .tabs { padding: 6px 8px; gap: 4px; }
  .tab { padding: 8px 12px; font-size: 14px; }
  .tab .ico { width: 18px; height: 18px; }

  #app main {
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }

  .card { border-radius: 12px; }
  .chat-pane { border-radius: 12px; }
  .chat-head { padding: 8px 10px; }
  .chat-scroll { padding: 10px 10px 2px; }
  .chat-pane .composer { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .msg { max-width: 92%; }

  .login { padding: 20px 16px calc(28px + env(safe-area-inset-bottom)); }
}



/* --- РєР°Р»РµРЅРґР°СЂСЊ Р»Р°Р±РѕСЂР°С‚РѕСЂРёРё: РЅРµРґРµР»СЏ РёР· 7 РґРЅРµР№ --- */
.week-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 10px;
}
.week-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.week-title strong { font-size: 16px; }

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.week-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 2px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  min-height: 84px;
  position: relative;
}

.week-cell:hover { border-color: rgba(92, 135, 99, .55); }

.week-name { font-size: 11px; color: var(--faint); }
.week-date { font-size: 20px; font-weight: 600; line-height: 1; }
.week-count {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(92, 135, 99, .10);
}

.week-cell.has-orders { background: #F6FAF4; }
.week-cell.has-orders .week-count { color: var(--green-dark); font-weight: 600; }

.week-cell.today {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(92, 135, 99, .18);
}

.week-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn);
}

.note-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.note-row:last-child { border-bottom: none; }
.note-text { font-size: 15px; white-space: pre-wrap; }

.note-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.note-form textarea { min-height: 56px; }
.note-form .primary { align-self: flex-end; padding: 10px 18px; }

@media (max-width: 899px) {
  .week-grid { gap: 4px; }
  .week-cell { padding: 8px 1px; min-height: 76px; border-radius: 10px; }
  .week-date { font-size: 17px; }
  .week-name { font-size: 10px; }
  .week-count { font-size: 11px; padding: 1px 4px; }
}

.ico-chevron { -webkit-mask-image: url("icons/ui_chevron.png"); mask-image: url("icons/ui_chevron.png"); }

/* --- РїРѕР»Рµ РІРІРѕРґР° С‡СѓС‚СЊ РІС‹С€Рµ Рё РЅРµ РѕР±СЂРµР·Р°РµС‚СЃСЏ --- */
.chat-pane .composer {
  padding-bottom: 16px;
}

@media (max-width: 899px) {
  #app main { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .chat-pane .composer { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
}

/* --- СЂР°СЃРїРёСЃР°РЅРёРµ РєР»РёРЅРёРєРё: РЅРµРґРµР»СЏ --- */
.sched-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 10px;
}

/* --- С…РёСЂСѓСЂРіРёСЏ --- */
.surgery-plan { cursor: pointer; }
.surgery-plan:hover { border-color: rgba(92, 135, 99, .5); }
.surgery-items { margin: 6px 0 0; padding: 0; list-style: none; }
.surgery-items li { font-size: 14px; color: var(--muted); padding: 2px 0; }
.surgery-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.surgery-item-row:last-child { border-bottom: none; }
.surgery-item-row .grow { flex: 1; min-width: 0; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.ico-implant { -webkit-mask-image: url("icons/ui_implant.png"); mask-image: url("icons/ui_implant.png"); }

.surgery-fields { display: flex; flex-wrap: wrap; gap: 8px; }
.surgery-fields label { flex: 1 1 30%; min-width: 120px; }
.surgery-fields select {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #FBFCFA;
  color: var(--text);
  font: inherit;
  padding: 0 10px;
}

/* --- С…РёСЂСѓСЂРіРёСЏ: СЃР±РѕСЂРєР° РїР»Р°РЅР° --- */
.surgery-list { display: flex; flex-direction: column; gap: 2px; }
.qty-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.qty-chip {
  width: 38px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  color: var(--text);
}
.qty-chip.on {
  border-color: var(--green);
  background: rgba(92, 135, 99, .12);
  color: var(--green-dark);
  font-weight: 600;
}
.surgery-reminder { cursor: pointer; }
.surgery-reminder:hover { color: var(--green-dark); }
.check-row.current {
  background: rgba(92, 135, 99, .10);
  border-radius: 10px;
  margin: 4px -8px;
  padding: 10px 8px;
}
/* строки-переходы в настройках: нажал — открылся список */
.setting-row.link-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 12px 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  text-align: left;
  font: inherit;
  color: var(--text);
  cursor: pointer;
}
.setting-row.link-row + .setting-row.link-row {
  margin-top: 0;
  border-top: 1px solid var(--line);
}
.link-row .chev {
  font-size: 22px;
  line-height: 1;
  color: var(--faint);
  flex: none;
}

/* таблица систем: название слева, галка справа */
.sys-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.modal-card .sys-line {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: #FBFCFA;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
}
.modal-card .sys-line + .sys-line { border-top: 1px solid var(--line); }
.modal-card .sys-line input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-width: 22px;
  padding: 0;
  margin: 0;
  flex: none;
  accent-color: var(--green);
}

.modal-card select {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #FBFCFA;
  color: var(--text);
  font: inherit;
  padding: 0 10px;
}

/* --- С‚РµР»РµС„РѕРЅ: РІРєР»Р°РґРєРё РЅР° РІСЃСЋ С€РёСЂРёРЅСѓ СЌРєСЂР°РЅР° --- */
@media (max-width: 899px) {
  .tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 2px;
    padding: 4px;
    overflow: visible;
  }

  .tab {
    flex-direction: column;
    gap: 3px;
    padding: 7px 2px;
    font-size: 10.5px;
    line-height: 1.15;
    border-radius: 10px;
    text-align: center;
    white-space: normal;
    word-break: break-word;
  }

  .tab .ico { width: 19px; height: 19px; }
  .tab.on { background: #fff; }
}

/* РїРѕРёСЃРє РїР°С†РёРµРЅС‚Р° РІ С„РѕСЂРјРµ РїР»Р°РЅР° */
.patient-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  max-height: 220px;
  overflow-y: auto;
}
.patient-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.patient-option:hover { border-color: var(--green); }
.patient-option-name { font-size: 15px; font-weight: 600; }
.patient-option-meta { font-size: 12px; color: var(--faint); }
.task-row .note-text { font-size: 15px; }
.task-done .note-text { text-decoration: line-through; color: var(--faint); }

/* РєРѕРіРґР° Р»РµРІРѕР№ РєРѕР»РѕРЅРєРё РЅРµС‚ вЂ” РєРѕРЅС‚РµРЅС‚ РЅР° РІСЃСЋ С€РёСЂРёРЅСѓ */
@media (min-width: 900px) {
  #app .shell:has(#rail[hidden]) {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- Р±РµР· Р°РІС‚Рѕ-Р·СѓРјР° РїСЂРё С„РѕРєСѓСЃРµ РЅР° РїРѕР»Рµ --- */
input, textarea, select {
  font-size: 16px;
}

button, .tab, .week-cell, .qty-chip, .icon {
  touch-action: manipulation;
}

@media (max-width: 899px) {
  .composer textarea,
  .note-form textarea,
  .modal-card input,
  .modal-card textarea,
  .modal-card select {
    font-size: 16px;
  }
}

/* --- СЃС‚Р°С‚РёС‡РЅРѕРµ РјРѕРґР°Р»СЊРЅРѕРµ РѕРєРЅРѕ: Р·Р°РіРѕР»РѕРІРѕРє Рё РєРЅРѕРїРєРё РЅР° РјРµСЃС‚Рµ --- */
.modal-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 92dvh;
  overflow: hidden;
}

.modal-card > strong {
  flex: none;
  padding-bottom: 4px;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 2px;
  overscroll-behavior: contain;
}

.modal-card .actions {
  flex: none;
  margin-top: 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  background: var(--card);
}

/* --- РѕРєРЅРѕ РїСЂРёРІСЏР·Р°РЅРѕ Рє РІРёРґРёРјРѕР№ РѕР±Р»Р°СЃС‚Рё (РєР»Р°РІРёР°С‚СѓСЂР° РЅРµ РґРІРёРіР°РµС‚ СЃС‚СЂР°РЅРёС†Сѓ) --- */
body:has(.modal) {
  position: fixed;
  inset: 0;
  width: 100%;
  overflow: hidden;
}

.modal {
  top: 0;
  bottom: auto;
  height: var(--vvh, 100dvh);
  align-items: center;
  padding: 12px;
}

.modal-card {
  max-height: calc(var(--vvh, 100dvh) - 24px);
}

/* --- РЅРёРєР°РєРѕРіРѕ РіРѕСЂРёР·РѕРЅС‚Р°Р»СЊРЅРѕРіРѕ СЃРґРІРёРіР° РІРЅСѓС‚СЂРё РѕРєРЅР° --- */
.modal-card,
.modal-body {
  overflow-x: hidden;
}

.surgery-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.surgery-fields label {
  flex: 1 1 120px;
  min-width: 0;
}

.surgery-fields select {
  min-width: 0;
}

@media (max-width: 480px) {
  .surgery-fields label { flex: 1 1 100%; }
  .qty-chip { width: 34px; height: 32px; }
}

/* --- СЃРІСЏР·СЊ РєР»РёРЅРёРєРё Рё Р»Р°Р±РѕСЂР°С‚РѕСЂРёРё РїРѕ РєРѕРґСѓ/QR --- */
.link-code {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.link-code-info { flex: 1; min-width: 0; }
.link-code-value {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--green-dark);
  margin-top: 4px;
}
.link-qr {
  width: 132px;
  height: 132px;
  border-radius: 12px;
  background: #fff;
  image-rendering: pixelated;
  flex: none;
}
.link-connect { display: flex; gap: 8px; margin-top: 10px; }
.link-connect input { flex: 1; text-transform: uppercase; }
.link-connect .primary { flex: none; padding: 0 16px; }

@media (max-width: 480px) {
  .link-qr { width: 108px; height: 108px; }
  .link-code-value { font-size: 19px; }
}

/* --- С„РѕС‚Рѕ РїР°С†РёРµРЅС‚РѕРІ --- */
.photos-area { display: flex; flex-direction: column; gap: 10px; }

.photo-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.photo-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: #E7EDE4;
  border: 1px solid var(--line);
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}

.photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, .85);
  color: var(--danger);
}

.photo-remove .ico { width: 16px; height: 16px; }

.photo-view .photo-full {
  width: 100%;
  max-height: 60dvh;
  object-fit: contain;
  border-radius: 12px;
  background: #0f120e;
}

.photo-bar label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--faint); }
.photo-bar select {
  height: 44px;
  min-width: 180px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #FBFCFA;
  color: var(--text);
  font: inherit;
  padding: 0 10px;
}

/* РѕРєРЅРѕ СЃР»РµРґСѓРµС‚ Р·Р° РІРёРґРёРјРѕР№ РѕР±Р»Р°СЃС‚СЊСЋ (iOS РїСЂРѕРєСЂСѓС‡РёРІР°РµС‚ РµС‘ Рє РїРѕР»СЋ) */
.modal {
  top: var(--vvt, 0px);
  height: var(--vvh, 100dvh);
}

body:has(.modal) {
  position: fixed;
  inset: 0;
  width: 100%;
  overflow: hidden;
}

/* С„РѕРЅ РѕРєРЅР° РЅРµ РїСЂРѕРєСЂСѓС‡РёРІР°РµС‚СЃСЏ */
html:has(.modal) { overflow: hidden; }

.modal {
  overscroll-behavior: contain;
  touch-action: none;
}

/* РїСЂРѕРєСЂСѓС‚РєР° СЂР°Р·СЂРµС€РµРЅР° С‚РѕР»СЊРєРѕ РІРЅСѓС‚СЂРё СЃРѕРґРµСЂР¶РёРјРѕРіРѕ РѕРєРЅР° */
.modal-body {
  touch-action: pan-y;
  overscroll-behavior: contain;
}

/* --- календарь: месяц + выбранный день --- */
.cal-head { display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; }
.cal-month { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.cal-month strong { font-size: 18px; }
.cal-month .ico { width: 18px; height: 18px; color: var(--green-dark); }
.cal-today {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.cal-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 8px 8px; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; color: var(--faint); margin-bottom: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day {
  position: relative;
  height: 42px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.cal-num { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; }
.cal-day.other { color: #C3CCC6; }
.cal-day.today .cal-num { box-shadow: inset 0 0 0 1px var(--green); }
.cal-day.sel .cal-num { background: var(--green-dark); color: #fff; font-weight: 600; }
.cal-dot { position: absolute; bottom: 2px; left: 50%; width: 5px; height: 5px; margin-left: -2px; border-radius: 50%; background: var(--green); }
.cal-day.sel .cal-dot { background: #fff; }

.cal-day-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin: 14px 2px 8px; }
.cal-day-label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.cal-day-title strong { font-size: 17px; }
.cal-day-count { font-size: 12px; color: var(--muted); text-align: right; }
.cal-notes { margin-top: 12px; }
.cal-notes .section-title { margin-top: 0; }

.ico.flip { transform: rotate(180deg); }

a.link {
  color: var(--green-dark, #256b42);
  text-decoration: none;
  font-size: 15px;
}
a.link:hover { text-decoration: underline; }
a.primary { color: #fff; }
