/* KTE Service — "Service Line" design trial: foundation (tokens, type, controls, pop-ups, app shell).
   Page styles: office.css, field.css, planner.css, register.css. Plan: docs/redesign/PLAN.md */
:root {
  --ink: #0d1b2a; --ink-2: #26364a; --muted: #5a6677; --faint: #8b95a3;
  --bg: #f3f5f8; --surface: #fff; --sunken: #eef1f5; --hover: #f6f8fb;
  --line: #e1e6ec; --line-strong: #c9d0d9;
  --primary: #0d1b2a; --primary-dark: #000; --primary-soft: #e8ecf2;
  --accent: #f5a524; --accent-dark: #d98a0b; --accent-soft: #fff4de; --on-accent: #1e1400;
  --link: #1f5fd1; --link-soft: #e9f0fc; --link-dark: #16479e;
  --alert: #e1251b; --alert-soft: #fdecea; --danger: #c81e16; --ok: #11875d; --ok-soft: #e3f5ec;
  --r-sm: 8px; --r: 12px; --r-lg: 18px; --radius: var(--r); --radius-sm: var(--r-sm);
  --font: "Barlow", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --font-c: "Barlow Semi Condensed", "Barlow", "Arial Narrow", system-ui, sans-serif;
  --shadow-float: 0 14px 36px rgba(13, 27, 42, 0.16), 0 2px 6px rgba(13, 27, 42, 0.06);
  --top-h: 60px; --tab-h: 64px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); scroll-padding-top: calc(var(--top-h) + var(--safe-t)); }
html, body { margin: 0; }
body { font: 500 15px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
  padding-left: var(--safe-l); padding-right: var(--safe-r); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-family: var(--font-c); font-weight: 700; letter-spacing: -0.005em; }
h1 { font-size: 1.95rem; letter-spacing: -0.015em; }
h2 { font-size: 1.2rem; margin-bottom: 12px; }
h2 small { font-family: var(--font); font-weight: 600; font-size: 0.8rem; color: var(--muted); margin-left: 6px; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 8px; }
a { color: var(--link); text-underline-offset: 2px; }
small { font-size: 0.83rem; }
b, strong { font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.block { display: block; }
.mt { margin-top: 22px; }
.mt-s { margin-top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.danger-text { color: var(--danger); }
.inactive { opacity: 0.55; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--link) 55%, transparent); outline-offset: 2px; }
::selection { background: #ffe3a8; }

/* ---------- buttons ---------- */
.btn { font: 600 0.92rem/1.2 var(--font); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  padding: 9px 16px; border-radius: var(--r-sm); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; min-height: 40px; white-space: nowrap; transition: background-color 0.12s, border-color 0.12s; }
.btn:hover { border-color: var(--ink); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #000; border-color: #000; }
/* the ONE next step on a screen: signal amber */
.btn.accent, .next-btn { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.btn.accent:hover, .next-btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.next-btn { min-height: 44px; padding: 10px 20px; font-size: 0.98rem; }
.btn.danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.dialog footer .btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--sunken); border-color: transparent; }
.btn.small { padding: 5px 11px; min-height: 32px; font-size: 0.84rem; border-radius: 7px; }
.btn.big { min-height: 52px; font-size: 1.02rem; padding: 12px 22px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: wait; }
.link { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--link); cursor: pointer; text-align: left; }
.link.danger { color: var(--danger); }
.icon-btn { background: none; border: 0; font-size: 1rem; cursor: pointer; color: var(--muted); padding: 6px; border-radius: var(--r-sm); line-height: 1; }
.icon-btn:hover { background: var(--sunken); color: var(--ink); }

/* ---------- form controls ---------- */
input, select, textarea { font: 500 0.95rem/1.35 var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); padding: 9px 12px; min-height: 42px; width: 100%; transition: border-color 0.12s, box-shadow 0.12s; }
input::placeholder, textarea::placeholder { color: var(--faint); text-overflow: ellipsis; }
input:hover, select:hover, textarea:hover { border-color: #aab4c0; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(13, 27, 42, 0.1); }
input[readonly]:focus { box-shadow: none; border-color: var(--line-strong); }
input:disabled, select:disabled, textarea:disabled { background: var(--sunken); color: var(--muted); }
textarea { resize: vertical; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235a6677' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 18px; padding: 0; accent-color: var(--ink); flex: none; }
input[type="date"], input[type="month"], input[type="time"] { min-width: 0; }
.field { display: block; margin-bottom: 14px; min-width: 0; }
.field > span { display: block; font-size: 0.86rem; font-weight: 600; margin-bottom: 6px; color: var(--ink-2); }
.field small { display: block; color: var(--muted); margin-top: 5px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.check { display: inline-flex; align-items: center; gap: 9px; font-size: 0.92rem; cursor: pointer; min-height: 32px; }
.check input { width: 18px; min-height: 18px; }
.choice { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 14px 12px; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 6px 18px; min-width: 0; }
.choice legend { font-size: 0.86rem; font-weight: 600; padding: 0 4px; }
.form-error { color: var(--danger); font-size: 0.9rem; font-weight: 600; min-height: 1.2em; margin: 0; padding: 0 22px; }
.form-error:empty { min-height: 0; }

/* search box with a clear ✕ (ui.addSearchClear) */
.search-box { position: relative; margin-bottom: 12px; }
.search-box input { min-height: 46px; padding: 10px 40px 10px 42px; font-size: 1rem; border-radius: 10px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%235a6677' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 14px center; }
.search-x { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; font-size: 0.95rem; }
.search-x:hover { background: var(--sunken); color: var(--ink); }
.match-line { display: block; margin-top: 3px; font-size: 0.82rem; color: var(--link); font-weight: 600; }

/* filter bars: a control away from its default is marked blue (ui.markFilters) */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select { width: auto; min-width: 0; max-width: 100%; }
.filters input[type="search"] { flex: 1 1 260px; }
.filters select.is-active, .search-box.is-active input { background-color: var(--link-soft); border-color: var(--link); color: var(--link-dark); font-weight: 600; box-shadow: inset 0 0 0 1px var(--link); }
.filters .check { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 13px 4px 10px; min-height: 36px; font-weight: 600; font-size: 0.88rem; }
.filters .check.is-active { background: var(--link-soft); border-color: var(--link); color: var(--link-dark); box-shadow: inset 0 0 0 1px var(--link); }
.filter-summary { font-size: 0.88rem; color: var(--muted); }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; margin-bottom: 16px; min-width: 0; }
.panel > h2:first-child, .panel-head h2 { margin-bottom: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.panel-head h2 { margin-bottom: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.two-col > * { min-width: 0; }
.two-col .panel { margin-bottom: 0; }
.two-col + .panel, .panel + .two-col { margin-top: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.empty { padding: 22px 18px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r); }
.empty.error { color: var(--danger); border-color: #f2b8b4; background: var(--alert-soft); }
.loading { padding: 28px; text-align: center; color: var(--muted); }
.ok-note { background: var(--ok-soft); color: #0b5c40; border-radius: var(--r-sm); padding: 10px 12px; font-weight: 600; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border-bottom: 0; }
.chips-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* loading outline (app.js SKELETON) */
.skeleton { display: grid; gap: 14px; padding: 6px 0; text-align: left; }
.sk { display: block; border-radius: var(--r-sm); background: linear-gradient(90deg, #e7ebf0 0%, #f1f3f6 50%, #e7ebf0 100%); background-size: 200% 100%; }
.sk-title { width: 220px; height: 30px; }
.sk-line { width: 340px; max-width: 70%; height: 14px; }
.sk-card { height: 86px; border-radius: var(--r); }
@media (prefers-reduced-motion: no-preference) { .sk { animation: sk 1.3s linear infinite; } @keyframes sk { to { background-position: -200% 0; } } }

/* ---------- tabs: an underlined strip ---------- */
.tabs { display: flex; gap: 4px; margin: 0 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button, .tabs a { font: 600 0.95rem var(--font); border: 0; background: none; padding: 10px 12px 11px; cursor: pointer; color: var(--muted); white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -1px; text-decoration: none; border-radius: 0; }
.tabs button:hover, .tabs a:hover { color: var(--ink); }
.tabs button[aria-selected="true"], .tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button small { font-weight: 600; color: var(--faint); margin-left: 3px; }

/* ---------- status: colours from STAGE_COLORS (app/js/ui.js); Overdue is a separate red badge ---------- */
.status { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.status-line { display: inline-flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 6px; font: 600 0.8rem/1.35 var(--font);
  background: var(--pill-bg); color: var(--pill-fg); white-space: nowrap; }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.75; flex: none; }
.overdue-badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 6px; font: 700 0.76rem/1.35 var(--font); background: var(--alert); color: #fff; white-space: nowrap; }
.repeat-badge { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 6px; font: 700 0.74rem/1.35 var(--font); background: var(--surface); color: var(--danger); border: 1px solid #f0a8a3; white-space: nowrap; }
.repeat-link { display: inline-flex; align-items: center; gap: 6px; font-size: 0.86rem; margin-top: 4px; }
.status-line .repeat-link { margin-top: 0; gap: 4px; font-weight: 600; white-space: nowrap; }
.status-due { color: var(--muted); font-size: 0.8rem; font-weight: 500; }
.tag { display: inline-flex; align-items: center; gap: 4px; font: 600 0.76rem/1.3 var(--font); padding: 2px 8px; border-radius: 6px; background: var(--sunken); color: var(--ink-2); vertical-align: middle; white-space: nowrap; }
.tag-int, .tag-admin, .tag-on { background: var(--link-soft); color: var(--link-dark); }
.tag-manager { background: var(--ink); color: #fff; }
.tag-technician, .tag-supervisor { background: var(--ok-soft); color: #0b5c40; }
.tag-on small { font-size: 0.7rem; opacity: 0.8; }
.chip-x { border: 0; background: none; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 0 0 2px; }
.chosen { min-height: 30px; align-items: center; }
.flag { display: inline-block; background: var(--accent-soft); color: #6b4300; border-radius: 6px; padding: 2px 8px; font-size: 0.76rem; font-weight: 700; white-space: nowrap; }
.count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--ink); color: #fff; font: 700 0.76rem var(--font-c); }
.unclaimed { color: #9a4a00; font-weight: 700; }

/* label | value rows (ui.kv) */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 0; font-size: 0.9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* people */
.av { border-radius: 50%; object-fit: cover; flex: none; display: inline-block; vertical-align: middle; background: var(--sunken); }
.av-initials { display: inline-grid; place-items: center; color: #fff; font-family: var(--font-c); font-weight: 700; letter-spacing: 0.02em; }

/* folding sections */
.fold > summary { list-style: none; cursor: pointer; font-weight: 700; min-height: 36px; display: flex; gap: 8px; align-items: center; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: ""; margin-left: auto; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translate(-2px, -2px); transition: transform 0.15s; flex: none; }
.fold[open] > summary::after { transform: rotate(225deg) translate(-2px, -2px); }
.fold[open] > summary { margin-bottom: 10px; }

/* info dot with an explanation on hover or tap */
.info { position: relative; width: 17px; height: 17px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); font: 700 0.64rem/1 var(--font); cursor: help; padding: 0; flex: none; }
.info::before { content: ""; position: absolute; inset: -14px; }
.info:hover::after, .info.show::after { content: attr(data-info); position: absolute; z-index: 30; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); width: 230px; background: var(--ink); color: #fff; font: 500 0.8rem/1.4 var(--font); padding: 8px 10px; border-radius: 8px; text-align: left; white-space: normal; }

/* ---------- pop-ups (ui.openForm): centred on computers, a bottom sheet on phones ---------- */
.dialog { background: var(--surface); border: 0; border-radius: var(--r-lg); padding: 0; width: min(560px, calc(100vw - 24px)); color: var(--ink); box-shadow: var(--shadow-float);
  max-height: calc(var(--vv-height, 100dvh) - 24px); }
.dialog::backdrop { background: rgba(13, 27, 42, 0.45); }
.dialog form { display: flex; flex-direction: column; max-height: calc(var(--vv-height, 100dvh) - 24px); }
.dialog header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 18px 22px 10px; }
.dialog header h2 { margin: 0; font-size: 1.35rem; }
.dialog header .icon-btn { width: 36px; height: 36px; background: var(--sunken); border-radius: 50%; }
.dialog-body { padding: 6px 22px 6px; overflow-y: auto; overscroll-behavior: contain; }
.dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 18px; border-top: 1px solid var(--line); margin-top: 8px; }
.dialog .form-error { padding-top: 6px; }
.dialog-wide { width: min(900px, calc(100vw - 24px)); }
/* wide forms (New Complaint) on computers: pick lists may hang below the form instead of scrolling inside it */
@media (min-width: 821px) and (min-height: 521px) { .dialog-wide.dialog, .dialog-wide .dialog-body { overflow: visible; } }
.dym { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.pill { font: 600 0.86rem var(--font); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 12px; cursor: pointer; color: var(--ink); display: inline-flex; gap: 6px; align-items: baseline; }
.pill small { color: var(--muted); font-weight: 500; font-size: 0.74rem; }
.pill:hover { border-color: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .dialog[open] { animation: pop-in 0.18s ease-out; }
  @keyframes pop-in { from { opacity: 0; transform: translateY(10px) scale(0.99); } }
}

/* drop-down menus */
.menu-wrap { position: relative; }
.menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-float); padding: 6px; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
.menu.pop-up { top: auto; bottom: calc(100% + 6px); }
.menu button, .menu a { text-align: left; background: none; border: 0; padding: 10px 12px; font: 600 0.92rem var(--font); color: var(--ink); border-radius: 8px; cursor: pointer; text-decoration: none; }
.menu button:hover, .menu button:focus-visible, .menu a:hover { background: var(--sunken); }

/* searchable pick list (ui.mountPicker) */
.picker { position: relative; }
.picker-input:disabled { background: var(--sunken); color: var(--muted); cursor: not-allowed; }
.picker-list { list-style: none; margin: 6px 0 0; padding: 6px; border: 1px solid var(--line); border-radius: var(--r); max-height: 240px; overflow-y: auto; background: var(--surface); box-shadow: var(--shadow-float); }
.picker-list li { padding: 9px 11px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.picker-list li small { color: var(--muted); margin: 0; }
.picker-list li.active, .picker-list li:hover { background: var(--sunken); }
.picker-list li[aria-selected="true"] { font-weight: 700; }
.picker-list .picker-create { color: var(--link); font-weight: 700; }
.picker-list .picker-empty { color: var(--muted); cursor: default; background: none; }
.add-link { display: inline-block; margin-top: 6px; font-weight: 600; }

/* toast and "new version" bar */
#toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 0.94rem; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 80; max-width: calc(100vw - 32px); box-shadow: var(--shadow-float); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); }
#toast.warn { background: #7a4f0a; }
.update-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + var(--safe-b)); z-index: 70; display: flex; gap: 12px; align-items: center; background: var(--ink); color: #fff;
  padding: 10px 12px 10px 18px; border-radius: 14px; box-shadow: var(--shadow-float); max-width: calc(100vw - 24px); }
@media (prefers-reduced-motion: reduce) { #toast, .btn, input, select, textarea { transition: none; } }

/* ============================ app shell ============================ */
.shell { min-height: 100vh; overflow-x: clip; }
.topbar { position: sticky; top: 0; z-index: 30; height: calc(var(--top-h) + var(--safe-t)); padding: var(--safe-t) 20px 0; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex: none; }
.brand-logo { height: 34px; width: auto; display: block; }
.brand-name { font: 700 1.05rem/1 var(--font-c); color: var(--ink); padding-left: 10px; border-left: 1px solid var(--line); letter-spacing: 0.01em; }
.topnav { display: flex; align-items: stretch; gap: 2px; height: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { display: flex; align-items: center; padding: 0 11px; font: 600 0.95rem var(--font); color: var(--muted); text-decoration: none; white-space: nowrap; position: relative; }
.topnav a:hover { color: var(--ink); }
.topnav a.active { color: var(--ink); }
.topnav a.active::after { content: ""; position: absolute; left: 11px; right: 11px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.top-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.find-btn { display: flex; align-items: center; gap: 8px; min-height: 38px; min-width: 230px; padding: 0 10px 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  font: 500 0.9rem var(--font); color: var(--muted); cursor: pointer; }
.find-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.find-btn svg { width: 17px; height: 17px; }
.find-btn kbd { margin-left: auto; font: 600 0.72rem var(--font); border: 1px solid var(--line-strong); border-radius: 5px; padding: 1px 6px; color: var(--muted); background: var(--surface); }
.top-new { min-height: 38px; }
/* bell */
.bell { position: relative; }
.bell summary { list-style: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; color: var(--ink-2); position: relative; }
.bell summary::-webkit-details-marker { display: none; }
.bell summary:hover, .bell[open] summary { background: var(--sunken); }
.bell summary svg { width: 21px; height: 21px; }
.bell-label { display: none; }
.bell-count { position: absolute; top: 3px; right: 1px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--alert); color: #fff; font: 700 0.68rem/18px var(--font-c); text-align: center; border: 2px solid var(--surface); box-sizing: content-box; }
.bell-pop { position: absolute; right: -60px; top: calc(100% + 10px); z-index: 45; width: min(360px, calc(100vw - 24px)); max-height: min(460px, calc(100dvh - 120px)); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-float); }
.bell:not([open]) .bell-pop { display: none; }
.bell-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.bell-head b { font: 700 1.05rem var(--font-c); }
.bell-head .link { font-size: 0.86rem; min-height: 32px; }
.bell-list { list-style: none; margin: 0; padding: 0; }
.bell-list li + li { border-top: 1px solid var(--line); }
.bell-item { display: grid; gap: 2px; width: 100%; text-align: left; background: none; border: 0; padding: 11px 16px; font: inherit; color: var(--ink); cursor: pointer; min-height: 44px; }
.bell-item:hover { background: var(--hover); }
.bell-item small { color: var(--muted); font-size: 0.78rem; }
.bell-item.is-unread { font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
.bell-empty { padding: 16px; margin: 0; }
/* account */
.me-chip { position: relative; }
.me-chip summary { list-style: none; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 3px 8px 3px 3px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.me-chip summary::-webkit-details-marker { display: none; }
.me-chip summary:hover, .me-chip[open] summary { background: var(--sunken); }
.me-first { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-caret { color: var(--muted); font-size: 0.7rem; }
.me-pop { position: absolute; right: 0; top: calc(100% + 10px); z-index: 45; width: min(270px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; display: grid; gap: 12px; box-shadow: var(--shadow-float); }
.me-pop-id { display: flex; align-items: center; gap: 10px; }
.me-pop-id b { display: block; overflow-wrap: anywhere; }
.me-pop-id small { color: var(--muted); }
.me-pop .btn { width: 100%; }
.topbar:has(details[open]) { z-index: 60; }

.space-notice { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--alert-soft); color: #7a1510; padding: 8px 20px; font-size: 0.92rem; font-weight: 600; }
.space-notice a { color: inherit; }

main { display: block; padding: 28px 28px 70px; max-width: 1480px; margin: 0 auto; width: 100%; outline: none; min-width: 0; }
.main-col { min-width: 0; }

/* page header: title left, the page's actions right */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.head-btns, .head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lead { color: var(--muted); margin-top: 3px; }
.crumb { margin: 0 0 3px; font-size: 0.84rem; font-weight: 600; color: var(--muted); }
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; font-size: 0.9rem; font-weight: 600; text-decoration: none; color: var(--muted); min-height: 32px; }
.back::before { content: ""; width: 8px; height: 8px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin: 0 2px 0 3px; }
.back:hover { color: var(--ink); }

/* settings section strip */
.subnav { display: flex; gap: 6px; flex-wrap: wrap; max-width: 1480px; margin: 0 auto; padding: 16px 28px 0; }
.subnav a { font: 600 0.88rem var(--font); padding: 7px 13px; border-radius: 999px; text-decoration: none; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); }
.subnav a:hover { border-color: var(--line-strong); }
.subnav a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.subnav-home::before { content: "‹ "; }

/* find any complaint (top bar search) */
.finder { width: min(640px, calc(100vw - 24px)); margin: 10vh auto auto; }
.finder form { max-height: 76vh; }
.finder .search-box { margin: 18px 18px 8px; }
.finder-list { list-style: none; margin: 0; padding: 4px 8px 12px; overflow-y: auto; }
.finder-list a { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 10px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.finder-list a:hover, .finder-list a.active { background: var(--sunken); }
.finder-list .sr { font: 700 0.95rem var(--font-c); }
.finder-list .f-main b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.finder-list .f-main small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.finder-hint { padding: 6px 20px 16px; margin: 0; color: var(--muted); font-size: 0.88rem; }

/* bottom tab bar: phones only */
.tabbar { display: none; }

/* complaint and job numbers: a small navy tag with condensed figures */
.sr-tag { display: inline-flex; align-items: center; font: 700 0.9em/1 var(--font-c); letter-spacing: 0.01em; background: var(--ink); color: #fff; padding: 4px 8px 4px; border-radius: 6px; white-space: nowrap; }

/* ============================ phones and small tablets ============================ */
@media (max-width: 1440px) { .find-btn { min-width: 0; } .find-btn span, .find-btn kbd { display: none; } }
@media (max-width: 1280px) { .brand-name { display: none; } .topnav a { padding: 0 9px; } .topnav a.active::after { left: 9px; right: 9px; } }
@media (max-width: 960px) { .top-new span { display: none; } }
@media (max-width: 820px), (pointer: coarse) and (max-height: 500px) {
  :root { --top-h: 54px; }
  body { font-size: 15.5px; }
  h1 { font-size: 1.85rem; }
  .topbar { padding: var(--safe-t) 12px 0; gap: 8px; }
  .topnav, .top-new, .find-btn { display: none; }
  .brand-logo { height: 32px; }
  .me-first { display: none; }
  .me-caret { display: none; }
  .me-chip summary { padding: 3px; }
  .bell-pop { right: -52px; }
  main { padding: 18px 16px calc(var(--tab-h) + var(--safe-b) + 36px); }
  .subnav { padding: 12px 16px 0; overflow-x: auto; flex-wrap: nowrap; }
  .subnav a { white-space: nowrap; }
  .two-col, .grid-2 { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; margin-bottom: 16px; }
  .head-btns, .head-actions { width: 100%; }
  .head-btns .btn, .head-actions .btn { flex: 1 1 auto; }
  .panel { padding: 16px; border-radius: 14px; }
  .filters select { flex: 1 1 45%; }
  /* the app's bottom menu */
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: rgba(255, 255, 255, 0.96); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--line); padding: 0 var(--safe-r) var(--safe-b) var(--safe-l); -webkit-transform: translateZ(0); transform: translateZ(0); }
  .tabbar > a, .tab-more > summary { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; min-height: var(--tab-h); padding: 9px 2px 6px;
    font: 600 clamp(0.66rem, 2.8vw, 0.76rem)/1.15 var(--font); color: var(--muted); text-decoration: none; text-align: center; cursor: pointer; list-style: none; position: relative; }
  .tabbar svg { width: 24px; height: 24px; }
  .tabbar .tab-ic { display: grid; place-items: center; width: 52px; height: 30px; border-radius: 999px; transition: background-color 0.15s; }
  .tabbar [aria-current="page"] { color: var(--ink); }
  .tabbar [aria-current="page"] .tab-ic { background: var(--accent-soft); color: #7a4c00; }
  .tab-more { flex: 1; position: relative; display: flex; }
  .tab-more > summary::-webkit-details-marker { display: none; }
  .tab-more[open] > summary { color: var(--ink); }
  .tab-more-list { position: absolute; right: 8px; bottom: calc(100% + 10px); min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-float); padding: 6px; display: grid; gap: 2px; }
  .tab-more-list a { display: block; padding: 12px 14px; border-radius: 10px; font: 600 1rem var(--font); color: var(--ink); text-decoration: none; }
  .tab-more-list a.active { background: var(--ink); color: #fff; }
  /* pop-ups become bottom sheets */
  .dialog:not(.dialog-page):not(.finder) { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: calc(var(--vv-height, 100dvh) - 24px); }
  .dialog:not(.dialog-page):not(.finder) form { max-height: calc(var(--vv-height, 100dvh) - 24px); padding-bottom: var(--safe-b); }
  .dialog:not(.dialog-page):not(.finder) header { padding-top: 22px; position: relative; }
  .dialog:not(.dialog-page):not(.finder) header::before { content: ""; position: absolute; top: 8px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 4px; background: var(--line-strong); }
  .dialog header { padding-left: 18px; padding-right: 18px; }
  .dialog-body { padding-left: 18px; padding-right: 18px; }
  .dialog footer { padding: 12px 18px 16px; }
  .dialog footer .btn { flex: 1; min-height: 46px; }
  .form-error { padding: 0 18px; }
  .dialog-page form { padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
  .finder { margin: calc(var(--safe-t) + 10px) auto auto; }
  .finder-list a { grid-template-columns: 1fr auto; }
  .finder-list .sr { grid-column: 1 / -1; }
  @media (prefers-reduced-motion: no-preference) {
    .dialog:not(.dialog-page):not(.finder)[open] { animation: sheet-up 0.24s cubic-bezier(0.2, 0.8, 0.2, 1); }
    @keyframes sheet-up { from { transform: translateY(40px); opacity: 0.4; } }
  }
  .kb-open .dialog:not(.dialog-page) { margin: calc(var(--vv-top, 0px) + 12px) 0 auto; border-radius: var(--r-lg); }
  .kb-open .dialog-page { margin-top: var(--vv-top, 0px); height: var(--vv-height, 100dvh); max-height: var(--vv-height, 100dvh); }
  .kb-open .dialog-page form { max-height: var(--vv-height, 100dvh); padding-bottom: 0; }
  .kb-open .dialog footer { padding-bottom: 10px; }
  .back { min-height: 40px; }
}
/* iPhone Safari zooms into any text box under 16px and stays zoomed: 16px form text on touch screens */
@media (max-width: 820px), (pointer: coarse) { input, select, textarea, .picker-input { font-size: 16px; } }

/* Planner on computers, Schedule on touch screens (the Planner is desktop-first; see docs/rules/planner.md) */
@media (pointer: coarse), (max-width: 767px) { [data-nav="planner"] { display: none !important; } }
.no-planner [data-nav="planner"] { display: none !important; }
@media (pointer: fine) and (min-width: 768px) { html:not(.no-planner) [data-nav="schedule"] { display: none !important; } }

/* figure strips (Performance, Ownership, Today Status): joined boxes, big condensed numbers */
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 16px; }
.tiles-3 { grid-template-columns: repeat(3, 1fr); } .tiles-5 { grid-template-columns: repeat(5, 1fr); } .tiles-6 { grid-template-columns: repeat(6, 1fr); }
.tile { display: grid; gap: 2px; align-content: start; padding: 14px 16px; text-decoration: none; color: var(--ink); box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); min-width: 0; }
a.tile:hover { background: var(--hover); }
.tile b { font: 700 2rem/1.05 var(--font-c); letter-spacing: -0.02em; }
.tile span { color: var(--muted); font-size: 0.84rem; font-weight: 600; line-height: 1.3; }
.tile-alert b { color: var(--alert); }
@media (max-width: 1100px) { .tiles, .tiles-5, .tiles-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 820px), (pointer: coarse) and (max-height: 500px) { .tiles, .tiles-5, .tiles-6 { grid-template-columns: repeat(2, 1fr); } .tiles-3 { grid-template-columns: repeat(3, 1fr); } .tile b { font-size: 1.7rem; } }
@media (max-width: 820px), (pointer: coarse) and (max-height: 500px) {
  #toast { bottom: calc(var(--tab-h) + var(--safe-b) + 14px); }
  body:has(.case-actions) #toast, body:has(.case-actions) .update-bar { bottom: calc(var(--tab-h) + var(--safe-b) + 84px); }
  .update-bar { bottom: calc(var(--tab-h) + var(--safe-b) + 12px); }
}
