/* Layout: fixed light sidebar on the left, airy working column on the right; on phones the sidebar slides in from a top bar. */
:root {
  --bg: #faf9fc;            /* soft lavender-white */
  --surface: #ffffff;
  --surface-2: #f3f1f7;
  --ink: #231d2e;
  --ink-2: #5e5770;
  --ink-3: #8f88a0;
  --line: #e9e5ee;
  --accent: #5b3d99;        /* indigo */
  --accent-ink: #ffffff;
  --accent-soft: #ece6f7;
  --accent-strong: #452d78;
  --spark: #8a6ad8;         /* light end of the indigo gradient */
  --ok: #1d8a57;   --ok-bg: #e4f4ea;
  --due: #b06800;  --due-bg: #fdf0da;
  --bad: #d83a2c;  --bad-bg: #fde7e4;
  --none: #6e7180; --none-bg: #f1f0ef;
  --cat-fire: #e0503a; --cat-security: #4f5bd5; --cat-cctv: #8b55d6; --cat-water: #1d8fd1;
  --cat-electrical: #d89a00; --cat-hvac: #138a87; --cat-building: #5c606b;
  --focus: #5b3d99;
  --shadow: 0 1px 2px rgb(40 20 30 / 0.03), 0 4px 18px rgb(40 20 30 / 0.05);
  --display: 'Outfit', 'Segoe UI', system-ui, sans-serif;
  --body: 'Outfit', 'Segoe UI', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --radius: 14px;
  --sidebar: 252px;
  color-scheme: light;
}
/* MiService is deliberately light-only, even when the device is in dark mode. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15.5px/1.55 var(--body); -webkit-text-size-adjust: 100%; }
a { color: var(--accent-strong); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
.muted { color: var(--ink-2); }
.mono { font-family: var(--mono); font-size: 0.86em; }
.num { font-variant-numeric: tabular-nums; }
.label { font-size: 0.82rem; font-weight: 600; color: var(--ink-2); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; }
.sidebar { position: fixed; top: env(safe-area-inset-top, 0px); bottom: 0; left: 0; width: var(--sidebar); background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 18px; padding: 20px 14px calc(16px + env(safe-area-inset-bottom, 0px)); padding-left: max(14px, env(safe-area-inset-left, 0px)); z-index: 1000; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); padding: 2px 8px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(140deg, var(--accent), var(--spark)); display: grid; place-items: center; color: #fff; flex: none; }
.brand-mark svg { width: 19px; height: 19px; stroke: #fff; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 1.15rem; }
.brand-co { font-size: 0.8rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 0.74rem; font-weight: 600; color: var(--ink-3); padding: 14px 10px 4px; letter-spacing: 0.02em; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); border-radius: 4px 10px 10px 4px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 8px; min-width: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; flex: none; }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-role { font-size: 0.8rem; color: var(--ink-2); }
.side-foot button { justify-content: flex-start; border: 0; background: transparent; color: var(--ink-2); padding: 8px 10px; }
.side-foot button:hover { background: var(--surface-2); color: var(--ink); }

.mobilebar { display: none; }
.scrim { display: none; }
.main-col { margin-left: var(--sidebar); min-width: 0; }
.shell.no-nav .main-col { margin-left: 0; }

.wrap { max-width: 1120px; margin: 0 auto; padding-block: 30px 72px;
  padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 22px; }

@media (max-width: 900px) {
  .main-col { margin-left: 0; }
  .sidebar { transform: translateX(-105%); transition: transform 0.22s ease; box-shadow: var(--shadow); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgb(15 20 30 / 0.35); z-index: 999; }
  .mobilebar { display: flex; align-items: center; gap: 10px; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 900; background: var(--surface); border-bottom: 1px solid var(--line);
    padding-block: 10px; padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .shell.no-nav .mobilebar { display: none; }
  .mobilebar button { border: 0; background: transparent; padding: 8px; }
  .mobilebar .brand { padding: 0; }
  .mobilebar .brand-mark { width: 30px; height: 30px; }
  body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 901; background: var(--surface); }
  .wrap { padding-block: 20px 56px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); gap: 18px; }
  h1 { font-size: 1.55rem; }
}

/* ---------- controls ---------- */
button, .btn { font: 500 0.92rem/1 var(--body); border-radius: 999px; padding: 10px 18px; border: 1px solid var(--accent); background: var(--surface); color: var(--accent); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; transition: background 0.12s, border-color 0.12s; }
button:hover, .btn:hover { background: var(--accent-soft); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-small { padding: 7px 14px; font-size: 0.85rem; }
.btn-danger { color: var(--bad); border-color: var(--bad); }
button:disabled { opacity: 0.5; cursor: default; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 88px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-weight: 600; font-size: 0.88rem; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* ---------- page heading ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head .stack { gap: 5px; }
.crumbs { font-size: 0.88rem; color: var(--ink-2); }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--accent-strong); text-decoration: underline; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-title { display: flex; align-items: center; gap: 12px; }
.chip { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 13%, transparent); }
.chip.sm { width: 30px; height: 30px; border-radius: 8px; }
.chip.sm svg.i { width: 16px; height: 16px; }

/* greeting */
.hello { display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; padding: 24px; border-radius: var(--radius);
  background: linear-gradient(120deg, var(--accent-soft), color-mix(in srgb, var(--spark) 9%, var(--surface))); border: 1px solid var(--line); }
.hello .stack { gap: 4px; }

/* summary tiles */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); }
.tile:hover { border-color: var(--ink-3); }
button.tile { font: inherit; line-height: 1.4; text-align: left; align-items: flex-start; cursor: pointer; white-space: normal; }
.tile.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tile .big { font-family: var(--display); font-size: 2.1rem; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.tile .label { font-weight: 500; }
@media (max-width: 760px) { .summary { grid-template-columns: repeat(2, 1fr); gap: 10px; } .tile { padding: 14px; } .tile .big { font-size: 1.8rem; } }

/* status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; font: 600 0.78rem/1 var(--body); padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.due, .pill.advisory { color: var(--due); background: var(--due-bg); }
.pill.overdue, .pill.fail { color: var(--bad); background: var(--bad-bg); }
.pill.none { color: var(--none); background: var(--none-bg); }
.pill.pass { color: var(--ok); background: var(--ok-bg); }

/* lists */
.list { display: flex; flex-direction: column; }
.item { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 12px 6px; border-top: 1px solid var(--line); min-width: 0; }
.list > .item:first-child { border-top: 0; }
.item .main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item .title { font-weight: 600; overflow-wrap: anywhere; color: var(--ink); }
.item .meta { font-size: 0.86rem; color: var(--ink-2); overflow-wrap: anywhere; }
.item .side { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--none); flex: none; margin: 0 4px; }
.dot.ok { background: var(--ok); } .dot.due { background: var(--due); } .dot.overdue, .dot.fail { background: var(--bad); }
a.item { text-decoration: none; border-radius: 10px; }
a.item:hover { background: var(--surface-2); }
@media (max-width: 560px) { .item { grid-template-columns: auto 1fr; } .item .side { grid-column: 2; justify-content: flex-start; } }

/* site cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); min-width: 0; }
a.card:hover { border-color: var(--accent); }
.card .title { font-weight: 600; font-size: 1.02rem; }
.card .meta { font-size: 0.86rem; color: var(--ink-2); overflow-wrap: anywhere; }
.bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--ok); }
.bar.warn > span { background: var(--due); } .bar.bad > span { background: var(--bad); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 0.8rem; color: var(--ink-2); font-weight: 600; background: var(--surface-2); }
th:first-child { border-top-left-radius: 10px; } th:last-child { border-top-right-radius: 10px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; background: var(--surface-2); padding: 4px; border-radius: 12px; align-self: flex-start; max-width: 100%; }
.tabs button { border: 0; background: transparent; padding: 9px 16px; color: var(--ink-2); }
.tabs button.active { color: var(--accent-ink); background: var(--accent); }

/* check form */
.q { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 13px 0; border-top: 1px solid var(--line); }
.q:first-child { border-top: 0; }
.q-text { min-width: 0; }
.seg { display: inline-flex; gap: 6px; }
.seg button { padding: 9px 16px; min-width: 64px; justify-content: center; border-color: var(--line); color: var(--ink); }
.seg button:hover { background: var(--surface-2); }
.seg button[aria-pressed="true"][data-v="pass"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.seg button[aria-pressed="true"][data-v="fail"] { background: var(--bad); border-color: var(--bad); color: #fff; }
.seg button[aria-pressed="true"][data-v="na"] { background: var(--ink-2); border-color: var(--ink-2); color: var(--surface); }
.reading { display: flex; gap: 8px; align-items: center; }
.reading input { width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .q { grid-template-columns: 1fr; } }

.gps { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); font-size: 0.93rem; box-shadow: var(--shadow); }
.gps .dot { margin-top: 6px; }
.gps.ok .dot { background: var(--ok); } .gps.warn .dot { background: var(--due); } .gps.bad .dot { background: var(--bad); }

.sig { border: 1.5px dashed var(--ink-3); border-radius: 10px; background: #fff; touch-action: none; width: 100%; height: 150px; display: block; }
.sig-img { max-width: 320px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }

/* record sheet */
.sheet { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px 24px; }
.sheet div { display: flex; flex-direction: column; gap: 3px; min-width: 0; overflow-wrap: anywhere; }

/* map */
.map { height: 540px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 0; box-shadow: var(--shadow); }
.map.small { height: 260px; box-shadow: none; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.86rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.2); }
.leaflet-popup-content { font: 14px/1.45 var(--body); }
.leaflet-popup-content-wrapper { border-radius: 12px; }

/* sign in */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
  background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 60%), radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--spark) 12%, transparent), transparent 60%), var(--bg); }
.auth { max-width: 420px; width: 100%; gap: 18px; padding: 28px; }
.auth .brand { padding: 0; margin-bottom: 6px; }
.demo-roles { display: flex; flex-direction: column; gap: 8px; }
.demo-roles button { justify-content: space-between; white-space: normal; text-align: left; border-radius: 12px; border-color: var(--line); color: var(--ink); line-height: 1.35; padding: 12px 14px; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--due-bg); color: var(--ink); font-size: 0.93rem; }

/* form picker */
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.picker .panel { gap: 10px; }
.picker label.check { padding: 6px 0; }
.picker .freq { color: var(--ink-3); font-size: 0.84rem; }

/* QR labels */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.qr-label { background: #fff; color: #111; border: 1px solid #d5dae3; border-radius: 12px; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; break-inside: avoid; }
.qr-label .qr-head { font-weight: 700; font-size: 0.8rem; color: #5b3d99; }
.qr-label .qr-title { font-weight: 700; line-height: 1.2; }
.qr-label .qr-sub { font-size: 0.8rem; color: #555; }
.qr-box img, .qr-box canvas { display: block; width: 150px; height: 150px; }

#scanner { width: 100%; max-width: 480px; border-radius: 12px; overflow: hidden; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(22px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--surface); padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 2000; max-width: calc(100% - 32px); box-shadow: var(--shadow); }
.empty { padding: 28px; text-align: center; color: var(--ink-2); border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--surface); }
.empty svg.i { display: block; margin: 0 auto 10px; width: 22px; height: 22px; color: var(--ink-3); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@media print {
  .sidebar, .mobilebar, .no-print, .toast, body::before, .scrim { display: none !important; }
  .main-col { margin: 0; }
  body { background: #fff; color: #000; }
  .wrap { padding: 0; max-width: none; }
  .panel, .card, .tile { border: 0; padding: 0; box-shadow: none; }
  .labels { grid-template-columns: repeat(3, 1fr); }
}

/* Task cards, in the manner of a digital log book: each obligation sits on its own card. */
.panel:has(> .list), .panel:has(> #att-list) { background: transparent; border: 0; box-shadow: none; padding: 0; }
.list { gap: 10px; }
.list > .item, .list > .item:first-child { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); padding: 14px 16px; }
a.item:hover { background: var(--surface); border-color: var(--accent); }
.art { width: 50px; height: 50px; border-radius: 12px; flex: none; display: grid; place-items: center; color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 9%, var(--surface)); }
.art svg { width: 36px; height: 36px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.art.lg { width: 64px; height: 64px; border-radius: 16px; }
.art.lg svg { width: 46px; height: 46px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.photo { position: relative; display: flex; flex-direction: column; gap: 6px; }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); max-width: 100%; }
.hist-year { font-size: 1.25rem; margin-top: 6px; }
.hist-month { font-weight: 600; color: var(--ink-2); font-size: 0.9rem; padding: 6px 2px 0; }
.who-tag { display: inline-block; font-size: 0.78rem; font-weight: 500; color: var(--ink-2); background: var(--surface-2); border-radius: 999px; padding: 2px 9px; margin-left: 6px; vertical-align: 1px; }
.segbar { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--surface); gap: 2px; flex-wrap: wrap; }
.segbar button { border: 0; padding: 7px 14px; color: var(--ink-2); font-size: 0.86rem; }
.segbar button:hover { background: var(--surface-2); }
.segbar button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.auth-wrap { background: linear-gradient(110deg, #3a2669 0%, #5b3d99 55%, #8a6ad8 100%); }
.tile .big { color: var(--ink); }