:root {
  --emerald: #10b981;
  --emerald-dark: #059669;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --amber: #b45309;
  --amber-bg: #fffbeb;
  --red: #b91c1c;
  --red-bg: #fef2f2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--ink);
  color: white;
  padding: 14px 16px calc(14px + env(safe-area-inset-top, 0px));
  padding-top: max(14px, env(safe-area-inset-top, 0px));
}

header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

header .logo {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--emerald);
}

header .date {
  margin: 2px 0 0;
  font-size: 12px;
  color: #94a3b8;
}

.status-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#status-text {
  font-size: 11px;
  color: #cbd5e1;
  flex: 1;
}

#status-text.offline { color: #fbbf24; }
#status-text.stale { color: #fca5a5; }

#sync-btn {
  background: var(--emerald);
  color: var(--ink);
  border: none;
  font-weight: 600;
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
#sync-btn:active { background: var(--emerald-dark); color: white; }
#sync-btn.syncing { opacity: 0.6; }

main {
  padding: 12px 12px calc(24px + env(safe-area-inset-bottom, 0px));
  max-width: 640px;
  margin: 0 auto;
}

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 60px 20px;
}
.empty .big { font-size: 32px; margin-bottom: 8px; }

.job-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}

.job-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.job-time {
  font-size: 13px;
  font-weight: 700;
  color: var(--emerald-dark);
}

.job-stage {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
}

.job-name {
  font-size: 16px;
  font-weight: 700;
  margin: 4px 0 2px;
}

.job-address {
  font-size: 13px;
  color: var(--ink-2);
  text-decoration: none;
}
.job-address:active { color: var(--emerald-dark); }

.job-phone {
  font-size: 13px;
  color: var(--emerald-dark);
  text-decoration: none;
  font-weight: 600;
}

.contact-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.barrier-flag {
  margin-top: 10px;
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
}
.barrier-flag.cleared {
  background: #ecfdf5;
  color: var(--emerald-dark);
  border-color: #a7f3d0;
}

.facts {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 12px;
}
.facts .k { color: var(--muted); }
.facts .v { font-weight: 600; color: var(--ink-2); }

.measures {
  margin-top: 10px;
  font-size: 12px;
}
.measures .k { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 10px; letter-spacing: 0.03em; }
.measures ul { margin: 4px 0 0; padding-left: 18px; }
.measures li { margin-bottom: 2px; }

.notes {
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 10px;
}

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

.actions a {
  flex: 1;
  min-width: 130px;
  text-align: center;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  color: var(--ink-2);
}

.actions a.ready {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: var(--emerald-dark);
}

.offline-banner {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  margin-bottom: 12px;
  font-weight: 600;
}
