/* Единая дизайн-система (раздел 11 ТЗ). Без внешних шрифтов и CDN. */
:root {
  --bg: #F5F7FB;
  --surface: #FFFFFF;
  --text: #162033;
  --muted: #536176;
  --primary: #2458D3;
  --primary-dark: #1B45A8;
  --primary-soft: #EAF0FC;
  --border: #E2E7F0;
  --border-strong: #CBD3E1;
  --success: #187244;
  --success-soft: #E5F4EC;
  --warning: #946200;
  --warning-soft: #FBF1DC;
  --danger: #BE3540;
  --danger-soft: #FBE9EA;
  --info: #5B3FB0;
  --info-soft: #EFEAFB;
  --radius: 12px;
  --radius-sm: 8px;
  --space: 8px;
  --sidebar: 224px;
  --topbar: 64px;
  --shadow-pop: 0 12px 32px rgba(22, 32, 51, .16), 0 2px 6px rgba(22, 32, 51, .08);
  --focus: 0 0 0 3px rgba(36, 88, 211, .35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font);
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 8px; }
small, .muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right, .table th.right, .table td.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.icon { flex: none; vertical-align: -3px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.skip-link { position: absolute; left: 8px; top: -60px; background: var(--primary); color: #fff; padding: 8px 16px; border-radius: 8px; z-index: 100; }
.skip-link:focus { top: 8px; }

/* --- Каркас ------------------------------------------------------------- */
.layout { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 700; font-size: 15px; color: var(--text); }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted);
  font-weight: 550; min-height: 44px;
}
.nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.nav-bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 8px; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar); background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
}
.topbar .search { flex: 1; max-width: 420px; position: relative; }
.topbar .search input { padding-left: 36px; }
.topbar .search .icon { position: absolute; left: 11px; top: 12px; color: var(--muted); }
.topbar-spacer { flex: 1; }
.topbar .menu-toggle, .topbar .hide-desktop { display: none; }
.nav-backdrop { display: none; }
main { padding: 24px; flex: 1; min-width: 0; }
.container-narrow { max-width: 760px; }

/* --- Заголовок страницы ------------------------------------------------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.context-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--primary-soft);
  color: var(--primary); font-size: 13px; font-weight: 600;
}
.breadcrumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.breadcrumbs a { color: var(--muted); }

/* --- Кнопки и поля ------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 40px; padding: 0; }
.btn[disabled], .btn.htmx-request { opacity: .6; cursor: progress; }
.btn-group { display: inline-flex; gap: 0; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 10px 0 0 10px; }
.btn-group .btn:last-child { border-radius: 0 10px 10px 0; }
.btn-group .btn + .btn { margin-left: -1px; }
.btn-group .btn[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); z-index: 1; }

input[type=text], input[type=search], input[type=email], input[type=tel], input[type=number], input[type=password],
input[type=date], input[type=datetime-local], input[type=time], input[type=file], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--primary); vertical-align: -3px; }
.form { display: grid; gap: 16px; max-width: 720px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.field label, .field .label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.field .req { color: var(--danger); }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.field .error { font-size: 13px; color: var(--danger); margin-top: 4px; display: flex; gap: 6px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-top: 4px; }
.form-error { background: var(--danger-soft); color: var(--danger); padding: 10px 14px; border-radius: 10px; display: flex; gap: 8px; }
.form-warning { background: var(--warning-soft); color: var(--warning); padding: 10px 14px; border-radius: 10px; }
.form-context { background: var(--bg); border: 1px solid var(--border); padding: 8px 12px; border-radius: 10px; font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0; }
legend { font-weight: 650; padding: 0 6px; }

/* --- Карточки и показатели ---------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 17px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 16px 20px 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); align-items: start; }
.stack { display: grid; gap: 16px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.metric {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  color: var(--text); min-width: 0;
}
a.metric:hover { border-color: var(--primary); text-decoration: none; }
.metric .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.metric .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: break-word; }
.metric .value .num { overflow-wrap: anywhere; }
.metric .value .unit { font-size: .6em; font-weight: 600; color: var(--muted); white-space: nowrap; }
.metric .hint { font-size: 13px; color: var(--muted); margin-top: 2px; }
.metric.tone-danger .value { color: var(--danger); }
.metric.tone-success .value { color: var(--success); }
.kv { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.bar { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; display: flex; }
.bar span { display: block; height: 100%; }
.bar .b-contract { background: var(--primary); }
.bar .b-booked { background: #8E7BD6; }
.bar .b-blocked { background: #D9A441; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* --- Статусы ------------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 13px; font-weight: 600;
  line-height: 20px; white-space: nowrap; background: var(--bg); color: var(--muted); border: 1px solid var(--border);
}
.badge .icon { width: 14px; height: 14px; vertical-align: 0; }
.tone-success.badge { background: var(--success-soft); color: var(--success); border-color: transparent; }
.tone-warning.badge { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.tone-danger.badge { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tone-primary.badge { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.tone-info.badge { background: var(--info-soft); color: var(--info); border-color: transparent; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }

/* --- Таблицы ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #FAFBFD; }
.table .row-title { font-weight: 600; color: var(--text); }
.table .row-sub { font-size: 13px; color: var(--muted); }
.table .actions { text-align: right; white-space: nowrap; }
tr.flash, .flash { animation: flash 1.4s ease-out; }
@keyframes flash { from { background: #FFF6D6; } to { background: transparent; } }

/* --- Фильтры и вкладки --------------------------------------------------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .field { min-width: 150px; }
.filters .field label { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.filters .grow { flex: 1 1 220px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px;
}
.chip:hover { text-decoration: none; border-color: var(--primary); }
.chip[aria-current="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip .count { font-size: 12px; background: rgba(0,0,0,.06); border-radius: 999px; padding: 0 7px; }
.chip[aria-current="true"] .count { background: rgba(255,255,255,.25); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: thin; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }

/* --- Список/лента ------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; }
.list > li:last-child { border-bottom: none; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; }
.list .meta { font-size: 13px; color: var(--muted); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 32px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.feed .ficon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); color: var(--muted); }
.feed .ficon.contact { background: var(--success-soft); color: var(--success); }
.feed .ficon.attempt { background: var(--warning-soft); color: var(--warning); }
.feed .fhead { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.feed .ftimes { font-size: 13px; color: var(--muted); }
.timeline {
  display: flex; flex-wrap: wrap; gap: 6px 4px; align-items: center; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; font-size: 14px;
}
.timeline .step { display: inline-flex; gap: 6px; align-items: center; }
.timeline .step b { font-variant-numeric: tabular-nums; }
.timeline .sep { color: var(--border-strong); margin: 0 4px; }
.timeline .missing { color: var(--muted); }
.timeline .late { color: var(--danger); }

/* --- Объекты ------------------------------------------------------------- */
.prop-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.prop-card { display: flex; flex-direction: column; gap: 10px; color: var(--text); }
.prop-card:hover { border-color: var(--primary); text-decoration: none; }
.prop-card .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.prop-card .name { font-weight: 650; font-size: 16px; }
.prop-card .addr { font-size: 13px; color: var(--muted); }
.prop-card .nums { display: flex; gap: 16px; font-size: 14px; flex-wrap: wrap; }
.prop-card .signal { font-size: 13px; display: flex; gap: 6px; align-items: center; }
.pin { color: var(--muted); }
.pin[aria-pressed="true"] { color: var(--warning); }
.floor-grid { display: grid; gap: 16px; }
.floor-row h3 { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.unit-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.unit-tile {
  display: block; border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: 10px; padding: 10px 12px;
  background: var(--surface); color: var(--text); font-size: 13px; text-align: left; cursor: pointer; font-family: inherit; width: 100%;
}
.unit-tile:hover { border-color: var(--primary); }
.unit-tile .no { font-weight: 700; font-size: 15px; }
.unit-tile.st-free { border-left-color: var(--success); }
.unit-tile.st-booked { border-left-color: var(--info); }
.unit-tile.st-signed { border-left-color: var(--primary); }
.unit-tile.st-occupied { border-left-color: var(--muted); }
.unit-tile.st-overdue { border-left-color: var(--danger); }
.unit-tile.st-blocked, .unit-tile.st-planned_release { border-left-color: var(--warning); }

/* --- Канбан -------------------------------------------------------------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col { background: #EEF1F7; border-radius: var(--radius); padding: 10px; min-height: 120px; }
.kanban-col h3 { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; margin: 4px 4px 10px; }
.kanban-col.drop-target { outline: 2px dashed var(--primary); }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: 14px; }
.kcard[draggable="true"] { cursor: grab; }
.kcard .t { font-weight: 600; }

/* --- Боковая панель, всплывающие элементы ------------------------------ */
.panel-backdrop { position: fixed; inset: 0; background: rgba(22, 32, 51, .32); z-index: 40; }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--surface); z-index: 41;
  box-shadow: var(--shadow-pop); display: flex; flex-direction: column;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: 18px; }
.panel-body { padding: 20px; overflow-y: auto; flex: 1; }
.panel .form { max-width: none; }
[hidden] { display: none !important; }
.popover {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 8px; min-width: 300px; max-width: min(420px, 92vw);
}
.popover .item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--text); min-height: 40px; }
.popover .item:hover, .popover .item:focus { background: var(--bg); text-decoration: none; }
.popover .item.active { background: var(--primary-soft); color: var(--primary); }
.popover .group { font-size: 12px; color: var(--muted); font-weight: 650; padding: 8px 10px 4px; text-transform: uppercase; letter-spacing: .03em; }
.rel { position: relative; }
.obj-switch { display: inline-flex; align-items: center; gap: 8px; max-width: 280px; }
.obj-switch span.lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bell { position: relative; }
.bell .count { position: absolute; top: 2px; right: 2px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 4px; }
.workday-chip { font-size: 13px; }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(440px, 92vw); }
.toast { background: var(--text); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-pop); display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.toast.error { background: var(--danger); }
.toast button { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 8px; padding: 4px 10px; cursor: pointer; font: inherit; }
.messages { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.messages li { padding: 10px 14px; border-radius: 10px; background: var(--success-soft); color: var(--success); font-weight: 600; }
.messages li.error { background: var(--danger-soft); color: var(--danger); }
.messages li.warning { background: var(--warning-soft); color: var(--warning); }

/* --- Пустые состояния, загрузка ---------------------------------------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .icon { width: 40px; height: 40px; color: var(--border-strong); margin-bottom: 8px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.loader { height: 3px; position: fixed; top: 0; left: 0; right: 0; z-index: 70; opacity: 0; background: linear-gradient(90deg, transparent, var(--primary), transparent); background-size: 200% 100%; }
.htmx-request .loader, .loader.htmx-request { opacity: 1; transition: opacity .1s .15s; animation: loading 1s linear infinite; }
@keyframes loading { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.results { transition: opacity .1s .15s; }
.results.htmx-request { opacity: .55; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.pager .btns { display: flex; gap: 8px; align-items: center; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(400px, 100%); }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; margin: 0 0 8px; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.attention li .grow .title a { color: var(--text); }
.print-only { display: none; }

/* --- Адаптивность ------------------------------------------------------- */
@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; z-index: 50; transform: translateX(-100%); transition: transform .15s; box-shadow: var(--shadow-pop); }
  body.nav-open .sidebar { transform: none; }
  .nav-backdrop { position: fixed; inset: 0; background: rgba(22, 32, 51, .32); z-index: 45; }
  body.nav-open .nav-backdrop { display: block; }
  .topbar .menu-toggle, .topbar .hide-desktop { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .search { display: none; }
  .topbar .search.open { display: block; position: absolute; left: 8px; right: 8px; top: 10px; max-width: none; }
  .obj-switch { max-width: 150px; }
  .hide-mobile { display: none !important; }
  main { padding: 16px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
  .btn, .chip, .nav a { min-height: 44px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
  .chip { flex: none; }
  /* Таблицы превращаются в карточки */
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { border-bottom: 1px solid var(--border); padding: 10px 14px; }
  table.cards td { border: none; padding: 3px 0; }
  table.cards td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 13px; }
  table.cards td.actions { text-align: left; padding-top: 8px; }
  .panel { width: 100vw; }
  .popover { position: fixed; left: 8px; right: 8px; top: 64px; min-width: 0; max-width: none; }
}
@media (max-width: 560px) {
  .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric { padding: 12px; }
  .metric .value { font-size: 18px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  #main .btn { white-space: normal; max-width: 100%; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
@media print {
  .sidebar, .topbar, .page-actions, .no-print, .filters, .chips, .tabs, .loader, .toasts { display: none !important; }
  .layout { display: block; }
  main { padding: 0; }
  body { background: #fff; }
  .card { border: none; padding: 0; }
  .print-only { display: block; }
}
