/* ===== Инвентаризация: общие стили ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #0099A8; --primary-dark: #00849E; --accent: #f5a623;
  --bg: #f5f5f5; --card: #fff;
  --text: #001A34; --muted: #5a6b7d; --border: #e2e8f0; --ok: #16a34a; --err: #dc2626;
  --navy: #001A34;
  --radius: 10px;
}
html { -webkit-text-size-adjust: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.ping-result { font-size: 13px; font-weight: 600; margin-left: 6px; }
.ping-result.ok { color: var(--ok); }
.ping-result.err { color: var(--err); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
.center { text-align: center; }
.hidden { display: none !important; }
.small { font-size: 0.85em; }
.alert { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; padding: 12px 16px; border-radius: var(--radius); margin: 14px 0; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }

/* кнопки */
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--border); color: var(--text); padding: 9px 16px; border-radius: 8px; font-size: 14px; cursor: pointer; text-decoration: none; transition: .15s; }
.btn:hover { border-color: var(--primary); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.topbar .btn-ghost, .admin-topbar .btn-ghost { color: #cbd5e1; border-color: rgba(255,255,255,.3); }
.topbar .btn-ghost:hover, .admin-topbar .btn-ghost:hover { color: #fff; border-color: #fff; background: rgba(255,255,255,.12); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; justify-content: center; }

/* топбар */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 10px 16px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; font-size: 17px; text-decoration: none; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav-link { color: #cbd5e1; padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.nav-link:hover { background: #1e293b; color: #fff; text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip { color: #94a3b8; font-size: 13px; }
@media (max-width: 640px) { .nav-label { display: none; } .nav-link { font-size: 18px; padding: 6px 8px; } }

.container { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 20px; border-top: 1px solid var(--border); background: var(--card); }
.breadcrumbs { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.section-title { margin: 26px 0 12px; font-size: 18px; }
h1 { font-size: 24px; margin-bottom: 10px; }

/* статистика */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-num { font-size: 30px; font-weight: 800; color: var(--primary); }
.stat-label { color: var(--muted); font-size: 13px; }
.ok-card .stat-num { color: var(--ok); }
.miss-card .stat-num { color: var(--err); }
.warn-card .stat-num { color: #d97706; }

/* поиск */
.search-box { position: relative; margin-bottom: 8px; }
.search-box form { display: flex; gap: 8px; }
.search-box input { flex: 1; padding: 12px 16px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; }
.search-results { position: absolute; top: 100%; left: 0; right: 0; background: var(--card); border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.1); z-index: 40; overflow: hidden; }
.search-item { display: block; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.search-item:hover { background: #f8fafc; text-decoration: none; }
.si-name { font-weight: 600; display: block; }
.si-sub { color: var(--muted); font-size: 12px; }
.search-all { display: block; padding: 10px 16px; text-align: center; font-size: 13px; }
.search-empty { padding: 12px 16px; color: var(--muted); font-size: 14px; }

/* карточки видов и комнат */
.type-grid, .room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.type-card, .room-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-decoration: none; color: var(--text); transition: .15s; }
.type-card:hover, .room-card:hover { border-color: var(--primary); transform: translateY(-1px); text-decoration: none; box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.type-name, .room-name { font-weight: 600; font-size: 15px; }
.type-count { float: right; color: var(--primary); font-weight: 700; }
.room-loc { color: var(--muted); font-size: 12px; margin-top: 2px; }
.room-count { color: var(--muted); font-size: 12px; margin-top: 6px; }
.room-actions { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }

/* таблицы */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 10px 12px; background: #f8fafc; border-bottom: 1px solid var(--border); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
.table td { padding: 9px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f8fafc; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: #e2e8f0; color: #334155; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-registered { background: #dbeafe; color: #1e40af; }
.badge-repair { background: #fef3c7; color: #92400e; }
.badge-spare { background: #e2e8f0; color: #334155; }
.badge-written_off { background: #fee2e2; color: #991b1b; }
.badge-other { background: #ede9fe; color: #5b21b6; }
.badge-admin { background: #fee2e2; color: #991b1b; }
.badge-editor { background: #dbeafe; color: #1e40af; }
.badge-viewer { background: #e2e8f0; color: #334155; }

/* страница комнаты: схема */
.room-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.room-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.room-qr-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 8px 12px; background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius); }
.room-qr { width: 64px; height: 64px; border: 1px solid var(--border); border-radius: 6px; padding: 2px; background: #fff; flex-shrink: 0; }
.plan-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.plan-scroll { overflow: auto; max-height: 70vh; }
.plan-scroll svg { display: block; margin: 0 auto; max-width: 100%; height: auto; background: #fff; }
.plan-legend { margin-top: 8px; font-size: 13px; }

/* стили элементов схемы (общие для редактора и сайта) */
svg .wall { stroke: #334155; stroke-width: 4; stroke-linecap: round; }
svg .furn { fill: #e0f7f9; stroke: #0099A8; stroke-width: 2; rx: 4; }
svg .furn-circle { fill: #fff3e0; stroke: #f5a623; stroke-width: 2; }
svg .plabel { fill: #334155; font-size: 16px; font-weight: 600; user-select: none; }
svg .asset-dot { fill: #0099A8; stroke: #fff; stroke-width: 2.5; cursor: pointer; }
svg .asset-dot:hover { fill: #dc2626; }
svg .asset-label { fill: #00849E; font-size: 13px; font-weight: 600; pointer-events: none; }
svg .draft { opacity: .5; pointer-events: none; }
svg .selected { filter: drop-shadow(0 0 4px #2563eb); }
svg .show-grid { background-image: linear-gradient(#eee 1px, transparent 1px), linear-gradient(90deg, #eee 1px, transparent 1px); background-size: 20px 20px; }

/* карточка актива */
.item-card { display: grid; grid-template-columns: 220px 1fr 200px; gap: 20px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.item-photo img { width: 100%; border-radius: 8px; border: 1px solid var(--border); background: #f8fafc; }
.item-type-badge { display: inline-block; background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; padding: 3px 12px; border-radius: 999px; font-size: 13px; margin-bottom: 8px; }
.item-info h1 { font-size: 22px; margin-bottom: 12px; }
.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv td { padding: 6px 8px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.kv td:first-child { color: var(--muted); width: 42%; white-space: nowrap; }
.item-qr { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr-img { width: 200px; height: 200px; border: 1px solid var(--border); border-radius: 8px; padding: 6px; background: #fff; }
@media (max-width: 800px) {
  .item-card { grid-template-columns: 1fr; }
  .item-photo img { max-width: 220px; }
  .item-qr { order: 3; }
}

/* обход */
.round-layout { display: grid; grid-template-columns: 1fr 360px; gap: 16px; }
.scan-box { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4/3; }
.scan-box video { width: 100%; height: 100%; object-fit: cover; }
.scan-overlay { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(transparent 44%, rgba(37,99,235,.25) 44%, rgba(37,99,235,.25) 56%, transparent 56%); }
.scan-hint { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; color: #fff; font-size: 13px; text-shadow: 0 1px 3px rgba(0,0,0,.8); background: rgba(0,0,0,.35); padding: 4px; }
.scan-controls { display: flex; gap: 8px; margin: 10px 0; }
.scan-log { margin-top: 10px; max-height: 200px; overflow-y: auto; }
.log-item { font-size: 13px; padding: 4px 0; color: #334155; }
.log-item.ok { color: var(--ok); }
.log-item.err { color: var(--err); }
.progress-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.progress-num { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.progress-bar { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; background: var(--ok); border-radius: 999px; transition: width .3s; }
.asset-check-list { list-style: none; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.asset-check-list li { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.asset-check-list li:last-child { border-bottom: none; }
.asset-check-list .dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; flex-shrink: 0; }
.asset-check-list li.ok .dot { background: var(--ok); }
.asset-check-list li.miss .dot { background: var(--err); }
.li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.li-name { font-weight: 600; }
.li-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-badge { color: var(--ok); font-weight: 800; }
.li-badge.miss-badge { color: var(--err); }
.li-badge.moved-badge { color: #d97706; }
.asset-check-list li.moved { background: #fffbeb; }
.asset-check-list li.moved .dot { background: #f59e0b; }
.li-moved { color: #b45309; font-size: 12px; font-weight: 600; }
@media (max-width: 900px) { .round-layout { grid-template-columns: 1fr; } }

/* ===== Тревога: актив найден не в своём кабинете ===== */
.scan-alarm {
  position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
  background: rgba(64, 8, 8, .82); padding: 14px; overflow-y: auto;
  animation: sa-in .18s ease-out;
}
@keyframes sa-in { from { opacity: 0; } to { opacity: 1; } }
.sa-card {
  width: 100%; max-width: 460px; background: #fff; border-radius: 14px; padding: 18px;
  border: 4px solid #dc2626; box-shadow: 0 18px 50px rgba(0, 0, 0, .45); text-align: center;
}
.sa-icon { font-size: 46px; line-height: 1; animation: sa-pulse .9s infinite; }
@keyframes sa-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
.sa-title { font-size: 19px; font-weight: 900; color: #b91c1c; letter-spacing: .3px; margin: 6px 0 12px; }
.sa-asset { background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 3px; }
.sa-asset b { font-size: 17px; }
.sa-sub { color: #7f1d1d; font-size: 12.5px; }
.sa-rows { text-align: left; font-size: 14px; margin-bottom: 12px; }
.sa-row { display: flex; gap: 8px; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed #e2e8f0; }
.sa-lbl { color: var(--muted); }
.sa-room { font-weight: 700; }
.sa-room.no-room { color: #b45309; }
.sa-note { font-size: 13px; color: #7f1d1d; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; padding: 8px 10px; margin-bottom: 14px; text-align: left; }
.sa-actions { display: flex; flex-direction: column; gap: 8px; }
.sa-ok { background: #dc2626; border-color: #dc2626; color: #fff; padding: 13px; font-size: 15px; font-weight: 700; }
.sa-ok:hover { background: #b91c1c; }

/* формы и утилиты */
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea, .inline-form input, .inline-form select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; }
.field textarea { resize: vertical; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .inline-form { flex: 1; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 140px; }

/* логин */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #001A34, #00849E); }
.login-card { background: var(--card); border-radius: 14px; padding: 32px; width: 100%; max-width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-logo { font-size: 42px; text-align: center; margin-bottom: 8px; }
.login-card h1 { text-align: center; font-size: 22px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 20px; }

/* Блок решения для администратора внутри тревоги */
.sa-admin { margin-top: 10px; padding-top: 10px; border-top: 2px dashed #fecaca; display: flex; flex-direction: column; gap: 8px; }
.sa-admin-title { font-size: 12.5px; color: var(--muted); }
