:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6b7a;
  --border: #dde3e9;
  --brand: #0b5cad;
  --brand-text: #ffffff;
  --ok: #1f7a3a;
  --warn-bg: #fff4d6;
  --warn-text: #7a5300;
  --err-bg: #fde8e8;
  --err-text: #9b1c1c;
  --ok-bg: #e5f5ea;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: #111; /* matches the Service2.0 logo */
  color: var(--brand-text);
}
.topbar h1 { font-size: 1.2rem; margin: 0; }
.topbar .brand { color: var(--brand-text); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.topbar .brand-logo { height: 44px; width: auto; display: block; }
.auth-logo { display: block; height: auto; margin: 0 auto 8px; max-width: 60%; }
.auth-card h1 { text-align: center; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 0.9rem; }
.topbar .button.small { padding: 5px 10px; font-size: 0.85rem; }

/* Sign-in and setup-link pages */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.3rem; margin: 0 0 4px; }
.auth-card .form { max-width: none; }
.auth-page:has(.auth-footer) { flex-direction: column; }
.auth-footer { margin-top: 12px; font-size: 0.85rem; }
.legal-card { width: 100%; max-width: 720px; line-height: 1.5; }
.legal-card h1 { font-size: 1.4rem; margin: 0 0 4px; }
.legal-card h2 { font-size: 1.05rem; margin: 20px 0 6px; }

/* Home page */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; color: var(--text); text-decoration: none; }
.stat:hover { border-color: var(--brand); }
.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat .count { font-size: 1.8rem; font-weight: 600; }
.rows { border: 1px solid var(--border); border-radius: 8px; }
.rows .row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.rows .row:last-child { border-bottom: none; }
.rows .row .meta { color: var(--muted); white-space: nowrap; }
.rows .row .flag { color: var(--warn-text); white-space: nowrap; }
.rows .empty { padding: 12px; color: var(--muted); }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; }
.search { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; }
.qr-box svg { width: 200px; height: 200px; }
.link-box { word-break: break-all; font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; background: var(--bg); padding: 8px; border-radius: 6px; }
@media (max-width: 800px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .home-grid { grid-template-columns: 1fr; } }

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--warn-bg);
  color: var(--warn-text);
}

.badge.live { background: var(--err-text); color: #fff; }
.confirm-live { color: var(--err-text); margin-bottom: 8px !important; }
.check-list { list-style: none; padding: 0; margin: 8px 0 0; }
.check-list li { padding: 6px 0; border-top: 1px solid var(--border); }
.check-list .ok { color: var(--ok); font-weight: 600; }
.check-list .bad { color: var(--err-text); font-weight: 600; }
.check-list .detail { display: block; color: var(--muted); font-size: 0.85rem; }

.layout { display: flex; min-height: calc(100vh - 52px); }

.sidebar {
  width: 200px;
  padding: 16px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar a, .sidebar .soon { padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
.sidebar a.active { background: var(--bg); font-weight: 600; }
.sidebar .soon { color: var(--muted); }
.sidebar small { display: block; font-size: 0.7rem; }

main { flex: 1; padding: 24px; max-width: 1100px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 10px; font-size: 1.05rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.details { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 12px 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; white-space: pre-line; }

.actions { display: flex; gap: 10px; margin-top: 12px; }

.button {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
}
.button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-text); }
.button:disabled { opacity: 0.6; cursor: wait; }

.message { padding: 12px 16px; border-radius: 6px; margin-bottom: 20px; }
.message.error { background: var(--err-bg); color: var(--err-text); }
.message.success { background: var(--ok-bg); color: var(--ok); }
.message.warning { background: var(--warn-bg); color: var(--warn-text); }
.message.warning p { margin: 0 0 6px; }
.message.warning ul { margin: 0; padding-left: 20px; }

.form { display: grid; gap: 14px; max-width: 520px; margin-top: 12px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: 0.92rem; }
.form .req { font-weight: 400; font-size: 0.75rem; color: var(--muted); }
.form .field { display: grid; gap: 4px; }
.form .field > label { font-weight: 600; font-size: 0.92rem; }

/* Type-to-search picker (New Job customer) */
.combo { position: relative; }
.combo input { width: 100%; box-sizing: border-box; padding-right: 34px; }
.combo input.chosen { font-weight: 600; }
.combo-select input { cursor: pointer; }
.combo-select input:not([readonly]) { cursor: text; }
/* Down arrow, so these still read as drop-downs */
.combo-select::after {
  content: ''; position: absolute; right: 13px; top: 50%; pointer-events: none;
  width: 7px; height: 7px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg);
}
.memo-row .combo { width: 190px; }
.combo-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--muted); font-size: 0.9rem;
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
}
.combo-clear:hover { background: var(--bg); color: var(--text); }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
  margin: 0; padding: 4px; list-style: none;
  max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(28, 36, 48, 0.12);
}
.combo-option {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer; font-weight: 400;
}
.combo-option.is-indented { padding-left: 26px; }
.combo-option.is-action { color: var(--brand); }
/* A line between the list and its extra choices ("+ New Contact…") */
.combo-option:not(.is-action) + .combo-option.is-action { border-top: 1px solid var(--border); border-radius: 0; }
.combo-option.is-selected .combo-name { font-weight: 600; }
.combo-option.active, .combo-option:hover { background: var(--bg); }
.combo-option.active { box-shadow: inset 3px 0 0 var(--brand); }
.combo-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-name mark { background: none; color: inherit; font-weight: 700; }
.combo-meta { color: var(--muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-empty { padding: 10px; color: var(--muted); font-size: 0.85rem; font-weight: 400; }
.form .memo { border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px 4px; margin: 0; }
.form .memo legend { font-weight: 600; font-size: 0.92rem; padding: 0 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.field-row.four { grid-template-columns: 2fr 1.2fr 0.6fr 0.8fr; }
.field-note { font-weight: 400; font-size: 0.8rem; color: var(--muted); }
.form input:disabled { background: var(--bg); }
@media (max-width: 500px) { .field-row, .field-row.three, .field-row.four { grid-template-columns: 1fr; } }
.memo-row { display: flex; gap: 10px; flex-wrap: wrap; }
.money-input { display: inline-flex; align-items: center; gap: 4px; }
.money-input input { width: 140px; }
.hint { color: var(--err-text); font-size: 0.85rem; margin: 6px 0 0; }
.form input.invalid, .form textarea.invalid { border-color: var(--err-text); background: var(--err-bg); }
.form textarea, .form input, .form select {
  font: inherit;
  font-weight: 400;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.confirm-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 6px;
  background: var(--warn-bg);
  color: var(--warn-text);
  max-width: 520px;
}
.confirm-box p { margin: 0; font-weight: 600; }

.folder-box { border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; font-size: 0.9rem; }
.folder-box .folder-title { margin: 0 0 6px; font-weight: 600; }
.folder-box p { margin: 4px 0; }
.folder-level + .folder-level { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.folder-level-title { margin: 0 0 4px; font-weight: 600; font-size: 0.85rem; color: var(--muted); }
.folder-box .choice { display: flex; gap: 8px; align-items: baseline; font-weight: 400; margin: 4px 0; }
.system-list { max-height: 280px; overflow-y: auto; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
.select-all { margin-top: 6px; }
.folder-path { font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; word-break: break-word; }
.confirm-folder { font-weight: 400 !important; margin-top: 8px !important; }
.folder-result { margin: 8px 0 12px; }

.result { border-color: var(--ok); }
.job-number { font-size: 1.3rem; margin: 4px 0 8px; }

.muted { color: var(--muted); }
.connected { color: var(--ok); font-weight: 600; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
.num { text-align: right; }

@media (max-width: 700px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; flex-direction: row; border-right: none; border-bottom: 1px solid var(--border); }
  main { padding: 16px; }
}
.no-margin { margin: 0; }
.small-note { font-weight: 400; font-size: 0.85rem; }
.spaced { margin-top: 20px; }

/* Needs attention: each item is a labelled, clickable row */
#attention.rows { border: none; display: grid; gap: 16px; }
.att-group { display: grid; gap: 6px; }
.att-head { display: flex; align-items: center; gap: 10px; }
.att-count { color: var(--muted); font-size: 0.85rem; }
.att-list { display: grid; gap: 6px; }
.att-more { justify-self: start; }
.att-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: 0.92rem; }
.att-item:hover { border-color: var(--brand); background: #f7faff; }
.att-title { overflow-wrap: anywhere; line-height: 1.3; }
.att-sub { display: block; color: var(--muted); font-size: 0.8rem; }
.att-days { font-weight: 600; white-space: nowrap; }
.pill { justify-self: start; padding: 3px 9px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; white-space: nowrap; }
.pill-parts { background: var(--warn-bg); color: var(--warn-text); }
.pill-invoice { background: var(--err-bg); color: var(--err-text); }
.pill-quote { background: #e3eefb; color: #0b4a8b; }

/* Job Board tabs and folder viewer */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 4px; }
.tab { padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); text-decoration: none; font-size: 0.9rem; }
.tab.active { background: var(--brand); border-color: var(--brand); color: var(--brand-text); }
.board { display: grid; gap: 16px; margin-top: 8px; }
.att-days.late { color: var(--warn-text); }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.88rem; margin-bottom: 8px; }
.crumbs a { color: var(--brand); text-decoration: none; }
.crumbs .sep { color: var(--muted); }
#entries { margin-top: 12px; }
.file-row { width: 100%; font: inherit; text-align: left; cursor: pointer; }
.kind { display: inline-block; min-width: 52px; margin-right: 10px; padding: 2px 7px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; text-align: center; background: var(--bg); color: var(--muted); }
.kind-folder { background: #e3eefb; color: #0b4a8b; }
.kind-pdf { background: var(--err-bg); color: var(--err-text); }
.kind-image, .kind-video { background: var(--ok-bg); color: var(--ok); }
.kind-text { background: var(--warn-bg); color: var(--warn-text); }
.viewer { margin-top: 20px; }
.viewer-frame { width: 100%; height: 80vh; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.viewer-image { max-width: 100%; max-height: 80vh; display: block; margin: 0 auto; border-radius: 6px; }
.viewer-text { white-space: pre-wrap; background: var(--bg); padding: 12px; border-radius: 6px; max-height: 70vh; overflow: auto; }

/* New Job: folder details with nothing to check (see hideIfAllFound) */
.all-found { display: none !important; }

/* What's New page (after signing in) */
.whats-new-card { max-width: 520px; }
.whats-new-card .center { text-align: center; margin-top: 0; }
.whats-new-day { margin-top: 14px; }
.whats-new-date { margin: 0 0 4px; font-weight: 600; font-size: 0.85rem; color: var(--muted); }
.whats-new-card ul { margin: 0 0 8px; padding-left: 20px; }
.whats-new-card li { margin: 4px 0; }
.whats-new-card .actions { margin-top: 16px; }

/* Technicians board */
.day-nav { display: flex; align-items: center; gap: 6px; }
.day-nav .button { padding: 7px 12px; }
.day-nav input { font: inherit; padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.button.small { padding: 5px 10px; font-size: 0.85rem; }
.link-button { border: 0; background: none; padding: 0; color: var(--brand); font: inherit; font-size: 0.8rem; cursor: pointer; text-align: left; }
.link-button:hover { text-decoration: underline; }
.icon-button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; width: 28px; height: 26px; cursor: pointer; font-size: 0.85rem; }
.icon-button:hover:not(:disabled) { border-color: var(--brand); }
.icon-button:disabled { opacity: 0.35; cursor: default; }
.tech-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 8px; }
/* Narrow windows: the techs' columns first, the job list under them (shorter). */
@media (max-width: 860px) {
  .tech-layout { grid-template-columns: 1fr; }
  .tech-jobs { order: 2; }
  .tech-job-list { max-height: 45vh; }
}
.tech-jobs { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.tech-jobs .tabs { margin: 8px 0; }
.tech-jobs .tab { font: inherit; font-size: 0.8rem; padding: 4px 10px; cursor: pointer; }
.tech-job-list { display: grid; gap: 6px; max-height: 70vh; overflow-y: auto; }
.tech-job { display: grid; gap: 2px; text-align: left; font: inherit; font-size: 0.9rem; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; }
.tech-job:hover { border-color: var(--brand); }
.tech-job.picked { border: 2px solid var(--brand); padding: 7px 9px; }
.tech-card-sub { color: var(--muted); font-size: 0.8rem; }
.tech-card-job { font-size: 0.85rem; }
.tech-scheduled { color: var(--ok); font-size: 0.78rem; }
.schedule-panel { background: var(--surface); border: 2px solid var(--brand); border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; display: grid; gap: 10px; }
.schedule-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.schedule-fields { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.schedule-fields label { display: grid; gap: 4px; font-weight: 600; font-size: 0.85rem; }
.schedule-fields input, .schedule-fields select { font: inherit; font-weight: 400; padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.schedule-fields .combo { width: 150px; }
.order-picks { display: flex; flex-wrap: wrap; gap: 14px; }
.tech-picks { border: 0; padding: 0; margin: 0; min-width: 200px; }
.tech-picks legend { font-weight: 600; font-size: 0.85rem; padding: 0; margin-bottom: 4px; }
.tech-picks .choice { display: flex; gap: 6px; align-items: center; font-size: 0.9rem; margin: 2px 0; }
.schedule-panel .actions { margin-top: 0; }
.tech-day-title { font-weight: 600; margin: 0 0 8px; }
.tech-columns { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.tech-column { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; display: grid; gap: 6px; align-content: start; }
.tech-column.is-off { background: var(--warn-bg); }
.tech-column-head { display: grid; gap: 1px; margin-bottom: 2px; }
.tech-column-head .muted, .tech-off { font-size: 0.8rem; }
.tech-off { color: var(--warn-text); font-weight: 600; }
.tech-empty { margin: 0; font-size: 0.85rem; }
.tech-card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; font-size: 0.88rem; display: grid; gap: 2px; }
.tech-with { font-size: 0.78rem; color: var(--brand); }
.tech-card-actions { display: flex; gap: 4px; margin-top: 4px; }
.test-tag { display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 4px; background: var(--warn-bg); color: var(--warn-text); font-size: 0.7rem; font-weight: 700; vertical-align: 1px; }

/* Technician's screen (works on phones, tablets and laptops) */
.tech-main { max-width: 1000px; margin: 0 auto; padding: 20px 16px; }
.view-as { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; background: var(--warn-bg); color: var(--warn-text); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 0.9rem; }
.view-as-pick .combo { width: 220px; }
.view-as-pick input { color: var(--text); }
.tech-view { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; margin-top: 12px; }
@media (max-width: 720px) { .tech-view { grid-template-columns: 1fr; } }
.tech-forms { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.tech-form-list { display: grid; gap: 6px; margin-top: 8px; }
.tech-form { text-align: left; font: inherit; padding: 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; min-height: 44px; }
.tech-form:hover { border-color: var(--brand); }
.tech-form.picked { border: 2px solid var(--brand); padding: 11px; font-weight: 600; }
.tech-job-detail { display: grid; gap: 12px; }
.tech-job-detail .card { margin: 0; }
.tech-job-customer { font-weight: 700; font-size: 1.15rem; margin: 0 0 4px; }
.tech-column-links { display: flex; gap: 12px; }
