/* Call'n'Go — оформление. Мобильный экран — основной (МП работают с телефона),
   компьютер — расширение. Цвета — только через токены, тёмная тема по настройке устройства. */

:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --fg: #17212b;
  --muted: #5f6b78;
  --line: #dde3e9;
  --accent: #0f6e74;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1f1;
  --ok: #23804f;
  --ok-soft: #e3f3ea;
  --warn: #a35f00;
  --warn-soft: #fbf0de;
  --err: #b42318;
  --err-soft: #fbe7e5;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 2px 8px rgba(16, 24, 32, .04);
  --tap: 44px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161b; --surface: #1a2128; --surface-2: #222b33; --fg: #e6ebf0; --muted: #9aa6b2; --line: #2e3842;
    --accent: #4fb7bd; --accent-ink: #062224; --accent-soft: #163236;
    --ok: #5cc48b; --ok-soft: #173126; --warn: #e3a54c; --warn-soft: #362a16; --err: #f08c82; --err-soft: #3a1f1c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 var(--font);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px);
}
a { color: var(--accent); }
h1 { font-size: 22px; line-height: 1.25; margin: 0; text-wrap: balance; }
h2 { font-size: 17px; line-height: 1.3; margin: 0; }
h3 { font-size: 15px; margin: 0; }
p { margin: 0; }
ul { margin: 0; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.err { color: var(--err); }
.req { color: var(--err); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
        stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- каркас ----------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
}
.topbar-inner { max-width: 1040px; margin: 0 auto; height: 56px; display: flex; align-items: center; gap: 16px; }
.brand { font-weight: 700; color: var(--fg); text-decoration: none; letter-spacing: -.01em; white-space: nowrap; }
.brand b { color: var(--accent); }
.topnav { display: none; gap: 4px; flex: 1; overflow-x: auto; }
.topnav a { padding: 8px 12px; border-radius: 999px; color: var(--muted); text-decoration: none; white-space: nowrap; font-size: 15px; }
.topnav a:hover { background: var(--surface-2); color: var(--fg); }
.topnav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.usermenu { margin-left: auto; position: relative; }
.outbox-pill { margin-left: auto; border: 0; border-radius: 999px; padding: 8px 12px; background: var(--err-soft); color: var(--err);
               font: 600 13px var(--font); cursor: pointer; white-space: nowrap; }
.outbox-pill:not([hidden]) + .usermenu { margin-left: 8px; }
.usermenu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: var(--tap); color: var(--muted); }
.usermenu summary::-webkit-details-marker { display: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
          display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.usermenu .menu { position: absolute; right: 0; top: 48px; min-width: 220px; background: var(--surface); border: 1px solid var(--line);
                  border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; display: grid; gap: 2px; }
.usermenu .menu a, .usermenu .menu button {
  display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--fg); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; width: 100%;
}
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--surface-2); }
.usermenu .menu .who { padding: 6px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

main {
  max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px));
}

/* нижняя панель на телефоне */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar a, .tabbar summary {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted);
  text-decoration: none; font-size: 11px; cursor: pointer; list-style: none; height: 100%;
}
.tabbar summary::-webkit-details-marker { display: none; }
.tabbar .icon { width: 24px; height: 24px; }
.tabbar a.active, .tabbar details[open] summary { color: var(--accent); font-weight: 600; }
.tabbar details { position: relative; }
.tabbar .more {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 8px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 8px; display: grid; gap: 2px;
}
.tabbar .more a {
  flex-direction: row; justify-content: flex-start; gap: 12px; font-size: 16px; color: var(--fg); padding: 0 12px;
  min-height: 48px; border-radius: var(--radius-sm);
}
.tabbar .more a.active { background: var(--accent-soft); color: var(--accent); }

@media (min-width: 900px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  body { padding-bottom: 32px; }
  h1 { font-size: 26px; }
}

/* --- заголовок страницы ------------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }

/* --- карточки и раскладка ---------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.warn { border-color: var(--warn); background: var(--warn-soft); }
.card > h2:first-child, .card > .row-between:first-child { margin-bottom: 8px; }
details.card > summary { cursor: pointer; min-height: 28px; }
details.card[open] > summary { margin-bottom: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.inline > label { flex: 1 1 160px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* --- кнопки --------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 18px;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: var(--accent); color: var(--accent-ink);
  font: 600 15px/1 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.05); }
.btn.secondary { background: var(--surface); color: var(--accent); border-color: var(--line); }
.btn.secondary:hover { background: var(--accent-soft); }
.btn.danger { background: var(--err); color: #fff; }
.btn.block { width: 100%; }
.link {
  background: none; border: 0; color: var(--accent); cursor: pointer; padding: 6px 2px; font: inherit; text-decoration: none;
  min-height: 32px; display: inline-flex; align-items: center; gap: 6px;
}
.link:hover { text-decoration: underline; }
button:disabled, fieldset:disabled .btn { opacity: .55; cursor: not-allowed; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

/* --- формы ---------------------------------------------------------------------- */
label { display: block; font-size: 14px; color: var(--muted); }
label > input:not([type=checkbox]):not([type=radio]), label > select, label > textarea { margin-top: 6px; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg); font: 16px/1.4 var(--font);
}
textarea { min-height: 80px; resize: vertical; }
select[multiple] { min-height: 120px; padding: 6px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid var(--accent-soft); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; flex: none; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.field-title { font-size: 14px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 6px; }
div > strong:first-child { display: block; font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }

/* плашки-переключатели вместо мелких галочек */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.chips > label {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 14px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface); color: var(--fg); font-size: 15px; cursor: pointer; user-select: none;
}
.chips > label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chips > label > input { position: absolute; opacity: 0; pointer-events: none; }
.chips > label:has(input:focus-visible) { outline: 3px solid var(--accent-soft); }
fieldset:disabled .chips > label { cursor: default; opacity: .8; }
.chips > a { display: inline-flex; align-items: center; min-height: 36px; padding: 4px 14px; border-radius: 999px; text-decoration: none; }
.chips > a.pill { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); font-weight: 600; }
.chips > a.link { border: 1px solid var(--line); color: var(--fg); }

/* --- списки --------------------------------------------------------------------- */
.list { list-style: none; padding: 0; margin: 0; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list > li > a {
  display: flex; align-items: center; gap: 12px; padding: 12px 0; color: inherit; text-decoration: none; min-height: 56px; flex-wrap: wrap;
}
.list > li > a:hover { background: linear-gradient(90deg, transparent, var(--surface-2), transparent); }
.list > li.muted { padding: 12px 0; }
.list .grow { flex: 1 1 200px; min-width: 0; }
.list .title { font-weight: 600; color: var(--fg); display: block; }
.list .meta { color: var(--muted); font-size: 14px; display: block; }
.list .chev { color: var(--muted); margin-left: auto; }
/* строка списка с кнопкой справа (АКБ сотрудника «от имени») */
.list > li.with-action { display: flex; align-items: center; gap: 8px; }
.list > li.with-action > a { flex: 1 1 auto; min-width: 0; }
.list > li.export-row { flex-wrap: wrap; padding: 12px 0; }
.btn.star { min-width: 44px; padding-inline: 10px; font-size: 18px; }
.owner-pick select { min-height: 36px; border-radius: 999px; padding: 4px 12px; }

.event-row .time { width: 56px; flex: none; font-variant-numeric: tabular-nums; font-weight: 600; }
.event-row .time small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.type-dot { width: 10px; height: 36px; border-radius: 6px; background: var(--muted); flex: none; }
.type-Visit { background: #2f6fd6; }
.type-PharmacyVisit, .type-PharmacyRoundTable { background: #0f8a6b; }
.type-Vacation, .type-SickLeave, .type-PublicHoliday { background: #b7791f; }
.type-Meeting, .type-Training, .type-Conference, .type-RoundTable, .type-CyclicConference, .type-Commute { background: #7a5bd3; }

/* --- статусы -------------------------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; line-height: 1; padding: 6px 10px; border-radius: 999px;
        background: var(--surface-2); color: var(--muted); white-space: nowrap; font-weight: 600; }
.state-planned { background: var(--surface-2); color: var(--muted); }
.state-started, .state-ended { background: var(--warn-soft); color: var(--warn); }
.state-finished { background: var(--ok-soft); color: var(--ok); }
.state-cancelled { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }

/* --- сводка «Мой день» ------------------------------------------------------------ */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: center; }
.kpi b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi.alert b { color: var(--err); }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick a {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); color: var(--fg); text-decoration: none; text-align: center; font-size: 14px; font-weight: 600;
}
.quick a .icon { width: 26px; height: 26px; color: var(--accent); }
.quick a:hover { border-color: var(--accent); }

/* --- что показывать на каком экране ------------------------------------------------- */
.mobile-only { display: none !important; }
@media (max-width: 899px) {
  .mobile-only { display: flex !important; }
  .desktop-only { display: none !important; }
}

/* --- визит ---------------------------------------------------------------------- */
.actionbar.desktop-only { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.reschedule > summary { list-style: none; }
.reschedule > summary::-webkit-details-marker { display: none; }
.reschedule[open] { flex: 1 1 100%; display: flex; flex-direction: column; gap: 8px; }
.reschedule[open] > summary { align-self: flex-start; }
.visit-head .who { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.actionbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@media (max-width: 899px) {
  .actionbar.sticky {
    position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 8px); z-index: 15;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0,0,0,.12);
    padding: 10px;
  }
  .actionbar.sticky > form:first-child { flex: 1 1 100%; }
  .actionbar.sticky > form:first-child .btn { width: 100%; }
}
.steps {
  position: sticky; top: 56px; z-index: 10; display: flex; overflow-x: auto; background: var(--surface);
  border-bottom: 1px solid var(--line); scrollbar-width: none; margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
}
.steps a {
  flex: 1 0 auto; text-align: center; padding: 14px 12px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 16px;
  border-bottom: 3px solid transparent;
}
.steps a:hover, .steps a:focus { color: var(--accent); border-bottom-color: var(--accent); }
@media (min-width: 900px) { .steps { margin: 0; border-radius: var(--radius) var(--radius) 0 0; } }
/* переход по вкладкам визита не прячет заголовок раздела под шапкой и вкладками */
#goods, #people, #reference, #summary { scroll-margin-top: 120px; }
/* тема фармкружка — только когда отмечен фармкружок */
label:has(> input[name=round_table]:not(:checked)) + .round-topic { display: none; }
.status { font-size: 13px; color: var(--muted); }
.status .ok::before { content: "✓ "; }

.sku-group { display: flex; flex-direction: column; }
.sku-group h3 { margin: 12px 0 4px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.sku-row .sku-name { font-weight: 600; }
.sku-row .status, .thl-row .status, .commitment-row .status, .sample-row .status, .agreement-row .status { grid-column: 1 / -1; }
.thl-row fieldset, .commitment-row fieldset { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.sample-row fieldset, .agreement-row fieldset { display: grid; grid-template-columns: 1fr 96px 1fr; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.sample-row fieldset > span:first-child, .agreement-row fieldset > span:first-child { font-weight: 600; }
@media (max-width: 600px) {
  .sample-row fieldset, .agreement-row fieldset { grid-template-columns: 1fr 88px; }
  .sample-row select, .agreement-row select { grid-column: 1 / -1; }
}
.person { border-top: 1px solid var(--line); padding-top: 12px; }
.goal-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.goal-row:first-of-type { border-top: 0; }
.state-btn { min-height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; cursor: pointer; font: 600 14px var(--font); color: var(--fg); }
.state-btn.on { color: #fff; border-color: transparent; background: var(--muted); }
.state-btn.on.state-started { background: var(--warn); }
.state-btn.on.state-finished { background: var(--ok); }
.rating-group { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.rating-row { display: flex; gap: 10px; align-items: flex-start; color: var(--fg); font-size: 15px; padding: 6px 0; cursor: pointer; }
.rating-row input { margin-top: 2px; }

/* --- «Мой день» по макету ---------------------------------------------------------- */
.banner {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px; border-radius: var(--radius);
  background: var(--warn-soft); color: var(--warn); text-decoration: none; font-weight: 600;
}
.banner b { white-space: nowrap; }
.event-cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.event-card {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--fg); text-decoration: none;
}
.event-card:hover { border-color: var(--accent); }
.event-top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.event-top .type-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.event-state { color: var(--muted); font-size: 14px; }
.event-title { font-weight: 700; font-size: 17px; }
.event-meta { color: var(--muted); font-size: 14px; }
.state-card-started, .state-card-ended { border: 2px solid var(--accent); }
.state-card-started .event-state, .state-card-ended .event-state { color: var(--accent); font-weight: 700; }
.state-card-finished { background: var(--surface-2); box-shadow: none; }
.state-card-finished .event-title { color: var(--muted); }
.state-card-cancelled { opacity: .6; }
.plan-menu > summary { list-style: none; }
.plan-menu > summary::-webkit-details-marker { display: none; }
.plan-menu[open] > summary { margin-bottom: 10px; }
.day .event-card { padding: 10px 12px; box-shadow: none; }
.day .event-title { font-size: 15px; }

/* --- визит по макету: блоки, свёрнутые строки, итог, нижняя полоса ------------------ */
.section-title { font-size: 20px; margin-top: 8px; }
.center { text-align: center; }
.prev-box { background: var(--surface-2); border-radius: var(--radius); padding: 14px 16px; }
.plain { list-style: none; padding: 0; display: grid; gap: 4px; }
.segmented { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; gap: 8px; }
.segmented > label, .segmented > a { justify-content: center; text-align: center; border-radius: var(--radius-sm); min-height: var(--tap); }
.segmented > label:has(input:checked), .segmented > a.pill { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
details.fold { border-top: 1px solid var(--line); padding-top: 10px; }
.card > details.fold:first-child, details.card.fold { border-top: 1px solid var(--line); }
details.card.fold { padding-top: 16px; }
details.fold > summary { list-style: none; display: flex; justify-content: space-between; gap: 12px; align-items: center; cursor: pointer; min-height: 36px; font-weight: 600; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "›"; color: var(--muted); font-size: 22px; line-height: 1; transition: transform .15s; }
details.fold[open] > summary::after { transform: rotate(90deg); }
details.fold[open] > summary { margin-bottom: 10px; }
.fold-value { margin-left: auto; color: var(--accent); font-weight: 600; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.score b { font-size: 18px; color: var(--accent); }
.checklist .check-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.checklist .check-row:first-of-type { border-top: 0; }
.check-ok { color: var(--ok); font-weight: 600; }
.check-err { color: var(--err); font-weight: 600; }
.check-warn { color: var(--warn); font-weight: 600; }
.check-none { color: var(--muted); }
.visit-footer {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); z-index: 15;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border-top: 1px solid var(--line); margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
}
@media (min-width: 900px) { .visit-footer { bottom: 0; margin: 0; border: 1px solid var(--line); border-radius: var(--radius); } }
#save-indicator { font-size: 14px; font-weight: 600; }

/* товары: карточки (до 20 SKU) и компактная таблица (больше) */
.goods .sku-group { padding: 4px 16px; }
.goods .sku-group h3 { margin: 12px 0 4px; }
.sku-row fieldset { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 14px 0; border-top: 1px solid var(--line); }
.sku-group h3 + .sku-row fieldset { border-top: 0; }
.sku-head { display: flex; flex-direction: column; gap: 2px; }
.sku-head .hint { font-size: 14px; color: var(--muted); }
.pill.matrix { font-size: 11px; padding: 4px 8px; margin-left: 4px; vertical-align: middle; background: var(--accent-soft); color: var(--accent); }
.sku-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggle { display: flex !important; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 12px; border-radius: var(--radius-sm);
          background: var(--surface-2); color: var(--fg) !important; font-size: 15px !important; cursor: pointer; }
.toggle:has(input:checked) { background: var(--accent-soft); color: var(--accent) !important; font-weight: 600; }
.sku-extra { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sku-extra label { display: block !important; font-size: 13px !important; color: var(--muted) !important; }
.sku-extra input { min-height: 44px !important; margin-top: 4px !important; }
.goods-head { display: none; }
.goods.compact .goods-head { display: grid; grid-template-columns: 1fr 60px 72px; padding: 0 16px; font-size: 13px; color: var(--muted); text-align: center; }
.goods.compact .goods-head span:first-child { text-align: left; }
.goods.compact .sku-row fieldset { grid-template-columns: 1fr 132px; align-items: center; gap: 6px 8px; padding: 8px 0; }
.goods.compact .sku-head .hint { display: none; }
.goods.compact .sku-toggles { grid-template-columns: 60px 72px; gap: 0; }
.goods.compact .toggle { background: none; justify-content: center; padding: 0; min-height: var(--tap); }
.goods.compact .toggle span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.goods.compact .toggle input { width: 24px; height: 24px; }
.goods.compact .sku-extra, .goods.compact .sku-row .status { grid-column: 1 / -1; }
.goods.compact .sku-extra { display: none; }
.goods.compact .sku-row:has(input[name=is_available]:checked) .sku-extra,
.goods.compact .sku-row:focus-within .sku-extra,
.goods.compact .sku-row.has-values .sku-extra { display: grid; }
.goods.compact .sku-row:has(input[name=is_available]:checked) fieldset { background: var(--accent-soft); margin: 0 -16px; padding: 8px 16px; }

/* --- таблицы -------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 13px; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { border-top: 1px solid var(--line); padding: 10px 6px; vertical-align: top; }
tr:first-child td { border-top: 0; }
/* «Команда» на телефоне: заголовки переносятся, должность прячется — иначе последние столбцы уезжают вбок */
@media (max-width: 599px) {
  table.team th { white-space: normal; hyphens: manual; padding-inline: 4px; }
  table.team td { padding-inline: 4px; }
  table.team .position { display: none; }
}

/* --- календарь ---------------------------------------------------------------- */
.week { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.day { display: flex; flex-direction: column; gap: 8px; }
.day .chips > a { min-height: 32px; font-size: 14px; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.day h2 { font-size: 15px; text-transform: capitalize; }

/* --- уведомления ------------------------------------------------------------------ */
.toasts {
  position: fixed; left: 12px; right: 12px; z-index: 40; display: grid; gap: 8px; pointer-events: none;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px); list-style: none; margin: 0; padding: 0;
}
@media (min-width: 900px) { .toasts { left: auto; right: 24px; bottom: 24px; width: 380px; } }
.toast {
  pointer-events: auto; background: var(--fg); color: var(--bg); border-radius: var(--radius); padding: 12px 16px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  animation: toast-in .2s ease-out, toast-out .4s ease-in 6s forwards;
}
.toast.error { background: var(--err); color: #fff; animation: toast-in .2s ease-out; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* пустые состояния */
.empty { text-align: center; padding: 24px 12px; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; margin-bottom: 8px; }

/* вход */
.login { max-width: 380px; margin: 8vh auto 0; }
.login .brand { font-size: 24px; display: block; margin-bottom: 4px; }

/* Бывшие style="" в шаблонах (CSP без 'unsafe-inline') */
.sprite { display: none; }
.search-field { flex: 1 1 240px; }
ol.steps { padding-left: 20px; margin: 0; }
input.narrow { max-width: 100px; }
/* Индикатор htmx — вместо стилей, которые htmx вставлял сам */
.htmx-indicator { opacity: 0; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; transition: opacity 200ms ease-in; }
