:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #162033;
  --muted: #667085;
  --line: #dbe3ef;
  --primary: #1f5eff;
  --primary-dark: #153eb2;
  --good: #0f8a4b;
  --warn: #b76e00;
  --bad: #b42318;
  --neutral: #475467;
  --shadow: 0 12px 30px rgba(16, 24, 40, .08);
  --radius: 16px;
}

* { box-sizing: border-box; }

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #101828;
  color: #fff;
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1f5eff, #7c3aed);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: -.04em;
}

.brand strong { display: block; font-size: 18px; }
.brand span { display: block; color: #cbd5e1; font-size: 12px; margin-top: 2px; }

.sidebar nav { display: grid; gap: 6px; }
.sidebar nav a {
  color: #d0d5dd;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  font-weight: 600;
}
.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(255,255,255,.10);
  color: #fff;
  text-decoration: none;
}

.material {
  width: 22px;
  opacity: .9;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: -.04em;
}

.sidebar-foot {
  color: #98a2b3;
  border-top: 1px solid rgba(255,255,255,.10);
  margin-top: 28px;
  padding-top: 18px;
}

.main { min-width: 0; }

.topbar {
  min-height: 88px;
  background: rgba(255,255,255,.84);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -.04em;
}

.topbar p { margin: 4px 0 0; color: var(--muted); }

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-pill {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 700;
  font-size: 13px;
}
.user-pill span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.content { padding: 28px; }

.grid { display: grid; gap: 18px; }
.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.two.asymmetric { grid-template-columns: minmax(0, 1.4fr) minmax(320px, .6fr); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card h2, .card h3 { margin-top: 0; letter-spacing: -.03em; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head h2, .card-head h3 { margin: 0; }

.metric span {
  display: block;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .04em;
}
.metric strong {
  display: block;
  font-size: 34px;
  letter-spacing: -.05em;
  margin: 7px 0;
}
.metric a { font-weight: 700; font-size: 13px; }

.notice { margin-top: 18px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: white;
  border-radius: 11px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  min-height: 40px;
  box-shadow: none;
  font-size: 14px;
}
.btn:hover { text-decoration: none; background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.secondary { background: #eef4ff; color: var(--primary-dark); border-color: #c7d7fe; }
.btn.secondary:hover { background: #dfeaff; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 6px 10px; min-height: 32px; border-radius: 9px; font-size: 12px; }
.btn.full { width: 100%; }

.inline { display: inline; }
.stack { display: grid; gap: 12px; }

.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

th, td {
  text-align: left;
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  background: var(--surface-2);
  color: #344054;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
tr:last-child td { border-bottom: 0; }
td small { color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid transparent;
}
.badge.good { color: var(--good); background: #ecfdf3; border-color: #abefc6; }
.badge.warn { color: var(--warn); background: #fffaeb; border-color: #fedf89; }
.badge.bad { color: var(--bad); background: #fef3f2; border-color: #fecdca; }
.badge.neutral { color: var(--neutral); background: #f2f4f7; border-color: #eaecf0; }

form label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-weight: 800;
  font-size: 13px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--text);
  border-radius: 11px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 500;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(31, 94, 255, .15);
  border-color: var(--primary);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.form-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar input { max-width: 460px; }

.details {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 14px;
}
.details dt { color: var(--muted); font-weight: 800; }
.details dd { margin: 0; }

.job-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.job-header h2 { margin: 0; }
.job-header p { margin: 5px 0 0; color: var(--muted); }
.job-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.timeline { display: grid; gap: 12px; }
.timeline-item {
  border-left: 4px solid #c7d7fe;
  background: #fbfdff;
  border-radius: 0 12px 12px 0;
  padding: 12px 14px;
}
.timeline-item strong { display: block; }
.timeline-item span { color: var(--muted); font-size: 13px; }
.timeline-item p { margin: 8px 0; }

.doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.doc-list li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.doc-list span { color: var(--muted); font-size: 12px; }

.export-grid,
.integration-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.export-card,
.integration {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: var(--surface-2);
}
.export-card strong,
.integration strong { display: block; color: var(--text); margin-bottom: 6px; }
.export-card span,
.integration p { color: var(--muted); margin: 0; }

.invoice { max-width: 980px; margin: 0 auto; }
.invoice-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}
.totals {
  margin-left: auto;
  max-width: 340px;
  display: grid;
  gap: 8px;
  margin-top: 18px;
}
.totals div {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}
.totals div:last-child {
  font-size: 20px;
  border-bottom: 0;
}

.flash {
  margin: 16px 28px 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: white;
  font-weight: 700;
}
.flash.success { color: var(--good); background: #ecfdf3; border-color: #abefc6; }
.flash.error { color: var(--bad); background: #fef3f2; border-color: #fecdca; }
.flash.info { color: var(--primary-dark); background: #eef4ff; border-color: #c7d7fe; }

.muted { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
code {
  background: #f2f4f7;
  padding: 3px 6px;
  border-radius: 6px;
  color: #344054;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(31,94,255,.18), transparent 28%),
    radial-gradient(circle at 80% 0%, rgba(124,58,237,.18), transparent 32%),
    var(--bg);
}
.login-card {
  width: min(460px, calc(100vw - 28px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.login-card .flash { margin: 0 0 12px; }
.login-brand { color: var(--text); margin-bottom: 22px; }
.legal-note { color: var(--muted); font-size: 12px; }

.gps-message { margin-left: 10px; color: var(--muted); font-weight: 700; font-size: 13px; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards, .two, .two.asymmetric, .export-grid, .integration-grid { grid-template-columns: 1fr; }
  .topbar { position: relative; align-items: flex-start; flex-direction: column; }
  .form-grid, .form-grid.compact { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .content { padding: 18px; }
  .topbar { padding: 18px; }
  .sidebar { padding: 18px; }
  .sidebar nav { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .job-header, .invoice-head { flex-direction: column; align-items: flex-start; }
  .details { grid-template-columns: 1fr; }
}

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .flash { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; }
  .card { border: 0; box-shadow: none; padding: 0; }
  a { color: #000; }
}

/* ServeFlow mobile field-app patch */
.field-app-link {
  background: #101828;
  border-color: #101828;
}
.field-app-link:hover {
  background: #000;
  border-color: #000;
}
.mobile-shell {
  max-width: 980px;
  margin: 0 auto;
}
.mobile-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  background: linear-gradient(135deg, #ffffff, #eef4ff);
}
.mobile-hero h2,
.mobile-job-card h3,
.mobile-attempt h2 {
  margin: 4px 0 6px;
}
.mobile-kicker {
  display: inline-block;
  color: var(--primary-dark);
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: 12px;
}
.mobile-hero p {
  color: var(--muted);
  max-width: 660px;
  margin: 0;
}
.mobile-hero-actions,
.mobile-job-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.mobile-job-list {
  display: grid;
  gap: 14px;
}
.mobile-job-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}
.mobile-job-top strong {
  color: var(--primary-dark);
}
.mobile-address,
.mobile-address-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.mobile-address-box {
  margin: 14px 0;
}
.mobile-address-box p {
  margin: 6px 0 12px;
}
.mobile-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.mobile-summary div {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px;
}
.mobile-summary b,
.mobile-summary span {
  display: block;
}
.mobile-summary b {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.mobile-attempt-form {
  display: grid;
  gap: 14px;
}
.mobile-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.mobile-gps-panel {
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 12px;
}
.mobile-gps-panel b {
  display: block;
  margin-bottom: 4px;
}
.mobile-gps-panel p {
  margin: 0;
  color: var(--muted);
}
.mobile-gps-panel.working {
  border-color: #fedf89;
  background: #fffaeb;
}
.mobile-gps-panel.ok {
  border-color: #abefc6;
  background: #ecfdf3;
}
.mobile-gps-panel.error {
  border-color: #fecdca;
  background: #fef3f2;
}
.gps-display {
  margin-top: 6px !important;
  font-weight: 800;
  color: var(--text) !important;
}
.gps-details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.gps-details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 10px;
}
.mobile-save-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  position: sticky;
  bottom: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
  z-index: 20;
}

@media (max-width: 720px) {
  .mobile-hero,
  .mobile-job-top {
    flex-direction: column;
    align-items: stretch;
  }
  .mobile-hero-actions,
  .mobile-job-actions {
    justify-content: stretch;
  }
  .mobile-hero-actions .btn,
  .mobile-job-actions .btn,
  .mobile-address-box .btn {
    width: 100%;
  }
  .mobile-summary,
  .mobile-two,
  .mobile-save-bar {
    grid-template-columns: 1fr;
  }
  .mobile-attempt.card,
  .mobile-job-card.card,
  .mobile-hero.card {
    padding: 16px;
    border-radius: 18px;
  }
  input,
  select,
  textarea,
  .btn {
    font-size: 16px;
  }
}


/* ServeFlow click/navigation repair */
a, button, input, select, textarea, summary, label { pointer-events: auto; }
a, button, summary, .btn { cursor: pointer; touch-action: manipulation; }
.sidebar, .topbar, .content, .card { pointer-events: auto; }
button[disabled], input[disabled], select[disabled], textarea[disabled] { cursor: not-allowed; }

/* ServeFlow custom logo - direct install 2026-04-20 */
.brand-logo {
  display: block;
  width: 165px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  flex: 0 0 auto;
}

.sidebar .brand {
  justify-content: flex-start;
  gap: 0;
  margin-bottom: 24px;
}

.sidebar .brand .brand-logo {
  width: 175px;
  max-height: 115px;
}

.sidebar .brand > div:not(:first-child) {
  display: none !important;
}

.login-brand {
  justify-content: center;
  flex-direction: column;
  text-align: center;
  gap: 8px;
}

.login-brand .brand-logo {
  width: min(300px, 85vw);
  max-height: 220px;
  margin: 0 auto 6px;
}

.login-brand > div:not(:first-child) {
  display: none !important;
}

@media (max-width: 620px) {
  .sidebar .brand .brand-logo {
    width: 150px;
  }

  .login-brand .brand-logo {
    width: min(260px, 82vw);
  }
}
/* ServeFlow lighter sidebar theme - logo visibility fix */
.sidebar {
  background: linear-gradient(180deg, #eaf6ff 0%, #d9efff 48%, #c8e7ff 100%) !important;
  color: #0b2f4a !important;
  border-right: 1px solid #b7dcf5 !important;
}

.sidebar .brand {
  background: rgba(255,255,255,.42) !important;
  border: 1px solid rgba(20,92,150,.14) !important;
  border-radius: 18px !important;
  padding: 12px 10px !important;
  justify-content: center !important;
}

.sidebar .brand strong,
.sidebar .brand span {
  color: #0b2f4a !important;
}

.sidebar nav a {
  color: #15435f !important;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(31, 94, 255, .12) !important;
  color: #082942 !important;
}

.sidebar-foot {
  color: #315a72 !important;
  border-top: 1px solid rgba(15, 67, 105, .18) !important;
}

.material {
  color: #1d5f8f !important;
  opacity: .95 !important;
}

/* ServeFlow UI cleanup: consistent logo and no SF fallback */
.brand-mark {
  display: none !important;
}
.brand-logo {
  display: block;
  width: 165px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  flex: 0 0 auto;
}
.sidebar .brand {
  justify-content: flex-start;
  gap: 0;
  margin-bottom: 24px;
  background: rgba(255,255,255,.42) !important;
  border: 1px solid rgba(20,92,150,.14) !important;
  border-radius: 18px !important;
  padding: 12px !important;
}
.sidebar .brand .brand-logo {
  width: 175px;
  max-height: 115px;
}
.sidebar .brand > div:not(:first-child) {
  display: none !important;
}
.login-brand {
  justify-content: center;
  flex-direction: column;
  text-align: center;
  gap: 8px;
}
.login-brand .brand-logo {
  width: min(300px, 85vw);
  max-height: 220px;
  margin: 0 auto 6px;
}
.login-brand > div:not(:first-child) {
  display: none !important;
}
@media (max-width: 620px) {
  .sidebar .brand .brand-logo { width: 150px; }
  .login-brand .brand-logo { width: min(260px, 82vw); }
}

/* ServeFlow Patch 01: legal acceptance + compact public/app logos */
.sf-legal-note {
  margin-top: 16px;
  color: #667085;
  font-size: 13px;
  line-height: 1.55;
}
.sf-legal-note a,
.sf-legal-check a { font-weight: 900; }
.sf-legal-check {
  display: flex !important;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0 !important;
  padding: 13px 14px;
  border: 1px solid #c7d7fe;
  background: #eef4ff;
  color: #26344a;
  border-radius: 14px;
  font-weight: 700 !important;
  line-height: 1.45;
}
.sf-legal-check input {
  width: auto !important;
  min-width: 18px;
  margin-top: 3px;
}
.sf-public-logo-small,
.login-card .logo img,
.sf-login-logo img {
  max-height: 82px !important;
  width: auto !important;
  max-width: 220px !important;
  object-fit: contain !important;
}
