/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #100e0a;
  --surface:    #1e1a13;
  --surface2:   #282118;
  --border:     #3a2e1e;
  --text:       #ede5d0;
  --text2:      #8a7a5a;
  --accent:     #e8921a;
  --installer:  #6ea8e8;
  --shop:       #e8921a;
  --parts:      #d95f4a;
  --complete:   #5ab87a;
  --radius:     12px;
  --header-h:   56px;
}

body[data-theme="light"] {
  --bg:         #ede8de;
  --surface:    #faf6ef;
  --surface2:   #f0e8d5;
  --border:     #cdbfa0;
  --text:       #1e1508;
  --text2:      #7a6645;
  --accent:     #c97a10;
  --installer:  #2a6abf;
  --shop:       #c97a10;
  --parts:      #bf3e2a;
  --complete:   #2a8a4a;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
}

/* ── Header ───────────────────────────────────────────────── */
#header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

#header-logo {
  height: 38px;
  width: 38px;
  object-fit: contain;
  border-radius: 50%;
  flex-shrink: 0;
}

#title-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
#page-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}
#page-subtitle {
  font-size: 11px;
  color: var(--text2);
  font-weight: 400;
  letter-spacing: 0.1px;
  line-height: 1.2;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 22px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

/* ── Main Content ─────────────────────────────────────────── */
#main-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

#content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 88px;
  min-width: 0;
}

/* ── Sidebar ──────────────────────────────────────────────── */
#sidebar {
  width: 320px;
  flex-shrink: 0;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--surface);
  padding: 16px 14px 88px;
}
#sidebar.hidden { display: none; }

/* Hide sidebar on mobile — use the 📅 button instead */
@media (max-width: 860px) {
  #sidebar { display: none !important; }
}

.sidebar-header {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text2);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-refresh-btn {
  background: none;
  border: none;
  color: var(--text3, #6b7280);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.sidebar-refresh-btn:hover { color: var(--text); }
.sidebar-add-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 1px 7px 3px;
  border-radius: 4px;
  font-weight: 700;
}
.sidebar-add-btn:hover { opacity: 0.85; }

.sidebar-day-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--accent);
  margin: 12px 0 5px;
}
.sidebar-day-label.today-label { color: var(--accent); }
.sidebar-day-label.past-label  { color: var(--text3, #6b7280); }

.sidebar-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.sidebar-item:hover { background: color-mix(in srgb, var(--accent) 8%, var(--surface2)); }
.sidebar-item-bar { width: 3px; flex-shrink: 0; border-radius: 2px; align-self: stretch; }
.visit-item-bar { background: var(--accent); }
.wo-item-bar    { background: #3b82f6; }
.fwo-item-bar   { background: #f59e0b; }
.sidebar-item-body { flex: 1; min-width: 0; }
.sidebar-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-item-meta {
  font-size: 11px;
  color: var(--text2);
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.sidebar-wo-num {
  font-family: monospace;
  font-size: 10px;
  background: color-mix(in srgb, #3b82f6 15%, var(--surface));
  color: #3b82f6;
  padding: 1px 5px;
  border-radius: 4px;
}
.sidebar-type-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
}
.sidebar-visit-tag { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.sidebar-wo-tag    { background: color-mix(in srgb, #3b82f6 12%, transparent); color: #3b82f6; }
.sidebar-fwo-tag   { background: color-mix(in srgb, #f59e0b 15%, transparent); color: #f59e0b; }

.sidebar-empty {
  font-size: 13px;
  color: var(--text2);
  text-align: center;
  padding: 24px 0;
  font-style: italic;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 12px;
}

.card:active { background: var(--surface2); transform: scale(0.98); }
.project-card:active { background: var(--surface2); transform: scale(0.98); }

.card-body { flex: 1; min-width: 0; }

.card-title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-sub {
  font-size: 13px;
  color: var(--text2);
  margin-top: 3px;
}

.card-arrow {
  color: var(--text2);
  font-size: 18px;
  flex-shrink: 0;
}

/* ── Phase Badge ──────────────────────────────────────────── */
.phase-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.phase-1 { background: #1e3a5f; color: #4f8eff; }
.phase-2 { background: #3d2c00; color: #f59e0b; }
.phase-3 { background: #1a3a2a; color: #10b981; }

/* ── Item Cards ───────────────────────────────────────────── */
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.item-card.complete {
  opacity: 0.5;
}

.item-card.in-progress {
  background: color-mix(in srgb, #f59e0b 8%, var(--surface));
  border-color: color-mix(in srgb, #f59e0b 40%, var(--border));
  border-left: 3px solid #f59e0b;
}

.item-check {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
  margin-top: 1px;
}

.item-check.done {
  background: var(--complete);
  border-color: var(--complete);
  color: white;
}

.item-check.in-progress {
  background: #f59e0b;
  border-color: #f59e0b;
  color: white;
  font-size: 20px;
  line-height: 1;
}

.item-body { flex: 1; min-width: 0; }

.item-desc {
  font-size: 15px;
  line-height: 1.4;
}

.item-meta {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.type-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.type-installer { background: #1a2a4a; color: var(--installer); }
.type-shop      { background: #3d2c00; color: var(--shop); }
.type-parts     { background: #3a1a1a; color: var(--parts); }

.item-photos {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.item-photo {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ── Section Header ───────────────────────────────────────── */
.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text2);
  margin: 20px 0 10px;
}

.section-label:first-child { margin-top: 0; }

/* ── Empty State ──────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}

.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-sub { font-size: 14px; }

/* ── FAB ──────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-size: 32px;
  font-weight: 300;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform 0.15s;
  z-index: 20;
}

.fab:active { transform: scale(0.9); }

/* ── Sheet ────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 30;
}

.sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 640px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  z-index: 40;
  padding: 12px 20px 40px;
  max-height: 90dvh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.sheet h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

/* ── Forms ────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text2);
  margin-bottom: 8px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
  padding: 12px 14px;
  outline: none;
  font-family: inherit;
  appearance: none;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
}

.field textarea { resize: none; min-height: 80px; }

/* Type selector */
.type-select {
  display: flex;
  gap: 8px;
}

.type-btn {
  flex: 1;
  padding: 12px 8px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.type-btn.active-installer { border-color: var(--installer); color: var(--installer); background: #1a2a4a; }
.type-btn.active-shop      { border-color: var(--shop);      color: var(--shop);      background: #3d2c00; }
.type-btn.active-parts     { border-color: var(--parts);     color: var(--parts);     background: #3a1a1a; }

/* Photo upload */
.photo-btn {
  width: 100%;
  padding: 20px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text2);
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.photo-preview {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.photo-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* Submit button */
.btn-primary {
  width: 100%;
  padding: 16px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.15s;
}

.btn-primary:active { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.4; cursor: default; }

.btn-skip {
  width: 100%;
  padding: 14px;
  background: none;
  color: var(--text2);
  border: none;
  font-size: 14px;
  cursor: pointer;
  margin-top: 4px;
}

/* ── Phase Switcher ───────────────────────────────────────── */
.phase-switcher {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
}

.phase-tab {
  flex: 1;
  padding: 8px 4px;
  border-radius: 8px;
  border: none;
  background: none;
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  min-height: 44px;
}

.phase-tab.active {
  background: var(--surface2);
  color: var(--text);
}

/* ── Debrief Tab ──────────────────────────────────────────── */
.phase-tab.debrief-tab { color: var(--text3, #9ca3af); }
.phase-tab.debrief-tab.active { color: var(--text); }

.debrief-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 40px;
}

.debrief-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3, #9ca3af);
}

.debrief-date-input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  width: 100%;
  box-sizing: border-box;
}

.debrief-notes-input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  line-height: 1.5;
}

.btn-save-debrief {
  margin-top: 8px;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: var(--accent, #3b82f6);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.btn-save-debrief:disabled { opacity: 0.6; cursor: default; }

/* ── Sort Bar ─────────────────────────────────────────────── */
.sort-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.sort-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
}

.sort-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

/* ── WO Status Pills ──────────────────────────────────────── */
.status-requested { background: #1a2a4a; color: var(--installer); }
.status-in-shop   { background: #3d2c00; color: var(--shop); }
.status-ready     { background: #0a3d3a; color: #2dd4bf; }
.status-complete  { background: #1a3a2a; color: var(--complete); }

.type-btn.active-ready    { border-color: #2dd4bf;        color: #2dd4bf;        background: #0a3d3a; }
.type-btn.active-complete { border-color: var(--complete); color: var(--complete); background: #1a3a2a; }

/* ── Detail field rows ────────────────────────────────────── */
.field-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  gap: 16px;
}

.field-label {
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

/* ── Projects Grid ────────────────────────────────────────── */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.project-card:active { background: var(--surface2); }

.project-card .card-title {
  font-size: 14px;
  font-weight: 700;
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
}

.project-card .card-sub {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-card .card-meta-row {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 3px;
  overflow: hidden;
}
.project-card .card-meta-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3, #9ca3af);
  flex-shrink: 0;
}
.project-card .card-meta-val {
  font-size: 11.5px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-card .card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

/* ── Background Textures ──────────────────────────────────── */
body[data-bg="grain"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='turbulence' baseFrequency='0.03 0.004' numOctaves='6' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='1.4 0.7 0.2 0 0.05 0.8 0.6 0.1 0 0.02 0.2 0.1 0 0 0 0 0 0 0.48 0'/%3E%3C/filter%3E%3Crect width='600' height='600' filter='url(%23w)'/%3E%3C/svg%3E");
  background-size: 600px 600px;
}

body[data-bg="linen"] {
  background-image:
    repeating-linear-gradient(0deg,   transparent, transparent 2px, rgba(128,90,40,0.12) 2px, rgba(128,90,40,0.12) 3px),
    repeating-linear-gradient(90deg,  transparent, transparent 2px, rgba(128,90,40,0.08) 2px, rgba(128,90,40,0.08) 3px);
}

body[data-bg="grid"] {
  background-image:
    linear-gradient(rgba(128,128,128,0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(128,128,128,0.18) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ── Settings Panel ───────────────────────────────────────── */
.settings-section { margin-bottom: 24px; }

.settings-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text2);
  margin-bottom: 12px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.theme-swatch {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s;
}

.theme-swatch.active { border-color: var(--accent); }

.swatch-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(128,128,128,0.2);
}

.swatch-label {
  font-size: 11px;
  font-weight: 600;
}

.accent-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.accent-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
}

.accent-swatch.active {
  border-color: var(--text);
  transform: scale(1.15);
}

.bg-grid {
  display: flex;
  gap: 8px;
}

.bg-swatch {
  flex: 1;
  padding: 10px 4px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.bg-swatch.active {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Login Screen ─────────────────────────────────────────── */
#login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.login-box {
  width: 100%;
  max-width: 360px;
}

.login-logo {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--accent);
  margin-bottom: 4px;
}

.login-sub {
  font-size: 14px;
  color: var(--text2);
  margin-bottom: 32px;
}

/* ── Photo Thumbnail with Markup Button ──────────────────── */
.photo-thumb-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.photo-thumb-wrap img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}

.photo-markup-btn {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

/* ── Markup Editor Overlay ────────────────────────────────── */
#markup-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
}

#markup-canvas {
  flex: 1;
  max-width: 100%;
  max-height: calc(100dvh - 80px);
  object-fit: contain;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

#markup-toolbar {
  width: 100%;
  height: 80px;
  background: #1a1a1a;
  border-top: 1px solid #333;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
}

.markup-colors {
  display: flex;
  gap: 8px;
}

.markup-color {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: border-color 0.1s;
}

.markup-color.active { border-color: #fff; }

.markup-tools {
  display: flex;
  gap: 6px;
}

.markup-tool, #markup-undo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid #444;
  background: #2a2a2a;
  color: #ccc;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.markup-tool.active { background: #444; color: #fff; border-color: #888; }
.markup-tool:active, #markup-undo:active { opacity: 0.7; }

.markup-actions {
  display: flex;
  gap: 8px;
}

#markup-cancel {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #444;
  background: none;
  color: #aaa;
  font-size: 14px;
  cursor: pointer;
}

#markup-done {
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  background: #e8921a;
  color: #000;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

/* ── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }
.mt8 { margin-top: 8px; }
.stats { display: flex; gap: 16px; margin-top: 4px; }
.stat { font-size: 12px; color: var(--text2); }
.stat span { color: var(--text); font-weight: 600; }

/* ── Toast Notification ──────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #282118;
  color: #fff;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  pointer-events: none;
  animation: toastFade 0.3s ease-out;
}

.toast.fade-out {
  animation: toastFadeOut 0.3s ease-in forwards;
}

@keyframes toastFade {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastFadeOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to   { opacity: 0; transform: translateX(-50%) translateY(10px); }
}

/* ── Loading Spinner ─────────────────────────────────────── */
.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Confirm Modal ───────────────────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.confirm-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 340px;
  width: 100%;
}

.confirm-dialog h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
}

.confirm-dialog p {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.5;
  margin-bottom: 20px;
}

.confirm-actions {
  display: flex;
  gap: 10px;
}

.confirm-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  min-height: 44px;
}

.confirm-cancel {
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border) !important;
}

.confirm-ok {
  background: var(--accent);
  color: #000;
}

/* ── Suggestions Dropdown ────────────────────────────────── */
.suggestions-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 4px;
  z-index: 50;
}

.suggestion-item {
  padding: 12px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.1s;
}

.suggestion-item:hover,
.suggestion-item:active {
  background: var(--surface2);
}

.suggestion-item + .suggestion-item {
  border-top: 1px solid var(--border);
}

/* ── Status Badges ───────────────────────────────────────── */
.status-open     { background: #3d2c00; color: #f59e0b; }
.status-progress { background: #1a2a4a; color: #6ea8e8; }

/* ── Focus Visible ───────────────────────────────────────── */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.card:focus-visible,
.item-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Micro-Animation Keyframes ───────────────────────────── */
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@keyframes checkBounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.item-check.done {
  animation: checkBounce 0.3s ease-out;
}

/* ── Planned Date Row ────────────────────────────────────── */
.planned-date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.planned-date-label {
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
}
.planned-date-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 5px 10px;
}

/* ── Next Site Visit Row ─────────────────────────────────── */
.next-visit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--accent, #f0a830);
  flex-wrap: wrap;
}
.next-visit-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text2);
}
.next-visit-value {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.next-visit-value.unset {
  color: var(--text2);
  font-weight: 500;
  font-style: italic;
}
.next-visit-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 6px 10px;
}
.next-visit-edit-btn,
.next-visit-clear-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
}
.next-visit-edit-btn:hover,
.next-visit-clear-btn:hover {
  background: var(--border);
}
.next-visit-clear-btn {
  padding: 6px 10px;
  color: var(--text2);
}
.howto-body { padding: 4px 0 8px; }
.howto-section { margin-bottom: 18px; }
.howto-heading {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  margin-bottom: 6px;
}
.howto-section ul {
  list-style: disc;
  padding-left: 20px;
  margin: 0;
}
.howto-section li {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 4px;
}
.howto-section b { color: var(--text); font-weight: 700; }
.howto-section i { color: var(--text2); }

.next-visit-notes-input {
  flex-basis: 100%;
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  resize: vertical;
  min-height: 32px;
  font-family: inherit;
  box-sizing: border-box;
  margin-top: 2px;
}

/* ── Site visit notes (thread + composer) ──────────────────── */
.next-visit-row {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.next-visit-date-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}
.visit-notes-composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.visit-notes-composer textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 8px 10px;
  resize: vertical;
  min-height: 48px;
  font-family: inherit;
  box-sizing: border-box;
}
.visit-note-post-btn {
  align-self: flex-end;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 16px;
  cursor: pointer;
}
.visit-note-post-btn:disabled { opacity: 0.5; cursor: wait; }
.visit-notes-thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.visit-notes-empty {
  font-size: 13px;
  color: var(--text2);
  font-style: italic;
  padding: 4px 0;
}
.visit-note-row {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.visit-note-row.latest {
  border-left: 3px solid var(--accent);
}
.visit-note-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.visit-note-author { font-weight: 600; color: var(--text); }
.visit-note-latest-tag {
  background: var(--accent);
  color: #000;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.visit-note-body {
  font-size: 14px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Notes search view ─────────────────────────────────────── */
.notes-search-wrap {
  padding: 10px 12px 4px;
}
.notes-search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  padding: 10px 14px;
  box-sizing: border-box;
}
.visit-note-card .visit-note-body { margin-top: 4px; }

/* ── Issues ──────────────────────────────────────────────── */
.issues-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.issue-count {
  font-size: 11px;
  font-weight: 400;
  color: var(--text2);
  margin-left: 6px;
}
.issue-count.has-open {
  color: var(--parts);
  font-weight: 600;
}
.issue-add-btn {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  margin-left: auto;
}
.issue-empty {
  font-size: 13px;
  color: var(--text2);
  padding: 8px 16px 16px;
}
.issue-card {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  cursor: pointer;
  position: relative;
}
.issue-card.resolved { opacity: 0.6; }
.issue-desc {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  padding-right: 72px;
}
.issue-meta {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
}
.issue-resolution { color: var(--complete); }
.issue-status-badge {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}
.issue-status-badge.open {
  background: rgba(255,160,0,0.15);
  color: #e69000;
}
.issue-status-badge.resolved {
  background: rgba(0,200,100,0.15);
  color: var(--complete);
}
.btn-danger {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--parts);
  background: none;
  color: var(--parts);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* ── Sync Jobs ───────────────────────────────────────────── */
.sync-job-row {
  font-size: 13px;
  color: var(--text2);
  padding: 7px 12px;
  border-radius: 8px;
  margin-bottom: 4px;
  background: var(--surface);
}
.sync-job-row.new {
  color: var(--complete);
  background: rgba(90,184,122,0.08);
  font-weight: 500;
}

/* ── Notify Button ───────────────────────────────────────── */
.btn-notify {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
}
.btn-notify:hover { border-color: var(--accent); color: var(--accent); }

.notify-btn {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  opacity: 0.6;
}
.notify-btn:hover { opacity: 1; background: var(--surface2); }

.issue-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.notify-person-row {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
}
.notify-person-row:last-child { border-bottom: none; }
.notify-person-row:hover { background: var(--surface2); }
.notify-person-row { display: flex; justify-content: space-between; align-items: center; }
.notify-person-row.selected { background: rgba(90,184,122,0.1); }
.notify-check { color: var(--complete); font-weight: 700; font-size: 15px; }

/* ── Inbox Button & Badge ────────────────────────────────── */
.inbox-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.inbox-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 16px; height: 16px;
  background: var(--parts);
  color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  pointer-events: none;
}
.inbox-badge.hidden { display: none; }

/* ── Notification Rows ───────────────────────────────────── */
.notif-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.notif-row:last-child { border-bottom: none; }
.notif-row:hover { opacity: 0.75; }
.notif-text { font-size: 14px; color: var(--text); line-height: 1.4; }
.notif-date { font-size: 11px; color: var(--text2); margin-top: 3px; }

/* ── Archive Toggle ──────────────────────────────────────── */
.archive-toggle {
  display: block;
  width: calc(100% - 32px);
  margin: 4px 16px 0;
  padding: 10px 12px;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
}
.archive-toggle:hover { background: var(--surface); }

/* ── Closed Banner ───────────────────────────────────────── */
.closed-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 16px 12px;
  padding: 10px 14px;
  background: rgba(90,184,122,0.12);
  border: 1px solid var(--complete);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--complete);
}
.reopen-btn {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--complete);
  background: none;
  color: var(--complete);
  cursor: pointer;
}

/* ── Close Job Button ────────────────────────────────────── */
.close-job-btn {
  display: block;
  width: calc(100% - 32px);
  margin: 24px 16px 8px;
  padding: 12px;
  background: none;
  border: 1px solid var(--complete);
  border-radius: 10px;
  color: var(--complete);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.close-job-btn:hover { background: rgba(90,184,122,0.08); }

/* ── Delete Project Button ───────────────────────────────── */
.delete-project-btn {
  display: block;
  width: calc(100% - 32px);
  margin: 24px 16px 80px;
  padding: 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--parts);
  font-size: 14px;
  cursor: pointer;
  text-align: center;
}

/* ── Search Bar ──────────────────────────────────────────── */
.search-wrap {
  padding: 10px 12px 4px;
}
.search-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  padding: 10px 14px;
  outline: none;
}
.search-input:focus {
  border-color: var(--accent);
}
.search-input::placeholder {
  color: var(--text2);
}

/* ── Dashboard Stats ──────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 12px 12px 4px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
}
.stat-value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text2);
}

/* ── WO Weekly Chart ─────────────────────────────────────── */
.wo-week-chart {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.wo-week-row {
  display: grid;
  grid-template-columns: 90px 1fr 32px;
  align-items: center;
  gap: 8px;
}
.wo-week-label {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
}
.wo-week-bar-wrap {
  background: var(--border);
  border-radius: 4px;
  height: 18px;
  overflow: hidden;
}
.wo-week-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.wo-week-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text1);
  text-align: right;
}

/* ── Comments ─────────────────────────────────────────────── */
.comment-row {
  background: var(--surface2);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 13px;
}
.comment-time {
  font-size: 11px;
  color: var(--text2);
  font-weight: 400;
}
.comment-text {
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
}
.comment-empty {
  font-size: 13px;
  color: var(--text2);
  padding: 8px 0;
}

/* ── FWO Updates Thread ────────────────────────────────────── */
/* Append-only log of distinct updates on a parent record (FWO or Issue).
   Each row is its own card with a clear divider so the thread
   reads like a log, not a chat blob. */
.update-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  background: var(--bg);
}
.update-row {
  background: var(--surface2);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 4px;
  border-left: 3px solid var(--accent);
}
.update-row + .update-row {
  margin-top: 8px;
}
.update-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}
.update-author {
  font-weight: 700;
  color: var(--text);
}
.update-time {
  font-size: 11px;
  color: var(--text2);
  font-weight: 400;
  white-space: nowrap;
}
.update-body {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.update-empty {
  font-size: 13px;
  color: var(--text2);
  padding: 12px;
  text-align: center;
}

/* "Last update: ..." line shown on FWO and Issue list cards */
.card-last-update {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.4;
  font-style: italic;
}
.card-last-update-label {
  font-style: normal;
  font-weight: 600;
  color: var(--text1);
  margin-right: 4px;
}

/* ── Phase Sign-off ───────────────────────────────────────── */
.signoff-section {
  padding: 12px 12px 0;
  margin-bottom: 8px;
}
.btn-signoff {
  width: 100%;
  padding: 12px;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn-signoff:active { opacity: 0.8; }
.signoff-badge {
  background: #d1fae5;
  color: #065f46;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 8px;
}
.dark .signoff-badge { background: #064e3b; color: #6ee7b7; }
.signoff-undo {
  font-size: 12px;
  color: var(--text2);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

/* CSS var aliases */
:root { --ok: #065f46; }
.dark { --ok: #6ee7b7; }

/* ── Changelog ────────────────────────────────────────────── */
.changelog-release {
  margin-bottom: 16px;
}
.changelog-date {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  margin-bottom: 6px;
}
.changelog-list {
  margin: 0;
  padding-left: 16px;
}
.changelog-list li {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}

/* ── Site Visits ───────────────────────────────────────────── */
.site-visit-header { display: flex; align-items: center; gap: 8px; }
.visit-count { font-size: 11px; font-weight: 400; color: var(--text2); background: var(--surface2); padding: 2px 8px; border-radius: 10px; }

.visit-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  position: relative;
}
.visit-card.upcoming { border-left: 3px solid var(--accent); }
.visit-card.past { opacity: 0.6; }

.visit-date-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  min-width: 80px;
  padding-top: 2px;
}
.visit-card.past .visit-date-badge { color: var(--text2); }

.visit-details { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.visit-team { font-size: 13px; font-weight: 600; color: var(--text); }
.visit-type-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  padding: 2px 8px;
  border-radius: 6px;
}
.visit-notes { font-size: 12px; color: var(--text2); width: 100%; margin-top: 2px; }

.visit-delete-btn {
  background: none;
  border: none;
  color: var(--text3, #6b7280);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  opacity: 0.6;
  flex-shrink: 0;
}
.visit-delete-btn:hover { opacity: 1; color: var(--parts); }

.past-visits-toggle {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 0;
  margin-bottom: 4px;
}
.past-visits-container.hidden { display: none; }

/* ── Schedule View ─────────────────────────────────────────── */
.schedule-day-header { font-size: 13px; font-weight: 700; }
.schedule-day-header.today { color: var(--accent); }
.schedule-day-header.past-day { color: var(--text3, #9ca3af); font-weight: 400; }

.schedule-visit-card.past { opacity: 0.6; }

.schedule-visit-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.schedule-team-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ── Installer Notes Card ──────────────────────────────────── */
.installer-notes-card {
  background: color-mix(in srgb, #f59e0b 10%, var(--surface));
  border: 1px solid color-mix(in srgb, #f59e0b 40%, var(--border));
  border-left: 3px solid #f59e0b;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.installer-notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.installer-notes-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #f59e0b;
}
.installer-notes-edit-btn {
  background: none;
  border: 1px solid color-mix(in srgb, #f59e0b 50%, transparent);
  color: #f59e0b;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.installer-notes-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
}
.installer-notes-empty {
  font-size: 13px;
  color: var(--text2);
  font-style: italic;
}
.installer-notes-ta {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  line-height: 1.6;
  resize: vertical;
  box-sizing: border-box;
  font-family: inherit;
}
.installer-notes-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.installer-notes-save {
  background: #f59e0b;
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 18px;
  cursor: pointer;
}
.installer-notes-save:disabled { opacity: 0.6; cursor: default; }
.installer-notes-cancel {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 8px;
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
}

/* ── Installer Notes View ──────────────────────────────────── */
.inotes-card { align-items: flex-start; cursor: pointer; }
.inotes-card.no-notes { opacity: 0.55; }
.inotes-card-inner { flex: 1; }
.inotes-project { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.inotes-meta { font-size: 12px; color: var(--text2); margin-bottom: 6px; }
.inotes-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  background: color-mix(in srgb, #f59e0b 8%, var(--surface2));
  border-left: 2px solid #f59e0b;
  padding: 8px 10px;
  border-radius: 6px;
  margin-top: 4px;
}
.inotes-text.inotes-empty { color: var(--text2); font-style: italic; background: none; border-left: none; padding: 0; }

/* ── Schedule view — Airtable WO entries ───────────────────── */
.daily-plan-btn { margin: 0 0 12px !important; padding: 14px !important; font-size: 15px !important; }
.schedule-top-bar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.schedule-legend { display: flex; gap: 16px; padding: 0 2px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text2); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.visit-dot { background: var(--accent); }
.wo-dot { background: #3b82f6; }

.schedule-visit-card { position: relative; padding-left: 18px !important; overflow: hidden; }
.schedule-source-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.visit-bar { background: var(--accent); }
.wo-bar { background: #3b82f6; }

.schedule-wo-card .card-title { color: var(--text); }
.wo-number-badge {
  font-size: 11px;
  font-weight: 700;
  font-family: monospace;
  background: color-mix(in srgb, #3b82f6 15%, var(--surface2));
  color: #3b82f6;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid color-mix(in srgb, #3b82f6 30%, var(--border));
}

/* FWO Source — single-letter pill, office-only signal (P/M). Never on print. */
.source-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: 1px;
  letter-spacing: 0;
}
.source-p { background: color-mix(in srgb, #8b5cf6 18%, var(--surface2)); color: #8b5cf6; border: 1px solid color-mix(in srgb, #8b5cf6 35%, var(--border)); }
.source-m { background: color-mix(in srgb, #14b8a6 18%, var(--surface2)); color: #14b8a6; border: 1px solid color-mix(in srgb, #14b8a6 35%, var(--border)); }
.wo-type-tag {
  background: color-mix(in srgb, #3b82f6 12%, var(--surface2));
  color: #3b82f6;
}

/* ── Manager Notes Sidebar ─────────────────────────────────── */
.manager-note-wrap { margin-bottom: 6px; }
.manager-note-ta {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
}
.manager-note-ta:focus { outline: none; border-color: var(--accent); }
.manager-note-ta::placeholder { color: var(--text3, #6b7280); }
.manager-note-save-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}
.manager-note-save-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 14px;
  cursor: pointer;
}
.manager-note-save-btn:disabled { opacity: 0.5; cursor: default; }
.manager-note-saved { font-size: 12px; color: var(--ok, #6ee7b7); font-weight: 600; }
.manager-note-saved.hidden { display: none; }

.past-note-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
}
.past-note-date { font-size: 11px; font-weight: 700; color: var(--text2); margin-bottom: 4px; }
.past-note-text { font-size: 12px; color: var(--text); white-space: pre-wrap; line-height: 1.5; }

/* ── PWA Install Banner ─────────────────────────────────────── */
.install-banner {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 9000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.install-banner-icon { font-size: 24px; flex-shrink: 0; }
.install-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.install-banner-text strong { font-size: 14px; color: var(--text); }
.install-banner-text span   { font-size: 12px; color: var(--text2); }
.install-banner-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  cursor: pointer;
  flex-shrink: 0;
}
.install-banner-dismiss {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  line-height: 1;
}
.install-banner { cursor: pointer; }
.install-banner:active { transform: translateX(-50%) scale(0.98); }

/* ── Install sheet contents ─────────────────────────────────── */
.install-step {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 10px 0;
}
.install-step.warn {
  background: color-mix(in srgb, #ffb74d 14%, transparent);
  border-left-color: #ffb74d;
}
.install-step.success {
  background: color-mix(in srgb, #66bb6a 14%, transparent);
  border-left-color: #66bb6a;
}
.install-step strong { display: block; margin-bottom: 4px; }
.install-step p { margin: 4px 0 0; color: var(--text2); font-size: 14px; }
.install-steps {
  padding-left: 24px;
  margin: 12px 0;
}
.install-steps li {
  margin: 14px 0;
  font-size: 15px;
  line-height: 1.45;
}
.install-share-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  background: #007aff;
  color: #fff;
  border-radius: 7px;
  vertical-align: middle;
  margin: 0 4px;
}
.install-note {
  font-size: 13px;
  color: var(--text2);
  margin-top: 4px;
  font-style: italic;
}
.install-note-bottom {
  font-size: 13px;
  color: var(--text2);
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border, rgba(255,255,255,0.08));
}
.howto-install-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  margin-right: 6px;
}

/* ── @mention ──────────────────────────────────────────────── */
.mention-tag {
  color: var(--accent);
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 4px;
  padding: 0 3px;
}
.mention-dropdown {
  position: absolute;
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  z-index: 200;
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
  overflow: hidden;
}
.mention-dropdown.hidden { display: none; }
.mention-option {
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.mention-option:last-child { border-bottom: none; }
.mention-option:hover { background: var(--surface2); }
