:root {
  /* Sedin design language */
  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-2: #f6f6f5;
  --surface-3: #f0f0ef;
  --text: #1c1c1e;
  --text-2: #5c5f66;
  --text-3: #8a8f98;
  --accent: #5e6ad2;
  --accent-hover: #4f5bc4;
  --accent-soft: #eceefb;
  --accent-text: #4a52b0;
  --green: #18a957;
  --green-soft: #e6f6ec;
  --amber: #d98a0b;
  --amber-soft: #fbf0db;
  --red: #d6453d;
  --red-soft: #fbe9e8;
  --blue: #2f72e2;
  --blue-soft: #e7f0fd;
  --ios-red: #ff3b30;
  --ios-hairline: rgba(60, 60, 67, 0.16);
  --border: rgba(28, 28, 30, 0.09);
  --border-strong: rgba(28, 28, 30, 0.16);
  --shadow-sm: 0 1px 2px rgba(28, 28, 30, 0.05), 0 0 0 1px rgba(28, 28, 30, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(28, 28, 30, 0.10), 0 0 0 1px rgba(28, 28, 30, 0.05);
  --shadow-lg: 0 12px 32px -6px rgba(28, 28, 30, 0.16), 0 0 0 1px rgba(28, 28, 30, 0.05);
  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'cv01', 'ss03';
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 15px; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---------- App shell, Sedin-style ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
  height: 100vh; padding: 0; color: var(--text);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7c87e8);
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
}
.brand strong { display:block; font-weight: 600; font-size: 16px; letter-spacing: -0.2px; }
.brand span { display:block; font-size: 11px; color: var(--text-3); margin-top: -2px; }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav::before {
  content: 'Arbetsyta'; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-3); padding: 14px 10px 6px; font-weight: 600;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 14px; font-weight: 510;
  transition: background 0.12s, color 0.12s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent-text); }
.sync-card {
  margin: 0 12px 12px; padding: 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
  display: flex; align-items: flex-start; gap: 10px; color: var(--text);
}
.sync-card strong { font-size: 13.5px; font-weight: 560; }
.sync-card small { display:block; color: var(--text-3); font-size: 11.5px; line-height: 1.35; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-top: 5px; flex: 0 0 auto; animation: pulseRing 1.8s infinite; }
@keyframes pulseRing { 0%{box-shadow:0 0 0 0 rgba(24,169,87,.35)} 70%{box-shadow:0 0 0 8px rgba(24,169,87,0)} 100%{box-shadow:0 0 0 0 rgba(24,169,87,0)} }

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }
.topbar {
  height: 56px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; border-bottom: 1px solid var(--border);
  background: rgba(251,251,250,0.85); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30; gap: 16px;
}
.topbar h1 { font-size: 17px; font-weight: 600; letter-spacing: -0.3px; }
.eyebrow { color: var(--text-3); font-size: 12px; font-weight: 560; margin: 0; }
.top-actions { display:flex; align-items:center; gap: 8px; }
.view { padding: 28px; max-width: 1180px; display: grid; gap: 24px; }
.mobile-menu { display:none; }

/* ---------- Buttons, fields, cards ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 560; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); transition: all 0.12s;
}
.btn:hover { background: var(--surface-2); }
.btn:active, .choice:active { transform: translateY(1px); }
.btn.primary, .btn-primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.primary:hover, .btn-primary:hover { background: var(--accent-hover); }
.btn.ghost, .btn-ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover, .btn-ghost:hover { background: var(--surface-2); }
.btn.soft { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.btn.danger { color: var(--red); background: var(--red-soft); border-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent) !important; }
.search, .field, select, textarea, input.field {
  height: 40px; padding: 0 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  transition: border 0.12s, box-shadow 0.12s;
}
.search { width: 260px; }
textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px;
}
.card h2, .card h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; margin-bottom: 12px; }
.card p { color: var(--text-2); }

.grid { display:grid; gap:14px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.metric { min-height: 118px; align-items: flex-start; justify-content: space-between; }
.metric strong { display:block; font-size: 26px; font-weight: 680; letter-spacing: -0.6px; margin-top: 6px; }
.metric p:not(.eyebrow) { font-size: 12px; margin-top: 4px; font-weight: 560; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 560; background: var(--surface-3); color: var(--text-2);
}
.badge.green, .badge-green { background: var(--green-soft); color: #137a40; }
.badge.amber, .badge-amber { background: var(--amber-soft); color: #9c6307; }
.badge.red, .badge-red { background: var(--red-soft); color: #b0332c; }
.badge.blue, .badge-blue { background: var(--blue-soft); color: #1f55b0; }
.badge.indigo, .badge-indigo { background: var(--accent-soft); color: var(--accent-text); }

.list { display:grid; gap:10px; }
.job {
  display:grid; grid-template-columns: 1fr auto; gap:12px; align-items:center;
  padding: 13px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); transition: background 0.1s, border 0.1s;
}
.job:hover { background: var(--surface-2); }
.job strong { font-weight: 560; }
.job p { margin-top: 2px; color: var(--text-3); font-size: 12.5px; }

.calendar { display:grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.day { min-height: 170px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.day strong { font-size: 13px; font-weight: 600; }
.slot { margin-top: 10px; padding: 10px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-text); border: 1px solid rgba(94,106,210,.14); font-size: 13px; }
.slot small { color: var(--accent-text); opacity: .75; }

/* ---------- Inspection form ---------- */
.inspection-layout { display:grid; grid-template-columns: minmax(0,1fr) 330px; gap: 16px; align-items:start; }
.question { border:1px solid var(--border); border-radius: var(--radius); padding: 16px; background: var(--surface); display:grid; gap:12px; }
.question.required { border-left: 3px solid var(--accent); }
.question.hidden { display:none; }
.q-title { display:flex; justify-content:space-between; gap:10px; align-items:center; font-weight:600; }
.segmented { display:flex; gap:8px; flex-wrap:wrap; }
.choice {
  min-height: 38px; display:inline-flex; align-items:center; justify-content:center;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  border-radius: var(--radius-sm); padding: 0 12px; font-weight:560; transition: all .12s;
}
.choice:hover { background: var(--surface-2); color: var(--text); }
.choice.active { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.photo-box { border: 1px dashed var(--border-strong); background: var(--surface-2); border-radius: var(--radius); padding: 16px; text-align:center; color: var(--text-2); }
.form-row { display:grid; grid-template-columns: 1fr auto; gap: 8px; align-items:center; }
.progress-bar { display:grid; grid-template-columns: repeat(3,1fr); gap:6px; margin: 14px 0; }
.progress-bar span { height: 8px; border-radius: 99px; background: var(--surface-3); }
.progress-bar span.done { background: var(--accent); }

.report { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 24px; }
.report-header { display:flex; justify-content:space-between; gap:16px; border-bottom: 1px solid var(--border); padding-bottom: 16px; margin-bottom: 14px; }
.report h2 { font-size: 20px; letter-spacing: -0.4px; }
.report h3 { font-size: 15px; margin: 18px 0 8px; }
.kv { display:grid; grid-template-columns: 140px 1fr; gap:8px; border-bottom:1px solid var(--border); padding:9px 0; }
.kv strong { font-weight:560; }
.kv span { color: var(--text-2); }
.toast { position: fixed; right: 22px; bottom: 22px; background: var(--text); color: white; padding: 11px 14px; border-radius: var(--radius); box-shadow: var(--shadow-lg); opacity:0; transform:translateY(10px); transition:.2s; z-index:100; }
.toast.show { opacity:1; transform:translateY(0); }
.mobile-primary { display:none; }

@media (max-width: 920px) {
  .app-shell { display:block; }
  .sidebar { transform: translateX(-105%); transition: transform .18s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .mobile-menu { display:inline-flex; width:36px; height:36px; align-items:center; justify-content:center; border:1px solid var(--border); background:var(--surface); border-radius:var(--radius-sm); }
  .top-actions { display:none; }
  .view { padding: 18px 14px 90px; max-width:none; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2, .inspection-layout, .calendar { grid-template-columns: 1fr; }
  .job { grid-template-columns: 1fr; }
  .q-title { align-items:flex-start; flex-direction:column; }
  .choice { min-height: 44px; }
  .form-row { grid-template-columns: 1fr; }
  .inspection-layout aside.card { position: sticky; bottom: 78px; z-index: 4; }
  .mobile-primary { display:grid; grid-template-columns:1fr 1fr; gap:8px; position:fixed; left:12px; right:12px; bottom:12px; z-index:50; background:rgba(255,255,255,.94); backdrop-filter:blur(10px); padding:8px; border:1px solid var(--border); border-radius:var(--radius-lg); box-shadow:var(--shadow-lg); }
}


/* ---------- Checklist builder ---------- */
.settings-head { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; margin-bottom:16px; }
.tabs { display:inline-flex; gap:2px; padding:3px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface-2); margin: 8px 0 18px; }
.tab { height:32px; padding:0 12px; border:0; border-radius:var(--radius-sm); background:transparent; color:var(--text-2); font-weight:560; }
.tab.active { background:var(--surface); color:var(--accent-text); box-shadow:var(--shadow-sm); }
.builder-layout { display:grid; grid-template-columns:minmax(0,1fr) 360px; gap:16px; align-items:start; }
.builder-card { position:sticky; top:76px; }
.question-row { display:grid; grid-template-columns:1fr auto; gap:12px; align-items:start; padding:14px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); }
.question-row:hover { background:var(--surface-2); }
.row-title { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.row-title strong { font-weight:600; }
.row-flags { display:flex; gap:6px; flex-wrap:wrap; margin-top:8px; }
.row-actions { display:flex; gap:6px; align-items:center; }
.between-add { padding:0 0 4px 14px; }
.inline-add-card { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px; border:1px dashed var(--border-strong); border-radius:var(--radius); background:var(--surface-2); }
.inline-add-card small { color:var(--text-3); }
.inline-add-card.always { background:var(--accent-soft); border-color:rgba(94,106,210,.25); }
.stepper { display:grid; grid-template-columns:repeat(3,1fr); gap:6px; margin:12px 0 16px; }
.stepper span { text-align:center; padding:7px 6px; border-radius:var(--radius-sm); background:var(--surface-2); color:var(--text-3); font-size:12px; font-weight:560; }
.stepper span.active { background:var(--accent-soft); color:var(--accent-text); }
.type-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin:12px 0; }
.type-card { text-align:left; min-height:74px; padding:10px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); transition:all .12s; }
.type-card strong { display:block; font-weight:600; }
.type-card small { display:block; color:var(--text-3); font-size:12px; margin-top:2px; line-height:1.25; }
.type-card:hover { background:var(--surface-2); }
.type-card.active { border-color:transparent; background:var(--accent-soft); color:var(--accent-text); }
.type-card.active small { color:var(--accent-text); opacity:.75; }
.field-label { display:block; font-size:13px; font-weight:560; margin:12px 0 6px; color:var(--text); }
.checkline { display:flex; align-items:center; gap:8px; margin:10px 0; color:var(--text-2); font-size:14px; }
.builder-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:16px; }
.builder-options { padding:8px 0; }
.btn-block { width:100%; margin-top:12px; }
.answer-list-card { display:grid; gap:12px; padding:14px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); }
.answer-list-card strong { font-weight:600; }
.chip-row { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.chip-row .badge button { border:0; background:transparent; color:inherit; margin-left:5px; font-weight:700; }
.checklist-heading { background:var(--surface-2); }
.segmented.readonly .choice { cursor:default; }
@media (max-width: 920px) {
  .settings-head, .inline-add-card { flex-direction:column; align-items:stretch; }
  .builder-layout { grid-template-columns:1fr; }
  .builder-card { position:static; }
  .question-row { grid-template-columns:1fr; }
  .row-actions { flex-wrap:wrap; }
  .type-grid { grid-template-columns:1fr; }
}

.definition-block { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 12px; }
.definition-block > strong { display:block; font-weight:600; margin-bottom:8px; }
.definition-block p, .definition-help { color: var(--text-2); font-size: 13px; margin: 6px 0 12px; }
.definition-grid { display:grid; grid-template-columns:1fr; gap: 2px; margin-top: 10px; }
.instruction-box { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--blue-soft); color: #1f55b0; font-size: 13px; }
.photo-box.compact { padding: 10px; font-size: 13px; text-align:left; }
@media (min-width: 1100px) { .definition-grid { grid-template-columns:1fr 1fr; } }

.field-hint { display:block; color: var(--text-3); font-size: 12px; margin-top: 5px; }
.rule-note { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--amber-soft); color: #9c6307; margin: 8px 0; }
.rule-note p { color: #9c6307; margin: 3px 0 0; font-size: 12.5px; }

.question-row.selected { border-color: rgba(94,106,210,.45); background: var(--accent-soft); }
.detail-head { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:12px; }
.follow-rule { display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:8px; padding:10px; border:1px solid var(--border); border-radius:var(--radius-sm); margin-top:8px; }
.question.follow-up { margin-left:22px; border-left:3px solid var(--amber); }
.rule-note.neutral { background: var(--blue-soft); color:#1f55b0; }
.rule-note.neutral p { color:#1f55b0; }
@media (max-width: 920px){ .follow-rule { grid-template-columns:1fr; } .question.follow-up { margin-left:0; } }

/* ---------- Clear modal creation flow ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 120; background: rgba(28,28,30,.42); backdrop-filter: blur(5px); display:grid; place-items:center; padding: 22px; }
.question-modal { width: min(760px, 100%); max-height: min(86vh, 860px); overflow:auto; background: var(--surface); border:1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-head { position: sticky; top:0; z-index:2; display:flex; justify-content:space-between; gap:16px; align-items:flex-start; padding:18px 20px; border-bottom:1px solid var(--border); background: rgba(255,255,255,.96); backdrop-filter: blur(8px); }
.modal-head h2 { font-size:20px; letter-spacing:-.4px; margin: 1px 0 2px; }
.modal-head small { color: var(--text-3); font-weight:560; }
.modal-close { width:34px; height:34px; border-radius:var(--radius-sm); border:1px solid var(--border); background:var(--surface); font-size:22px; line-height:1; color:var(--text-2); }
.modal-close:hover { background: var(--surface-2); color:var(--text); }
.modal-body { padding:20px; }
.empty-detail h3 { margin: 10px 0 8px; }
.empty-detail p { color: var(--text-2); margin-bottom:14px; }
.mini-guide { margin-top:16px; padding:12px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface-2); }
.mini-guide strong { display:block; margin-bottom:6px; }
.mini-guide ol { padding-left:18px; color:var(--text-2); font-size:13px; }
@media (max-width: 920px) { .modal-backdrop { padding:10px; align-items:end; } .question-modal { max-height:92vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; } .modal-body { padding:16px; } }

.inline-add-card.clean { justify-content:flex-start; background: var(--surface-2); border-style: solid; }
.inline-add-card.clean small { color: var(--text-2); }
.between-add { display:none; }

.image-options { border-color: rgba(47,114,226,.18); background: var(--blue-soft); }
.image-options p { color:#1f55b0; }


/* ---------- Upgraded calendar ---------- */
.calendar-hero { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; background:linear-gradient(135deg, var(--surface), #f2f3ff); }
.calendar-hero h2 { font-size:24px; letter-spacing:-.6px; margin-bottom:4px; }
.calendar-actions { display:flex; flex-wrap:wrap; gap:8px; justify-content:flex-end; }
.calendar-summary { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; }
.calendar-mini { padding:16px; display:grid; gap:4px; position:relative; overflow:hidden; }
.calendar-mini::after { content:''; position:absolute; right:-18px; top:-18px; width:64px; height:64px; border-radius:50%; background:var(--accent-soft); }
.calendar-mini strong { font-size:26px; letter-spacing:-.5px; z-index:1; }
.calendar-mini span { color:var(--text-2); font-size:13px; z-index:1; }
.calendar-mini i { justify-self:start; font-style:normal; margin-top:4px; z-index:1; }
.calendar-shell { display:grid; gap:12px; }
.calendar-toolbar { padding:12px 14px; display:flex; justify-content:space-between; align-items:center; gap:12px; }
.calendar-filter-group { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.filter-chip { height:30px; padding:0 11px; border-radius:999px; border:1px solid var(--border); background:var(--surface); color:var(--text-2); font-weight:560; }
.filter-chip.active, .filter-chip:hover { background:var(--accent-soft); color:var(--accent-text); border-color:transparent; }
.legend { display:inline-flex; align-items:center; gap:6px; color:var(--text-2); font-size:12px; font-weight:560; }
.legend-dot { width:8px; height:8px; border-radius:50%; display:inline-block; }
.legend-dot.confirmed { background:var(--green); }
.legend-dot.planned { background:var(--blue); }
.legend-dot.unassigned { background:var(--amber); }
.calendar-board { display:grid; grid-template-columns:repeat(5,minmax(210px,1fr)); gap:12px; overflow-x:auto; padding-bottom:4px; }
.calendar-day-pro { min-height:540px; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow-sm); display:flex; flex-direction:column; }
.calendar-day-pro header { padding:14px; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:flex-start; }
.calendar-day-pro header div { display:grid; gap:2px; }
.calendar-day-pro header span { color:var(--text-3); font-size:12px; font-weight:650; text-transform:uppercase; letter-spacing:.4px; }
.calendar-day-pro header strong { font-size:25px; letter-spacing:-.5px; }
.calendar-day-pro header em { font-style:normal; color:var(--text-3); font-size:12px; font-weight:560; }
.capacity { height:5px; background:var(--surface-3); overflow:hidden; }
.capacity span { display:block; height:100%; border-radius:999px; }
.capacity span.high { background:var(--amber); }
.capacity span.ok { background:var(--accent); }
.capacity span.low { background:var(--green); }
.calendar-slots { display:grid; gap:10px; padding:12px; align-content:start; flex:1; }
.calendar-job { display:grid; grid-template-columns:46px 1fr; gap:10px; padding:11px; border-radius:var(--radius); border:1px solid var(--border); background:var(--surface); position:relative; overflow:hidden; }
.calendar-job::before { content:''; position:absolute; left:0; top:0; bottom:0; width:4px; background:var(--blue); }
.calendar-job.confirmed::before { background:var(--green); }
.calendar-job.planned::before { background:var(--blue); }
.calendar-job.unassigned::before { background:var(--amber); }
.calendar-job:hover { box-shadow:var(--shadow-md); transform:translateY(-1px); transition:.12s; }
.job-time { font-weight:680; color:var(--text); font-size:13px; padding-left:2px; }
.job-main strong { font-weight:620; font-size:13.5px; display:block; line-height:1.25; }
.job-main p { margin-top:3px; color:var(--text-2); font-size:12.5px; }
.job-main small { display:block; color:var(--text-3); font-size:12px; margin-top:1px; }
.job-meta { display:flex; gap:6px; flex-wrap:wrap; margin-top:8px; }
.job-meta span { background:var(--surface-2); color:var(--text-2); border-radius:999px; padding:3px 7px; font-size:11px; font-weight:560; }
.add-slot { height:36px; border:1px dashed var(--border-strong); border-radius:var(--radius); background:var(--surface-2); color:var(--text-3); font-weight:560; }
.add-slot:hover { background:var(--accent-soft); color:var(--accent-text); border-color:rgba(94,106,210,.3); }
.unscheduled-card { display:grid; grid-template-columns:1fr auto; align-items:center; gap:12px; padding:13px 14px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); }
.unscheduled-card p { color:var(--text-3); font-size:12.5px; margin:2px 0 8px; }
.inspector-list { display:grid; gap:10px; }
.inspector-list > div { display:grid; grid-template-columns:34px 1fr; column-gap:10px; align-items:center; padding:10px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); }
.inspector-list p { grid-column:2; color:var(--text-3); font-size:12.5px; }
.avatar-mini { width:32px; height:32px; border-radius:50%; background:var(--accent-soft); color:var(--accent-text); display:grid; place-items:center; font-weight:700; grid-row:span 2; }
@media (max-width: 1100px) { .calendar-board { grid-template-columns:repeat(5,240px); } .calendar-summary { grid-template-columns:repeat(2,1fr); } }
@media (max-width: 920px) { .calendar-hero, .calendar-toolbar { flex-direction:column; align-items:stretch; } .calendar-actions { justify-content:flex-start; } .calendar-summary { grid-template-columns:1fr 1fr; } .calendar-board { grid-template-columns:1fr; overflow:visible; } .calendar-day-pro { min-height:auto; } .calendar-filter-group.right { display:none; } }


/* ---------- macOS Calendar-style desktop calendar ---------- */
.calendar-app { padding:0; overflow:hidden; }
.mac-toolbar { min-height:64px; padding:10px 18px; display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; border-bottom:1px solid var(--border); background:rgba(255,255,255,.92); }
.mac-title { font-size:24px; letter-spacing:-.5px; margin:0; font-weight:400; color:var(--text-2); }
.mac-title strong { font-weight:750; color:var(--text); }
.mac-controls { display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
.mac-nav { display:inline-flex; align-items:center; gap:2px; }
.mac-nav .btn { height:30px; min-height:0; padding:0 10px; }
.mac-nav .btn.ghost { font-size:17px; color:var(--text-2); }
.mac-new { height:30px; min-height:0; padding:0 12px; font-size:13.5px; }
.view-switch { display:inline-flex; padding:2px; border:1px solid var(--border); border-radius:8px; background:var(--surface-2); }
.view-switch button { height:28px; padding:0 14px; border:0; border-radius:6px; background:transparent; color:var(--text-2); font-weight:560; font-size:13px; }
.view-switch button.active { background:var(--surface); color:var(--text); box-shadow:var(--shadow-sm); }
.apple-calendar { background:var(--surface); }
.mac-scroll { max-height:640px; overflow:auto; position:relative; }
.week-days-head { display:grid; border-bottom:1px solid var(--border); position:sticky; top:0; z-index:7; background:rgba(255,255,255,.97); backdrop-filter:blur(6px); }
.week-days-head > div { min-height:54px; padding:7px 10px; border-left:1px solid var(--border); display:grid; align-content:center; justify-items:center; gap:1px; }
.week-days-head > div:first-child { border-left:0; }
.week-days-head span { color:var(--text-3); font-size:11px; font-weight:650; text-transform:uppercase; }
.week-days-head strong { width:28px; height:28px; border-radius:50%; display:grid; place-items:center; font-size:15px; font-weight:560; }
.week-days-head .today span { color:var(--ios-red); }
.week-days-head .today strong { background:var(--ios-red); color:#fff; }
.time-grid { height:1152px; display:grid; position:relative; }
.time-col { border-right:1px solid var(--border); background:var(--surface); }
.time-col div { height:48px; padding:0 8px 0 0; text-align:right; color:var(--text-3); font-size:11px; transform:translateY(-7px); }
.time-day { position:relative; border-right:1px solid var(--border); }
.time-day:last-child { border-right:0; }
.time-day.today { background:rgba(255,59,48,.03); }
.hour-line { display:block; height:48px; border-bottom:1px solid rgba(28,28,30,.06); }
.event-block { position:absolute; left:8px; right:8px; border-radius:7px; padding:4px 8px 4px 11px; overflow:hidden; box-shadow:0 1px 2px rgba(28,28,30,.08); border:0; display:flex; flex-direction:column; }
.event-block::before { content:''; position:absolute; left:0; top:0; bottom:0; width:4px; background:currentColor; opacity:.85; }
.event-block strong { font-size:12px; line-height:1.25; font-weight:650; }
.event-block span, .event-block small { font-size:11px; opacity:.82; line-height:1.3; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mac-now { position:absolute; left:0; right:0; border-top:2px solid var(--ios-red); z-index:5; pointer-events:none; }
.mac-now i { position:absolute; left:-4px; top:-5px; width:8px; height:8px; border-radius:50%; background:var(--ios-red); }
.event-block.blue { background:#dbeafe; color:#1e3a8a; }
.event-block.green { background:#dcfce7; color:#166534; }
.event-block.red { background:#fee2e2; color:#991b1b; }
.event-block.purple { background:#ede9fe; color:#5b21b6; }
.event-block.orange { background:#ffedd5; color:#9a3412; }
.event-block.gray { background:#f1f5f9; color:#475569; }
.overview-layout { display:grid; grid-template-columns:248px 1fr; min-height:680px; }
.mini-month-panel { border-right:1px solid var(--border); padding:16px; background:var(--surface); }
.mini-month-head { display:flex; justify-content:space-between; align-items:baseline; margin-bottom:10px; }
.mini-month-head strong { font-size:17px; }
.mini-month-head span { color:var(--text-3); }
.mini-cal { display:grid; grid-template-columns:repeat(7,1fr); gap:1px; margin-bottom:18px; }
.mini-cal .mini-wd { text-align:center; font-size:10px; font-weight:700; color:var(--text-3); padding:3px 0; }
.mini-cal button { appearance:none; border:0; background:none; height:26px; border-radius:50%; font-size:11.5px; color:var(--text); cursor:pointer; }
.mini-cal button:hover { background:var(--surface-2); }
.mini-cal button.focus { background:var(--accent-soft); color:var(--accent-text); font-weight:700; }
.mini-cal button.today { background:var(--ios-red); color:#fff; font-weight:700; }
.agenda-list h3 { font-size:14px; margin-bottom:10px; }
.agenda-list { display:grid; gap:8px; }
.agenda-list article { display:grid; grid-template-columns:10px 1fr; gap:9px; align-items:start; padding:9px; border-radius:var(--radius); background:var(--surface-2); }
.agenda-list strong { font-size:12.5px; }
.agenda-list p { color:var(--text-3); font-size:12px; }
.dot { width:8px; height:8px; border-radius:50%; margin-top:5px; display:inline-block; background:var(--accent); }
.dot.blue { background:#3b82f6; }.dot.green { background:#22c55e; }.dot.red { background:#ef4444; }.dot.purple { background:#8b5cf6; }.dot.orange,.dot.amber { background:#f97316; }.dot.gray { background:#94a3b8; }
.month-grid { display:grid; grid-template-rows:42px 1fr; }
.month-weekdays { display:grid; grid-template-columns:repeat(7,1fr); border-bottom:1px solid var(--border); }
.month-weekdays span { padding:13px 10px; color:var(--text-3); font-size:12px; font-weight:650; text-transform:uppercase; border-left:1px solid var(--border); text-align:right; }
.month-cells { display:grid; grid-template-columns:repeat(7,1fr); grid-auto-rows:106px; }
.month-cell { padding:6px; border-left:1px solid var(--border); border-bottom:1px solid var(--border); overflow:hidden; background:var(--surface); }
.month-cell.weekend { background:#fafafa; }
.month-cell.muted { background:var(--surface-2); }
.month-cell.muted .month-date { color:var(--text-3); opacity:.55; }
.month-cell small { color:var(--text-3); font-size:10.5px; display:block; margin-top:2px; }
.month-date { width:24px; height:24px; border-radius:50%; display:grid; place-items:center; font-size:12px; font-weight:600; margin:0 0 3px auto; }
.month-cell.today .month-date { background:var(--ios-red); color:#fff; }
.month-event { display:block; width:100%; text-align:left; appearance:none; border:0; cursor:pointer; border-radius:5px; padding:2px 6px; margin-top:3px; font-size:11px; line-height:1.4; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.month-event.blue { background:#dbeafe; color:#1e3a8a; }.month-event.green { background:#dcfce7; color:#166534; }.month-event.orange { background:#ffedd5; color:#9a3412; }
.month-event.red { background:#fee2e2; color:#991b1b; }.month-event.purple { background:#ede9fe; color:#5b21b6; }.month-event.gray { background:#f1f5f9; color:#475569; }
.calendar-underbar { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.compact-agenda, .compact-team { display:grid; gap:10px; }
.compact-agenda article { display:grid; grid-template-columns:12px 1fr; gap:8px; padding:10px; border:1px solid var(--border); border-radius:var(--radius); }
.compact-agenda p, .compact-team p { color:var(--text-3); font-size:12px; }
.compact-team { grid-template-columns:32px 1fr; align-items:center; }
.compact-team span { width:30px; height:30px; border-radius:50%; background:var(--accent-soft); color:var(--accent-text); display:grid; place-items:center; font-weight:700; }
@media (max-width: 1050px){ .overview-layout { grid-template-columns:1fr; } .mini-month-panel { border-right:0; border-bottom:1px solid var(--border); } }


/* ---------- Click-to-book calendar ---------- */
.time-day { cursor: crosshair; }
.event-block { cursor: pointer; }
.event-block.draft { background: rgba(255,59,48,.10); color: #b3261e; border: 1.5px dashed rgba(255,59,48,.5); box-shadow: none; pointer-events:none; }
.event-block.draft::before { display:none; }
.booking-popover { position: fixed; right: 28px; top: 86px; z-index: 90; width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 110px); overflow:auto; background: var(--surface); border:1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.booking-popover-head { position: sticky; top:0; display:flex; justify-content:space-between; gap:12px; align-items:flex-start; padding:16px; background:rgba(255,255,255,.96); border-bottom:1px solid var(--border); backdrop-filter:blur(8px); }
.booking-popover-head h3 { font-size:17px; letter-spacing:-.3px; margin:0; }
.booking-form { padding:16px; display:grid; gap:2px; }
.booking-form .form-row { grid-template-columns:1fr 1fr; }
.booking-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:14px; }
@media (max-width: 920px){ .booking-popover { left:10px; right:10px; top:auto; bottom:10px; width:auto; max-height:82vh; } }


/* ---------- Booking popover viewport fit fix ---------- */
.booking-popover {
  position: fixed;
  top: clamp(72px, 9vh, 96px);
  right: clamp(12px, 2vw, 28px);
  width: min(440px, calc(100vw - var(--sidebar-w) - 56px));
  max-width: calc(100vw - var(--sidebar-w) - 56px);
  max-height: calc(100dvh - clamp(72px, 9vh, 96px) - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.booking-popover-head {
  flex: 0 0 auto;
}
.booking-form {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 18px;
}
.booking-form textarea {
  min-height: 78px;
}
.booking-actions {
  position: sticky;
  bottom: -16px;
  background: linear-gradient(to top, var(--surface) 78%, rgba(255,255,255,0));
  padding-top: 14px;
  padding-bottom: 2px;
}
@media (max-width: 1200px) {
  .booking-popover {
    width: min(420px, calc(100vw - var(--sidebar-w) - 32px));
    max-width: calc(100vw - var(--sidebar-w) - 32px);
    right: 16px;
  }
}
@media (max-width: 920px) {
  .booking-popover {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 10px;
    width: auto;
    max-width: none;
    max-height: min(82dvh, 680px);
    border-radius: var(--radius-lg) var(--radius-lg) 12px 12px;
  }
  .booking-form .form-row {
    grid-template-columns: 1fr;
  }
}
@media (max-height: 700px) and (min-width: 921px) {
  .booking-popover {
    top: 64px;
    max-height: calc(100dvh - 76px);
  }
  .booking-form {
    gap: 0;
  }
  .booking-form textarea {
    min-height: 60px;
  }
}


/* ---------- Booking window: fixed no visible sliders ---------- */
.booking-popover {
  width: min(420px, calc(100vw - var(--sidebar-w) - 40px));
  height: auto;
  max-height: none;
  overflow: hidden !important;
  resize: none;
  display: block;
}
.booking-popover, .booking-popover * {
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
}
.booking-form {
  overflow: hidden !important;
  display: grid;
  gap: 6px;
  padding: 12px 14px 14px;
}
.booking-form .field-label {
  margin: 6px 0 3px;
  font-size: 12.5px;
}
.booking-form .field,
.booking-form select,
.booking-form input,
.booking-form textarea {
  width: 100%;
  height: 34px;
  min-height: 0;
  font-size: 14px;
}
.booking-form textarea {
  height: 62px;
  resize: none;
  overflow: hidden;
}
.booking-popover-head {
  position: static;
  padding: 13px 14px;
}
.booking-popover-head h3 {
  font-size: 16px;
}
.booking-popover .modal-close {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
}
.booking-form .form-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  gap: 8px;
}
.booking-actions {
  position: static;
  background: transparent;
  padding: 8px 0 0;
  margin-top: 4px;
}
@media (max-width: 920px) {
  .booking-popover {
    left: 10px;
    right: 10px;
    bottom: 10px;
    top: auto;
    width: auto;
    max-width: none;
    max-height: none;
    overflow: hidden !important;
  }
  .booking-form {
    padding: 10px 12px 12px;
    gap: 4px;
  }
  .booking-form .form-row {
    grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  }
  .booking-form .field-label {
    margin: 4px 0 2px;
  }
  .booking-form .field,
  .booking-form select,
  .booking-form input {
    height: 32px;
  }
  .booking-form textarea {
    height: 48px;
  }
}
@media (max-height: 740px) {
  .booking-popover-head { padding: 10px 12px; }
  .booking-popover-head h3 { font-size: 15px; }
  .booking-form { padding: 8px 10px 10px; gap: 3px; }
  .booking-form .field-label { margin: 3px 0 1px; font-size: 12px; }
  .booking-form .field,
  .booking-form select,
  .booking-form input { height: 30px; font-size: 13.5px; }
  .booking-form textarea { height: 42px; }
  .booking-actions { padding-top: 5px; }
}


/* ---------- Draggable booking window ---------- */
.booking-popover-head.drag-handle { cursor: grab; user-select: none; touch-action: none; }
.booking-popover-head.drag-handle:active, body.dragging-booking .booking-popover-head.drag-handle { cursor: grabbing; }
.booking-popover-head small { display:block; color: var(--text-3); font-size: 11.5px; margin-top: 1px; }
body.dragging-booking { user-select: none; }
body.dragging-booking .booking-popover { transition: none !important; }
@media (max-width: 920px) {
  .booking-popover[style] { width: min(420px, calc(100vw - 20px)); }
}


/* ---------- Multi-worker booking/edit support ---------- */
.worker-rows { display:grid; gap:6px; }
.worker-row { display:grid; grid-template-columns:minmax(0,1fr) 34px; gap:6px; align-items:center; }
.worker-row select { width:100%; }
.btn-small { height:30px; font-size:13px; justify-self:start; }
.event-block { min-width: 0; }
.event-block:hover { filter: brightness(.98); outline: 2px solid rgba(94,106,210,.18); }
.booking-actions { display:flex; flex-wrap:wrap; }
.booking-actions .btn.danger { margin-right:auto; }


/* ---------- Booking window higher + visible actions ---------- */
.booking-popover {
  top: 54px;
  right: 20px;
  width: min(390px, calc(100vw - var(--sidebar-w) - 34px));
  max-width: calc(100vw - var(--sidebar-w) - 34px);
}
.booking-popover-head {
  padding: 9px 12px !important;
  min-height: 58px;
  align-items: center;
}
.booking-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.btn-mini {
  height: 28px;
  padding: 0 9px;
  font-size: 12px;
}
.booking-form {
  padding: 8px 12px 10px !important;
  gap: 2px !important;
}
.booking-form .field-label {
  margin: 3px 0 2px !important;
  font-size: 12px !important;
}
.booking-form .field,
.booking-form select,
.booking-form input {
  height: 30px !important;
  font-size: 13.5px !important;
}
.worker-rows { gap: 4px; }
.worker-row { gap: 5px; }
.btn-small { height: 28px; }
.booking-form textarea {
  height: 38px !important;
}
.booking-actions {
  padding-top: 5px !important;
  margin-top: 2px !important;
}
.booking-actions .btn {
  height: 30px;
}
@media (max-width: 920px) {
  .booking-popover {
    top: 50px;
    bottom: auto !important;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
  }
}


/* ---------- Booking drag both axes fix ---------- */
.booking-popover[style] {
  right: auto !important;
  bottom: auto !important;
}
.booking-popover-head.drag-handle {
  cursor: move;
}
body.dragging-booking .booking-popover {
  will-change: left, top;
}


/* ---------- Phone workflow optimization ---------- */
.mobile-tabbar,
.mobile-today,
.mobile-calendar-agenda { display:none; }

@media (max-width: 920px) {
  :root { --mobile-tabbar-h: 68px; }
  body { padding-bottom: calc(var(--mobile-tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  .main { padding-bottom: calc(var(--mobile-tabbar-h) + 18px); }
  .topbar { position: sticky; top: 0; z-index: 40; min-height: 58px; padding: 10px 14px; backdrop-filter: blur(16px); }
  .topbar .eyebrow { display:none; }
  .topbar h1 { font-size: 20px; }
  .top-actions { display:none; }
  .view { gap: 12px; padding: 12px; }
  .card { border-radius: 14px; }
  .mobile-tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; height: calc(var(--mobile-tabbar-h) + env(safe-area-inset-bottom, 0px)); padding: 7px 8px calc(7px + env(safe-area-inset-bottom, 0px)); display:grid; grid-template-columns:repeat(5,1fr); gap: 4px; background: rgba(255,255,255,.94); border-top: 1px solid var(--border); box-shadow: 0 -12px 30px rgba(28,28,30,.10); backdrop-filter: blur(18px); }
  .mobile-tabbar a { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; min-width:0; border-radius: 13px; color: var(--text-3); font-size: 11px; font-weight: 650; text-decoration:none; }
  .mobile-tabbar a span { font-size: 17px; line-height:1; }
  .mobile-tabbar a.active { background: var(--accent-soft); color: var(--accent-text); }
  .mobile-primary { display:none !important; }

  .mobile-today { display:block; background: linear-gradient(135deg, #fff, #f2f3ff); }
  .mobile-today h2 { font-size: 20px; margin: 2px 0 3px; }
  .mobile-today p { color: var(--text-2); }
  .mobile-action-row { display:grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 12px; }
  .mobile-action-row .btn { height: 42px; }

  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid.cols-2, .grid.cols-3, .inspection-layout, .settings-layout, .calendar-underbar { grid-template-columns: 1fr !important; }
  .metric, .job, .question, .check-card { padding: 13px; }
  .job { align-items:start; }
  .btn, button, select, input, textarea { font-size: 16px; }
  .btn { min-height: 40px; }
  .choice { min-height: 44px; padding: 10px 12px; }

  .booking-sheet-backdrop { display:block; position:fixed; inset:0; z-index:94; background:rgba(0,0,0,.32); }
  .booking-popover,
  .booking-popover[style] { left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: auto !important; max-width: none !important; max-height: 93dvh !important; border-radius: 14px 14px 0 0; border: 0; background: #f2f2f7; z-index: 95; padding-bottom: env(safe-area-inset-bottom, 0px); animation: sheetUp .28s cubic-bezier(.32,.72,.35,1); }
  .booking-popover-head { display:none !important; }
  .sheet-bar { display:block; position:sticky; top:0; z-index:2; background:#f2f2f7; padding:8px 10px 8px; border-bottom:1px solid var(--ios-hairline); }
  .booking-form { padding:14px 14px 22px; }
  .booking-form .form-row { grid-template-columns: 1fr 1fr; }
  .booking-form .field, .booking-form select, .booking-form input { height: 44px !important; }
  .booking-form textarea { height: 64px !important; }
  .booking-form .field, .booking-form select, .booking-form textarea { background:#fff; border:0; box-shadow:none; border-radius:10px; }
  .booking-actions { display:none !important; }
  .sheet-delete { display:block; }

  .inspection-layout .card:first-child { order: 1; }
  .inspection-actions { position: sticky; bottom: calc(var(--mobile-tabbar-h) + 8px); z-index: 30; order: 2; box-shadow: var(--shadow-lg); }
  .inspection-actions h3 { display:none; }
  .inspection-actions #progressText { font-size: 13px; }
  .inspection-actions .btn { margin-top: 8px !important; height: 42px; }
  .inline-add-card { display:none; }

  .settings-head { align-items:stretch; gap:10px; }
  .settings-head .btn { width:100%; }
  .tabs { overflow-x:auto; padding-bottom:2px; }
  .tab { min-width:max-content; height:38px; }
  .modal-card { width: calc(100vw - 20px); max-height: 88dvh; }
}

@media (max-width: 520px) {
  .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .metric strong { font-size: 22px; }
  .mobile-action-row { grid-template-columns:1fr; }
}


/* ---------- Sedin-style mobile tab icons + reliable hit area ---------- */
@media (max-width: 920px) {
  .mobile-tabbar button {
    appearance: none;
    border: 0;
    background: transparent;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:3px;
    min-width:0;
    min-height: 52px;
    border-radius: 13px;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 650;
    text-decoration:none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-tabbar button .tab-icon {
    width: 22px;
    height: 22px;
    display:grid;
    place-items:center;
  }
  .mobile-tabbar button svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.85;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .mobile-tabbar button.active {
    background: var(--accent-soft);
    color: var(--accent-text);
  }
  .mobile-tabbar button.active svg {
    stroke-width: 2.05;
  }
  .mobile-tabbar button:active {
    transform: scale(.97);
  }
  .mobile-tabbar a { display:none; }
}


/* ---------- Mobile navigation: bottom tabs only ---------- */
@media (max-width: 920px) {
  .mobile-menu { display: none !important; }
  .sidebar { display: none !important; }
  body.nav-open .sidebar { display: none !important; transform: none !important; }
  .app-shell { display: block; }
  .main { margin-left: 0; width: 100%; }
  .topbar { grid-template-columns: 1fr; }
}


/* ---------- Phone: iOS Calendar clone + decluttered report footer ---------- */
.mobile-calendar-flow { display:none; }
.booking-sheet-backdrop, .sheet-bar, .sheet-delete { display:none; }
@keyframes sheetUp { from { transform: translateY(45%); opacity:.6; } to { transform: translateY(0); opacity:1; } }

@media (max-width: 920px) {
  .inspection-actions .report-preview-action { display:none !important; }
  .inspection-actions { padding: 10px 12px; }
  .inspection-actions .btn.primary { margin-top: 6px !important; }

  .mobile-calendar-flow { display:block; }
  .calendar-app, .calendar-underbar, .mobile-calendar-agenda { display:none !important; }

  body.route-calendar { padding-bottom: 0; }
  body.route-calendar .topbar { display:none; }
  body.route-calendar .main { padding-bottom: 0; }
  body.route-calendar .view { padding: 0; gap: 0; max-width: none; display:block; }

  .ios-cal {
    display:flex; flex-direction:column; background:var(--surface); overflow:hidden;
    height: calc(100vh - var(--mobile-tabbar-h) - env(safe-area-inset-bottom, 0px));
    height: calc(100dvh - var(--mobile-tabbar-h) - env(safe-area-inset-bottom, 0px));
  }
  .ios-cal-nav { display:flex; align-items:center; justify-content:space-between; min-height:50px; padding:4px 4px 4px 8px; }
  .ios-back { appearance:none; border:0; background:none; color:var(--ios-red); font-size:17px; font-weight:500; display:flex; align-items:center; gap:3px; padding:6px 10px 6px 2px; -webkit-tap-highlight-color:transparent; }
  .ios-back .chev { font-size:28px; line-height:1; font-weight:400; margin-top:-3px; }
  .ios-nav-year { font-size:17px; font-weight:650; letter-spacing:-.3px; padding-left:8px; }
  .ios-nav-actions { display:flex; align-items:center; }
  .ios-text-btn { appearance:none; border:0; background:none; color:var(--ios-red); font-size:17px; font-weight:500; padding:8px 10px; -webkit-tap-highlight-color:transparent; }
  .ios-icon-btn { appearance:none; border:0; background:none; color:var(--ios-red); font-size:28px; font-weight:300; line-height:1; padding:4px 14px 8px 10px; -webkit-tap-highlight-color:transparent; }

  .ios-weekday-row { display:grid; grid-template-columns:repeat(7,1fr); text-align:center; padding:2px 0 7px; font-size:12px; font-weight:650; color:var(--text-2); border-bottom:1px solid var(--ios-hairline); }

  .ios-month-scroll { flex:1; min-height:0; overflow-y:auto; -webkit-overflow-scrolling:touch; position:relative; }
  .ios-month { padding:16px 0 4px; }
  .ios-month > h3 { font-size:22px; font-weight:700; letter-spacing:-.4px; padding:0 16px 10px; }
  .ios-month > h3.now { color:var(--ios-red); }
  .ios-month-grid { display:grid; grid-template-columns:repeat(7,1fr); }
  .ios-day, .ios-day-blank { border:0; border-top:1px solid var(--ios-hairline); background:none; min-height:54px; }
  .ios-day { display:flex; flex-direction:column; align-items:center; gap:2px; padding-top:5px; color:var(--text); touch-action:manipulation; -webkit-tap-highlight-color:transparent; }
  .ios-day strong { width:34px; height:34px; display:grid; place-items:center; border-radius:50%; font-size:17px; font-weight:500; }
  .ios-day.today strong { background:var(--ios-red); color:#fff; font-weight:650; }
  .ios-day .evdot { width:6px; height:6px; border-radius:50%; background:#c7c7cc; }
  .ios-day .evdot.none { background:transparent; }
  .ios-day:active strong { background:var(--surface-3); }
  .ios-day.today:active strong { background:var(--ios-red); }

  .ios-week-strip { display:grid; grid-template-columns:repeat(7,1fr); padding:0 4px 8px; border-bottom:1px solid var(--ios-hairline); }
  .ios-strip-day { appearance:none; border:0; background:none; display:flex; flex-direction:column; align-items:center; gap:5px; padding:4px 0; color:var(--text); touch-action:manipulation; -webkit-tap-highlight-color:transparent; }
  .ios-strip-day span { font-size:11px; font-weight:650; color:var(--text-2); }
  .ios-strip-day strong { width:36px; height:36px; display:grid; place-items:center; border-radius:50%; font-size:18px; font-weight:500; }
  .ios-strip-day.today strong { color:var(--ios-red); font-weight:650; }
  .ios-strip-day.today span { color:var(--ios-red); }
  .ios-strip-day.sel strong { background:var(--text); color:var(--surface); font-weight:600; }
  .ios-strip-day.sel.today strong { background:var(--ios-red); color:#fff; }
  .ios-day-title { padding:9px 16px; font-size:14px; color:var(--text-2); border-bottom:1px solid var(--ios-hairline); }
  .ios-day-title strong { color:var(--text); font-weight:650; }

  .ios-timeline { flex:1; min-height:0; overflow-y:auto; -webkit-overflow-scrolling:touch; }
  .ios-timeline-body { position:relative; height:1452px; margin:6px 0 14px; }
  .ios-hour { position:absolute; left:58px; right:0; border-top:1px solid var(--ios-hairline); }
  .ios-hour span { position:absolute; left:-50px; top:-8px; width:42px; text-align:right; font-size:11px; font-weight:550; color:var(--text-3); }
  .ios-event { position:absolute; left:62px; right:12px; appearance:none; border:0; text-align:left; border-radius:8px; padding:4px 8px 4px 10px; overflow:hidden; display:flex; flex-direction:column; touch-action:manipulation; -webkit-tap-highlight-color:transparent; }
  .ios-event::before { content:''; position:absolute; left:0; top:0; bottom:0; width:4px; background:currentColor; opacity:.85; }
  .ios-event strong { font-size:13px; font-weight:650; line-height:1.3; }
  .ios-event span, .ios-event small { font-size:11.5px; opacity:.8; line-height:1.3; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .ios-event.blue { background:#dbeafe; color:#1e40af; }
  .ios-event.green { background:#dcfce7; color:#166534; }
  .ios-event.red { background:#fee2e2; color:#991b1b; }
  .ios-event.purple { background:#ede9fe; color:#5b21b6; }
  .ios-event.orange { background:#ffedd5; color:#9a3412; }
  .ios-event.gray { background:#f1f5f9; color:#475569; }
  .ios-event.draft { background:rgba(255,59,48,.10); color:#b3261e; border:1.5px dashed rgba(255,59,48,.5); pointer-events:none; }
  .ios-event.draft::before { display:none; }
  .ios-now { position:absolute; left:58px; right:0; border-top:2px solid var(--ios-red); z-index:5; pointer-events:none; }
  .ios-now i { position:absolute; left:-3px; top:-7px; width:12px; height:12px; border-radius:50%; background:var(--ios-red); }
  .ios-now span { position:absolute; left:-54px; top:-9px; width:44px; text-align:right; font-size:11px; font-weight:750; color:var(--ios-red); background:var(--surface); }

  .booking-sheet-backdrop { display:block; }
  .sheet-bar { display:block; }
  .sheet-delete { display:block; }
  .sheet-grabber { width:36px; height:5px; border-radius:3px; background:#c7c7cc; margin:0 auto 8px; }
  .sheet-actions { display:grid; grid-template-columns:1fr auto 1fr; align-items:center; }
  .sheet-actions strong { font-size:17px; font-weight:650; text-align:center; }
  .sheet-cancel, .sheet-save { appearance:none; border:0; background:none; color:var(--ios-red); font-size:17px; padding:6px 8px; -webkit-tap-highlight-color:transparent; }
  .sheet-cancel { justify-self:start; font-weight:450; }
  .sheet-save { justify-self:end; font-weight:700; }
  .sheet-delete { width:100%; margin-top:16px; appearance:none; border:0; background:#fff; border-radius:12px; padding:13px; color:var(--ios-red); font-size:16px; font-weight:600; }
}


/* ---------- Client/BRF list prototype ---------- */
.clients-page { display: grid; gap: 18px; }
.clients-head { align-items: flex-start; }
.client-layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 18px; align-items: start; }
.client-list { padding: 10px; position: sticky; top: 82px; max-height: calc(100dvh - 110px); display: flex; flex-direction: column; gap: 10px; }
.client-search .input { width: 100%; height: 40px; }
.client-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 7px 10px; font-size: 12px; color: var(--text-2); cursor: pointer; }
.chip.active { background: var(--accent-soft); color: var(--accent-text); border-color: rgba(94,106,210,.24); }
.client-list-scroll { display: grid; gap: 6px; overflow: auto; padding-right: 2px; }
.client-list-item { text-align: left; border: 1px solid transparent; background: transparent; border-radius: 12px; padding: 11px; display: grid; gap: 5px; cursor: pointer; color: var(--text); }
.client-list-item:hover { background: var(--surface-2); }
.client-list-item.active { background: var(--accent-soft); border-color: rgba(94,106,210,.22); }
.client-list-item strong { font-size: 14px; font-weight: 650; }
.client-list-item small { color: var(--text-3); line-height: 1.35; }
.client-detail { min-width: 0; display: grid; gap: 14px; }
.client-title-card { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.client-title-card h2 { margin: 8px 0 4px; font-size: 24px; letter-spacing: -0.03em; }
.client-title-card p { margin: 0; color: var(--text-3); }
.client-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.client-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.client-columns { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(330px, .95fr); gap: 14px; align-items: start; }
.section-title { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.section-title strong { font-size: 15px; }
.section-title small { color: var(--text-3); max-width: 280px; text-align: right; }
.unit-list { display: grid; gap: 8px; }
.unit-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.unit-row:last-child { border-bottom: 0; }
.unit-row div { display: grid; gap: 3px; }
.unit-row strong { font-size: 14px; }
.unit-row span, .unit-row small { color: var(--text-3); font-size: 12px; }
.status-pill { border-radius: 999px; padding: 5px 9px; font-size: 12px; white-space: nowrap; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.status-pill.ok { color: #147d3f; background: #eaf8ef; border-color: #bee8ca; }
.status-pill.danger { color: #a64228; background: #fff0eb; border-color: #ffd4c7; }
.status-pill.planned { color: #7a5a00; background: #fff8df; border-color: #f5df8b; }
.client-stat-block { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.client-stat-block:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.client-stat-block h4 { margin: 0 0 10px; font-size: 13px; color: var(--text-2); }
.client-stat-row { display: grid; grid-template-columns: 105px 34px 1fr 42px; gap: 8px; align-items: center; min-height: 26px; font-size: 12px; color: var(--text-2); }
.client-stat-row strong { color: var(--text); text-align: right; }
.client-stat-row small { color: var(--text-3); text-align: right; }
.client-stat-track { height: 7px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.client-stat-track i { display:block; height:100%; background: var(--accent); border-radius: inherit; }
.empty-state { color: var(--text-3); padding: 18px 10px; font-size: 13px; }

@media (max-width: 920px) {
  .client-layout { grid-template-columns: 1fr; gap: 12px; }
  .client-list { position: static; max-height: none; }
  .client-list-scroll { grid-auto-flow: column; grid-auto-columns: minmax(230px, 78vw); overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; }
  .client-title-card { display: grid; }
  .client-actions { justify-content: stretch; }
  .client-actions .btn { flex: 1; }
  .client-metrics { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .client-columns { grid-template-columns: 1fr; }
  .section-title { display: grid; }
  .section-title small { text-align: left; max-width: none; }
  .client-stat-row { grid-template-columns: 92px 28px 1fr 36px; }
}
@media (max-width: 520px) {
  .client-metrics { grid-template-columns: 1fr; }
  .unit-row { align-items: flex-start; }
}


/* Client hierarchy: huvudkund -> underkunder/adresser -> aggregated list statistics */
.client-master-grid{display:grid;grid-template-columns:1.7fr repeat(3,minmax(120px,.8fr));gap:12px;margin:14px 0 16px}
.contact-card,.mini-summary{border:1px solid var(--border);border-radius:14px;background:#fff;padding:14px;display:flex;flex-direction:column;gap:5px;min-width:0}
.contact-card small,.mini-summary span{font-size:11px;text-transform:uppercase;letter-spacing:.08em;color:var(--muted);font-weight:700}
.contact-card strong,.mini-summary strong{font-size:18px;color:var(--text)}
.contact-card a{color:var(--accent);text-decoration:none;font-weight:700;font-size:13px;overflow-wrap:anywhere}
.contact-card span,.contact-card p,.mini-summary small{color:var(--muted);font-size:13px;margin:0}
.client-workspace{display:grid;grid-template-columns:minmax(0,1.35fr) minmax(320px,.75fr);gap:16px;align-items:start}
.subclient-panel,.client-stat-panel{min-width:0}
.unit-list.detailed{display:flex;flex-direction:column;gap:10px}
.detailed-unit{display:grid;grid-template-columns:minmax(180px,1fr) minmax(190px,.85fr) auto;gap:14px;align-items:center;padding:14px;border:1px solid var(--border);border-radius:14px;background:linear-gradient(180deg,#fff,#fbfbff)}
.unit-main{display:flex;flex-direction:column;gap:4px;min-width:0}.unit-main strong{font-size:15px}.unit-main span,.unit-main small{color:var(--muted);font-size:13px;overflow-wrap:anywhere}
.unit-contact{display:flex;flex-direction:column;gap:3px;border-left:1px solid var(--border);padding-left:12px;min-width:0}
.unit-contact small{font-size:10px;text-transform:uppercase;letter-spacing:.08em;color:var(--muted);font-weight:800}.unit-contact strong{font-size:13px}.unit-contact span{font-size:12px;color:var(--muted);overflow-wrap:anywhere}
.client-stat-panel{position:sticky;top:18px}.client-stat-panel .field-label{display:block;margin:10px 0 6px;color:var(--muted);font-size:12px;font-weight:800;text-transform:uppercase;letter-spacing:.07em}
.stats-context{display:flex;justify-content:space-between;gap:10px;align-items:center;border:1px solid var(--border);background:#f7f7ff;border-radius:12px;padding:10px 12px;margin:12px 0}.stats-context span{color:var(--muted);font-size:12px;text-align:right}
.client-stat-block{margin-top:14px}.client-stat-block h4{margin:0 0 8px;font-size:14px}.client-stat-row{grid-template-columns:minmax(80px,1fr) 38px minmax(80px,1.2fr) 38px}
@media (max-width:1100px){.client-master-grid{grid-template-columns:1fr 1fr}.client-workspace{grid-template-columns:1fr}.client-stat-panel{position:static}.detailed-unit{grid-template-columns:1fr}}
@media (max-width:720px){.client-master-grid{grid-template-columns:1fr}.client-layout{grid-template-columns:1fr}.client-list{position:static}.detailed-unit{grid-template-columns:1fr;align-items:start}.unit-contact{border-left:0;border-top:1px solid var(--border);padding:10px 0 0}.client-stat-row{grid-template-columns:1fr 34px}.client-stat-row .client-stat-track{grid-column:1/-1}.stats-context{align-items:flex-start;flex-direction:column}.client-actions{width:100%;display:grid;grid-template-columns:1fr 1fr}.client-actions .btn{width:100%}}


/* ---------- Layout repair pass: centered desktop + real phone fit ---------- */
:root { --muted: var(--text-3); }
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
body { min-width: 0; }
.app-shell, .main, .view { min-width: 0; }
.main { width: calc(100% - var(--sidebar-w)); }
.view {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding-left: clamp(18px, 3vw, 32px);
  padding-right: clamp(18px, 3vw, 32px);
}
.card, .client-list, .client-detail, .client-title-card, .client-workspace, .subclient-panel, .client-stat-panel { max-width: 100%; min-width: 0; }
img, svg, video, canvas { max-width: 100%; }
input, select, textarea, button { max-width: 100%; }

/* Client page: stable desktop grid without distorting the shell */
.clients-page { width: 100%; min-width: 0; }
.client-layout { grid-template-columns: minmax(260px, 300px) minmax(0, 1fr); width: 100%; min-width: 0; }
.client-list { overflow: hidden; }
.client-list-scroll { min-width: 0; }
.client-list-item { width: 100%; min-width: 0; overflow: hidden; }
.client-list-item strong, .client-list-item small { overflow-wrap: anywhere; }
.client-master-grid { grid-template-columns: minmax(0, 1.25fr) repeat(3, minmax(100px, .65fr)); }
.client-workspace { grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); }
.detailed-unit { grid-template-columns: minmax(0, 1fr) minmax(170px, .75fr) auto; }
.client-stat-row { min-width: 0; }

@media (max-width: 1100px) {
  .client-layout { grid-template-columns: 1fr; }
  .client-list { position: static; max-height: none; }
  .client-master-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .client-workspace { grid-template-columns: 1fr; }
  .client-stat-panel { position: static; }
  .detailed-unit { grid-template-columns: minmax(0,1fr); }
}

@media (max-width: 920px) {
  :root { --mobile-tabbar-h: 72px; }
  html, body { overflow-x: hidden; }
  body { padding-bottom: calc(var(--mobile-tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  .app-shell { display: block; width: 100%; overflow-x: hidden; }
  .sidebar, body.nav-open .sidebar { display: none !important; transform: none !important; }
  .main { margin-left: 0 !important; width: 100% !important; max-width: 100%; padding-bottom: calc(var(--mobile-tabbar-h) + 10px); }
  .topbar { width: 100%; min-height: 56px; padding: 10px 14px; }
  .topbar h1 { font-size: 19px; line-height: 1.15; }
  .view { width: 100%; max-width: none; margin: 0; padding: 12px 12px calc(var(--mobile-tabbar-h) + 18px); gap: 12px; overflow-x: hidden; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr !important; }
  .card { padding: 14px; border-radius: 12px; }

  .mobile-tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
    height: calc(var(--mobile-tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding: 6px 5px calc(6px + env(safe-area-inset-bottom, 0px));
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 2px;
    background: rgba(255,255,255,.96);
    border-top: 1px solid var(--border);
    box-shadow: 0 -10px 26px rgba(28,28,30,.10);
    backdrop-filter: blur(18px);
    overflow: hidden;
  }
  .mobile-tabbar button { min-width: 0; width: 100%; padding: 5px 1px; border-radius: 11px; font-size: 9.5px; line-height: 1.05; }
  .mobile-tabbar button .tab-icon { width: 20px; height: 20px; margin-bottom: 1px; }
  .mobile-tabbar button svg { width: 19px; height: 19px; }
  .mobile-tabbar button span:last-child { display:block; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

  .clients-head { display: grid; gap: 10px; }
  .clients-head .btn { width: 100%; }
  .client-layout { display: grid; grid-template-columns: 1fr !important; gap: 12px; }
  .client-list { padding: 10px; }
  .client-list-scroll { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(210px, 82vw); overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .client-title-card { display: grid; gap: 12px; }
  .client-title-card h2 { font-size: 21px; }
  .client-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; justify-content: stretch; }
  .client-master-grid { display: grid; grid-template-columns: 1fr !important; gap: 10px; }
  .client-workspace { display: grid; grid-template-columns: 1fr !important; gap: 12px; }
  .detailed-unit { display: grid; grid-template-columns: 1fr !important; gap: 10px; align-items: start; }
  .unit-contact { border-left: 0; border-top: 1px solid var(--border); padding: 10px 0 0; }
  .client-stat-row { grid-template-columns: minmax(0,1fr) 32px !important; gap: 6px; }
  .client-stat-row .client-stat-track { grid-column: 1 / -1; }
  .client-stat-row small { text-align: left; }
  .stats-context { flex-direction: column; align-items: flex-start; }
  .section-title { display: grid; gap: 4px; }
  .section-title small { text-align: left; max-width: none; }
}

@media (max-width: 380px) {
  .mobile-tabbar button { font-size: 8.5px; }
  .mobile-tabbar button .tab-icon { width: 18px; height: 18px; }
  .mobile-tabbar button svg { width: 17px; height: 17px; }
  .view { padding-left: 10px; padding-right: 10px; }
}


/* ---------- Phone polish: no desktop squeeze on Kunder ---------- */
@media (max-width: 920px) {
  .clients-page { gap: 12px; }
  .client-filter { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .chip { white-space: nowrap; flex: 0 0 auto; }
  .client-list-item { min-height: 104px; align-content: start; }
  .client-detail { gap: 12px; }
  .contact-card, .mini-summary { padding: 12px; border-radius: 12px; }
  .contact-card strong, .mini-summary strong { font-size: 16px; }
  .client-stat-panel .input { width: 100%; height: 44px; }
  .status-pill { justify-self: start; }
}


/* ---------- UI polish pass: prevent text spills and cramped controls ---------- */
* { min-width: 0; }
.btn, button, .chip, .badge, .status-pill, .choice {
  max-width: 100%;
  min-width: 0;
  white-space: normal;
  line-height: 1.18;
  overflow-wrap: anywhere;
  text-align: center;
}
.btn {
  height: auto;
  min-height: 36px;
  padding-top: 8px;
  padding-bottom: 8px;
}
.btn-small, .btn-mini, .mac-nav .btn {
  white-space: nowrap;
  overflow-wrap: normal;
}
.badge, .status-pill {
  min-height: 22px;
  height: auto;
  align-items: center;
  justify-content: center;
  white-space: normal;
}
.card, .job, .question, .unit-row, .detailed-unit, .client-list-item, .contact-card, .mini-summary {
  overflow-wrap: anywhere;
}
.client-title-card p, .unit-main span, .unit-main small, .unit-contact span, .client-list-item small, .section-title small, .job p, .card p {
  overflow-wrap: anywhere;
  word-break: normal;
}
.client-actions, .mobile-action-row, .booking-actions, .builder-actions, .row-actions, .calendar-actions, .mac-controls {
  min-width: 0;
}
.client-actions .btn, .mobile-action-row .btn, .booking-actions .btn, .builder-actions .btn, .row-actions .btn {
  min-width: 0;
}
.search, .field, select, textarea, input.field, .input {
  width: 100%;
  min-width: 0;
}
.topbar { min-width: 0; }
.topbar > div:first-of-type { min-width: 0; }
.topbar h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { min-width: 0; }
.top-actions .search { width: clamp(170px, 22vw, 260px); }

/* Cleaner statistics rows: avoid label/value collisions */
.client-stat-row {
  grid-template-columns: minmax(0, 1fr) auto minmax(70px, 1fr) auto !important;
}
.client-stat-row span:first-child {
  overflow-wrap: anywhere;
}
.client-stat-track { min-width: 48px; }

/* Calendar/header buttons should not squash each other */
.mac-toolbar { align-items: flex-start; }
.mac-controls { flex-wrap: wrap; justify-content: flex-end; }
.view-switch { max-width: 100%; overflow: hidden; }
.view-switch button { white-space: nowrap; min-width: 0; }

@media (max-width: 920px) {
  .btn { min-height: 42px; padding: 9px 10px; }
  .btn.primary, .btn.soft, .btn.ghost { overflow-wrap: anywhere; }
  .client-actions { grid-template-columns: 1fr !important; }
  .mobile-action-row { grid-template-columns: 1fr !important; }
  .booking-actions, .builder-actions { display: grid !important; grid-template-columns: 1fr; gap: 8px; }
  .booking-actions .btn, .builder-actions .btn { width: 100%; }
  .row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 100%; }
  .row-actions .btn { width: 100%; }
  .section-title .btn { width: 100%; margin-top: 4px; }
  .client-stat-row { grid-template-columns: minmax(0,1fr) auto !important; align-items: start; }
  .client-stat-row strong { text-align: right; }
  .client-stat-row small { text-align: right; }
  .client-stat-row .client-stat-track { grid-column: 1 / -1; width: 100%; }
  .client-list-item { padding: 10px; }
  .client-title-card p { font-size: 13px; }
  .contact-card a, .contact-card span, .unit-contact span { font-size: 12.5px; }
  .mobile-tabbar { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; }
  .mobile-tabbar button {
    white-space: normal;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: auto;
  }
  .mobile-tabbar button span:last-child {
    white-space: normal !important;
    overflow: hidden;
    text-overflow: clip;
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    min-height: 20px;
  }
}

@media (max-width: 420px) {
  .view { padding-left: 9px; padding-right: 9px; }
  .card { padding: 12px; }
  .page-title, .client-title-card h2 { font-size: 19px !important; }
  .clients-head .sub, .section-title small { font-size: 12px; }
  .client-list-scroll { grid-auto-columns: minmax(196px, 86vw); }
  .mobile-tabbar button { font-size: 8px; padding-left: 0; padding-right: 0; }
  .mobile-tabbar button .tab-icon { width: 17px; height: 17px; }
  .mobile-tabbar button svg { width: 16px; height: 16px; }
}


/* ---------- UI polish pass 2: narrow-screen stacking and readable labels ---------- */
@media (max-width: 920px) {
  .kv { grid-template-columns: 1fr !important; gap: 2px; }
  .report-header { display: grid; gap: 10px; }
  .inspection-layout { grid-template-columns: 1fr !important; }
  .builder-layout { grid-template-columns: 1fr !important; }
  .question-row { grid-template-columns: 1fr !important; }
  .inline-add-card { display: grid !important; grid-template-columns: 1fr; align-items: stretch; }
  .inline-add-card .btn { width: 100%; }
  .type-grid { grid-template-columns: 1fr !important; }
  .definition-grid { grid-template-columns: 1fr !important; }
  .follow-rule { grid-template-columns: 1fr !important; }
  .mac-toolbar, .calendar-hero, .calendar-toolbar { display: grid !important; grid-template-columns: 1fr; align-items: stretch; }
  .mac-controls, .calendar-actions { display: grid !important; grid-template-columns: 1fr; justify-content: stretch; }
  .mac-new, .mac-controls .btn, .calendar-actions .btn { width: 100%; }
  .view-switch { width: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
  .view-switch button { padding-left: 6px; padding-right: 6px; }
  .booking-row, .booking-worker-row { grid-template-columns: 1fr !important; }
  .booking-worker-row .btn, .worker-add { width: 100%; }
  .question-modal { width: 100%; }
  .modal-head { gap: 10px; }
  .modal-head h2 { font-size: 18px; }
  .modal-body { min-width: 0; }
}

@media (max-width: 520px) {
  .btn { font-size: 14px; }
  button, input, select, textarea { font-size: 16px; }
  .badge, .status-pill { font-size: 11px; padding-left: 7px; padding-right: 7px; }
  .segmented { display: grid; grid-template-columns: 1fr; gap: 7px; }
  .choice { width: 100%; min-height: 42px; }
  .client-filter { margin-left: -2px; margin-right: -2px; }
  .chip { padding: 7px 9px; font-size: 11.5px; }
  .client-stat-block h4 { font-size: 13px; }
  .client-stat-row { font-size: 11.5px; }
}


/* ---------- Imported checklist templates ---------- */
.imported-layout{display:grid;grid-template-columns:minmax(240px,310px) minmax(0,1fr);gap:16px;align-items:start}.imported-list{position:sticky;top:76px}.imported-preview{min-width:0}.imported-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin:10px 0 16px}.imported-stats span{border:1px solid var(--border);border-radius:12px;background:var(--surface-2);padding:10px;color:var(--text-2);font-size:12px}.imported-stats strong{display:block;color:var(--text);font-size:20px}.imported-question{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;align-items:start;padding:11px 12px;border:1px solid var(--border);border-radius:12px;background:#fff}.imported-question.sub{margin-left:18px;border-left:3px solid var(--amber);background:#fffdf7}.imported-question strong{font-size:13.5px}.imported-question p{font-size:12px;color:var(--text-3);margin-top:3px}.imported-question .row-flags{justify-content:flex-end}@media(max-width:920px){.imported-layout{grid-template-columns:1fr}.imported-list{position:static}.imported-stats{grid-template-columns:repeat(2,minmax(0,1fr))}.imported-question{grid-template-columns:1fr}.imported-question.sub{margin-left:0}.imported-question .row-flags{justify-content:flex-start}}

/* ---------- Cache v42: imported lists visibility + final overflow guard ---------- */
.answer-list-summary{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:10px;
  margin-bottom:12px;
}
.answer-list-summary span{
  border:1px solid var(--border);
  border-radius:12px;
  background:var(--surface-2);
  padding:10px 12px;
  color:var(--text-2);
  font-size:13px;
  min-width:0;
}
.answer-list-summary strong{display:block;color:var(--text);font-size:20px;line-height:1.1;}
.answer-list-scroll{max-height:68dvh;overflow:auto;padding-right:4px;}
.answer-list-card{min-width:0;overflow:hidden;}
.answer-list-card .chip-row{max-width:100%;overflow:hidden;}
.answer-list-card .badge{display:inline-flex;max-width:100%;align-items:center;text-align:left;}
.answer-list-card .badge button{flex:0 0 auto;}
.imported-question,.imported-stats span,.answer-list-card,.client-list-item,.detailed-unit{overflow-wrap:anywhere;word-break:normal;}
@media(max-width:920px){
  .answer-list-summary{grid-template-columns:1fr;}
  .answer-list-scroll{max-height:none;overflow:visible;padding-right:0;}
  .answer-list-card .form-row{display:grid;grid-template-columns:1fr;}
}

/* ---------- Cache v43: first-class checklists + answer-list browser ---------- */
.template-picker{
  display:grid;
  grid-template-columns:minmax(240px,360px) minmax(0,1fr);
  gap:12px;
  align-items:center;
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--surface-2);
  padding:12px;
  margin:14px 0;
}
.template-picker label{display:grid;gap:5px;min-width:0;}
.template-picker label span,.inspection-template-switch span{font-size:11px;text-transform:uppercase;letter-spacing:.08em;color:var(--text-3);font-weight:800;}
.template-picker select,.inspection-template-switch select{width:100%;height:40px;border:1px solid var(--border-strong);border-radius:10px;background:#fff;padding:0 10px;color:var(--text);}
.template-picker div{min-width:0;display:grid;gap:3px;}
.template-picker strong{font-size:15px;overflow-wrap:anywhere;}
.template-picker small{color:var(--text-3);overflow-wrap:anywhere;}
.question-list-scroll{max-height:72dvh;overflow:auto;padding-right:4px;}
.answer-list-browser{display:grid;grid-template-columns:minmax(230px,300px) minmax(0,1fr);gap:14px;align-items:start;}
.answer-list-create{grid-column:1/-1;}
.answer-list-master,.answer-list-detail,.answer-list-create{min-width:0;}
.answer-list-master-scroll{max-height:64dvh;overflow:auto;padding-right:3px;}
.answer-list-item{appearance:none;border:1px solid transparent;background:transparent;border-radius:12px;padding:10px;text-align:left;display:grid;gap:4px;color:var(--text);width:100%;min-width:0;}
.answer-list-item:hover{background:var(--surface-2);}
.answer-list-item.active{background:var(--accent-soft);border-color:rgba(94,106,210,.25);}
.answer-list-item strong,.answer-list-item small{overflow-wrap:anywhere;}
.answer-list-item small{color:var(--text-3);font-size:12px;}
.answer-list-back{display:none;margin-bottom:10px;}
.answer-values{max-height:58dvh;overflow:auto;padding:2px 2px 8px 0;}
.answer-add-row{margin-top:12px;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;}
.inspection-head{display:flex;justify-content:space-between;gap:14px;align-items:flex-start;margin-bottom:14px;}
.inspection-template-switch{display:grid;gap:5px;min-width:min(320px,45%);}
@media(max-width:920px){
  .template-picker{grid-template-columns:1fr;}
  .question-list-scroll{max-height:none;overflow:visible;padding-right:0;}
  .answer-list-browser{grid-template-columns:1fr;}
  .answer-list-master-scroll{max-height:none;overflow:visible;}
  .answer-list-detail{order:-1;}
  .answer-list-back{display:inline-flex;}
  .answer-values{max-height:none;overflow:visible;}
  .answer-add-row{grid-template-columns:1fr;}
  .inspection-head{display:grid;}
  .inspection-template-switch{min-width:0;width:100%;}
}

/* ---------- Cache v45: inspection start/back chooser ---------- */
.inspection-start{display:grid;gap:16px;}
.inspection-template-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:10px;}
.inspection-template-card{
  appearance:none;
  border:1px solid var(--border);
  border-radius:14px;
  background:#fff;
  padding:14px;
  text-align:left;
  display:grid;
  gap:8px;
  color:var(--text);
  min-width:0;
  cursor:pointer;
}
.inspection-template-card:hover{border-color:rgba(94,106,210,.35);box-shadow:var(--shadow-sm);transform:translateY(-1px);}
.inspection-template-card strong{font-size:15px;overflow-wrap:anywhere;}
.inspection-template-card small{color:var(--text-3);font-size:12.5px;line-height:1.35;overflow-wrap:anywhere;}
.inspection-back{margin-bottom:10px;justify-self:start;}
.inspection-head h2{margin-top:0;}
@media(max-width:920px){
  .inspection-template-grid{grid-template-columns:1fr;}
  .inspection-back{width:100%;}
}
