/* Plan Hal - style interfejsu */
:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --line: #e3e7ed;
  --line-2: #cfd6df;
  --text: #1f2733;
  --muted: #667085;
  --faint: #98a2b3;
  --primary: #1d4ed8;
  --primary-2: #1e40af;
  --primary-soft: #e8efff;
  --danger: #c43d3d;
  --warn: #d97706;
  --ok: #2f8f3f;
  --st-wolny: #bfe6fb;
  --st-wolny-line: #5aa9d6;
  --st-rez: #9bdc9b;
  --st-rez-line: #3f9f3f;
  --st-wyn: #f19a9a;
  --st-wyn-line: #c43d3d;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-2: 0 8px 24px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .08);
  --shadow-3: 0 24px 64px rgba(16, 24, 40, .22);
  --r: 10px;
  --r-sm: 7px;
  --topbar-h: 56px;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.sm { width: 15px; height: 15px; }

/* ---------- przyciski i pola */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: #fff; cursor: pointer; white-space: nowrap; font-weight: 500; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--panel-2); border-color: #b8c1cd; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--danger); border-color: #efc2c2; }
.btn.danger:hover { background: #fdf1f1; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(16, 24, 40, .06); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon-only { width: 36px; padding: 0; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: #475467; }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; line-height: 1.4; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29, 78, 216, .15); }
.input[readonly], .textarea[readonly] { background: var(--panel-2); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-weight: 500; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); margin: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; border: 1px solid rgba(0, 0, 0, .15); }
.dot.wolny { background: var(--st-wolny); border-color: var(--st-wolny-line); }
.dot.rezerwacja { background: var(--st-rez); border-color: var(--st-rez-line); }
.dot.wynajety { background: var(--st-wyn); border-color: var(--st-wyn-line); }

/* ---------- logowanie */
#login-view { position: fixed; inset: 0; display: grid; place-items: center; background: linear-gradient(135deg, #e9eef8 0%, #f6f7fb 55%, #eaf4ee 100%); }
.login-card { width: 360px; max-width: calc(100vw - 32px); background: #fff; border-radius: 16px; box-shadow: var(--shadow-3); padding: 28px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; }
.logo { width: 38px; height: 38px; border-radius: 10px; background: var(--primary); display: grid; place-items: center; color: #fff; flex: none; }
.logo svg { width: 24px; height: 24px; }

/* ---------- górny pasek */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 30;
  display: flex; align-items: center; gap: 10px; padding: 0 12px; background: #fff; border-bottom: 1px solid var(--line); box-shadow: var(--shadow-1);
}
.topbar .brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; margin-right: 6px; }
.topbar .brand .logo { width: 32px; height: 32px; border-radius: 8px; }
.topbar .brand .logo svg { width: 20px; height: 20px; }
.sep { width: 1px; height: 28px; background: var(--line); margin: 0 4px; }
.variant-btn {
  display: flex; align-items: center; gap: 9px; height: 40px; min-width: 260px; max-width: 420px; padding: 0 10px 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm); background: #fff; cursor: pointer; text-align: left;
}
.variant-btn:hover { border-color: #b8c1cd; background: var(--panel-2); }
.variant-btn .vb-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.15; }
.variant-btn .vb-kind { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.variant-btn .vb-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vb-badge { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none; }
.vb-badge.base { background: #475467; }
.online { display: flex; align-items: center; margin-left: 4px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700;
  border: 2px solid #fff; margin-left: -6px; box-shadow: 0 0 0 1px var(--line); flex: none; position: relative;
}
.avatar.me { box-shadow: 0 0 0 2px var(--primary); }
.avatar.small { width: 22px; height: 22px; font-size: 10px; margin: 0; border-width: 1px; }
.user-btn { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px; border: none; background: transparent; border-radius: var(--r-sm); cursor: pointer; }
.user-btn:hover { background: var(--panel-2); }
.user-btn .avatar { margin: 0; }
.role-tag { font-size: 10.5px; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 1px 6px; border-radius: 4px; }

/* ---------- menu rozwijane */
.menu {
  position: fixed; z-index: 60; min-width: 240px; background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-2); padding: 6px; max-height: calc(100vh - 80px); overflow: auto; animation: pop .12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.menu .mi { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 6px; text-align: left; cursor: pointer; }
.menu .mi:hover, .menu .mi.active { background: var(--panel-2); }
.menu .mi.danger { color: var(--danger); }
.menu .mi .mi-sub { font-size: 12px; color: var(--muted); }
.menu .mi-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.menu .mi-text > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu .mh { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; padding: 10px 10px 4px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.menu .search { padding: 4px 4px 6px; }
.menu.variants { width: 400px; }

/* ---------- scena z mapą */
.stage { position: fixed; top: var(--topbar-h); left: 0; right: 0; bottom: 0; }
.banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 12; display: flex; align-items: center; gap: 10px;
  padding: 7px 8px 7px 14px; border-radius: 999px; background: rgba(255, 255, 255, .96); box-shadow: var(--shadow-2); font-size: 13px; max-width: calc(100vw - 420px);
}
.banner.warn { background: #fff7e6; color: #8a4b00; }
.banner.readonly { background: #f2f4f7; }
.banner.offline { background: #fdecec; color: #8f1d1d; }
#map { position: absolute; inset: 0; overflow: hidden; background: #e9edf2; touch-action: none; cursor: grab; }
#map.dragging { cursor: grabbing; }
.plan-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; }
.plan-svg text { font-family: "Segoe UI", "Arial Narrow", Arial, sans-serif; }
.bg-text { pointer-events: none; }
.big-texts { pointer-events: none; }
.bg-text.big { fill: #4b5563; fill-opacity: .28; }
.lok { stroke-width: 1px; vector-effect: non-scaling-stroke; cursor: pointer; transition: filter .12s; }
.lok.wolny { fill: var(--st-wolny); stroke: var(--st-wolny-line); }
.lok.rezerwacja { fill: var(--st-rez); stroke: var(--st-rez-line); }
.lok.wynajety { fill: var(--st-wyn); stroke: var(--st-wyn-line); }
.lok:hover { filter: brightness(1.07) saturate(1.1); stroke-width: 2px; }
.plan-svg.show-diff .lok.src-variant { stroke: #7c3aed; stroke-width: 2.4px; stroke-dasharray: 5 3; }
.plan-svg.review .lok.needs-review { stroke: #7c3aed; stroke-width: 2.6px; }
.lok.dim { opacity: .28; }
.column { fill: #4b5563; stroke: #374151; stroke-width: .6px; vector-effect: non-scaling-stroke; pointer-events: none; }
.entrance-line { fill: none; stroke: #1f2733; stroke-linecap: butt; vector-effect: non-scaling-stroke; pointer-events: none; }
.entrance-tri { fill: #1f2733; pointer-events: none; }
.witryna-line { fill: none; stroke: #38bdf8; stroke-linecap: butt; vector-effect: non-scaling-stroke; pointer-events: none; }
.witryna-core { fill: none; stroke: #0c4a6e; stroke-width: 1px; vector-effect: non-scaling-stroke; pointer-events: none; }
.lok.hit { stroke: #111827; stroke-width: 2.5px; }
.sel-outline { fill: none; stroke: #111827; stroke-width: 3px; vector-effect: non-scaling-stroke; pointer-events: none; }
.sel-outline.pulse { animation: pulse 1.2s ease-out 2; }
@keyframes pulse { 0% { stroke-width: 3px; stroke-opacity: 1; } 50% { stroke-width: 9px; stroke-opacity: .35; } 100% { stroke-width: 3px; stroke-opacity: 1; } }
.lab { pointer-events: none; text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: rgba(255, 255, 255, .85); stroke-linejoin: round; }
.lab.num { font-weight: 700; fill: #1f2733; }
.lab.name { font-weight: 500; fill: #344054; }
.lab.unknown { fill: #7c3aed; }
.ico-badge { pointer-events: none; }
.ico-badge circle { fill: #fff; stroke: rgba(16, 24, 40, .25); vector-effect: non-scaling-stroke; }
.ico-badge.alert circle { fill: #f59e0b; stroke: #b45309; }
.ico-badge.lock circle { fill: #1f2733; stroke: #1f2733; }
.ico-badge.review circle { fill: #7c3aed; stroke: #5b21b6; }
.ico-badge use { color: #1f2733; }
.ico-badge.alert use, .ico-badge.lock use, .ico-badge.review use { color: #fff; }
#map-tip {
  position: absolute; z-index: 20; pointer-events: none; background: rgba(17, 24, 39, .94); color: #fff; padding: 7px 10px; border-radius: 8px;
  font-size: 12.5px; line-height: 1.35; max-width: 280px; box-shadow: var(--shadow-2); transform: translate(14px, 14px);
}
#map-tip b { font-size: 13.5px; }
#map-tip .t-st { display: flex; align-items: center; gap: 6px; }

/* kontrolki mapy */
.map-ctrl { position: absolute; right: 14px; top: 14px; z-index: 10; display: flex; flex-direction: column; gap: 10px; }
.ctrl-group { display: flex; flex-direction: column; background: #fff; border-radius: var(--r); box-shadow: var(--shadow-2); overflow: hidden; }
.ctrl-group button {
  width: 46px; height: 42px; border: 0; background: #fff; cursor: pointer; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  border-bottom: 1px solid var(--line); color: #344054; position: relative;
}
.ctrl-group button:last-child { border-bottom: 0; }
.ctrl-group button:hover { background: var(--panel-2); color: var(--primary); }
.ctrl-group button .hall-label { font-size: 10px; font-weight: 700; color: var(--muted); display: block; line-height: 1; margin-top: 2px; }
.ctrl-group button.hall { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 17px; }

/* legenda */
.legend {
  position: absolute; left: 14px; bottom: 14px; z-index: 10; background: rgba(255, 255, 255, .97); border-radius: var(--r); box-shadow: var(--shadow-2);
  padding: 8px 10px; min-width: 232px; font-size: 12.5px;
}
.legend h4 { margin: 0 0 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.legend .lg-row { display: grid; grid-template-columns: 16px 1fr auto auto; gap: 8px; align-items: center; padding: 2px 0; cursor: pointer; border-radius: 4px; }
.legend .lg-row:hover { background: var(--panel-2); }
.legend .lg-row.off { opacity: .4; }
.legend .lg-row .n { font-weight: 700; text-align: right; min-width: 26px; }
.legend .lg-row .a { color: var(--muted); text-align: right; min-width: 78px; font-variant-numeric: tabular-nums; }
.legend .lg-icons { display: flex; flex-wrap: wrap; gap: 3px 10px; margin-top: 6px; padding-top: 6px; max-width: 250px; border-top: 1px solid var(--line); color: #475467; font-size: 12px; }
.legend .lg-icons span { display: inline-flex; align-items: center; gap: 5px; }
.legend .lg-icons svg { width: 15px; height: 15px; }
.legend .lg-toggles { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 12.5px; }
.legend .lg-toggles .check { font-weight: 400; }
.legend .lg-toggles .check input { width: 15px; height: 15px; }
.legend.collapsed .lg-body { display: none; }

/* ---------- panel boczny (zestawienie) */
.drawer {
  position: fixed; top: var(--topbar-h); right: 0; bottom: 0; width: 460px; max-width: 100vw; z-index: 25; background: #fff; border-left: 1px solid var(--line);
  box-shadow: var(--shadow-2); display: flex; flex-direction: column; transform: translateX(105%); transition: transform .22s ease;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 0 16px; }
.drawer-head h3 { margin: 0; font-size: 16px; flex: 1; }
.tabs { display: flex; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); }
.tab { padding: 8px 12px; border: 0; background: none; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .count { font-size: 11px; background: var(--panel-2); border-radius: 999px; padding: 1px 6px; margin-left: 4px; color: var(--muted); }
.drawer-body { flex: 1; overflow: auto; padding: 12px 16px 20px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.fchip { border: 1px solid var(--line-2); background: #fff; border-radius: 999px; padding: 4px 11px; cursor: pointer; font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.fchip.on { background: var(--primary-soft); border-color: #aac0f5; color: var(--primary-2); }
.lok-list { display: flex; flex-direction: column; }
.lok-item { display: grid; grid-template-columns: 14px 64px 1fr auto; gap: 10px; align-items: center; padding: 8px 6px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 6px; }
.lok-item:hover { background: var(--panel-2); }
.lok-item .nr { font-weight: 700; }
.lok-item .nr small { color: var(--muted); font-weight: 600; }
.lok-item .nm { min-width: 0; }
.lok-item .nm div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lok-item .nm .sub { font-size: 12px; color: var(--muted); }
.lok-item .ar { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; font-size: 13px; }
.lok-item .fl { display: flex; gap: 3px; justify-content: flex-end; margin-top: 2px; }
.lok-item .fl svg { width: 14px; height: 14px; color: #475467; }
.list-foot { padding: 10px 6px; color: var(--muted); font-size: 12.5px; }
table.sum { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 16px; }
table.sum th, table.sum td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
table.sum th:first-child, table.sum td:first-child { text-align: left; }
table.sum th { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
table.sum tr.total td { font-weight: 700; border-top: 2px solid var(--line-2); }
.bar { height: 10px; border-radius: 5px; overflow: hidden; display: flex; background: var(--st-wolny); margin: 4px 0 14px; }
.bar i { display: block; height: 100%; }
.feed-item { display: flex; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 13px; }
.feed-item .when { color: var(--faint); font-size: 12px; white-space: nowrap; }
.feed-item .what { flex: 1; min-width: 0; }
.feed-item .what .sub { color: var(--muted); font-size: 12px; }
.feed-item a { cursor: pointer; font-weight: 600; text-decoration: none; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 14px 0 6px; }
.empty { color: var(--muted); padding: 24px 6px; text-align: center; }

/* ---------- okna modalne */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(16, 24, 40, .38); display: grid; place-items: center; padding: 16px; animation: fade .12s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow-3); width: 520px; max-width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: rise .16s ease-out; }
@keyframes rise { from { transform: translateY(10px) scale(.99); opacity: 0; } to { transform: none; opacity: 1; } }
.modal.wide { width: 980px; }
.modal.mid { width: 720px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.modal-head .sub { font-size: 13px; color: var(--muted); font-weight: 500; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 14px 14px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.note { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.alert { display: flex; gap: 10px; padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.4; }
.alert.info { background: #eef4ff; color: #1e3a8a; }
.alert.warn { background: #fff5e5; color: #7a4100; }
.alert.danger { background: #fdecec; color: #8f1d1d; }
.alert.lock { background: #1f2733; color: #fff; }
.alert .icon { margin-top: 1px; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* karta lokalu */
.card-grid { display: grid; grid-template-columns: 400px 1fr; gap: 18px; }
.card-draw { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.card-draw svg { width: 100%; height: 280px; display: block; }
.card-facts { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 10px; }
.fact { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.fact .k { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.fact .v { font-size: 14px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.statuses { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.st-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px; height: 40px; border-radius: 8px; border: 2px solid var(--line-2); background: #fff;
  cursor: pointer; font-weight: 600; font-size: 13px; transition: all .1s;
}
.st-btn .dot { width: 12px; height: 12px; }
.st-btn:hover:not([disabled]) { border-color: #98a2b3; }
.st-btn.on.wolny { background: var(--st-wolny); border-color: var(--st-wolny-line); }
.st-btn.on.rezerwacja { background: var(--st-rez); border-color: var(--st-rez-line); }
.st-btn.on.wynajety { background: var(--st-wyn); border-color: var(--st-wyn-line); }
.st-btn[disabled] { cursor: default; }
.flag-row { display: grid; grid-template-columns: 210px 1fr; gap: 10px; align-items: center; }
.flag-row .check svg { width: 17px; height: 17px; color: #475467; }
.meta-line { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.num-edit { display: flex; gap: 6px; align-items: center; }
.num-edit .input { width: 110px; height: 32px; font-weight: 700; }
.cand { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.cand button { border: 1px solid #c4b5fd; background: #f5f3ff; color: #5b21b6; border-radius: 6px; padding: 2px 8px; cursor: pointer; font-weight: 700; font-size: 12px; }
.hist { max-height: 320px; overflow: auto; }
.hist-item { display: grid; grid-template-columns: 118px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.hist-item .when { color: var(--muted); font-size: 12px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.admin-table th { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; background: var(--panel-2); position: sticky; top: 0; }
.admin-table .input, .admin-table .select { height: 30px; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; font-size: 13px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.drop { border: 2px dashed var(--line-2); border-radius: 10px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--primary); background: var(--primary-soft); }
.radio-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.radio-card { border: 2px solid var(--line-2); border-radius: 10px; padding: 10px; cursor: pointer; font-size: 13px; }
.radio-card.on { border-color: var(--primary); background: var(--primary-soft); }
.radio-card b { display: block; margin-bottom: 2px; }
.radio-card span { color: var(--muted); font-size: 12px; }

/* ---------- komunikaty */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  background: #1f2733; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-2); font-size: 13px; max-width: 380px; line-height: 1.4;
  display: flex; gap: 10px; align-items: flex-start; animation: rise .18s ease-out; cursor: default;
}
.toast.ok { background: #1f6f35; }
.toast.err { background: #a42a2a; }
.toast.info .avatar { margin: 0; }
.toast a { color: #bcd2ff; cursor: pointer; font-weight: 600; }
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(29, 78, 216, .2); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { position: fixed; inset: 0; display: grid; place-items: center; z-index: 80; background: rgba(238, 241, 245, .7); }

@media (max-width: 1100px) {
  .variant-btn { min-width: 180px; }
  .topbar .brand span { display: none; }
  .card-grid { grid-template-columns: 1fr; }
  .hide-md { display: none !important; }
}
@media print { body { display: none; } }

/* ---------- tryb prezentacji */
.present-btn { height: 38px; padding: 0 16px; font-weight: 600; border-color: #c7d2fe; color: var(--primary-2); background: var(--primary-soft); }
.present-btn:hover { background: #dbe6ff; border-color: #a5b4fc; }
.present-btn.on { background: #1f2733; border-color: #1f2733; color: #fff; }
.present-btn.on:hover { background: #111827; }
.pres-only { display: none; }
body.presenting .pres-only { display: inline-flex; }
body.presenting .variant-btn, body.presenting #btn-new-variant, body.presenting #btn-variant-menu, body.presenting #online,
body.presenting .topbar .sep, body.presenting #btn-list, body.presenting #btn-print, body.presenting #user-btn { display: none; }
body.presenting .legend { min-width: 0; }
body.presenting .lok:hover { filter: brightness(1.04) saturate(1.15); }

.modal.pres { width: 1040px; border-radius: 18px; overflow: hidden; }
.modal.pres .modal-head { border-bottom: 0; padding-bottom: 4px; }
.modal.pres .modal-body { padding-top: 8px; }
.pres-grid { display: grid; grid-template-columns: 470px 1fr; gap: 22px; }
.pres-left { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pres-stage {
  position: relative; height: 250px; border-radius: 14px; overflow: hidden; transition: height .35s ease;
  background: radial-gradient(120% 130% at 50% 12%, #2b3f63 0%, #14213a 55%, #0a1224 100%);
  box-shadow: inset 0 0 0 1px rgba(148, 197, 255, .18), 0 10px 30px rgba(10, 18, 36, .25);
}
.pres-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer; touch-action: pan-y; }
.pres-stage-btn {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(15, 23, 42, .45); color: #e2e8f0; display: grid; place-items: center; cursor: pointer;
}
.pres-stage-btn:hover { background: rgba(15, 23, 42, .75); }
.pres-hint { position: absolute; left: 12px; bottom: 9px; right: 12px; font-size: 11.5px; color: rgba(226, 232, 240, .62); pointer-events: none; letter-spacing: .01em; }
.pres-left.expanded .pres-stage { height: 520px; }
.pres-left.expanded .pres-plan, .pres-left.expanded .pres-facts { display: none; }
.pres-plan { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.pres-plan svg { width: 100%; height: 200px; display: block; }
.pres-facts { display: flex; gap: 8px; flex-wrap: wrap; }
.pres-fact { flex: 1 1 0; min-width: 96px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; }
.pres-fact .k { font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.pres-fact .v { font-size: 15px; font-weight: 700; margin-top: 1px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pres-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.pres-head { display: flex; align-items: center; gap: 16px; }
.pres-num { font-size: 58px; font-weight: 800; line-height: 1; letter-spacing: -.02em; color: #111827; }
.pres-hall { font-size: 15px; font-weight: 600; color: var(--muted); }
.pres-area { font-size: 24px; font-weight: 700; line-height: 1.15; }
.pres-tenant { font-size: 13px; color: var(--muted); margin-top: 2px; }
.pres-mini-box { border: 1px solid var(--line); border-radius: 12px; background: #f8fafc; padding: 6px; }
.pres-mini { width: 100%; height: 150px; display: block; }
.pres-mini-ring { animation: miniPulse 1.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes miniPulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.35); opacity: .45; } }
.modal.pres .st-btn { height: 46px; font-size: 14px; border-radius: 10px; }
.modal.pres .textarea { min-height: 96px; }
.pres-fly { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 90; pointer-events: none; filter: drop-shadow(0 10px 24px rgba(10, 18, 36, .45)); }
@media (max-width: 1100px) { .pres-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .pres-mini-ring { animation: none; } .pres-stage { transition: none; } }


/* ==========================================================================
   TELEFON (wąski ekran lub telefon w poziomie).
   Wszystko poniżej działa wyłącznie w tym zakresie - widok komputerowy bez zmian.
   ========================================================================== */
@media (max-width: 760px), (max-height: 520px) {
  :root { --topbar-h: 52px; }
  body { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
  .input, .select, .textarea { font-size: 16px; }            /* iOS nie powiększa strony przy wpisywaniu */

  /* górny pasek: logo, wariant, prezentacja, awatar - reszta w menu użytkownika */
  .topbar { gap: 6px; padding: 0 8px; }
  .topbar .brand { margin-right: 0; }
  .topbar .brand span, .topbar .grow, .topbar .sep, #online, #btn-new-variant, #btn-variant-menu, #btn-list, #btn-print,
  #me-name, #user-btn > .icon, #btn-fullscreen { display: none !important; }
  .variant-btn { flex: 1 1 0; min-width: 0; max-width: none; height: 40px; padding: 0 8px 0 10px; gap: 7px; }
  .variant-btn .vb-kind { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .variant-btn .vb-name { font-size: 13.5px; }
  .present-btn { width: 40px; height: 40px; padding: 0; flex: none; }
  .present-btn span { display: none; }
  .user-btn { padding: 0 2px; flex: none; }
  body.presenting .topbar .grow { display: block !important; }
  body.presenting .present-btn { width: auto; padding: 0 14px; }
  body.presenting .present-btn span { display: inline; font-size: 13.5px; }

  .menu { max-width: calc(100vw - 16px); max-height: calc(100dvh - 70px); }
  .menu.variants { width: calc(100vw - 16px); }
  .menu .mi { padding: 11px 10px; }

  /* mapa */
  .banner { left: 8px; right: 62px; top: 8px; transform: none; max-width: none; border-radius: 12px; padding: 7px 8px 7px 10px; font-size: 12px; line-height: 1.3; gap: 6px; }
  .banner .btn { flex: none; }
  .map-ctrl { right: 8px; top: 8px; gap: 8px; }
  .map-ctrl .ctrl-group:nth-child(2) { display: none; }       /* +/- zbędne: zoom dwoma palcami */
  .ctrl-group button { width: 44px; height: 44px; }
  .legend { left: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); padding: 7px 9px; font-size: 12px; min-width: 0; max-width: calc(100vw - 16px); }
  .legend.collapsed h4 { margin: 0; }
  .legend .lg-row .a { min-width: 62px; }
  #map-tip { display: none !important; }

  /* panel zestawienia na cały ekran */
  .drawer { width: 100vw; border-left: 0; }
  .tabs { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .tab { flex: none; padding: 10px 11px; }
  .lok-item { padding: 11px 4px; }

  /* okna: duże na cały ekran, małe (potwierdzenia) wyśrodkowane */
  .modal-backdrop { padding: 0; }
  .modal { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); }
  .modal.wide, .modal.mid, .modal.pres { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; place-self: stretch; }
  .modal-head { padding: 12px 8px 10px 14px; }
  .modal-head h2 { font-size: 16px; flex-wrap: wrap; row-gap: 4px; }
  .modal-body { padding: 12px 14px; -webkit-overflow-scrolling: touch; }
  .modal-foot { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); gap: 8px; }
  .modal.wide .modal-foot, .modal.mid .modal-foot, .modal.pres .modal-foot { border-radius: 0; }
  .modal-foot .grow { display: none; }
  .modal-foot .btn { flex: 1 1 28%; height: 36px; padding: 0 6px; font-size: 12.5px; gap: 5px; }
  .modal-foot .btn:not(.primary) .icon { display: none; }
  .modal-foot .btn.primary { flex-basis: 100%; order: 10; height: 46px; font-size: 15px; }
  .form-grid, .kv { grid-template-columns: 1fr; }
  .kv > div:nth-child(odd) { margin-top: 4px; }
  .radio-cards { gap: 6px; }
  .radio-card { padding: 9px 8px; }
  .admin-table { min-width: 640px; }

  /* karta lokalu (edycja) */
  .card-grid { grid-template-columns: 1fr; gap: 14px; }
  .card-draw svg { height: 220px; }
  .statuses { grid-template-columns: 1fr; }
  .st-btn { height: 46px; font-size: 15px; justify-content: flex-start; padding: 0 14px; }
  .flag-row { grid-template-columns: 1fr; gap: 6px; }
  .check input { width: 22px; height: 22px; }
  .num-edit { flex-wrap: wrap; }
  .hist-item { grid-template-columns: 1fr; gap: 2px; }

  /* karta prezentacyjna */
  .modal.pres .modal-head { padding-bottom: 0; }
  .pres-grid { grid-template-columns: 1fr; gap: 14px; }
  .pres-stage { height: 230px; border-radius: 12px; }
  .pres-left.expanded .pres-stage { height: 64dvh; }
  .pres-plan svg { height: 190px; }
  .pres-num { font-size: 46px; }
  .pres-area { font-size: 21px; }
  .pres-mini { height: 130px; }
  .pres-hint { font-size: 11px; }

  #toasts { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); align-items: stretch; }
  .toast { max-width: none; }
  .login-card { padding: 22px; }
}

/* telefon w poziomie: niski ekran - karta prezentacyjna w dwóch kolumnach, niższa scena */
@media (max-height: 520px) and (min-width: 600px) {
  .pres-grid, .card-grid { grid-template-columns: 1fr 1fr; }
  .pres-stage { height: 200px; }
  .pres-left.expanded .pres-stage { height: 70dvh; }
}

/* ---------- pomoc */
.role-tag.soft { color: #475467; background: #eef1f5; }
.help { line-height: 1.55; font-size: 13.5px; }
.help .help-role { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.help .help-lead { background: #eef4ff; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.help .help-lead ol { margin: 6px 0 0; padding-left: 20px; }
.help .help-lead li { margin-bottom: 5px; }
.help details { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: #fff; }
.help details[open] { box-shadow: var(--shadow-1); }
.help summary { cursor: pointer; padding: 10px 14px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; user-select: none; }
.help summary::-webkit-details-marker { display: none; }
.help summary::before { content: "▸"; color: var(--faint); width: 12px; }
.help details[open] summary::before { content: "▾"; }
.help summary .tag { margin-left: auto; font-size: 10.5px; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 1px 7px; border-radius: 4px; }
.help .help-body { padding: 0 16px 12px 34px; }
.help .help-body p { margin: 0 0 8px; }
.help .help-body ul, .help .help-body ol { margin: 0 0 8px; padding-left: 18px; }
.help .help-body li { margin-bottom: 5px; }
.help kbd { font: inherit; font-size: 12px; background: var(--panel-2); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; }
@media (max-width: 760px), (max-height: 520px) { .help .help-body { padding-left: 16px; } }

/* ---------- szybkie wyszukiwanie lokalu */
.menu.search-pop { width: 400px; padding: 8px; }
.search-box { padding: 0 0 6px; }
.search-box .input { height: 40px; font-size: 15px; }
.search-results { max-height: min(420px, calc(100vh - 170px)); overflow: auto; }
.search-results .mi { display: grid; grid-template-columns: 12px 74px 1fr auto; gap: 10px; align-items: center; }
.search-results .sr-num { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results .sr-num small { color: var(--muted); font-weight: 600; }
.search-results .sr-area { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.search-hint { padding: 10px 8px; color: var(--muted); font-size: 13px; line-height: 1.4; }
@media (max-width: 760px), (max-height: 520px) {
  #btn-search { width: 40px; height: 40px; flex: none; }
  .menu.search-pop { width: calc(100vw - 16px); }
  .search-box .input { font-size: 16px; }
  .search-results { max-height: calc(100dvh - 190px); }
  .search-results .mi { grid-template-columns: 12px 64px 1fr; }
  .search-results .sr-area { display: none; }
}
