:root {
    --bg: #16171b;
    --surface: #1e2025;
    --surface-2: #262930;
    --border: #34373f;
    --text: #eceef1;
    --text-secondary: #9a9ea8;
    --text-muted: #6b6f78;
    --accent: #5a7de8;
    --success: #3ba873;
    --danger: #d9534f;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1400px; margin: 0 auto; padding: 2rem 1.5rem; }

.two-col {
    display: grid;
    grid-template-columns: minmax(380px, .65fr) minmax(0, 1.35fr);
    gap: 1.5rem;
    align-items: start;
}
.two-col > div { min-width: 0; }
@media (max-width: 960px) { .two-col { grid-template-columns: 1fr; } }

.room-command-bar {
    display: grid; grid-template-columns: minmax(280px, .75fr) minmax(0, 1.25fr);
    gap: 1.5rem; align-items: center;
}
.room-command-primary { display: flex; gap: 14px; align-items: center; min-width: 0; }
.room-run-button { min-width: 180px; min-height: 44px; font-size: 14px; font-weight: 600; }
.room-run-status { min-width: 0; }
.room-run-status p { margin: 0; }
.room-run-status .hint { margin-top: 4px; }
.room-feed-command { min-width: 0; }
.room-feed-heading {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; margin-bottom: 8px;
}
.room-feed-heading .hint { margin: 2px 0 0; }
.room-feed-row { display: flex; gap: 8px; align-items: center; }
.room-feed-row input { flex: 1; min-width: 0; font-size: 12px; }
.room-settings-grid {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, .82fr);
    gap: 1rem; align-items: start;
}
.room-settings-grid-single { grid-template-columns: 1fr; }
.room-data-card { grid-column: 1; grid-row: 1; margin-bottom: 0; }
.room-building-form { grid-column: 2; grid-row: 1; min-width: 0; }
.room-building-card { margin-bottom: 0; }
.room-description-card { grid-column: 1 / -1; grid-row: 2; margin-bottom: 0; }
.room-description-editor { min-height: clamp(480px, 65vh, 760px); line-height: 1.45; }
.room-card-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.room-media-card { margin-top: 1rem; }

@media (max-width: 960px) {
    .room-command-bar { grid-template-columns: 1fr; gap: 1rem; }
    .room-settings-grid { grid-template-columns: 1fr; }
    .room-data-card { grid-column: 1; grid-row: auto; order: 1; }
    .room-building-form { grid-column: 1; grid-row: auto; order: 2; }
    .room-description-card { grid-column: 1; grid-row: auto; order: 3; }
}
@media (max-width: 560px) {
    .room-command-primary { align-items: stretch; flex-direction: column; }
    .room-run-button { width: 100%; }
    .room-feed-heading { align-items: flex-start; }
    .room-feed-row { align-items: stretch; flex-direction: column; }
    .room-description-editor { min-height: 70vh; }
}

.rooms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.rooms-grid .room-row { margin-bottom: 0; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 1.5rem; }
.tab {
    padding: 8px 16px; border-radius: var(--radius); font-size: 14px;
    border: 1px solid var(--border); color: var(--text-secondary);
}
.tab.active { background: var(--accent); color: white; border-color: var(--accent); }

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 1.25rem; margin-bottom: 1rem;
}
.card h3 { margin: 0 0 12px; font-size: 16px; font-weight: 500; }
.card p.hint { font-size: 12px; color: var(--text-muted); margin: 8px 0 0; }

label { font-size: 13px; color: var(--text-secondary); display: block; margin-bottom: 4px; }
/* input БЕЗ атрибута type — тоже текстовое поле: браузер по умолчанию
   рисует его белым и по своей ширине, поэтому селектор перечисляет и
   :not([type]) — иначе разметка без type="text" выпадает из темы. */
input[type=text], input[type=password], input:not([type]), textarea {
    width: 100%; background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text); border-radius: var(--radius); padding: 8px 10px; font-size: 14px;
    font-family: inherit;
}
textarea { min-height: 100px; resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }

.field { margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 1180px) { .grid-2 { grid-template-columns: 1fr; } }

.description-variables {
    display: grid; gap: 6px; margin: 8px 0;
}
.description-tag-reference {
    margin-bottom: 10px; padding: 10px; background: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--radius);
}
.description-tag-reference summary { color: var(--text-secondary); font-size: 13px; cursor: pointer; }
.description-variable-row {
    display: grid; grid-template-columns: minmax(165px, max-content) 1fr;
    gap: 10px; align-items: center;
}
.description-variable-row span { color: var(--text-muted); font-size: 12px; }
.description-variable-row button { padding: 5px 8px; font-size: 12px; text-align: left; }
.description-variable-row code { color: var(--text); }
.description-example { margin: 0 0 10px !important; }
.description-example code { color: var(--text-secondary); }
@media (max-width: 520px) {
    .description-variable-row { grid-template-columns: 1fr; gap: 3px; }
}

button, .btn {
    background: transparent; border: 1px solid var(--border); color: var(--text);
    border-radius: var(--radius); padding: 8px 14px; font-size: 13px; cursor: pointer;
    font-family: inherit;
}
button:hover, .btn:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: white; }
button.primary:hover { opacity: 0.9; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.room-row {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 16px; margin-bottom: 8px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 10px; }
.dot.ok { background: var(--success); }
.dot.off { background: var(--text-muted); }

.stat-label { font-size: 12px; color: var(--text-muted); margin: 0 0 2px; }
.stat-value { font-size: 20px; font-weight: 500; margin: 0; }

.template-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.template-thumb {
    width: 90px; height: 90px; border-radius: var(--radius); background: var(--surface-2);
    display: flex; align-items: center; justify-content: center; position: relative;
    font-size: 11px; color: var(--text-secondary); border: 1px solid var(--border);
}
.template-thumb form { position: absolute; top: 2px; right: 2px; }
.template-thumb button { padding: 2px 5px; font-size: 11px; border: none; background: var(--danger); color: white; }
.template-upload-box {
    width: 90px; height: 90px; border-radius: var(--radius); border: 1px dashed var(--border);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 11px; cursor: pointer; text-align: center;
}

.media-details { margin-top: 12px; }
.media-details summary { color: var(--text-secondary); font-size: 13px; cursor: pointer; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 8px; margin-top: 8px; }
.media-tile {
    position: relative; min-width: 0; padding: 6px; background: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--radius); cursor: grab;
}
.media-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; border-radius: 5px; }
.media-enabled { position: absolute; top: 10px; right: 10px; z-index: 2; }
.media-drag-handle {
    position: absolute; top: 9px; left: 9px; z-index: 2; padding: 1px 4px;
    color: white; background: rgba(0,0,0,.6); border-radius: 4px;
}
.media-tile-label { display: block; min-width: 0; margin-top: 5px; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-tile-label small { display: block; color: var(--text-muted); font-size: 10px; }

/* кому показывать фото: список видов из окон под карточкой. Свёрнут по
   умолчанию — у большинства картинок адресации нет, и раскрытые списки
   превратили бы сетку в простыню */
/* подпись на карточке площадки: адресация задаётся на проекте, здесь
   только видно, почему фото уходит не всем квартирам */
.media-tile-views { display: block; margin-top: 3px; font-size: 10px; color: var(--accent); }

.template-cards-row { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 12px; scroll-snap-type: x proximity; }
.template-card {
    position: relative; flex: 0 0 300px; max-width: 300px; padding: 10px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
    scroll-snap-align: start;
}
.zone-editor { position: relative; width: 100%; background: #0000000d; }
.zone-editor-img { width: 100%; display: block; border-radius: 4px; }
.template-card-body { margin-top: 8px; }
.template-filename { margin: 0 0 6px; font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-form { display: flex; gap: 8px; align-items: flex-start; flex-direction: column; }
.zone-status { font-size: 12px; color: var(--text-muted); }
.room-category-picker { width: 100%; margin: 0; padding: 8px; border: 1px solid var(--border); border-radius: 6px; }
.room-category-picker legend { padding: 0 4px; color: var(--text-secondary); font-size: 12px; }
.room-category-picker label { display: inline-flex; align-items: center; gap: 4px; margin: 3px 8px 3px 0; font-size: 12px; cursor: pointer; }
.template-replace-form { display: grid; gap: 6px; margin-top: 10px; }
.template-replace-form input[type=file] { width: 100%; font-size: 11px; color: var(--text-secondary); }
.template-delete-form { position: absolute; top: 10px; right: 10px; z-index: 3; }
.template-delete-form button { background: rgba(22,23,27,.8); }
.template-warning { color: var(--danger); font-size: 12px; margin: 6px 0 0; }

.flash { background: var(--surface-2); border-left: 3px solid var(--accent); padding: 8px 12px; margin-bottom: 1rem; border-radius: 4px; font-size: 13px; }

.breadcrumb { font-size: 13px; color: var(--text-secondary); margin-bottom: 1rem; }
.breadcrumb .current { color: var(--text); font-weight: 500; }

.success-box {
    background: rgba(59,168,115,0.12); border-radius: var(--radius); padding: 12px 16px;
    display: flex; justify-content: space-between; align-items: center; margin-top: 1rem;
}
.success-box p { color: var(--success); margin: 0; font-size: 13px; }

.template-cards-stack { display:grid; gap:18px; }
.template-card-wide { width:100%; max-width:none; padding:0; overflow:hidden; flex:auto; }
.template-card-header { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px 16px; border-bottom:1px solid var(--border); flex-wrap:wrap; }
.template-card-header > div { display:flex; align-items:center; gap:9px; flex-wrap:wrap; }
.template-header-actions { display:flex; gap:8px; }
.template-status { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; padding:4px 8px; border-radius:999px; }
.template-status-active { color:#70e3a1; background:rgba(35,180,100,.14); }
.template-status-draft { color:#ffd166; background:rgba(255,193,7,.12); }
.template-status-disabled { color:var(--text-muted); background:rgba(128,128,128,.12); }
.template-editor-grid { display:grid; grid-template-columns:minmax(320px, 1fr) minmax(430px, 1.15fr); gap:18px; padding:16px; }
.template-card-wide .zone-editor { width:100%; align-self:start; }
.template-card-wide .template-card-body { margin:0; }
.template-card-wide .template-delete-form { position:static; margin:0 16px 16px; }
.zone-box { touch-action:none; }
.zone-box-label { position:absolute; z-index:3; font-size:11px; font-weight:700; line-height:1; padding:4px 6px; color:#071216; background:#00e0ff; }
.zone-box-label { left:-2px; top:-22px; }
.zone-center-mark { position:absolute; left:50%; top:50%; width:10px; height:10px; margin:-5px; border:1px solid #fff; border-radius:50%; background:#00e0ff; box-shadow:0 0 0 1px rgba(0,0,0,.4); pointer-events:none; }
.box-handle { position:absolute; z-index:5; width:15px; height:15px; padding:0; border:2px solid #fff; border-radius:50%; background:currentColor; color:#00e0ff; touch-action:none; }
.box-handle-nw { left:-8px; top:-8px; cursor:nwse-resize; }
.box-handle-ne { right:-8px; top:-8px; cursor:nesw-resize; }
.box-handle-se { right:-8px; bottom:-8px; cursor:nwse-resize; }
.box-handle-sw { left:-8px; bottom:-8px; cursor:nesw-resize; }
.center-lock { display:flex; align-items:center; gap:7px; font-size:12px; color:var(--text-secondary); cursor:pointer; }
.text-zone-box { position:absolute; z-index:4; display:flex; box-sizing:border-box; border:2px dashed #ff4fd8; background:rgba(255,79,216,.13); overflow:visible; cursor:move; touch-action:none; outline:none; padding:8px; }
.text-zone-box.is-selected { border-style:solid; box-shadow:0 0 0 2px rgba(255,255,255,.75); z-index:6; }
.text-zone-box .box-handle { color:#ff4fd8; opacity:0; }
.text-zone-box.is-selected .box-handle { opacity:1; }
.text-zone-area { border-color:#a78bfa; background:rgba(167,139,250,.13); }
.text-zone-area .box-handle { color:#a78bfa; }
.text-zone-group { border-color:#ffb020; background:rgba(255,176,32,.14); }
.text-zone-group .box-handle { color:#ffb020; }
.text-zone-label { position:absolute; left:-2px; top:-23px; padding:4px 6px; color:#fff; background:#ff4fd8; border-radius:4px 4px 0 0; font:700 11px/1 sans-serif; white-space:nowrap; }
.text-zone-area .text-zone-label { background:#7c5ce1; }
.text-zone-group .text-zone-label { background:#b86c00; }
.text-zone-sample { display:block; max-width:100%; line-height:1.05; white-space:nowrap; overflow:hidden; pointer-events:none; }
.text-group-preview { display:flex; align-items:baseline; max-width:none; overflow:visible; }
.text-group-preview > span { display:block; white-space:nowrap; }

/* Страница проекта: обзор сверху, настройки — по тематическим вкладкам. */
.project-header { display:flex; justify-content:space-between; align-items:flex-end; gap:20px; margin-bottom:18px; }
.project-header h2 { margin:2px 0 0; font-size:26px; }
.project-eyebrow { margin:0; color:var(--text-muted); font-size:12px; text-transform:uppercase; letter-spacing:.08em; }
.project-header-actions { display:flex; align-items:flex-end; gap:8px; flex-wrap:wrap; }
.project-picker-label { margin:0; }
.project-picker-label span { display:block; margin-bottom:4px; color:var(--text-muted); font-size:11px; }
.project-picker-label select { min-width:180px; }
.project-health { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; margin-bottom:18px; }
.project-health > div { display:grid; gap:3px; min-height:88px; padding:14px 16px; background:var(--surface); border:1px solid var(--border); border-radius:12px; }
.project-health span,.project-health small { color:var(--text-muted); font-size:12px; }
.project-health strong { font-size:18px; font-weight:600; }
.project-platforms { margin-bottom:22px; }
.section-heading,.card-heading { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; margin-bottom:14px; }
.section-heading h3,.card-heading h3 { margin:0 0 4px; }
.section-heading .hint,.card-heading .hint { margin:0; }
.platform-add-form,.upload-row { display:flex; align-items:center; gap:8px; }
.project-room-card { min-height:68px; }
.project-room-title { display:flex; align-items:center; }
.project-room-title p { margin:0; font-size:14px; font-weight:600; }
.project-room-title small { color:var(--text-muted); font-size:12px; }
.project-settings-tabs { position:sticky; top:0; z-index:20; display:flex; gap:6px; padding:10px 0; margin-bottom:10px; overflow-x:auto; background:var(--bg); }
.project-settings-tab { flex:0 0 auto; }
.project-settings-tab.active { color:#fff; background:var(--accent); border-color:var(--accent); }
.project-settings-panel { display:none; }
.project-settings-panel.active { display:block; }
.project-data-form { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; align-items:start; }
.project-settings-card { margin:0; }
.project-data-form .project-save-bar { grid-column:1/-1; }
.status-pill { display:inline-flex; align-items:center; padding:4px 8px; color:var(--text-secondary); background:var(--surface-2); border:1px solid var(--border); border-radius:999px; font-size:11px; white-space:nowrap; }
.mono-input { font:12px ui-monospace,SFMono-Regular,Consolas,monospace !important; }
.settings-details { margin-top:12px; border-top:1px solid var(--border); padding-top:10px; }
.settings-details summary { display:flex; justify-content:space-between; gap:12px; color:var(--text-secondary); cursor:pointer; font-size:13px; }
.settings-details summary span { color:var(--text-muted); }
.settings-details-body { margin-top:12px; }
.toggle-label { display:flex; align-items:center; gap:9px; color:var(--text); cursor:pointer; }
.project-save-bar { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:14px; padding:12px 14px; color:var(--text-muted); background:var(--surface); border:1px solid var(--border); border-radius:10px; font-size:12px; }
.building-table { display:grid; gap:8px; }
.building-table-head,.building-table-row { display:grid; grid-template-columns:minmax(90px,.5fr) minmax(280px,2fr) minmax(120px,1fr) minmax(120px,1fr); gap:8px; align-items:center; }
.building-table-head { padding:0 8px; color:var(--text-muted); font-size:12px; }
.building-table-row { padding:10px; background:var(--surface-2); border-radius:9px; }
.building-table-row strong { font-size:13px; }
.empty-state { padding:28px; color:var(--text-muted); text-align:center; background:var(--surface-2); border:1px dashed var(--border); border-radius:9px; }
.media-kind { position:absolute; left:3px; bottom:3px; padding:2px 5px; color:#fff; background:rgba(0,0,0,.65); border-radius:4px; font-size:10px; }
.collapsible-card { margin-top:14px; }
.collapsible-card > summary { display:flex; justify-content:space-between; align-items:center; cursor:pointer; }
.collapsible-card > summary span:first-child { display:grid; gap:3px; }
.collapsible-card > summary small { color:var(--text-muted); font-size:11px; }
.collapsible-card-body { margin-top:14px; padding-top:14px; border-top:1px solid var(--border); }
.font-upload-grid { display:grid; grid-template-columns:1fr 1fr auto; gap:8px; align-items:center; }
.promotion-list { display:grid; gap:6px; }
.promotion-row { display:flex; align-items:flex-start; gap:10px; padding:10px 12px; margin:0; color:var(--text); background:var(--surface-2); border-radius:8px; cursor:pointer; }
.promotion-row span { display:grid; gap:2px; }
.promotion-row small { color:var(--text-muted); }
.promotion-row.is-inactive { opacity:.62; }
.inactive-view-toggle { margin-bottom:12px; }
.window-view-table-wrap { overflow:auto; }
.window-view-table { width:100%; border-collapse:collapse; font-size:13px; }
.window-view-table th,.window-view-table td { padding:9px 8px; border-top:1px solid var(--border); text-align:left; }
.window-view-table th:not(:first-child),.window-view-table td:not(:first-child) { text-align:center; }
.window-view-table td small { display:block; color:var(--text-muted); font-size:10px; }
.window-view-table:not(.show-inactive) tr.is-inactive { display:none; }
.window-view-table tr.is-inactive { opacity:.55; }
.danger-zone { margin-top:16px; color:var(--text-muted); }
.danger-zone summary { cursor:pointer; font-size:12px; }
.danger-zone > div { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-top:8px; padding:12px; border:1px solid rgba(217,83,79,.35); border-radius:8px; }
.danger-zone p { margin:0; font-size:12px; }
.danger-button { color:#ff8e8a; border-color:rgba(217,83,79,.55); }

@media (max-width:900px) {
    .project-header { align-items:flex-start; flex-direction:column; }
    .project-health { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .project-data-form { grid-template-columns:1fr; }
    .project-data-form .project-save-bar { grid-column:auto; }
    .building-table-head { display:none; }
    .building-table-row { grid-template-columns:1fr 1fr; }
    .building-table-row strong { grid-column:1/-1; }
}
@media (max-width:560px) {
    .project-health { grid-template-columns:1fr; }
    .project-header-actions,.platform-add-form,.upload-row,.project-save-bar { align-items:stretch; flex-direction:column; width:100%; }
    .project-picker-label select { width:100%; }
    .section-heading { align-items:flex-start; flex-direction:column; }
    .building-table-row,.font-upload-grid { grid-template-columns:1fr; }
}
.zone-editor.is-drawing-layer { cursor:crosshair; }
.zone-editor.is-drawing-layer::after { content:'Протяни рамку для тега'; position:absolute; left:10px; bottom:10px; z-index:20; padding:6px 9px; color:#fff; background:rgba(0,0,0,.75); border-radius:5px; font-size:12px; pointer-events:none; }
.new-layer-ghost { position:absolute; z-index:20; box-sizing:border-box; border:2px solid #ff4fd8; background:rgba(255,79,216,.2); pointer-events:none; }
.new-layer-ghost.text-zone-area { border-color:#a78bfa; background:rgba(167,139,250,.2); }
.new-layer-ghost span { position:absolute; left:0; top:-22px; padding:4px 6px; color:#fff; background:#111; font-size:11px; white-space:nowrap; }
.range-field { display:grid; grid-template-columns:auto 1fr; gap:6px 12px; align-items:center; margin:12px 0; width:100%; }
.range-field output { justify-self:end; color:var(--text-secondary); }
.range-field input { grid-column:1 / -1; width:100%; }
.text-layer-settings { width:100%; margin:14px 0; border-top:1px solid var(--border); padding-top:12px; }
.text-layer-settings summary { cursor:pointer; font-weight:700; }
.text-layer-panel { margin:10px 0; border:1px solid var(--border); border-radius:10px; background:rgba(255,255,255,.018); }
.text-layer-panel.is-selected { border-color:var(--accent); }
.text-layer-panel > summary { display:flex; align-items:center; gap:8px; padding:11px 12px; }
.text-layer-panel > summary code { margin-left:auto; color:var(--text-muted); font-weight:400; }
.layer-color-dot { width:11px; height:11px; border-radius:3px; border:1px solid rgba(255,255,255,.55); }
.text-layer-form { margin:0; padding:12px; border-top:1px solid var(--border); }
.text-layer-form label { display:grid; gap:5px; font-size:12px; color:var(--text-secondary); }
.layer-style-grid { display:grid; grid-template-columns:minmax(180px,1.4fr) minmax(130px,.7fr) minmax(165px,.9fr); gap:10px; margin:10px 0; }
.group-layout-grid { display:grid; grid-template-columns:repeat(2,minmax(160px,1fr)); gap:10px; margin:10px 0; padding:10px; border:1px solid rgba(255,176,32,.35); border-radius:8px; background:rgba(255,176,32,.05); }
.layer-color-control { display:grid; grid-template-columns:44px 1fr; gap:7px; }
.layer-color-picker { width:44px; min-width:44px; height:36px; padding:3px; cursor:pointer; }
.layer-color-hex { min-width:0; font-family:ui-monospace,SFMono-Regular,Consolas,monospace; text-transform:uppercase; }
.layer-advanced { margin-top:10px; padding:9px 10px; border:1px solid var(--border); border-radius:7px; }
.layer-advanced > summary { color:var(--text-secondary); font-size:12px; }
.layer-advanced small { color:var(--text-muted); font-size:10px; }
.layer-actions { display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin-top:10px; }
.layer-actions label { display:flex; align-items:center; gap:6px; }
.layer-actions button { margin-left:auto; }
.layer-secondary-actions { display:flex; gap:8px; padding:0 12px 12px; }
.layer-secondary-actions form { margin:0; }
.layer-remove-form { padding:0; }
.layer-remove-form button { color:#ff7b83; }
.layer-add-toolbar { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.layer-add-form { margin:0; }
.layer-draw-help { margin-top:8px; }
.small-number { width:80px; }
.template-preview-panel { width:100%; margin:14px 0; padding:12px; border:1px solid var(--border); border-radius:10px; box-sizing:border-box; }
.preview-controls { display:flex; gap:8px; margin:9px 0; }
.preview-controls select { flex:1; min-width:0; }
.template-render-preview { display:block; width:100%; max-height:560px; object-fit:contain; border-radius:8px; background:#111; }
.template-render-preview:not([src]) { display:none; }

@media (max-width: 900px) {
    .template-editor-grid { grid-template-columns:1fr; }
    .layer-style-grid { grid-template-columns:1fr; }
    .group-layout-grid { grid-template-columns:1fr; }
}

/* ---- Реестр помещений ---- */
.registry-sources { display:flex; flex-wrap:wrap; gap:10px; align-items:stretch; margin-bottom:1.25rem; }
.registry-source { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:10px 14px; min-width:160px; display:flex; flex-direction:column; gap:2px; }
.registry-source span { font-size:12px; color:var(--text-muted); }
.registry-source strong { font-size:18px; font-weight:500; }
.registry-source small { font-size:11px; color:var(--text-secondary); }
.registry-source.is-missing { opacity:.6; border-style:dashed; }
.registry-refresh { margin-left:auto; display:flex; flex-direction:column; gap:6px; justify-content:center; max-width:360px; }
.registry-refresh small { font-size:11px; color:var(--text-muted); }
.registry-refresh small.registry-error { color:#ff8e8a; }
.registry-filters { display:grid; grid-template-columns:repeat(5, minmax(130px, 1fr)) auto; gap:10px; align-items:end; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:12px 14px; margin-bottom:1rem; }
.registry-filters label { display:flex; flex-direction:column; gap:4px; font-size:12px; color:var(--text-muted); }
.registry-filters select { background:var(--surface-2); color:var(--text); border:1px solid var(--border); border-radius:6px; padding:7px 8px; font-size:13px; font-family:inherit; min-width:0; }
.registry-filter-actions { display:flex; gap:8px; flex-wrap:wrap; }
.registry-filter-actions .btn[aria-disabled="true"] { opacity:.4; pointer-events:none; }
.registry-summary { display:grid; grid-template-columns:repeat(auto-fit, minmax(170px, 1fr)); gap:10px; margin-bottom:1rem; }
.registry-summary > div { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:10px 14px; display:flex; flex-direction:column; gap:2px; }
.registry-summary span { font-size:12px; color:var(--text-muted); }
.registry-summary strong { font-size:20px; font-weight:500; }
.registry-summary small { font-size:11px; color:var(--text-secondary); }
.registry-table-wrap { overflow:auto; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); }
.registry-table { width:100%; border-collapse:collapse; font-size:12.5px; white-space:nowrap; }
.registry-table th, .registry-table td { padding:7px 10px; border-bottom:1px solid var(--border); text-align:left; }
.registry-table th { position:sticky; top:0; background:var(--surface-2); color:var(--text-secondary); font-weight:500; font-size:11.5px; cursor:pointer; user-select:none; }
.registry-table th[data-dir="asc"]::after { content:" ↑"; }
.registry-table th[data-dir="desc"]::after { content:" ↓"; }
.registry-table td.num, .registry-table th[data-kind="num"] { text-align:right; font-variant-numeric:tabular-nums; }
.registry-table tbody tr:hover { background:var(--surface-2); }
.registry-table .status-chip { display:inline-block; padding:1px 8px; border-radius:10px; font-size:11px; background:var(--surface-2); border:1px solid var(--border); }
.registry-table tr.status-available .status-chip { color:#8fd9b1; border-color:rgba(59,168,115,.5); }
.registry-table tr.status-booked .status-chip { color:#f0c674; border-color:rgba(240,198,116,.5); }
.registry-table tr.status-sold .status-chip { color:var(--text-muted); }
.registry-table tr.status-unavailable .status-chip { color:#ff8e8a; border-color:rgba(217,83,79,.5); }
@media (max-width: 960px) {
    .registry-filters, .registry-summary { grid-template-columns:1fr 1fr; }
    .registry-filter-actions { grid-column:1/-1; }
    .registry-refresh { margin-left:0; max-width:none; }
}


/* ---- Медиа проекта: карточки и окно «Кому показывать» ---- */
.media-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(200px, 1fr)); gap:12px; margin-top:10px; }
.media-card { position:relative; background:var(--surface-2); border:1px solid var(--border); border-radius:10px; overflow:hidden; display:flex; flex-direction:column; }
.media-card.is-targeted { border-color:rgba(90,125,232,.55); }
.media-card-image { position:relative; aspect-ratio:4/3; background:#000; }
.media-card-image img { width:100%; height:100%; object-fit:cover; display:block; }
.media-card-image .media-kind { position:absolute; left:8px; bottom:8px; }
.media-card-remove { position:absolute; top:6px; right:6px; opacity:0; transition:opacity .15s; }
.media-card:hover .media-card-remove, .media-card:focus-within .media-card-remove { opacity:1; }
.media-card-remove button { width:26px; height:26px; padding:0; border:none; border-radius:50%; background:rgba(22,23,27,.85); color:#ff8e8a; font-size:16px; line-height:1; }
.media-card-body { display:flex; flex-direction:column; gap:8px; padding:10px; }
.media-chips { display:flex; flex-wrap:wrap; gap:4px; min-height:22px; }
.media-chip { display:inline-block; padding:2px 8px; border-radius:10px; font-size:11px; background:rgba(90,125,232,.16); color:#b9c8f5; border:1px solid rgba(90,125,232,.35); white-space:nowrap; max-width:100%; overflow:hidden; text-overflow:ellipsis; }
.media-chip.is-all { background:transparent; color:var(--text-muted); border-color:var(--border); }
.media-card-edit { width:100%; padding:6px 10px; font-size:12px; }
.media-dialog { border:1px solid var(--border); border-radius:12px; background:var(--surface); color:var(--text); padding:0; width:min(680px, calc(100vw - 32px)); }
.media-dialog::backdrop { background:rgba(0,0,0,.6); }
.media-dialog-head { display:grid; grid-template-columns:160px 1fr; gap:14px; padding:16px 18px; border-bottom:1px solid var(--border); align-items:center; }
.media-dialog-head img { width:160px; height:120px; object-fit:cover; border-radius:8px; }
.media-dialog-head h4 { margin:0 0 4px; font-size:15px; }
.media-dialog-head .hint { margin:0; }
.media-dialog-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; padding:16px 18px; }
.media-fieldset { border:1px solid var(--border); border-radius:10px; padding:10px 12px 12px; min-width:0; display:flex; flex-direction:column; gap:8px; }
.media-fieldset legend { padding:0 6px; font-size:12px; color:var(--text-secondary); }
.media-fieldset legend small { color:var(--text-muted); }
.media-fieldset .field { display:flex; flex-direction:column; gap:4px; font-size:12px; color:var(--text-muted); margin:0; }
.media-fieldset .field input, .media-fieldset .field select { background:var(--surface-2); color:var(--text); border:1px solid var(--border); border-radius:6px; padding:7px 8px; font-size:13px; font-family:inherit; width:100%; }
.media-view-list { display:flex; flex-direction:column; gap:2px; max-height:260px; overflow:auto; }
.media-view-option { display:grid; grid-template-columns:auto 1fr auto; gap:8px; align-items:center; padding:6px 8px; border-radius:6px; font-size:13px; cursor:pointer; }
.media-view-option:hover { background:var(--surface-2); }
.media-view-option small { color:var(--text-muted); font-size:11px; }
.media-dialog-actions { display:flex; justify-content:flex-end; gap:8px; padding:12px 18px 16px; border-top:1px solid var(--border); }
@media (max-width: 640px) {
    .media-dialog-grid, .media-dialog-head { grid-template-columns:1fr; }
    .media-dialog-head img { width:100%; height:160px; }
}

.description-variable-row em { color:var(--text-muted); font-style:normal; }
.tag-coverage { width:100%; border-collapse:collapse; font-size:12px; margin-top:6px; }
.tag-coverage td { padding:4px 8px; border-top:1px solid var(--border); vertical-align:top; color:var(--text-secondary); }
.tag-coverage td.num { text-align:right; white-space:nowrap; font-variant-numeric:tabular-nums; color:var(--text); }
.tag-coverage tr.is-partial td.num { color:#f0c674; }
.tag-coverage tr.is-empty td { color:#ff8e8a; }
.tag-coverage code { color:var(--text); }

.desc-length-report { margin-top:8px; }
.desc-length-report.is-over { color:#ff8e8a; }
