:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #e3e8ee;
  --text: #17212b;
  --muted: #5f6b7a;
  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-soft: #ccfbf1;
  --on-primary: #ffffff;
  --danger: #c0262d;
  --danger-soft: #fde8e8;
  --warn: #a45b00;
  --warn-soft: #fff1d6;
  --ok: #1d7a3e;
  --ok-soft: #dcf5e4;
  --neutral-soft: #eef1f4;
  --radius: 4px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --shadow-lg: 0 20px 50px rgb(16 24 40 / 22%);
  --tabbar-h: 64px;
  color-scheme: light;
}

/* A company's accent (its secondary color): highlights such as chips, the chosen filter and the
   round account and Log buttons. The main color unless it has one of its own. --secondary is it
   as text, --tertiary as the fill of a round button. */
:root {
  --secondary: var(--primary);
  --secondary-soft: var(--primary-soft);
  --tertiary: var(--primary);
  --tertiary-hover: var(--primary-hover);
  --on-tertiary-color: var(--on-primary);
}
:root[data-secondary] {
  --secondary: var(--secondary-light);
  --secondary-soft: color-mix(in srgb, var(--secondary-solid) 16%, white);
  --tertiary: var(--secondary-solid);
  --tertiary-hover: color-mix(in srgb, var(--secondary-solid) 85%, black);
  --on-tertiary-color: var(--on-secondary);
}

/* A company's color, worked out to stay readable in app.js's applyBranding. */
:root[data-branded] {
  --primary: var(--brand-light);
  --primary-hover: color-mix(in srgb, var(--brand-light) 85%, black);
  --primary-soft: color-mix(in srgb, var(--brand-light) 14%, white);
  --on-primary: #ffffff;
}

/* Dark: as the phone or computer is set, unless the company has chosen light or dark for
   everyone in it (data-theme, from applyBranding). The same colors either way. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #0e1418;
    --surface: #161e24;
    --surface-2: #1b252c;
    --border: #28343d;
    --text: #e6edf2;
    --muted: #93a1ad;
    --primary: #2dd4bf;
    --primary-hover: #5eead4;
    --primary-soft: #11332f;
    --on-primary: #042f2b;
    --danger: #ff6b6b;
    --danger-soft: #3a1618;
    --warn: #fbbf24;
    --warn-soft: #36290c;
    --ok: #4ade80;
    --ok-soft: #10301c;
    --neutral-soft: #222d35;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-lg: 0 20px 50px rgb(0 0 0 / 55%);
    color-scheme: dark;
  }
}
:root[data-theme=dark] {
    --bg: #0e1418;
    --surface: #161e24;
    --surface-2: #1b252c;
    --border: #28343d;
    --text: #e6edf2;
    --muted: #93a1ad;
    --primary: #2dd4bf;
    --primary-hover: #5eead4;
    --primary-soft: #11332f;
    --on-primary: #042f2b;
    --danger: #ff6b6b;
    --danger-soft: #3a1618;
    --warn: #fbbf24;
    --warn-soft: #36290c;
    --ok: #4ade80;
    --ok-soft: #10301c;
    --neutral-soft: #222d35;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-lg: 0 20px 50px rgb(0 0 0 / 55%);
    color-scheme: dark;
}
/* A company's colors in dark mode, made readable on it. */
@media (prefers-color-scheme: dark) {
  :root[data-branded]:not([data-theme=light]) {
    --primary: var(--brand-dark);
    --primary-hover: color-mix(in srgb, var(--brand-dark) 80%, white);
    --primary-soft: color-mix(in srgb, var(--brand-dark) 20%, #161e24);
    --on-primary: #0e1418;
  }
  :root[data-secondary]:not([data-theme=light]) {
    --secondary: var(--secondary-dark);
    --secondary-soft: color-mix(in srgb, var(--secondary-solid) 24%, #161e24);
  }
}
:root[data-branded][data-theme=dark] {
    --primary: var(--brand-dark);
    --primary-hover: color-mix(in srgb, var(--brand-dark) 80%, white);
    --primary-soft: color-mix(in srgb, var(--brand-dark) 20%, #161e24);
    --on-primary: #0e1418;
}
:root[data-secondary][data-theme=dark] {
    --secondary: var(--secondary-dark);
    --secondary-soft: color-mix(in srgb, var(--secondary-solid) 24%, #161e24);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
svg.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.icon.small { width: 16px; height: 16px; vertical-align: -3px; }
/* An icon with its number or words beside it, on one line and centred on each other. */
.with-icon { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- layout ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; width: 248px; flex: none;
  padding: 20px 14px; border-right: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; gap: 24px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.company-logo { display: block; max-width: 100%; max-height: 56px; object-fit: contain; }
.company:empty { display: none; }
.company { padding: 0 10px; }
.company select { width: 100%; }
:root[data-branded] .sidebar { background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.company-mark { overflow: hidden; }
.look { display: flex; align-items: center; gap: 12px; }
.look .brand { padding: 0; min-width: 0; }
.look .company-logo { height: 48px; width: auto; max-width: 60vw; }
.swatch { width: 28px; height: 28px; flex: none; border-radius: 4px; border: 1px solid var(--border); }
.company-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.content-column { flex: 1; min-width: 0; }

/* Above every page: on phones the company (its logo, or its name), and everywhere the
   button for the signed-in person's menu, at the right. */
.topbar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px clamp(16px, 4vw, 40px) 0; max-width: 1180px; }
.topbar-brand { display: none; }
.account { position: relative; flex: none; }
.account:empty { display: none; }
.avatar-button {
  width: 38px; height: 38px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  display: grid; place-items: center; font: inherit; font-size: 14px; font-weight: 700; letter-spacing: 0.02em;
  background: var(--tertiary); color: var(--on-tertiary-color); box-shadow: var(--shadow);
}
.avatar-button:hover { background: var(--tertiary-hover); }
.avatar-button:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: 2px; }
.account-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 230px; max-width: calc(100vw - 32px);
  padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.account-menu .who { display: flex; flex-direction: column; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.account-menu .who strong, .account-menu .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu .who span { color: var(--muted); font-size: 13px; }
.account-menu a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text); font-weight: 500; }
.account-menu a:hover { background: var(--surface-2); text-decoration: none; }
.account-menu a.active { color: var(--primary); }
.account-menu a .icon { color: var(--muted); }
.account-menu .sign-out { margin-top: 4px; border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--primary); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--primary-hover); text-decoration: none; }
.nav a.active { background: var(--secondary-soft); color: var(--secondary); }

/* Pages without room in the phone's tab bar, linked from the Overview instead. */
.more-links { display: none; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
@media (max-width: 860px) { .more-links { display: flex; } }

.main { min-width: 0; padding: 12px clamp(16px, 4vw, 40px) 48px; max-width: 1180px; outline: none; }

.tabbar { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  /* Phones have no sidebar, so the company (its logo, or its name) is shown here instead. */
  .topbar { justify-content: space-between; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .topbar-brand {
    display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 700; font-size: 1.1rem; color: var(--text);
  }
  .topbar-brand:hover { text-decoration: none; }
  .topbar-brand span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* A set height, so a logo without a size of its own (an SVG with only a viewBox) gets its
     width from its shape; with only a max-height it came out 0 px wide here. */
  .topbar-brand .company-logo { height: 40px; width: auto; max-width: 60vw; }
  .main { padding: 16px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; inset: auto 0 0 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: 11px; font-weight: 600; color: var(--muted);
  }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--primary); }
  .tabbar a.log span.bubble {
    display: grid; place-items: center; width: 46px; height: 46px; margin-top: -22px; border-radius: 50%;
    background: var(--tertiary); color: var(--on-tertiary-color); box-shadow: var(--shadow-lg);
  }
  h1 { font-size: 1.35rem; }
}

/* ---------- page header ---------- */

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 20px; }
.page-header .sub { color: var(--muted); margin-top: 4px; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.crumbs .sep { opacity: .6; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible, .input:focus-visible, .nav a:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 40%, transparent); outline-offset: 1px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--neutral-soft); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.icon-only { padding: 0; width: 40px; }
.btn.sm.icon-only { width: 32px; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ---------- cards & lists ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card, .stats > .card, .charts > .card { margin-top: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
/* When the buttons don't fit beside the title they wrap below it, still on the right. */
.card-head > :not(h2):last-child { margin-left: auto; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px; }
.card-head .count { color: var(--muted); font-weight: 500; font-size: .9rem; }

.grid { display: grid; gap: 16px; }
.card + .grid { margin-top: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); align-items: start; }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(5, 1fr); margin-bottom: 20px; }
@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stats > :last-child:nth-child(odd) { grid-column: 1 / -1; } /* no lone tile in the last row */
  .stat { padding: 12px 14px; }
  .stat .value { font-size: 1.6rem; }

  /* Phones have the tab bar's Log button (for the object shown, on an object page), so
     page headers leave theirs out; the remaining buttons share each row evenly. */
  .page-header .actions [data-action=log] { display: none; }
  .page-header .actions { width: 100%; }
  .page-header .actions > .btn:not(.icon-only) { flex: 1 1 auto; }
  .page-header .actions:empty { display: none; }
}
.stat { padding: 16px; display: flex; flex-direction: column; gap: 2px; color: var(--text); }
.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; }
.stat.danger .value { color: var(--danger); }
.stat.warn .value { color: var(--warn); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--border); }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--text); min-height: 60px;
}
a.row:hover { background: var(--surface-2); text-decoration: none; }
.row .avatar {
  width: 40px; height: 40px; border-radius: 4px; display: grid; place-items: center; flex: none;
  background: var(--neutral-soft); color: var(--muted); font-weight: 700;
}
.row .avatar.overdue { background: var(--danger-soft); color: var(--danger); }
.row .avatar.due_soon { background: var(--warn-soft); color: var(--warn); }
.row .avatar.ok { background: var(--ok-soft); color: var(--ok); }
.row .avatar.photo { object-fit: cover; background: var(--neutral-soft); }
.contact-hero { display: block; padding: 0; margin: 0 0 16px; border: 0; background: none; border-radius: 4px; cursor: pointer; }
.contact-hero img { display: block; width: 140px; height: 140px; border-radius: 4px; object-fit: cover; }
.contact-photo-preview { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.contact-photo-preview img { width: 64px; height: 64px; border-radius: 4px; object-fit: cover; }
.contact .avatar.photo { border-radius: 4px; }
.photo-button { padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 4px; display: block; }
.photo-button:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 40%, transparent); outline-offset: 2px; }

/* ---------- pictures ---------- */

.main-picture { display: block; width: 100%; aspect-ratio: 4 / 3; max-height: 320px; object-fit: cover; border-radius: var(--radius); background: var(--neutral-soft); }
.gallery { display: grid; gap: 8px; padding: 12px; grid-template-columns: repeat(auto-fill, minmax(min(30%, 150px), 1fr)); }
.gallery figure > button { position: relative; padding: 0; border: 0; border-radius: 4px; overflow: hidden; cursor: pointer; background: var(--neutral-soft); aspect-ratio: 1; width: 100%; display: block; }
/* A picture in the list, its description under it (two lines at most; all of it in its viewer). */
.gallery figure { margin: 0; min-width: 0; }
.gallery figcaption { margin-top: 4px; display: flex; align-items: flex-start; gap: 2px; }
.gallery figcaption .text { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gallery figcaption .btn { flex: none; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .badge-main {
  position: absolute; left: 6px; top: 6px; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 4px; background: var(--primary); color: var(--on-primary); font-size: 12px; font-weight: 600;
}
.gallery .badge-main svg { width: 12px; height: 12px; }
.gallery .badge-shared { position: absolute; top: 6px; right: 6px; display: flex; padding: 4px; border-radius: 4px; background: rgba(0, 0, 0, .6); color: #fff; }
.gallery .badge-shared svg { width: 12px; height: 12px; }
.viewer { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.viewer .stage { position: relative; background: #000; display: grid; place-items: center; min-height: 200px; }
.viewer .stage img { max-width: 100%; max-height: calc(100vh - 220px); object-fit: contain; display: block; }
.viewer .nav-btn { position: absolute; top: 50%; transform: translateY(-50%); background: rgb(0 0 0 / 45%); color: #fff; border: 0; }
.viewer .nav-btn:hover { background: rgb(0 0 0 / 65%); }
.viewer .nav-btn.prev { left: 8px; } .viewer .nav-btn.next { right: 8px; }
@media (max-width: 560px) { .viewer { max-height: 92vh; } .viewer .stage img { max-height: 60vh; } }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .path { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; }
/* Who a plan or fault is assigned to: initials in a small square, then the name. */
.assignee { display: inline-flex; align-items: center; gap: 5px; color: var(--text); font-weight: 500; }
.assignee .initials {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 4px;
  background: var(--primary-soft); color: var(--primary); font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
}
.row .end { display: flex; align-items: center; gap: 6px; flex: none; text-align: right; }
.row .end .date { font-size: 13px; color: var(--muted); }

@media (max-width: 560px) {
  .row { flex-wrap: wrap; }
  .row .end.wrap { width: 100%; justify-content: flex-end; padding-left: 52px; margin-top: -4px; }
}

.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.empty > .icon { width: 36px; height: 36px; opacity: .6; margin-bottom: 6px; }
.empty p { margin: 4px 0 12px; }

/* ---------- pills ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 4px; font-size: 12px; font-weight: 700;
  background: var(--neutral-soft); color: var(--muted); white-space: nowrap;
}
.pill.overdue, .pill.out_of_service { background: var(--danger-soft); color: var(--danger); }
.pill.due_soon { background: var(--warn-soft); color: var(--warn); }
.pill.ok, .pill.active { background: var(--ok-soft); color: var(--ok); }
.pill.brand { background: var(--secondary-soft); color: var(--secondary); }
/* A contact's role on the object whose page this is; tap to change it. */
.role-pill { border: 0; margin: 4px 0 2px; cursor: pointer; font-family: inherit; background: var(--secondary-soft); color: var(--secondary); }
.role-pill:disabled { cursor: default; }
/* Shown alone when the sign-in has expired. */
.signed-out { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.signed-out-card { max-width: 420px; width: 100%; padding: 32px 24px; text-align: center; }
.signed-out-card h1 { margin: 16px 0 8px; font-size: 1.4rem; }
.signed-out-card p { margin: 0 0 24px; }
.signed-out-card .btn { width: 100%; justify-content: center; }
/* The contact form's connections: object and role side by side, stacked on narrow phones. */
.connections .field-label { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.connection { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
/* Logging work by talking: at the top of the Log work form. */
.voice { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--radius-sm); background: var(--primary-soft); }
.voice-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.voice-head .small { flex: 1 1 200px; }
.voice .btn.listening { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
@media (prefers-reduced-motion: no-preference) { .voice .btn.listening svg { animation: pulse 1.2s ease-in-out infinite; } }
@keyframes pulse { 50% { opacity: .35; } }
/* The name box under a select whose “+ New …” was chosen. */
.inline-new { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.inline-new > span { font-size: 13px; font-weight: 600; }
.inline-new-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.inline-new-row .input { flex: 1 1 180px; }
.inline-new .error-text:empty { display: none; }
@media (max-width: 420px) {
  .connection { grid-template-columns: 1fr auto; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  .connection [data-role] { grid-column: 1; }
  .connection [data-remove-connection] { grid-row: 1 / span 2; grid-column: 2; }
}

/* ---------- toolbar & tabs ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.toolbar .search { flex: 1 1 260px; position: relative; }
.toolbar .search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .search .input { padding-left: 40px; }
.toolbar select.input { width: auto; flex: 0 1 180px; }
@media (max-width: 560px) { .toolbar select.input { flex: 1 1 140px; } }

.tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 16px; padding: 0 16px;
  border-bottom: 1px solid var(--border);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs-bar { position: relative; }
.tabs-arrow {
  position: absolute; top: 0; bottom: 17px; width: 40px; display: none; align-items: center; justify-content: center;
  border: 0; padding: 0; color: var(--text); cursor: pointer; background: linear-gradient(to right, var(--bg) 60%, transparent);
}
.tabs-arrow.prev { left: 0; }
.tabs-arrow.next { right: 0; background: linear-gradient(to left, var(--bg) 60%, transparent); }
@media (hover: hover) { .tabs-arrow:not([hidden]) { display: flex; } }
.tabs a {
  padding: 10px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.tabs .badge { font-size: 11px; background: var(--neutral-soft); color: var(--muted); border-radius: 4px; padding: 0 7px; }
@media (min-width: 861px) { .tabs { margin: 0 0 16px; padding: 0; } }

/* ---------- key/value ---------- */

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); gap: 14px 20px; margin: 0; }
.kv dt { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kv dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.notes { white-space: pre-wrap; margin: 16px 0 0; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---------- contacts ---------- */

.contact { display: flex; gap: 12px; padding: 12px 16px; align-items: flex-start; }
.contact .links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.contact .links a { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 10px; border-radius: 4px; background: var(--neutral-soft); color: var(--text); }
.contact .links a:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.contact .links .icon { width: 15px; height: 15px; }
.party-label { padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; }
.party-label + .list, .list + .party-label { border-top: 0; }
.card > .party-label:first-child { border-radius: var(--radius) var(--radius) 0 0; }

/* ---------- forms ---------- */

.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field[hidden] { display: none; }
.field > span { font-size: 13px; font-weight: 600; }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.input {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; /* 16px stops iOS zoom */
}
textarea.input { min-height: 90px; resize: vertical; }
select.input { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23889' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }
.inline { display: flex; gap: 8px; }
.inline > * { flex: 1; }
.error-text { color: var(--danger); font-size: 14px; margin: 0; }

/* ---------- dialog ---------- */

.dialog {
  width: min(640px, calc(100% - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border);
  border-radius: 4px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgb(10 15 20 / 45%); backdrop-filter: blur(2px); }
.dialog form.sheet { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.dialog header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dialog .content { padding: 20px; overflow-y: auto; }
.dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
@media (max-width: 560px) {
  .dialog {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 4px 4px 0 0; max-height: 92vh;
    animation: sheet-up .22s ease-out;
  }
  .dialog form.sheet { max-height: 92vh; }
  .dialog footer { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .dialog footer .btn { flex: 1; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 50; opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 4px; font-weight: 600; box-shadow: var(--shadow-lg);
  transition: opacity .2s, transform .2s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
@media (max-width: 860px) { .toast { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); } }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.loading { padding: 48px; text-align: center; color: var(--muted); }
.hide-mobile { }
@media (max-width: 560px) { .hide-mobile { display: none !important; } }

/* ---------- reports ---------- */

.report-picker { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.report-choice { display: flex; gap: 14px; padding: 18px; color: var(--text); margin: 0; }
.report-choice:hover { text-decoration: none; border-color: var(--primary); }
.report-choice > svg { flex: none; width: 24px; height: 24px; color: var(--tertiary); margin-top: 2px; }
.report-choice p { margin: 4px 0 0; font-size: 14px; }
.report-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 16px; padding: 16px; margin-bottom: 16px; }
.report-form .field { min-width: 160px; }
.report-form .field:has(select[name=object]) { flex: 1 1 260px; }
.report { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: clamp(16px, 4vw, 36px); }
.report-head { border-bottom: 2px solid var(--text); padding-bottom: 12px; margin-bottom: 18px; }
.report-head .brand { padding: 0 0 10px; font-size: 1rem; }
.report-head h1 { margin: 0 0 4px; font-size: 1.5rem; }
.report h2 { font-size: 1.05rem; margin: 26px 0 8px; }
.report-object { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.report-object img { width: 180px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 4px; }
.report-object .kv { flex: 1 1 300px; }
.report-summary { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0; }
.report-summary div { border: 1px solid var(--border); border-radius: 4px; padding: 8px 14px; min-width: 110px; }
.report-summary dt { font-size: 12px; color: var(--muted); }
.report-summary dd { margin: 2px 0 0; font-size: 1.25rem; font-weight: 700; }
.report-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.report-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); border-bottom: 1px solid var(--border); padding: 6px 8px; }
.report-table td { border-bottom: 1px solid var(--border); padding: 8px; vertical-align: top; }
.report-table tfoot td { font-weight: 700; border-top: 2px solid var(--text); border-bottom: 0; }
.report-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.report-table .nowrap { white-space: nowrap; }
.report-table .sign { width: 150px; }
.report-table .wide { width: 34%; }
.report-table th.num { white-space: normal; }
.report-table .sign-line { display: block; border-bottom: 1px solid var(--muted); height: 22px; }
.report-notes { color: var(--muted); font-size: 13px; white-space: pre-wrap; margin-top: 2px; }
.report-empty { margin: 4px 0; }
@media (max-width: 700px) { .report { overflow-x: auto; } .report-table { min-width: 640px; } }

/* ---------- labels ---------- */

/* Pages are laid out at real size in mm, so the preview matches what prints. */
.label-pages { overflow-x: auto; display: flex; flex-direction: column; gap: 16px; padding-bottom: 8px; }
.label-page { background: #fff; color: #000; box-shadow: var(--shadow); flex: none; box-sizing: border-box; }
.label-page.sheet { display: grid; align-content: start; }
.label-page .label { box-sizing: border-box; height: 100%; display: flex; align-items: center; gap: 2.5mm; padding: 2.5mm 3mm; overflow: hidden;
  outline: 1px dashed #cfd6dd; outline-offset: -1px; font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; }
.label .qr { height: 100%; aspect-ratio: 1; flex: none; }
.label-text { min-width: 0; display: flex; flex-direction: column; gap: .6mm; font-size: 8pt; line-height: 1.2; }
.label-name { font-weight: 700; font-size: 10.5pt; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.label-line { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.label-foot { font-size: 6.5pt; color: #444; margin-top: .8mm; }
.label-pages.small .label { padding: 1.5mm 2mm; gap: 2mm; }
.label-pages.small .label-name { font-size: 9pt; -webkit-line-clamp: 1; }
.label-pages.small .label-text { font-size: 7pt; }
.label-pages.narrow .label .qr { height: 78%; }
.label-pages.large .label .qr { height: 72%; }
.label-pages.large .label-name { font-size: 14pt; }
.label-pages.large .label-text { font-size: 10pt; }
.label-pages.large .label-foot { font-size: 8pt; }

@media print {
  .label-pages { overflow: visible; display: block; padding: 0; }
  .label-page { box-shadow: none; break-after: page; }
  .label-page:last-child { break-after: auto; }
  .label-page .label { outline: none; }
}

@media print {
  :root, :root:not([data-theme=light]), :root[data-theme=dark] { --surface: #fff; --surface-2: #fff; --bg: #fff; --text: #000; --muted: #555; --border: #bbb; }
  @page { margin: 14mm; }
  body { background: #fff; color: #000; }
  .sidebar, .tabbar, .toast, .no-print, dialog { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .report { border: 0; padding: 0; border-radius: 0; overflow: visible; }
  .report-table { min-width: 0; font-size: 11pt; }
  .report-table tr, .report-summary div, .report-object { break-inside: avoid; }
  .report h2 { break-after: avoid; }
  .pill { border: 1px solid currentColor; }
}


/* ---------- measured data (an object's Data tab) ---------- */

.data-toolbar { align-items: center; }
/* The period: presets as one group, the chosen one filled. It scopes every chart below. */
.segmented { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.segmented a { padding: 6px 12px; border-radius: 4px; color: var(--muted); font-weight: 500; font-size: 14px; white-space: nowrap; }
.segmented a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.segmented a.active { background: var(--secondary-soft); color: var(--secondary); }
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.chart-card { padding: 14px 16px 8px; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.chart-head h2 { font-size: 0.95rem; color: var(--muted); font-weight: 600; }
.chart-head .value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart { position: relative; min-height: 170px; outline: none; touch-action: pan-y; }
.chart:focus-visible { box-shadow: 0 0 0 3px var(--primary-soft); border-radius: 4px; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .band { fill: var(--primary); opacity: 0.12; }
.chart .dot { fill: var(--primary); }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart .marker { fill: var(--primary); stroke: var(--surface); stroke-width: 2; }
.chart-tip {
  position: absolute; top: 0; pointer-events: none; z-index: 2;
  display: flex; flex-direction: column; gap: 1px; padding: 6px 10px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: 12px;
}
.chart-tip[hidden] { display: none; }
.chart-tip strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.chart-tip span { color: var(--muted); }
.chart-empty { margin: -100px 0 80px; text-align: center; position: relative; }

/* Testing the broker settings, in their form. */
.connection-test { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 14px; }
.test-result { width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.test-result.good { border-color: var(--ok); background: var(--ok-soft); }
.test-result.bad { border-color: var(--danger); background: var(--danger-soft); }
.test-result ul { margin: 6px 0 0; padding-left: 18px; }
.test-result code { font-size: 12px; }

/* An address on a map (see viewMap). */
@media (min-width: 561px) { .dialog:has(.map-viewer) { width: min(900px, calc(100% - 32px)); } }
.map-viewer header h2 { min-width: 0; }
.map-viewer .stage { background: var(--surface-2); display: block; }
.map-viewer iframe { display: block; width: 100%; height: min(65vh, 560px); border: 0; }
.map-viewer footer { justify-content: flex-end; flex-wrap: wrap; }
.map-viewer footer .btn { white-space: nowrap; }
@media (max-width: 560px) { .map-viewer footer .btn { flex: 1 1 100%; } }
.map-viewer h2 .muted { display: block; font-weight: 400; margin-top: 2px; }

/* A document's file (see viewDocument). */
@media (min-width: 561px) { .dialog:has(.doc-viewer) { width: min(1100px, calc(100% - 32px)); } }
.doc-viewer header h2 { min-width: 0; overflow-wrap: anywhere; }
.doc-viewer h2 .muted { display: block; font-weight: 400; margin-top: 2px; }
.doc-viewer .stage:not(.image):not(.video) { background: var(--surface-2); display: block; }
.doc-viewer iframe { display: block; width: 100%; height: min(75vh, 900px); border: 0; background: #fff; }
.doc-viewer video { max-width: 100%; max-height: calc(100vh - 220px); display: block; }
.doc-viewer audio { display: block; width: calc(100% - 40px); margin: 40px 20px; }
.doc-viewer .unviewable { padding: 48px 20px; text-align: center; color: var(--muted); }
.doc-viewer footer { flex-wrap: wrap; }
.doc-viewer footer .btn { white-space: nowrap; }
@media (max-width: 560px) { .doc-viewer iframe { height: 65vh; } }

/* A date shown in the app's language over the browser's own date field (see dateInput):
   the browser's field is transparent on top, so tapping anywhere opens its calendar. */
.date-field { position: relative; display: flex; align-items: center; width: 100%; }
.date-field .date-shown { display: flex; align-items: center; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-field .date-shown.empty { color: var(--muted); }
.date-field .date-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.date-field .date-native::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.date-field:focus-within .date-shown { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.date-field .date-clear { position: absolute; right: 6px; z-index: 1; }
.date-field .date-clear[hidden] { display: none; }
/* Who is logging work: shown, not chosen. */
.performer { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; font-size: 14px; }

/* A row's chips (Customer, Brand, a role, visible to customers): one line under its text, from the left. */
.chips-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chips-row .pill { margin: 0; white-space: nowrap; }
.pill.icon-pill { display: inline-flex; align-items: center; padding: 2px 6px; }

/* What is known about a document or picture, in its viewer. */
.doc-details { padding: 12px 20px 4px; border-bottom: 1px solid var(--border); }
.doc-details .kv { margin: 0 0 8px; }
.viewer .description { margin: 0 0 8px; white-space: pre-wrap; }
.viewer .caption { padding: 12px 20px 4px; }
.viewer .shared-note { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.viewer .shared-note svg.icon { width: 14px; height: 14px; }
/* The details and the file scroll between the viewer's title and its buttons, which stay in view. */
.viewer-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.viewer h2 .file-name { display: block; font-weight: 400; margin-top: 2px; overflow-wrap: anywhere; }
/* A viewer's buttons wrap onto more lines on a phone instead of running off its left edge
   (a picture can have Edit and Delete, and its Main picture label). */
.viewer footer { flex-wrap: wrap; }
.viewer footer .btn { white-space: nowrap; }
@media (max-width: 560px) { .viewer footer .btn { flex: 1 1 auto; } }

/* The part of the screen that is visible: on phones the browser's own bars (Chrome's address
   bar at the bottom, say) come and go, and 100vh counts the space behind them, so a sheet's
   buttons could end up behind the bar. Browsers without dvh keep the vh values above. */
.viewer { max-height: calc(100dvh - 48px); }
.viewer .stage img, .doc-viewer video { max-height: calc(100dvh - 260px); }
.dialog, .dialog form.sheet { max-height: calc(100dvh - 48px); }
@media (max-width: 560px) {
  .dialog, .dialog form.sheet, .viewer { max-height: 92dvh; }
  .viewer .stage img { max-height: 50dvh; }
  .doc-viewer iframe { height: 50dvh; }
}
/* A document's description in its row: two lines at most, all of it when it is opened. */
.row .description { margin: 2px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* Documents and pictures in lists look alike: a 64 px thumbnail (or the file's icon), the title,
   description and details, and download, edit and delete stacked at the right. */
.media-row { align-items: flex-start; }
.media-row .title { white-space: normal; }
.media-thumb { flex: none; width: 64px; height: 64px; padding: 0; border: 0; border-radius: 4px; overflow: hidden;
  background: var(--neutral-soft); object-fit: cover; display: grid; place-items: center; color: var(--muted); }
button.media-thumb { cursor: pointer; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-thumb.doc-thumb { object-position: top; background: #fff; border: 1px solid var(--border); }
/* A row's buttons, on every list: stacked at its right, top first (a Done or Fixed button,
   then edit, then delete), all at the right edge. */
.end.stack, .row .end.stack { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; align-self: flex-start; }
/* The picture being edited, above its fields. */
.picture-preview { display: grid; place-items: center; background: var(--neutral-soft); border-radius: 4px; overflow: hidden; }
.picture-preview img { display: block; max-width: 100%; max-height: 40dvh; max-height: 40vh; object-fit: contain; }
@supports (height: 1dvh) { .picture-preview img { max-height: 40dvh; } }
/* A note in a form: the person already has this role on an object it is in. */
.above-note { margin: 4px 0 8px; padding: 8px 12px; border-radius: var(--radius-sm, 8px); background: var(--warn-soft, #fff4d6); color: var(--text); font-size: 13px; }

/* The logo on the background chosen, in the company's form. */
.look-preview { display: flex; align-items: center; justify-content: center; min-height: 64px; padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); }
.look-preview img { max-height: 48px; max-width: 100%; }
.look-swatches { display: flex; flex-wrap: wrap; gap: 12px 20px; margin-top: 12px; }
.look-swatches span { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

/* A company's menu color: the whole menu on a computer and the top bar on a phone, behind its
   logo, with text in white or near-black, whichever reads; the page around the cards takes a
   faint tint of it, so it blends in. Only when the company has chosen one. */
:root[data-brand-bg] { --bg: color-mix(in srgb, var(--brand-bg) 6%, #f4f6f8); }
:root[data-brand-bg] .sidebar { background: var(--brand-bg); color: var(--on-brand-bg); border-right-color: transparent; }
:root[data-brand-bg] .sidebar .brand { color: var(--on-brand-bg); }
:root[data-brand-bg] .sidebar .nav a { color: color-mix(in srgb, var(--on-brand-bg) 80%, transparent); }
:root[data-brand-bg] .sidebar .nav a:hover { background: color-mix(in srgb, var(--on-brand-bg) 10%, transparent); color: var(--on-brand-bg); }
:root[data-brand-bg] .sidebar .nav a.active { background: color-mix(in srgb, var(--on-brand-bg) 16%, transparent); color: var(--on-brand-bg); }
@media (max-width: 860px) {
  :root[data-brand-bg] .topbar { background: var(--brand-bg); border-bottom-color: transparent; }
  :root[data-brand-bg] .topbar-brand { color: var(--on-brand-bg); }
}
@media (prefers-color-scheme: dark) {
  :root[data-brand-bg]:not([data-theme=light]) { --bg: color-mix(in srgb, var(--brand-bg) 8%, #0e1418); }
}
:root[data-brand-bg][data-theme=dark] { --bg: color-mix(in srgb, var(--brand-bg) 8%, #0e1418); }

/* The company form's preview: its menu with the logo and a chosen item, a button and a chip. */
.look-mock { display: grid; grid-template-columns: 132px 1fr; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-height: 150px; }
.look-mock .mock-menu { padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.look-mock .mock-menu img { max-width: 100%; max-height: 32px; object-fit: contain; margin-bottom: 6px; }
.look-mock .mock-menu .mock-name { font-weight: 700; font-size: 13px; margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.look-mock .mock-item { font-size: 12px; padding: 5px 8px; border-radius: var(--radius-sm); }
.look-mock .mock-page { padding: 12px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; background: var(--bg); }
:is(.look-mock, .look-phone) .mock-card { align-self: stretch; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; font-size: 12px; display: flex; gap: 8px; align-items: center; }
:is(.look-mock, .look-phone) .mock-button { font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: var(--radius-sm); }
:is(.look-mock, .look-phone) .mock-chip { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 4px; }
.look-mock .mock-dot { width: 22px; height: 22px; border-radius: 50%; margin-left: auto; }

/* A page's "?", after its title: small and quiet until it is wanted. */
.help-button {
  display: inline-grid; place-items: center; width: 24px; height: 24px; margin-left: 6px; vertical-align: 0.15em;
  border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 700; line-height: 1; cursor: pointer; padding: 0;
}
.help-button:hover { color: var(--secondary); border-color: var(--secondary); }
.help-button:focus-visible { outline: 3px solid var(--secondary-soft); outline-offset: 2px; }

/* The first-time guide: the part it is about lit up, the rest dimmed, a card beside it. */
.tour { position: fixed; inset: 0; z-index: 1000; }
.tour::before { content: ''; position: absolute; inset: 0; background: rgb(10 15 20 / 45%); }
.tour:has(.tour-spot:not([hidden]))::before { background: transparent; }
.tour-spot { position: absolute; border-radius: var(--radius); box-shadow: 0 0 0 9999px rgb(10 15 20 / 45%); outline: 2px solid var(--on-primary); transition: all .2s ease; pointer-events: none; }
.tour-card {
  position: absolute; width: min(320px, calc(100vw - 24px)); padding: 16px; border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.tour-card.centred { left: 50%; top: 50%; transform: translate(-50%, -50%); }
.tour-card h2 { margin: 2px 0 6px; font-size: 1.05rem; }
.tour-card p { margin: 0 0 14px; }
.tour-actions { display: flex; align-items: center; gap: 6px; }
.tour-actions .btn { min-height: 36px; padding: 0 14px; }
.tour-actions .btn.icon-only { width: 36px; padding: 0; }
.tour-actions [data-skip] { padding: 0 8px; }
.tour-actions .grow { flex: 1; }

/* How to put the app on the home screen. */
.install-steps { margin: 12px 0 0; padding-left: 1.4em; display: grid; gap: 8px; }
.install-steps svg { width: 18px; height: 18px; vertical-align: -3px; color: var(--brand, #0f766e); }

/* A logo that would be hard to see on what it is shown on (a dark logo on the menu in dark
   mode, a white one on a white menu) gets a plate of its own behind it. */
.company-logo.on-light, .company-logo.on-dark { padding: 4px 8px; border-radius: 8px; box-sizing: content-box; }
.company-logo.on-light { background: #ffffff; }
.company-logo.on-dark { background: #17212b; }
.look-mock .mock-menu img.on-light, .look-mock .mock-menu img.on-dark { padding: 3px 6px; border-radius: 6px; max-width: calc(100% - 12px); }
.look-mock.dark { border-color: #2a3640; }
.look-mock.dark .mock-page { color: #e5e7eb; }
.look-mock.dark .mock-card, .look-phone.dark .mock-card { border-color: #2a3640; }
/* The company profile: the form, a note and Save, one under the other. */
[data-look] { display: grid; gap: 16px; }
[data-look] .card { margin: 0; }
[data-look] > p { margin: 0; }
.look-actions { display: flex; gap: 8px; }
/* Light and dark side by side, when each device decides. */
.look-previews { display: grid; gap: 16px; }
.look-mode { display: grid; gap: 6px; }
.look-mode-name { font-weight: 600; font-size: 13px; }
/* A computer and a phone, side by side; the phone keeps its narrow shape. */
.look-devices { display: grid; grid-template-columns: minmax(0, 400px) 150px; gap: 16px; align-items: start; justify-content: start; }
@media (max-width: 420px) { .look-devices { grid-template-columns: 1fr; justify-items: start; } }
.look-device { display: grid; gap: 4px; min-width: 0; }
.look-device > .small { display: inline-flex; align-items: center; gap: 6px; }
.look-device > .small svg { width: 14px; height: 14px; }
.look-phone { width: 150px; height: 250px; border: 6px solid #1f2937; border-radius: 18px; overflow: hidden; display: grid; grid-template-rows: auto 1fr auto; background: var(--bg); color: var(--text); }
.look-phone.dark { border-color: #3a4650; color: #e5e7eb; }
.look-phone .phone-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 8px; min-height: 34px; }
.look-phone .phone-top img { max-height: 20px; max-width: 90px; object-fit: contain; }
.look-phone .phone-top .mock-name { font-weight: 700; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.look-phone .phone-page { padding: 8px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.look-phone .mock-card { align-self: stretch; padding: 6px; font-size: 11px; display: flex; gap: 6px; align-items: center; }
.look-phone .mock-button { font-size: 11px; padding: 4px 8px; }
.look-phone .phone-tabs { display: flex; align-items: center; justify-content: space-around; padding: 6px 4px; border-top: 1px solid var(--border); }
.look-phone.dark .phone-tabs { border-top-color: #2a3640; }
.look-phone .phone-tabs > span:not(.mock-dot) { width: 12px; height: 12px; border-radius: 3px; background: color-mix(in srgb, currentColor 35%, transparent); }
.look-phone .phone-tabs .mock-dot { margin: -14px 0 0; }
.look-mock .mock-dot, .look-phone .mock-dot { display: inline-grid; place-items: center; border-radius: 50%; font-weight: 700; font-size: 13px; line-height: 1; margin-left: 0; flex: none; }
.look-mock .mock-page .mock-card { display: flex; }
.color-field .btn.icon-only { flex: none; }
.look-phone .phone-top .mock-dot svg { width: 11px; height: 11px; }
.color-field .btn[hidden] { display: none; }
/* A color: its picker, and its code beside it to type or paste. */
.color-field { display: flex; gap: 8px; align-items: stretch; }
.color-field input[type=color] { flex: 1; min-width: 0; }
.color-field input[type=text] { width: 7.5em; flex: none; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }
.color-field input[type=text]:invalid { border-color: var(--danger); }
.color-field input[type=text]::placeholder { text-transform: none; font-family: ui-sans-serif, system-ui, sans-serif; }

/* An object with a sensor mapped: a small mark in the accent color. */
.sensor-mark { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-left: 8px; vertical-align: -4px; border-radius: 50%; color: var(--secondary); background: var(--secondary-soft); }
.sensor-mark svg { width: 14px; height: 14px; }
