/* IntelliFM app styles. Colours are tokens so light and dark both work. */
:root {
  color-scheme: light dark;
  --bg: #f5f6f8; --panel: #ffffff; --fg: #1b2230; --muted: #5c6577; --line: #dde1e8;
  --accent: #1f5fbf; --accent-fg: #ffffff; --danger: #b42318; --ok: #1a7f37; --warn-bg: #fff4e5; --err-bg: #fdecea;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c; --panel: #1a2029; --fg: #e7eaf0; --muted: #9aa4b6; --line: #2c3442;
    --accent: #5b9bff; --accent-fg: #0b1220; --danger: #ff7b72; --ok: #56d364; --warn-bg: #3a2a12; --err-bg: #3d1d1b;
  }
}
* { box-sizing: border-box; }
/* "hidden" must win over layout rules like .stack { display: flex } */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
.loading { text-align: center; margin-top: 30vh; color: var(--muted); }
.foot { text-align: center; padding: 24px 16px; font-size: 13px; color: var(--muted); }
.foot a { color: var(--muted); }

/* Sign-in cards */
.card { max-width: 400px; margin: 8vh auto 0; padding: 28px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card h1 { font-size: 1.4rem; margin: 0 0 4px; }
.card .sub { margin: 0 0 20px; color: var(--muted); }
.brand { font-weight: 700; letter-spacing: .2px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 6px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; margin-top: 14px; }

/* Forms */
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 500; }
input, select { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.hint { font-size: 13px; color: var(--muted); font-weight: 400; }
button, .btn {
  font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg);
  cursor: pointer; text-decoration: none;
}
button.secondary, .btn.secondary { background: transparent; color: var(--fg); border-color: var(--line); }
button.danger { background: transparent; color: var(--danger); border-color: var(--line); }
button:disabled { opacity: .6; cursor: default; }
.btn.provider { background: var(--panel); color: var(--fg); border-color: var(--line); }

/* Messages */
.notice { padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.notice.error { background: var(--err-bg); color: var(--danger); }
.notice.info { background: var(--warn-bg); color: var(--fg); }
.notice.ok { color: var(--ok); padding: 0; }

/* Signed-in layout */
.top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.top .who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; margin-left: auto; }

/* Side menu (one scrolling row on narrow screens) */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: start; }
nav.side { position: sticky; top: 0; padding: 18px 12px; display: flex; flex-direction: column; gap: 14px; }
nav.side .group { display: flex; flex-direction: column; gap: 2px; }
nav.side .group-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 10px 4px; }
nav.side a { padding: 6px 10px; border-radius: 6px; color: var(--fg); text-decoration: none; }
nav.side a:hover { background: var(--panel); }
nav.side a.on { background: var(--panel); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.shell .page { margin: 0; max-width: 1100px; }
.top select { padding: 5px 8px; }
.page { max-width: 1000px; margin: 0 auto; padding: 24px 20px; }
.page h1 { font-size: 1.5rem; margin: 0 0 4px; }
.page > .sub { color: var(--muted); margin: 0 0 20px; }
section.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
section.box h2 { font-size: 1.05rem; margin: 0 0 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row label { flex: 1 1 180px; }
.row button { flex: 0 0 auto; }
.row.align-top { align-items: flex-start; } /* fields with hints underneath: line up the labels, not the bottoms */

.stack.tight { gap: 8px; }
.row.end { justify-content: flex-end; margin-top: 14px; }
button.small, .btn.small { padding: 5px 10px; font-size: 13px; }
.checklist { display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow-y: auto; }
ul.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
input[type=search] { flex: 1 1 260px; }

/* Buildings and lots */
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
.contacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 14px 0; }
.contact { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.contact h3 { margin: 0 0 4px; font-size: .95rem; }
.contact p { margin: 0; }
section.lot > h3 { font-size: .95rem; margin: 18px 0 8px; }
tr.bad td { color: var(--danger); }

/* Work orders and contractors */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; color: var(--fg); font-weight: 500; padding: 7px 12px; }
.seg button.on { background: var(--accent); color: var(--accent-fg); }
.tag.ok { color: var(--ok); border-color: var(--ok); }
.tag.warn { color: #9a6700; border-color: #d4a72c; }
.tag.bad { color: var(--danger); border-color: var(--danger); }
.tag.new { color: var(--accent); border-color: var(--accent); }
textarea { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; resize: vertical; }
p.details { white-space: pre-wrap; margin: 12px 0 0; }
ul.timeline { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 10px; }
ul.timeline li { border-left: 2px solid var(--line); padding-left: 10px; }
ul.timeline .note { background: var(--bg); border-radius: 6px; padding: 6px 8px; margin-top: 2px; white-space: pre-wrap; }
form.row input[name=text] { flex: 1 1 260px; }
tr.muted td { color: var(--muted); }

/* The induction on a phone */
.indrun { max-width: 560px; }
.indrun h2 { font-size: 1.25rem; }
.indrun .stack + .row { margin-top: 16px; }
button.big { padding: 12px 18px; font-size: 1rem; min-width: 120px; }
button.choice { display: block; width: 100%; text-align: left; padding: 14px 16px; background: var(--panel); color: var(--fg); border: 1px solid var(--line); font-weight: 500; }
button.choice.on { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.progress span { display: block; height: 100%; background: var(--accent); width: 0; }
.progress span[data-pct] { transition: width .2s; }
.contact .row input { flex: 1 1 260px; }
.contact label.check input:not([type=radio]) { flex: 1 1 auto; }
.stack > button.small { align-self: flex-start; }
.row label.narrow { flex: 0 1 340px; }
.row.spread { justify-content: space-between; align-items: center; }

/* Key register */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 16px 0 18px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.tile .lbl { font-size: 13px; color: var(--muted); }
.tile .big { font-size: 1.6rem; font-weight: 700; }
.tile.bad .big { color: var(--danger); }
.mono { font-family: ui-monospace, Consolas, monospace; white-space: nowrap; }
td.actions button + button { margin-left: 6px; }
td.over { color: var(--danger); font-weight: 600; }
canvas.sigpad { width: 100%; max-width: 560px; aspect-ratio: 56 / 17; background: #fff; border: 1px solid var(--line); border-radius: 8px; touch-action: none; cursor: crosshair; }
img.sigimg { height: 40px; background: #fff; border-radius: 4px; }
span.label { font-size: 14px; font-weight: 500; }

/* Inspections */
.indrun.wide { max-width: 760px; }
.indrun section.item h3 { font-size: 1.05rem; margin: 0 0 6px; }
.indrun section.item textarea { width: 100%; margin-top: 10px; }
section.item.attention { border-color: #d4a72c; }
.seg.big-seg button { padding: 12px 22px; font-size: 1rem; }
.seg button.on.pass { background: var(--ok); border-color: var(--ok); }
.seg button.on.fail { background: var(--danger); border-color: var(--danger); }
.photos { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
figure.phf { position: relative; margin: 0; }
figure.phf img, img.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
button.phx { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; padding: 0; border-radius: 50%; font-size: 14px; line-height: 1; }
.contact.muted { opacity: .7; }
button.choice.inline { display: inline-flex; width: auto; padding: 9px 16px; }

/* Long-term maintenance plan */
.ltchart { display: flex; align-items: stretch; gap: 4px; height: 220px; border-bottom: 1px solid var(--line); }
.ltcol { flex: 1 1 0; position: relative; display: flex; flex-direction: column; justify-content: flex-end; padding: 0 0 22px; border: 0; border-radius: 6px; background: transparent; color: var(--fg); min-width: 0; font-weight: 400; }
.ltcol:hover, .ltcol.on { background: var(--bg); }
.ltbar { display: block; width: 64%; margin: 0 auto; background: var(--accent); border-radius: 3px 3px 0 0; opacity: .75; min-height: 1px; max-height: 86%; }
.ltcol.on .ltbar { opacity: 1; }
.ltbal { position: absolute; left: 50%; width: 9px; height: 9px; margin-left: -4px; border-radius: 50%; background: var(--ok); }
.ltbal.neg { background: var(--danger); bottom: 22px !important; }
.ltyear { position: absolute; bottom: 2px; left: 0; right: 0; font-size: 11px; color: var(--muted); text-align: center; }
.ltyear.now { color: var(--fg); font-weight: 700; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; }
.sw.bar { background: var(--accent); }
.sw.bal { background: var(--ok); border-radius: 50%; }

/* Staff roster */
table.roster td, table.roster th { vertical-align: top; min-width: 92px; }
table.roster td.nm { min-width: 150px; }
table.roster .today { background: var(--bg); }
button.shift { display: flex; flex-direction: column; align-items: flex-start; gap: 0; width: 100%; padding: 5px 7px; font-size: 12px; background: var(--panel); color: var(--fg); border: 1px solid var(--accent); box-shadow: inset 3px 0 0 var(--accent); margin-bottom: 4px; }
button.shift small { color: var(--muted); font-weight: 400; }
button.shift:disabled { opacity: 1; cursor: default; }
button.addcell { width: 100%; padding: 5px; font-size: 12px; background: transparent; color: var(--muted); border: 1px dashed var(--line); font-weight: 500; }
button.addcell:hover { color: var(--accent); border-color: var(--accent); }
td.num { white-space: nowrap; }
.over { color: var(--danger); }

/* Visitor parking */
.bays { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.bay { display: flex; flex-direction: column; gap: 3px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: 13px; }
.bay .bayn { font-size: 12px; color: var(--muted); }
.bay.used { border-color: var(--ok); box-shadow: inset 3px 0 0 var(--ok); background: var(--panel); }
.bay.over { border-color: var(--danger); box-shadow: inset 3px 0 0 var(--danger); background: var(--panel); }
.bay button { align-self: flex-start; margin-top: 4px; }

/* Document library */
.docs { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
nav.folders { display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
nav.folders button { justify-content: space-between; background: transparent; color: var(--fg); border: 0; font-weight: 500; padding: 7px 10px; text-align: left; }
nav.folders button.on { background: var(--bg); box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
.ftype { display: inline-block; min-width: 38px; margin-right: 8px; padding: 1px 4px; font-size: 11px; font-weight: 700; text-align: center; border-radius: 4px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
@media (max-width: 700px) { .docs { grid-template-columns: minmax(0, 1fr); } nav.folders { flex-direction: row; overflow-x: auto; min-width: 0; } nav.folders button { white-space: nowrap; } }

/* Governance */
.vote { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--line); margin: 6px 0; }
.vote span { display: block; height: 100%; width: 0; }
.vote .for { background: var(--ok); }
.vote .against { background: var(--danger); }
.vote .abstain { background: var(--muted); }
.cols2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 18px; }
.done { text-decoration: line-through; color: var(--muted); }
input.inline-num { display: inline-block; width: 90px; padding: 3px 8px; margin: 0 4px; }

/* Reports */
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hrow { display: grid; grid-template-columns: 140px minmax(0, 1fr) 40px; gap: 8px; align-items: center; font-size: 14px; }
.htrack { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.hbar { display: block; height: 100%; background: var(--accent); }
article.report h1 { font-size: 1.4rem; margin: 4px 0; }
article.report h2 { font-size: 1.05rem; margin: 20px 0 8px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
@media print {
  .top, nav.side, .no-print, .foot { display: none !important; }
  .shell { display: block; }
  body, section.box { background: #fff; color: #000; border: 0; padding: 0; }
  article.report h2 { break-after: avoid; }
}
section.box h3 { font-size: .95rem; margin: 14px 0 6px; }
table.mapping select { width: 100%; }
section.box > p { margin: 0 0 12px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
td.actions { text-align: right; white-space: nowrap; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.tag.suspended { color: var(--danger); }
.empty { color: var(--muted); }

@media (max-width: 900px) {
  .shell { display: block; }
  nav.side { position: static; flex-direction: row; gap: 4px; overflow-x: auto; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
  nav.side .group { flex-direction: row; gap: 2px; }
  nav.side .group-title { display: none; }
  nav.side a { white-space: nowrap; }
  nav.side a.on { box-shadow: inset 0 -2px 0 var(--accent); }
}
@media (max-width: 600px) {
  .card { margin-top: 3vh; border-radius: 0; border-left: 0; border-right: 0; }
  .top { padding: 10px 16px; gap: 10px; }
  .page { padding: 18px 16px; }
}
