@font-face {
  font-family: "Golos Text";
  src: url("/fonts/golos-text-cyrillic-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos Text";
  src: url("/fonts/golos-text-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212;
}

:root {
  /* Цвета логотипа: яркий синий и тёмно-синий. Нейтральная шкала подкрашена тем же синим. */
  --ink: #0B1F3F;
  --text-2: #42516A;
  --muted: #64738B;
  --bg: #F3F6FB;
  --surface: #FFFFFF;
  --raised: #E8EEF7;
  --line: rgba(11, 31, 63, .16);
  --line-soft: rgba(11, 31, 63, .08);
  --brand: #0A6CD6;
  --brand-bright: #0A84F0;
  --brand-deep: #06306B;
  --brand-soft: #E1EEFD;
  /* Смысловые цвета: только для состояний и шкалы загрузки */
  --amber: #E8A200;
  --amber-soft: #FCF1D6;
  --amber-ink: #8A5A00;
  --red: #DC2626;
  --red-soft: #FBE6E3;
  --green: #15803D;
  --green-soft: #DFF1E6;
  --r-control: 8px;
  --r-panel: 12px;
  --tabs-h: 60px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 20px;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

b, strong { font-weight: 500; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
[hidden] { display: none !important; }
.grow { flex: 1 1 auto; min-width: 0; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ic { flex: none; }

/* ---------- кнопки и поля ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: var(--r-control);
  border: 1px solid var(--line); background: var(--surface); font-weight: 500; text-decoration: none; color: var(--ink);
  white-space: nowrap;
}
.btn:hover { border-color: var(--line); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--line-soft); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-ghost { background: transparent; border-color: transparent; color: var(--red); }
.btn.danger-ghost:hover { background: var(--red-soft); }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.big { min-height: 48px; width: 100%; font-size: 15px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: var(--r-control);
  background: transparent; color: var(--muted); position: relative; flex: none;
}
.icon-btn:hover { background: var(--line-soft); color: var(--ink); }
.link { border: 0; background: none; padding: 0; color: var(--brand); text-decoration: underline; text-align: left; }

input, select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-control);
  background: var(--surface);
}
/* 16px в полях на телефоне: iOS не увеличивает страницу при вводе */
@media (max-width: 760px) { input, select, textarea { font-size: 16px; } }
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--brand); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled input, fieldset:disabled .sel-btn, fieldset:disabled textarea { background: var(--bg); color: var(--ink); opacity: 1; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); }
.grid2, .grid3 { display: grid; gap: 0 12px; grid-template-columns: 1fr 1fr; }
@media (min-width: 761px) { .grid3 { grid-template-columns: 1fr 1fr 1fr; } }
@media (max-width: 480px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.hint { font-size: 13px; color: var(--text-2); }
.text { margin-bottom: 12px; max-width: 68ch; }
.form-error { color: var(--red); background: var(--red-soft); padding: 8px 12px; border-radius: var(--r-control); font-size: 13px; }
.notice { background: var(--amber-soft); border-radius: var(--r-control); padding: 12px 12px; margin-bottom: 12px; max-width: 72ch; }
.ok-line { color: var(--green); font-weight: 500; margin-bottom: 8px; }
.btn-line { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- вход ---------- */

.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.login-box { width: min(360px, 100%); background: var(--surface); border-radius: 16px; padding: 32px 24px; box-shadow: 0 8px 24px rgba(0, 0, 0, .06); }
.login-box .login-logo { display: block; width: 200px; height: auto; margin: 0 auto 24px; }
.login-box h1 { font-size: 20px; line-height: 28px; font-weight: 500; margin-bottom: 16px; }
.login-box .form-error { margin-bottom: 12px; }

/* ---------- каркас ---------- */

.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100dvh; }
.side { background: var(--raised); border-right: 1px solid var(--line-soft); color: var(--text-2); display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100dvh; }
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 16px; font-weight: 600; color: var(--ink); font-size: 16px; }
.brand img { object-fit: contain; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: var(--r-control); color: inherit; text-decoration: none; }
.side nav a:hover { background: rgba(11, 31, 63, .06); color: var(--ink); }
.side nav a.on { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: 0 1px 2px rgba(0, 0, 0, .05); }
.side nav a.on .ic { color: var(--brand); }
.side-user { margin-top: 8px; padding: 8px; border-radius: var(--r-control); display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; position: relative; }
.side-user::before { content: ""; position: absolute; left: 0; right: 0; top: -5px; border-top: 1px solid var(--line-soft); }
.side-user:hover { background: rgba(11, 31, 63, .06); }
.side-user.on { background: var(--surface); box-shadow: 0 1px 2px rgba(6, 26, 58, .08); }
.side-user-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 18px; }
.side-user-text b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-text small { color: var(--muted); font-size: 12px; }
.side-user .ic { color: var(--muted); }
.side-user:hover .ic, .side-user.on .ic { color: var(--brand); }

.main-col { min-width: 0; display: flex; flex-direction: column; max-width: 1488px; }
.top { display: flex; align-items: center; gap: 12px; padding: 16px 24px 6px; }
.top h1 { font-size: 28px; line-height: 32px; font-weight: 500; flex: 1; }
.bell .badge {
  position: absolute; top: 0; right: 0; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 10px;
  background: var(--red); color: #fff; font-size: 12px; font-weight: 600; line-height: 20px; text-align: center;
}
#view { padding: 8px 24px 40px; outline: none; }
.tabs { display: none; }

@media (max-width: 760px) {
  .shell { display: block; }
  .side { display: none; }
  .top { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line-soft); padding: calc(8px + env(safe-area-inset-top)) 8px 8px 16px; }
  .top h1 { font-size: 18px; line-height: 24px; }
  #view { padding: 12px 12px calc(var(--tabs-h) + 28px + env(safe-area-inset-bottom)); }
  .tabs {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabs a, .tabs button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tabs-h);
    border: 0; background: none; color: var(--muted); text-decoration: none; font-size: 12px; padding: 0;
  }
  .tabs .on { color: var(--brand); font-weight: 500; }
}

/* ---------- панели, строки ---------- */

.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.bar .sel, .bar input[type=search], .bar input[type=date] { width: auto; min-width: 0; }
.bar input[type=search] { flex: 1 1 180px; max-width: 320px; }
.date-title { font-size: 18px; font-weight: 500; }
.stepper { display: flex; align-items: center; gap: 2px; }

.panel { background: var(--surface); border-radius: var(--r-panel); padding: 16px; margin-bottom: 16px; }
.panel.flush { padding: 4px 0; }
.panel > h3, .column > h3, .sub > h3 { font-size: 15px; font-weight: 500; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.panel.alert > h3 { color: var(--red); }
.count { font-size: 12px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.panel .rows { margin: 0 -16px -8px; }
.panel.flush .rows, .rows.panel.flush { margin: 0; }

.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line-soft);
  cursor: pointer; position: relative;
}
.rows > .row:first-child { border-top: 0; }
.row:hover { background: var(--raised); }
.row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-main strong { font-weight: 500; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 13px; color: var(--muted); }
.late-text { color: var(--red); font-weight: 500; }
.row.task.pr-high::before, .row.task.late::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 3px 0; background: var(--amber); }
.row.task.late::before { background: var(--red); }
.row.visit time { font-weight: 500; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; line-height: 1.2; min-width: 44px; }
.row.visit time small { color: var(--muted); font-weight: 400; }
.row.visit.st-no_show strong, .row.visit.st-cancelled strong { text-decoration: line-through; color: var(--muted); }
.row.inactive { opacity: .6; }
.order-no { font-weight: 500; color: var(--muted); min-width: 44px; font-variant-numeric: tabular-nums; }
.row .sum { font-weight: 500; }
@media (max-width: 760px) {
  .row { flex-wrap: wrap; gap: 6px 8px; padding: 12px 12px; }
  .row-main { flex-basis: calc(100% - 60px); }
  .row.task .row-main, .row.order .row-main { flex-basis: 100%; }
  .row.order .order-no { min-width: 0; }
  .panel { padding: 16px 12px; }
  .panel .rows { margin: 0 -12px -6px; }
}

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.chip.none { color: var(--muted); }
.dot { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 600; flex: none; }
.dot.big { width: 36px; height: 36px; font-size: 13px; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--bg); color: var(--muted); white-space: nowrap; }
.pill.ts-in_progress, .pill.os-in_progress, .pill.vs-arrived { background: var(--brand-soft); color: var(--brand-deep); }
.pill.ts-done, .pill.os-done, .pill.os-issued, .pill.vs-done { background: var(--green-soft); color: var(--green); }
.pill.os-waiting, .pill.vs-booked { background: var(--amber-soft); color: var(--amber-ink); }
.pill.os-new { background: var(--raised); color: var(--ink); }
.pill.late, .pill.vs-no_show { background: var(--red-soft); color: var(--red); }

.empty { padding: 24px 16px; color: var(--muted); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty.error { color: var(--red); }

/* ---------- шкала загрузки: деление = час ---------- */

.gauge { display: inline-flex; gap: 2px; }
.gauge .seg { display: block; position: relative; background: var(--line); border-radius: 2px; overflow: hidden; }
.gauge .seg b { display: block; position: absolute; left: 0; bottom: 0; background: var(--brand); }
.gauge.h .seg { width: 16px; height: 12px; }
.gauge.h .seg b { height: 100%; }
.gauge.v { flex-direction: column-reverse; width: 100%; max-width: 30px; }
.gauge.v .seg { width: 100%; height: 8px; }
.gauge.v .seg b { width: 100%; }
.gauge.high .seg b { background: var(--amber); }
.gauge.over .seg b, .gauge .seg.over b { background: var(--red); }
.gauge .seg.off { background: transparent; border: 1px dashed var(--line); }
.gauge.h .seg.off { width: 40px; }

.load-today { display: flex; flex-direction: column; }
.load-line { display: grid; grid-template-columns: minmax(120px, 220px) 1fr auto; align-items: center; gap: 12px; padding: 8px 0; color: inherit; text-decoration: none; }
.load-line + .load-line { border-top: 1px solid var(--line-soft); }
@media (max-width: 480px) {
  .load-line { grid-template-columns: 1fr auto; }
  .load-line .gauge { grid-column: 1 / -1; grid-row: 2; }
  .load-line .gauge.h .seg { flex: 1; width: auto; max-width: 28px; }
}

.load-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.load-card { margin: 0; }
.load-card header { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.load-card .pos { display: block; color: var(--muted); padding-left: 32px; }
.week-sum { text-align: right; font-size: 13px; color: var(--muted); }
.week-sum b { font-size: 18px; font-weight: 500; color: var(--ink); }
.week-sum.high b { color: var(--amber-ink); }
.week-sum.over b { color: var(--red); }
.week-sum small { display: block; }
.load-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; align-items: end; }
.load-cell {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; padding: 8px 2px 6px;
  border: 0; border-radius: var(--r-control); background: none; min-height: 132px;
}
.load-cell:hover { background: var(--bg); }
.load-cell.today { background: var(--brand-soft); }
.load-cell b { font-size: 13px; font-variant-numeric: tabular-nums; }
.load-cell b.over { color: var(--red); }
.load-cell small { font-size: 12px; color: var(--muted); }
.load-cell.dayoff small { opacity: .7; }
.load-card footer { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.day-sum { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-weight: 500; }

.legend { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 0 0 12px; }
.lg { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-left: 8px; }
.lg:first-child { margin-left: 0; }
.lg.seg-ok { background: var(--brand); } .lg.seg-high { background: var(--amber); } .lg.seg-over { background: var(--red); }
.lg.task { background: var(--surface); border: 1px solid var(--line); } .lg.visit { background: var(--amber-soft); border: 1px solid var(--amber); }

/* ---------- доска задач ---------- */

.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.column { background: var(--surface); border-radius: var(--r-panel); padding: 16px 0 4px; }
.column > h3 { padding: 0 16px; }
.seg-tabs { display: none; }
.seg-switch, .seg-tabs { background: var(--raised); border-radius: var(--r-control); padding: 4px; gap: 2px; }
.seg-switch { display: inline-flex; }
.seg-switch button, .seg-tabs button { border: 0; background: none; border-radius: 4px; padding: 4px 12px; font-size: 13px; line-height: 20px; color: var(--text-2); white-space: nowrap; }
.seg-switch button.on, .seg-tabs button.on { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: 0 1px 2px rgba(0, 0, 0, .05); }
@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; }
  .column { display: none; }
  .column.on { display: block; }
  .column > h3 { display: none; }
  .seg-tabs { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 12px; }
}

/* ---------- календарь ---------- */

.cal { background: var(--surface); border-radius: var(--r-panel); overflow-x: auto; }
.cal-row { display: grid; grid-template-columns: 50px repeat(var(--days), minmax(0, 1fr)); min-width: calc(50px + var(--days) * 104px); }
.cal.one .cal-row { min-width: 0; }
.cal-head { border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.day-head { border: 0; background: none; padding: 8px 4px; display: flex; align-items: baseline; justify-content: center; gap: 6px; border-left: 1px solid var(--line-soft); }
.day-head small { color: var(--muted); font-size: 13px; }
.day-head b { font-size: 18px; font-weight: 500; }
.day-head.today b { background: var(--brand); color: #fff; border-radius: 50%; min-width: 28px; height: 28px; display: inline-grid; place-items: center; font-size: 15px; }
.cal-due { border-bottom: 1px solid var(--line); }
.gutter { font-size: 12px; color: var(--muted); text-align: right; padding-right: 6px; }
.cal-due .gutter { padding-top: 8px; }
.due-cell { border-left: 1px solid var(--line-soft); padding: 4px 4px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.due-chip, .ev {
  border: 1px solid var(--line); border-left: 4px solid var(--c, var(--muted)); background: var(--surface); border-radius: 6px;
  font-size: 12px; line-height: 1.25; text-align: left; padding: 2px 6px; overflow: hidden; color: var(--ink);
}
.due-chip { white-space: nowrap; text-overflow: ellipsis; }
.due-chip.late, .ev.late { border-color: var(--red); border-left-color: var(--c); background: var(--red-soft); }
.due-chip.done, .ev.done { opacity: .55; text-decoration: line-through; }
.cal-body .gutter .hr { position: relative; }
.cal-body .gutter .hr span { position: absolute; top: -8px; right: 6px; }
.cal-body .gutter .hr:first-child span { top: 0; }
.day-col {
  position: relative; border-left: 1px solid var(--line-soft); cursor: cell;
  background-image: linear-gradient(to bottom, var(--line-soft) 1px, transparent 1px); background-size: 100% 48px;
}
.day-col.today { background-color: var(--bg); }
.ev { position: absolute; display: flex; flex-direction: column; cursor: pointer; z-index: 1; }
.ev small { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ev span { overflow: hidden; hyphens: auto; font-weight: 500; }
.ev.visit { background: var(--amber-soft); border-color: var(--line); border-left-color: var(--c); }
.ev.visit.st-done, .ev.visit.st-no_show { opacity: .6; }
.now { position: absolute; left: 0; right: 0; height: 2px; background: var(--red); z-index: 2; pointer-events: none; }
.now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 8px; }
.week-strip button { border: 0; background: var(--surface); border-radius: var(--r-control); padding: 6px 0; display: flex; flex-direction: column; align-items: center; }
.week-strip small { font-size: 12px; color: var(--muted); }
.week-strip b { font-weight: 500; }
.week-strip .today b { color: var(--brand); }
.week-strip .on { background: var(--brand); color: #fff; }
.week-strip .on small, .week-strip .on b { color: #fff; }

.month { background: var(--surface); border-radius: var(--r-panel); overflow: hidden; }
.m-head { display: grid; grid-template-columns: repeat(7, 1fr); font-size: 12px; color: var(--muted); text-align: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.m-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.m-cell { border: 0; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); background: none; min-height: 104px; padding: 6px; text-align: left; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.m-cell:nth-child(7n) { border-right: 0; }
.m-cell:hover { background: var(--raised); }
.m-cell.other b { color: var(--muted); }
.m-cell.today b { background: var(--brand); color: #fff; border-radius: 50%; width: 26px; height: 26px; display: inline-grid; place-items: center; }
.m-items { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.m-chip { display: flex; align-items: center; gap: 4px; font-size: 12px; min-width: 0; }
.m-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.m-chip.visit i { border-radius: 2px; }
.m-chip em { font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-more { font-size: 12px; color: var(--muted); }
@media (max-width: 760px) {
  .cal-bar .date-title { order: -1; flex-basis: 100%; }
  .cal.one .cal-head { display: none; }
  .seg-switch button { padding: 6px 8px; }
  .cal-bar .stepper .btn { padding: 0 8px; }
  .m-cell { min-height: 56px; padding: 4px; align-items: center; }
  .m-items { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 4px; }
  .m-chip em, .m-more { display: none; }
}

/* ---------- отчёты ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat { background: var(--surface); border-radius: var(--r-panel); padding: 16px 16px; display: flex; flex-direction: column; }
.stat b { font-size: 28px; font-weight: 500; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px 12px 6px 0; border-bottom: 1px solid var(--line); vertical-align: bottom; }
.table td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line-soft); }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th:not(:first-child) { text-align: right; }
.table th.wide-col { text-align: left; min-width: 160px; }
.bar-cell { display: flex; align-items: center; gap: 8px; }
.bar-cell i { height: 10px; border-radius: 2px; background: var(--brand); min-width: 2px; max-width: calc(100% - 30px); }
.bar-cell b { font-variant-numeric: tabular-nums; }

/* ---------- диалоги ---------- */

dialog.dlg { border: 0; padding: 0; border-radius: 16px; width: min(580px, calc(100vw - 32px)); max-height: min(92dvh, 900px); color: var(--ink); background: var(--surface); overflow: hidden; }
dialog.dlg.wide { width: min(880px, calc(100vw - 32px)); }
dialog.dlg::backdrop { background: rgba(6, 26, 58, .45); }
.dlg-box { display: flex; flex-direction: column; max-height: min(92dvh, 900px); }
.dlg-box > header { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px 20px; }
.dlg-box > header h2 { font-size: 18px; font-weight: 500; flex: 1; overflow-wrap: anywhere; }
.dlg-body { padding: 6px 20px 12px; overflow-y: auto; flex: 1 1 auto; }
.dlg-box > .form-error { margin: 0 20px 8px; }
.dlg-box > footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line-soft); }
.dlg-box > footer:empty { display: none; }
.confirm-text { font-size: 15px; padding: 6px 0 12px; }
dialog.side-panel { margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; border-radius: 0; width: min(420px, 100vw); }
dialog.side-panel .dlg-box { max-height: 100dvh; height: 100%; }
@media (max-width: 760px) {
  dialog.dlg, dialog.dlg.wide, dialog.side-panel {
    width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 16px 16px 0 0; max-height: 94dvh; height: fit-content;
  }
  .dlg-box, dialog.side-panel .dlg-box { max-height: 94dvh; }
  .dlg-box > header { padding-left: 16px; }
  .dlg-body { padding: 6px 16px 12px; }
  .dlg-box > footer { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .dlg-box > footer .btn.primary { flex: 1 1 auto; }
}

.view-title { font-size: 18px; font-weight: 500; margin-bottom: 6px; overflow-wrap: anywhere; }
.view-text { white-space: pre-wrap; margin-bottom: 12px; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 8px 0; }
.facts dt { color: var(--muted); font-size: 13px; padding-top: 2px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.sub { border-top: 1px solid var(--line-soft); padding: 16px 0 12px; }
.items-head, .item-row { display: grid; grid-template-columns: minmax(0, 1fr) 84px 110px 40px; gap: 6px; align-items: center; }
.items-head { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.item-row { margin-bottom: 6px; }
.items-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; }
.total { font-size: 15px; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .items-head { display: none; }
  .item-row { grid-template-columns: 1fr 1fr 40px; padding-bottom: 8px; border-bottom: 1px solid var(--line-soft); }
  .item-row [name=it_title] { grid-column: 1 / -1; }
}
.mini-task { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; border-top: 1px solid var(--line-soft); background: none; padding: 8px 0; text-align: left; }
.mini-task:first-child { border-top: 0; }
.mini-task:hover { background: var(--raised); }
[data-tasks] { margin-bottom: 8px; }
.dlg-body .rows { margin: 0; }

.checks, .swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.checks legend, .swatches legend { font-size: 13px; color: var(--muted); margin-bottom: 4px; padding: 0; }
.checks label { position: relative; }
.checks input, .swatches input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.checks span { display: grid; place-items: center; width: 40px; height: 36px; border: 1px solid var(--line); border-radius: var(--r-control); font-size: 13px; }
.checks input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }
.checks input:focus-visible + span, .swatches input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.swatches label { position: relative; }
.swatches span { display: block; width: 32px; height: 32px; border-radius: 50%; border: 4px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.swatches input:checked + span { box-shadow: 0 0 0 2px var(--ink); }
.check-line { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }

.menu { display: flex; flex-direction: column; }
.menu a { display: flex; align-items: center; gap: 12px; padding: 16px 4px; color: var(--ink); text-decoration: none; border-top: 1px solid var(--line-soft); font-size: 15px; }
.menu a:first-child { border-top: 0; }

.notes { display: flex; flex-direction: column; margin: 0 -20px; }
.note { display: flex; flex-direction: column; gap: 2px; text-align: left; border: 0; border-top: 1px solid var(--line-soft); background: none; padding: 12px 20px 12px 28px; position: relative; }
.note:first-child { border-top: 0; }
.note:hover { background: var(--raised); }
.note.new::before { content: ""; position: absolute; left: 10px; top: 18px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.note strong { font-weight: 500; }
.note span { color: var(--ink); overflow-wrap: anywhere; }
.note small { color: var(--muted); font-size: 12px; }

.me { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.me .chip { font-size: 18px; font-weight: 500; }
.pwd, .city { max-width: 360px; }
.pwd .form-error { margin-bottom: 12px; }
.pwd .hint, .city .hint { margin-top: 8px; }
.city { margin-top: 16px; }
.city .field { margin-bottom: 12px; }

/* ---------- всплывающие сообщения ---------- */

#toasts { border: 0; padding: 0; margin: 0; background: transparent; overflow: visible; inset: auto; top: auto; right: auto;
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 20px; z-index: 2147483000; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
@media (max-width: 760px) { #toasts { bottom: calc(var(--tabs-h) + 12px + env(safe-area-inset-bottom)); } }
.toast { pointer-events: auto; background: var(--ink); color: #fff; border: 0; border-radius: 8px; padding: 12px 16px; font-size: 13px; text-align: left; max-width: 100%; box-shadow: 0 8px 24px rgba(0, 0, 0, .06); }
.toast.error { background: var(--red); }
.toast.note { border-left: 4px solid var(--amber); }

/* ---------- печать заказ-наряда ---------- */

#print-root { display: none; }
@media print {
  @page { margin: 14mm; }
  html, body { background: #fff; height: auto; }
  #app, #toasts, dialog, dialog::backdrop { display: none !important; }
  #print-root { display: block; font-size: 12pt; color: #000; }
  .sheet-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #000; padding-bottom: 6pt; margin-bottom: 10pt; font-size: 14pt; }
  .sheet table { width: 100%; border-collapse: collapse; margin-bottom: 10pt; }
  .sheet-facts th { text-align: left; font-weight: 400; color: #444; width: 14%; padding: 3pt 0; }
  .sheet-facts td { width: 36%; padding: 3pt 0; font-weight: 500; }
  .sheet-items th, .sheet-items td { border: 1px solid #000; padding: 4pt 6pt; text-align: left; }
  .sheet-items td:nth-child(n+3), .sheet-items th:nth-child(n+3) { text-align: right; white-space: nowrap; }
  .sheet-items tfoot td { font-weight: 600; }
  .sheet-sign { display: flex; justify-content: space-between; margin-top: 28pt; }
}

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise 300ms var(--ease); }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } }
}

/* ---------- клиент из базы, каталог работ ---------- */

.client-box { background: var(--bg); border-radius: var(--r-control); padding: 12px 12px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.client-box .check-line { margin: 0; }
.client-linked { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-weight: 500; }
.client-find { display: flex; flex-direction: column; gap: 8px; }
.client-results:not(:empty) { background: var(--surface); border-radius: var(--r-control); padding: 0 12px; }
.client-cars { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.client-cars:empty { display: none; }
.sel.small { width: auto; max-width: 260px; }
.sel.small .sel-btn { min-height: 32px; padding: 4px 8px 4px 10px; font-size: 13px; }
.items-foot .btn-line { align-items: center; }
.sub > h3 .hint { font-weight: 400; }
.row.service .sum { min-width: 90px; text-align: right; }

.field.span2 { grid-column: span 2; }
@media (max-width: 480px) { .field.span2 { grid-column: auto; } }

/* ---------- кнопка «Позвонить» ---------- */

.phone-line { display: flex; gap: 6px; }
.phone-line input { flex: 1 1 auto; min-width: 0; }
.phone-fact { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }

/* ---------- движение ---------- */

@media (prefers-reduced-motion: no-preference) {
  .btn, .icon-btn, .row, .side nav a, .side-user, .sel-btn, .sel-opt, .tabs a, .tabs button, .mini-task, .note, .load-cell, .m-cell, .seg-switch button, .seg-tabs button {
    transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease), transform 150ms var(--ease);
  }
  .btn:active:not(:disabled) { transform: scale(.98); }
}

/* В колонках доски строка задачи складывается: название занимает всю ширину, исполнитель и кнопка — под ним */
.column .row { flex-wrap: wrap; gap: 8px 12px; }
.column .row-main { flex-basis: 100%; }
.row-main { min-width: 12ch; }

/* ---------- выпадающие списки ---------- */

.sel { position: relative; display: inline-flex; width: 100%; min-width: 0; vertical-align: middle; }
.sel-native { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; padding: 0; margin: 0; border: 0; opacity: 0; pointer-events: none; }
.sel-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; min-height: 40px; padding: 8px 10px 8px 12px;
  border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); color: var(--ink); text-align: left;
  font-size: 15px; line-height: 20px;
}
@media (max-width: 760px) { .sel-btn, .sel-opt { font-size: 16px; } }
.sel-btn:hover:not(:disabled) { border-color: rgba(11, 31, 63, .32); }
.sel-btn:focus-visible, .sel-btn.open { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.sel-btn:disabled { cursor: default; }
.sel-btn:disabled .sel-chev { visibility: hidden; }
.sel-val { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel-val.placeholder { color: var(--muted); }
.sel-chev { flex: none; color: var(--muted); }
.sel-btn.open .sel-chev { transform: rotate(180deg); color: var(--brand); }
.sel-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }

.sel-pop {
  position: fixed; inset: auto; margin: 0; z-index: 50; box-sizing: border-box; padding: 4px; overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
  box-shadow: 0 12px 32px rgba(6, 26, 58, .16), 0 2px 6px rgba(6, 26, 58, .08);
  font-size: 15px; line-height: 20px;
}
.sel-opt { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 8px 6px 10px; border-radius: 8px; cursor: pointer; user-select: none; }
@media (max-width: 760px) { .sel-opt { min-height: 44px; } }
.sel-opt.active { background: var(--raised); }
.sel-opt[aria-selected=true] { color: var(--brand-deep); font-weight: 500; }
.sel-opt.placeholder { color: var(--muted); }
.sel-opt[aria-disabled=true] { opacity: .5; cursor: default; }
.sel-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.sel-check { flex: none; color: var(--brand); visibility: hidden; }
.sel-opt[aria-selected=true] .sel-check { visibility: visible; }
@media (prefers-reduced-motion: no-preference) {
  .sel-chev { transition: transform 150ms var(--ease); }
  .sel-pop { animation: sel-in 120ms var(--ease); transform-origin: top; }
  .sel-pop.up { transform-origin: bottom; }
  @keyframes sel-in { from { opacity: 0; transform: scaleY(.96); } }
}

/* ---------- календарь на устройстве ---------- */

.cal-sync .sel { max-width: 360px; }
.cal-sync .btn-line { margin-top: 12px; align-items: center; }
.feeds { margin: 12px 0 0; border-top: 1px solid var(--line-soft); }
.feed { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.feed-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.feed-link { display: flex; gap: 6px; margin-bottom: 12px; }
.feed-link input { flex: 1 1 auto; min-width: 0; font-size: 13px; }
.steps { margin: 0 0 12px; padding-left: 20px; max-width: 64ch; }
.steps li { margin-bottom: 4px; }
