/* Парковка «Офис мечты» — стили
   Палитра: бетон + цвета парковочной навигации */
:root {
  --concrete: #E6E9E7;
  --panel: #FFFFFF;
  --line: #CDD3D0;
  --ink: #262626;
  --head: #2B2B2B;      /* шапка — нейтральный тёмный, без синего */
  --orange: #F26722;    /* корпоративный оранжевый */
  --orange-dark: #D4520F;
  --muted: #6B6B6B;
  --blue: #1F4FD8;      /* сотрудник */
  --blue-soft: #DCE5FB;
  --amber: #DF9410;     /* гость */
  --amber-soft: #FBEBC9;
  --green: #2A9466;     /* свободно */
  --green-soft: #DDF1E6;
  --slate: #6E7B8C;     /* резерв */
  --red: #C33A2E;
  --radius-s: 6px;
  --radius-l: 14px;
  --font: "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--concrete); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

/* ---------- шапка */
.top { display: flex; align-items: center; gap: 24px; height: 56px; padding: 0 20px;
  background: var(--head); color: #fff; position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 600; font-size: 16px; white-space: nowrap; letter-spacing: .01em; }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tabs button { background: none; border: 0; color: #CFCFCF; padding: 8px 12px; border-radius: var(--radius-s);
  cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: #fff; background: rgba(255,255,255,.08); }
.tabs button.active { color: #fff; background: rgba(255,255,255,.14); box-shadow: inset 0 -2px 0 var(--orange); }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.top .btn.ghost { color: #fff; border-color: rgba(255,255,255,.3); }
.top .btn.ghost:hover { background: rgba(255,255,255,.1); }

/* ---------- кнопки и поля */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--panel); cursor: pointer;
  text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--slate); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); }
.btn.danger { color: var(--red); border-color: #E8B8B3; }
.btn.danger:hover { background: #FBEDEB; }
.btn.ghost { background: transparent; }
.btn.icon { width: 36px; height: 36px; padding: 0; font-size: 18px; }
.btn.small { padding: 3px 9px; font-size: 13px; }
input, select, textarea { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 7px 10px;
  background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--orange); outline: none; }

main { height: calc(100vh - 56px); }
.tab { display: none; height: 100%; }
.tab.active { display: flex; flex-direction: column; }

/* ---------- схема */
.scheme { display: grid; grid-template-columns: 84px 1fr 360px; height: 100%; }
.elevator { background: #333333; display: flex; flex-direction: column; align-items: center;
  padding: 18px 0; gap: 14px; }
.floor-btn { width: 58px; height: 58px; border-radius: 50%; border: 2px solid #5E5E5E; background: #424242;
  color: #D6D6D6; font-size: 19px; font-weight: 600; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; line-height: 1; font-variant-numeric: tabular-nums; }
.floor-btn small { font-size: 11px; font-weight: 400; margin-top: 4px; color: #A8A8A8; }
.floor-hint { color: #9A9A9A; font-size: 10px; text-align: center; line-height: 1.2; }
.floor-btn:hover { border-color: #9A9A9A; color: #fff; }
.floor-btn.active { background: #fff; color: var(--ink); border-color: #fff;
  box-shadow: 0 0 0 4px rgba(255,255,255,.18); }
.floor-btn.active small { color: var(--muted); }

.plan-wrap { position: relative; overflow: hidden; background: #FAFBFA; cursor: grab; touch-action: none; }
.plan-wrap.dragging { cursor: grabbing; }
#plan { width: 100%; height: 100%; display: block; user-select: none; }
.plan-tools { position: absolute; right: 14px; top: 14px; display: flex; flex-direction: column; gap: 6px; }
.plan-tools .btn { box-shadow: 0 1px 2px rgba(29,39,51,.15); }

.pl { stroke-width: 3; cursor: pointer; transition: fill-opacity .12s; }
.pl.moto { stroke-dasharray: 10 6; stroke-width: 4; }
.pl:hover { filter: brightness(.92); }
.pl.selected { stroke: #111 !important; stroke-width: 9; stroke-dasharray: none; }
.pl.found { stroke: #111 !important; stroke-width: 9; animation: pulse 1s ease-in-out 3; }
@keyframes pulse { 50% { stroke-opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .pl.found { animation: none; } }
.pl-label { font-family: var(--font); font-weight: 600; fill: #fff; pointer-events: none; paint-order: stroke;
  stroke: rgba(0,0,0,.55); stroke-width: 4px; }
.pl-code { font-family: var(--font); font-weight: 700; fill: #1E1E1E; pointer-events: none; paint-order: stroke;
  stroke: #fff; stroke-width: 5px; stroke-linejoin: round; }
.hide-labels .labels { display: none; }

.tooltip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; padding: 6px 10px;
  border-radius: var(--radius-s); font-size: 13px; max-width: 280px; z-index: 5; }
.tooltip b { font-variant-numeric: tabular-nums; }

/* ---------- правая панель */
.side { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 16px 18px 24px; }
.search { position: relative; margin-bottom: 18px; }
.search input { width: 100%; }
.search-results { position: absolute; left: 0; right: 0; top: 40px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-s); box-shadow: 0 6px 18px rgba(29,39,51,.15); z-index: 10; max-height: 340px; overflow: auto; }
.search-results button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px;
  cursor: pointer; border-bottom: 1px solid #EEF1EF; }
.search-results button:hover { background: #FDEBDD; }
.search-results .sr-sub { color: var(--muted); font-size: 12px; }

.floor-title { font-size: 28px; font-weight: 600; margin: 0; font-variant-numeric: tabular-nums; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; margin: 12px 0 6px; }
.stat-row div { background: #fff; padding: 8px 10px; }
.stat-row b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat-row span { color: var(--muted); font-size: 12px; }
.legend { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 10px; }
.sw { display: inline-block; width: 22px; height: 14px; border-radius: 3px; border: 2px solid transparent; flex: none;
  vertical-align: -2px; margin-right: 8px; }
.sw.free { background: #E3E5E8; border-color: #9AA1A8; }
.sw.guest { background: repeating-linear-gradient(45deg,#E5772E 0 4px,#fff 4px 7px); border-color: #E5772E; }
.sw.reserved { background: repeating-linear-gradient(45deg,#fff 0 3px,#8C9298 3px 5px); border-color: #5B6168; }
.sw.moto { background: #fff; border-style: dashed; border-color: var(--ink); }
.legend-num { font-weight: 700; width: 22px; margin-right: 8px; text-align: center; }
.small { font-size: 12px; }
/* цвета зон: A–G как в файле коллеги, H–L — только на −2 и −3 */
.sw.z-A { background: #2E75B6; } .sw.z-B { background: #5E9E3A; } .sw.z-C { background: #D9A400; }
.sw.z-D { background: #7B5EA7; } .sw.z-E { background: #E5772E; } .sw.z-F { background: #16A096; }
.sw.z-G { background: #C0392B; } .sw.z-H { background: #C2417F; } .sw.z-I { background: #4A5BC4; }
.sw.z-J { background: #8A6A3D; } .sw.z-K { background: #0E8CB8; } .sw.z-L { background: #7C9417; }
.chip.z-A { background: #DDEBF7; } .chip.z-B { background: #E2EFDA; } .chip.z-C { background: #FFF2CC; }
.chip.z-D { background: #E4DFEC; } .chip.z-E { background: #FCE4D6; } .chip.z-F { background: #D9F2EF; }
.chip.z-G { background: #F8CBAD; } .chip.z-H { background: #F6DCE9; } .chip.z-I { background: #E0E3F7; }
.chip.z-J { background: #EDE3D6; } .chip.z-K { background: #D6EDF6; } .chip.z-L { background: #E8EED3; }
.zones h3, .card h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 18px 0 6px; }
.zone-line { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px solid #EEF1EF;
  cursor: pointer; }
.zone-line:hover { color: var(--orange-dark); }
.zone-line > span:first-child { display: flex; align-items: center; }
.zone-line span:last-child { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }

.card .place-no { font-size: 34px; font-weight: 600; margin: 0; font-variant-numeric: tabular-nums; }
.status-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-pill.free { background: #ECEEF0; color: #4E555C; }
.status-pill.employee { background: #DDEBF7; color: #1F4E79; }
.status-pill.guest { background: var(--amber-soft); color: #8A5A00; }
.status-pill.reserved { background: #E7EAEE; color: #4A5665; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 10px; margin: 12px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.car { padding: 6px 0; border-bottom: 1px solid #EEF1EF; }
.plate { font-weight: 600; letter-spacing: .03em; font-variant-numeric: tabular-nums; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.back-link { background: none; border: 0; color: var(--orange-dark); cursor: pointer; padding: 0; margin-bottom: 10px; }
.assign-box { margin-top: 14px; padding: 12px; background: #F4F6F5; border-radius: var(--radius-s); display: grid; gap: 8px; }

/* ---------- таблицы */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 20px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.toolbar .filter { width: 360px; max-width: 100%; }
.toolbar .count { color: var(--muted); margin-right: auto; }
.table-wrap { flex: 1; overflow: auto; padding: 0 20px 24px; }
table.grid { width: 100%; border-collapse: collapse; background: var(--panel); margin-top: 14px;
  border: 1px solid var(--line); }
.grid th { position: sticky; top: 0; background: #F1F3F2; text-align: left; font-weight: 600; font-size: 13px;
  padding: 8px 10px; border-bottom: 1px solid var(--line); z-index: 1; white-space: nowrap; }
.grid td { padding: 7px 10px; border-bottom: 1px solid #EEF1EF; vertical-align: top; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover td { background: #FFF6EF; }
.grid th.sortable { cursor: pointer; user-select: none; }
.grid th.sortable:hover { background: #E8EAE9; }
.grid th.sorted { color: var(--orange-dark); }
.grid th .arr { font-size: 10px; margin-left: 4px; }
.grid td.num, .grid th.num { width: 48px; min-width: 48px; color: var(--muted); }
table.grid.fixed td.num { text-overflow: clip; }
.grid .center { text-align: center; }
.grid .nowrap { white-space: nowrap; }
.grid td.note { max-width: 240px; }
.carline { min-height: 21px; line-height: 21px; white-space: nowrap; }
.corp { color: var(--orange-dark); font-weight: 700; cursor: help; }
.grid tr.undone td { color: #9A9A9A; }
.grid .sub.warn, .warn { color: var(--red); }
.grid .sub { color: var(--muted); font-size: 12px; }
.grid .empty-cell { color: #A9B2BC; }
.grid tr.expired td { background: #FDF1EF; }
.chip { display: inline-block; padding: 1px 8px; margin: 1px 4px 1px 0; border-radius: 999px; background: #ECEEF0;
  color: var(--ink); font-size: 12px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip.guest { background: var(--amber-soft); color: #8A5A00; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 0 0 4px; font-weight: 700; }
.place-stats { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 20px 0; }
.place-stats div { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 14px; }
.place-stats b { font-size: 18px; margin-right: 6px; font-variant-numeric: tabular-nums; }

/* ---------- сводка */
.summary { overflow: auto; padding: 20px; display: grid; gap: 20px; align-content: start; }
.summary-top { display: grid; gap: 20px; grid-template-columns: repeat(4, 1fr); align-items: stretch; }
.summary-zones { display: grid; gap: 20px; grid-template-columns: repeat(3, 1fr); align-items: stretch; }
.summary .zone-cell { white-space: nowrap; display: inline-flex; align-items: center; }
.summary .zone-card { display: flex; flex-direction: column; }
.summary .zone-card table.totals { margin-top: auto; padding-top: 14px; }
.summary .zone-card .totals td { border-bottom: 1px solid #EEF1EF; }
.summary .zone-card .totals tr:first-child td { border-top: 2px solid var(--line); }
.summary .indent { padding-left: 14px; color: var(--muted); }
.summary .hint, .dict .hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.summary .zone-card table:first-of-type td:first-child { width: 60%; }
@media (max-width: 1400px) { .summary-top { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 1200px) { .summary-zones { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .summary-top { grid-template-columns: 1fr; } }
.summary section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 16px 18px; }
.summary h2 { font-size: 16px; margin: 0 0 10px; }
.summary table { width: 100%; border-collapse: collapse; }
.summary td, .summary th { padding: 5px 0; border-bottom: 1px solid #EEF1EF; text-align: left; }
.summary td.n, .summary th.n { text-align: right; font-variant-numeric: tabular-nums; padding-left: 10px; }
.summary .warn { color: var(--red); }
.bar { height: 8px; background: var(--green-soft); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.bar { background: #E3E5E8; }
.bar i { display: block; height: 100%; background: var(--orange); }

/* ---------- диалоги */
dialog { border: 0; border-radius: var(--radius-l); padding: 0; width: min(760px, 96vw); max-height: 92vh;
  box-shadow: 0 20px 60px rgba(29,39,51,.35); }
dialog::backdrop { background: rgba(29,39,51,.45); }
dialog form { padding: 22px 24px; display: grid; gap: 14px; }
dialog h2 { margin: 0; font-size: 20px; }
#confirmDlg { width: min(440px, 94vw); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid label, dialog label.wide { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form-grid label input, .form-grid label select, dialog label textarea { color: var(--ink); font-size: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px 12px; margin: 0; }
legend { padding: 0 6px; color: var(--muted); font-size: 13px; }
.chips { min-height: 26px; margin-bottom: 8px; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.car-row { display: grid; grid-template-columns: 140px 1fr auto 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.car-row label { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.form-error { color: var(--red); margin: 0; }
.dlg-actions { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }
body.guest-mode .emp-only, body.emp-mode .guest-only { display: none; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: var(--radius-s); z-index: 100; max-width: 90vw; }
.toast.warn { background: #8A4A12; }
.toast.err { background: var(--red); }

/* ---------- вход */
.login-body { display: grid; place-items: center; min-height: 100vh; background: var(--head); }
.login { background: #fff; padding: 30px 32px; border-radius: var(--radius-l); width: min(380px, 92vw); display: grid; gap: 12px; }
.login h1 { font-size: 20px; margin: 6px 0 0; }
.login p { margin: 0 0 6px; }
.login label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login input { font-size: 15px; color: var(--ink); }
.login .btn { margin-top: 6px; padding: 10px; }
.login-error { color: var(--red) !important; }
.login-floors { display: flex; gap: 8px; }
.login-floors span { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--ink); display: grid; place-items: center;
  font-weight: 600; font-size: 13px; }
.login-floors span:first-child { background: var(--orange); border-color: var(--orange); color: #fff; }

/* ---------- узкие экраны */
@media (max-width: 1100px) {
  .scheme { grid-template-columns: 70px 1fr; grid-template-rows: 1fr auto; }
  .side { grid-column: 1 / -1; max-height: 44vh; border-left: 0; border-top: 1px solid var(--line); }
  .floor-btn { width: 48px; height: 48px; font-size: 16px; }
  .brand { display: none; }
}
@media (max-width: 640px) {
  .top { gap: 10px; padding: 0 10px; }
  .top-actions .btn { padding: 6px 8px; font-size: 13px; }
  .form-grid { grid-template-columns: 1fr; }
  .car-row { grid-template-columns: 1fr 1fr; }
}

.sr-empty { padding: 8px 12px; }
.summary h2.mt { margin-top: 14px; }

/* ---------- фильтры с галочками */
.ms { position: relative; }
.ms-btn { border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff; padding: 7px 30px 7px 10px; cursor: pointer;
  position: relative; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.ms-btn::after { content: "▾"; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.ms-btn.on { border-color: var(--orange); background: #FFF6EF; }
.ms-panel { position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-s); box-shadow: 0 8px 24px rgba(0,0,0,.15); min-width: 240px; max-height: 360px; overflow: auto; padding: 6px 0; }
.ms-head { display: flex; justify-content: space-between; padding: 4px 12px 8px; border-bottom: 1px solid #EEF1EF; margin-bottom: 4px; }
.ms-head button { border: 0; background: none; color: var(--orange-dark); cursor: pointer; padding: 0; font-size: 13px; }
.ms-opt { display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.ms-opt:hover { background: #FFF6EF; }
.ms-opt input { accent-color: var(--orange); margin: 0; }
.ms-opt .sw { margin-right: 0; }

/* ---------- подписи на схеме */
.pl-free { font-family: var(--font); font-weight: 500; fill: #6B7076; pointer-events: none; paint-order: stroke;
  stroke: rgba(255,255,255,.85); stroke-width: 4px; }

/* ---------- изменяемая ширина столбцов */
.grid th { position: sticky; }
.grid th .col-resize { position: absolute; top: 0; right: -4px; width: 9px; height: 100%; cursor: col-resize; z-index: 2; }
.grid th .col-resize:hover, .grid th .col-resize:active { background: linear-gradient(to right, transparent 3px, var(--orange) 3px, var(--orange) 5px, transparent 5px); }
table.grid.fixed { table-layout: fixed; }
table.grid.fixed td, table.grid.fixed th { overflow: hidden; text-overflow: ellipsis; }
table.grid.fixed .carline { overflow: hidden; text-overflow: ellipsis; }

/* ---------- справочники */
.dicts { overflow: auto; padding: 20px; display: grid; gap: 20px; grid-template-columns: 3fr 2fr; align-items: start; }
.dict { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 16px 18px; }
.dict h2 { font-size: 16px; margin: 0; }
.dict .hint { margin: 6px 0 12px; }
.dict-add { display: flex; gap: 8px; margin-bottom: 4px; }
.dict-add input { flex: 1; }
.dict .grid { margin-top: 10px; }
.dict .grid tbody tr { cursor: default; }
.dict .n { text-align: right; width: 80px; }
.ren-input { width: 100%; }
@media (max-width: 1000px) { .dicts { grid-template-columns: 1fr; } }

/* ---------- редактирование в ячейках */
.grid td.editable { cursor: cell; }
.grid tbody tr.sel td { background: #FFEFE3; }
.cell-editor { width: 100%; min-width: 70px; padding: 4px 6px; font-size: 14px; border-color: var(--orange); }
.carline .cell-editor { padding: 1px 4px; }
.grid th.actions-cell, .grid td.actions-cell { width: 1%; white-space: nowrap; text-align: right; }
.grid table.fixed th.actions-cell { width: 150px; }
.row-open { color: var(--orange-dark); border-color: #F3C3A4; }
.row-open:hover { background: #FFF1E7; border-color: var(--orange); }

.grid td.num, .grid th.num { width: 58px; white-space: nowrap; }

/* ---------- пользователи и небольшие формы */
#miniDlg { width: min(480px, 94vw); }
.mini-fields { display: grid; gap: 12px; }
.mini-fields label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.mini-fields input, .mini-fields select { color: var(--ink); font-size: 14px; }
.mini-row { display: flex; gap: 8px; }
.mini-row input { flex: 1; }
.login a.muted { text-align: center; font-size: 13px; }

.grid.fixed th.actions-cell { width: 150px; }
.grid td.note { max-width: none; }
