:root {
  --bg: #0B1620;
  --nav: #0E1C28;
  --panel: #12212E;
  --line: #1E3242;
  --line-strong: #2A4558;
  --text: #E6EEF3;
  --soft: #B7C6D1;
  --muted: #8FA3B3;
  --accent: #5FD3EE;
  --accent-hover: #9BE6F6;
  --low: #4CC38A;
  --medium: #F2B33D;
  --high: #FF7A6B;
  --high-line: #7A3A33;
  --medium-line: #5A4520;
  --radius: 12px;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: 'IBM Plex Sans', system-ui, sans-serif; font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { margin: 0; }
h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 18px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.soft { color: var(--soft); }
.eyebrow { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }
.hidden, [hidden] { display: none !important; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.nav {
  width: 232px; flex-shrink: 0; background: var(--nav); border-right: 1px solid var(--line);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 24px; font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }
/* The logo is dark navy and blue on white, so it sits on its own white panel. */
.logo-panel { background: #fff; border-radius: 12px; padding: 12px; display: flex; justify-content: center; align-items: center; }
.logo-panel img { display: block; width: 100%; height: auto; max-width: 380px; }
.nav .brand.logo-panel { padding: 10px 12px; margin-bottom: 18px; }
.nav .brand.logo-panel:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.logo-mark { background: #fff; border-radius: 8px; padding: 2px; display: inline-flex; }
.logo-mark img { display: block; width: 32px; height: 32px; }
.nav a.item { text-decoration: none; color: var(--muted); padding: 12px; border-radius: 8px; }
.nav a.item:hover { color: var(--text); background: var(--panel); }
.nav a.item.active { color: var(--bg); background: var(--accent); font-weight: 600; }
.nav .spacer { flex-grow: 1; }
.nav .who { font-size: 13px; color: var(--muted); padding: 8px 12px; word-break: break-all; }
main { flex-grow: 1; padding: 32px 40px; display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.page { max-width: 1360px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.header .titles { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.columns { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.columns > .wide { flex: 1 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.columns > .side { flex: 0 0 340px; display: flex; flex-direction: column; gap: 24px; max-width: 100%; }

/* Panels and tiles */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.panel.alert-high { border-color: var(--high-line); }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .value { font-family: var(--mono); font-size: 32px; font-weight: 600; }
.tile .sub { font-size: 13px; color: var(--muted); }
.tile.is-high { border-color: var(--high-line); }
.c-high { color: var(--high); }
.c-medium { color: var(--medium); }
.c-low { color: var(--low); }

/* Flat grid */
.floor { display: flex; flex-direction: column; gap: 10px; }
.flats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.flat-card {
  text-decoration: none; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 44px;
}
.flat-card:hover { border-color: var(--accent); color: var(--text); }
.flat-card.s-high { border-color: var(--high-line); }
.flat-card.s-medium { border-color: var(--medium-line); }
.flat-card .top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.flat-card .name { font-weight: 600; }
.flat-card .nums { font-family: var(--mono); font-size: 13px; color: var(--soft); }
.flat-card .bottom { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
.flat-card.battery-low { border-style: dashed; }
.flat-card .replace { font-size: 12px; font-weight: 600; color: var(--high); }
.battery { display: inline-flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.battery.b-ok { color: var(--muted); }
.battery.b-soon { color: var(--medium); }
.battery.b-low { color: var(--high); font-weight: 600; }

.chip { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.chip.s-low { color: var(--low); background: rgba(76,195,138,0.14); }
.chip.s-medium { color: var(--medium); background: rgba(242,179,61,0.16); }
.chip.s-high { color: var(--high); background: rgba(255,122,107,0.16); }
.chip.s-offline, .chip.s-unknown, .chip.s-no_sensor, .chip.s-disabled { color: var(--soft); background: rgba(183,198,209,0.14); }
.site-search { position: relative; max-width: 1360px; width: 100%; margin: 0 auto; display: flex; align-items: center; }
.site-search > svg { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.site-search input { width: 100%; padding-left: 42px; min-height: 46px; font-size: 15px; }
.site-search .results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 18px 40px -12px rgba(0,0,0,0.6); max-height: 420px; overflow-y: auto; padding: 6px; }
.site-search .result { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.site-search .result:hover, .site-search .result.active { background: rgba(95,211,238,0.10); }
.site-search .result .kind { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); width: 64px; flex-shrink: 0; }
.site-search .result .text { display: flex; flex-direction: column; min-width: 0; flex-grow: 1; }
.site-search .result .title { font-weight: 600; font-size: 14px; }
.site-search .result .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-search .none { padding: 12px; color: var(--muted); font-size: 14px; }
.attn { display: flex; flex-direction: column; gap: 0; padding: 0; overflow: hidden; }
.attn a.item { display: grid; grid-template-columns: 6px minmax(0, 1.4fr) minmax(0, 1.6fr) minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 16px 20px 16px 0; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--line); }
.attn a.item:last-child { border-bottom: 0; }
.attn a.item:hover { background: rgba(95,211,238,0.05); }
.attn .bar { align-self: stretch; }
.attn .bar.s-high { background: var(--high); }
.attn .bar.s-medium { background: var(--medium); }
.attn .place, .attn .why { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.attn .place .flat { font-weight: 600; font-size: 16px; }
.attn .place .addr, .attn .why .meta, .attn .job-col .meta { font-size: 13px; color: var(--muted); }
.attn .why .reason { font-size: 14px; color: var(--soft); }
.attn .job-col { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.attn .go { color: var(--muted); font-size: 20px; }
.attn .awaab, .alert-item .awaab { white-space: normal; max-width: 100%; }
.attn .noaction { color: var(--high); font-size: 13px; font-weight: 600; }
@media (max-width: 860px) {
  .attn a.item { grid-template-columns: 6px minmax(0, 1fr) auto; gap: 6px 14px; }
  .attn .why, .attn .job-col { grid-column: 2 / 3; }
  .attn .go { grid-row: 1; grid-column: 3; }
}
.photo-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.photo-strip img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line-strong); display: block; }
.photo-strip a:focus-visible img { outline: 2px solid var(--accent); }
.photo-pick { display: flex; flex-direction: column; gap: 8px; }
.photo-pick .label-text { font-size: 14px; color: var(--soft); }
.photo-pick label.btn { cursor: pointer; }
.photo-pick input[type=file]:focus-visible + * , .photo-pick label.btn:focus-within { outline: 2px solid var(--accent); }
.thumb { position: relative; }
.thumb .remove { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 50%; font-size: 15px; line-height: 1; background: var(--high); color: #fff; }
.role-tag { display: inline-block; margin-top: 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
table.perm { margin-top: 8px; font-size: 13px; }
table.perm td:not(:first-child), table.perm th:not(:first-child) { text-align: center; width: 90px; }
select[data-role] { min-width: 132px; }
.awaab { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 6px; border: 1px solid; white-space: nowrap; margin-top: 2px; }
.awaab::before { content: "⚖"; font-weight: 400; }
.awaab.a-overdue { color: #fff; background: #C0392B; border-color: #C0392B; }
.awaab.a-soon { color: var(--medium); background: rgba(242,179,61,0.12); border-color: rgba(242,179,61,0.45); }
.awaab.a-ok { color: var(--soft); background: rgba(183,198,209,0.08); border-color: var(--line-strong); }
.awaab.a-done { color: var(--low); background: rgba(76,195,138,0.10); border-color: rgba(76,195,138,0.4); }
.awaab.a-late { color: var(--high); background: rgba(255,122,107,0.10); border-color: var(--high-line); }
.awaab.a-none { color: var(--muted); background: transparent; border-color: var(--line-strong); border-style: dashed; }
.law { display: flex; flex-direction: column; gap: 0; }
.law .step { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.law .step:last-child { border-bottom: 0; }
.law .icon { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; margin-top: 1px; }
.law .s-done .icon, .law .s-not_needed .icon { background: var(--low); color: var(--bg); }
.law .s-done_late .icon, .law .s-not_recorded .icon { background: var(--high); color: var(--bg); }
.law .s-overdue .icon { background: #C0392B; color: #fff; }
.law .s-due_soon .icon { background: var(--medium); color: var(--bg); }
.law .s-due .icon, .law .s-waiting .icon { border: 2px solid var(--line-strong); }
.law .name { font-weight: 600; font-size: 14px; }
.law .rule { font-size: 12px; color: var(--muted); }
.law .when { text-align: right; font-size: 13px; white-space: nowrap; }
.law .when .left { font-weight: 600; }
.law .s-overdue .when .left, .law .s-done_late .when .left { color: var(--high); }
.law .s-due_soon .when .left { color: var(--medium); }
.law .s-done .when .left, .law .s-not_needed .when .left { color: var(--low); }
.law-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.nav .install-app { margin-top: 10px; width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.job { font-family: var(--mono); font-size: 0.92em; font-weight: 600; color: var(--text); background: rgba(183,198,209,0.10); border: 1px solid var(--line-strong); border-radius: 6px; padding: 1px 6px; margin-right: 4px; white-space: nowrap; }
.chip.t-open { color: var(--high); background: rgba(255,122,107,0.16); }
.chip.t-in_progress { color: var(--medium); background: rgba(242,179,61,0.16); }
.chip.t-resolved { color: var(--low); background: rgba(76,195,138,0.14); }
.ticket-log { display: flex; flex-direction: column; gap: 0; }
.ticket-log .entry { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 12px; padding-bottom: 16px; position: relative; }
.ticket-log .entry::before { content: ""; position: absolute; left: 6px; top: 14px; bottom: 0; width: 2px; background: var(--line); }
.ticket-log .entry:last-child::before { display: none; }
.ticket-log .dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 3px; background: var(--line-strong); }
.ticket-log .dot.t-open { background: var(--high); }
.ticket-log .dot.t-in_progress { background: var(--medium); }
.ticket-log .dot.t-resolved { background: var(--low); }
.ticket-log .head { font-weight: 600; font-size: 14px; }
.ticket-log .head.sev-critical { color: var(--high); }
.ticket-log .head.sev-warning { color: var(--medium); }
.ticket-log .note { font-size: 14px; color: var(--soft); white-space: pre-wrap; margin-top: 3px; }
.ticket-log .meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.chip.big { font-size: 14px; padding: 6px 12px; letter-spacing: 0.04em; }

.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }

/* Alerts list */
.alert-item { display: flex; flex-direction: column; gap: 3px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.alert-item:last-child { border-bottom: 0; padding-bottom: 0; }
.alert-item .t { font-weight: 600; font-size: 14px; }
.alert-item .t.sev-critical { color: var(--high); }
.alert-item .t.sev-warning { color: var(--medium); }
.alert-item .d { font-size: 14px; color: var(--soft); }
.alert-item .w { font-size: 12px; color: var(--muted); }

/* Forms and buttons */
.btn, button {
  font: inherit; font-weight: 600; border-radius: 8px; padding: 11px 16px; min-height: 44px; cursor: pointer;
  background: var(--accent); color: var(--bg); border: 0; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover, button:hover { background: var(--accent-hover); color: var(--bg); }
.btn.secondary, button.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--line-strong); font-weight: 500; }
.btn.secondary:hover, button.secondary:hover { border-color: var(--accent); }
button.small, .btn.small { min-height: 34px; padding: 6px 10px; font-size: 13px; }
button:disabled { opacity: 0.6; cursor: wait; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 10px 12px; min-height: 44px; width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
textarea { min-height: 88px; resize: vertical; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--soft); font-size: 14px; }
label.check input { width: 20px; min-height: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; align-items: end; }

.message { border-radius: 8px; padding: 12px 14px; font-size: 14px; }
.message.error { background: rgba(255,122,107,0.14); color: #FFB3A9; border: 1px solid var(--high-line); }
.message.ok { background: rgba(76,195,138,0.14); color: #9BE3BF; border: 1px solid #245C42; }
.message.info { background: rgba(95,211,238,0.10); color: var(--soft); border: 1px solid var(--line-strong); word-break: break-all; }

/* Small auth pages */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px; display: flex; flex-direction: column; gap: 18px; }
.auth .brand { padding: 0; justify-content: center; font-size: 22px; }
.auth form { display: flex; flex-direction: column; gap: 14px; }
.qr { background: #fff; border-radius: 10px; padding: 14px; display: flex; justify-content: center; }

/* Charts */
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid line { stroke: var(--line); }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
.key { display: flex; gap: 18px; font-size: 13px; color: var(--soft); flex-wrap: wrap; }
.key i { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-right: 6px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
details { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
details summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
details[open] summary { margin-bottom: 10px; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* Phones */
.mobile-bar { display: none; }
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .nav { display: none; }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; background: var(--nav); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
  .mobile-bar .brand { padding: 0; }
  .mobile-bar nav { display: flex; gap: 4px; flex-wrap: wrap; }
  .mobile-bar nav a { text-decoration: none; color: var(--muted); padding: 10px; border-radius: 8px; font-size: 14px; }
  .mobile-bar nav a.active { color: var(--bg); background: var(--accent); }
  main { padding: 20px 16px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile .value { font-size: 26px; }
  .columns > .side { flex: 1 1 100%; }
  h1 { font-size: 24px; }
}
