:root {
  --navy: #0F285B;
  --navy-2: #16356f;
  --navy-3: #0a1b3d;
  --orange: #FD6F1A;
  --orange-2: #e45e0d;
  --orange-soft: #fff1e8;
  --ink: #050505;
  --body: #363636;
  --muted: #7A7A7A;
  --line: #E4E7EE;
  --canvas: #F3F5F8;
  --white: #ffffff;
  --ok: #1b8a5a;
  --ok-soft: #e7f7ee;
  --warn: #b45309;
  --danger: #c24141;
  --danger-soft: #fdecec;
  --sidebar: 248px;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 40, 91, 0.08);
  --font: "Outfit", system-ui, sans-serif;
  --text: "IBM Plex Sans", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); color: var(--body); font-family: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy); text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--font); color: var(--navy); margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
[hidden] { display: none !important; }

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(253, 111, 26, 0.22), transparent 50%),
    linear-gradient(160deg, var(--navy-3), var(--navy) 55%, #1a3f86);
  position: relative;
  z-index: 1;
}
.login-card {
  width: min(420px, 100%);
  background: var(--white);
  border-radius: 22px;
  padding: 36px 32px 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,.28);
  position: relative;
  z-index: 2;
}
.login-card img { height: auto; width: min(280px, 100%); margin: 0 auto 12px; }
.login-card h1 { text-align: center; font-size: 22px; margin-bottom: 4px; }
.login-card .tag { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-card label { display: block; font-size: 12px; font-weight: 600; color: var(--navy); margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .06em; }
.login-card input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fbfcfe;
}
.login-card input:focus { outline: 2px solid var(--orange); border-color: var(--orange); }
.hint { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center; }

.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100dvh; }
.sidebar {
  background: var(--navy); color: #d7e0f3; padding: 22px 16px 16px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh;
}
.brand { display: flex; flex-direction: column; gap: 10px; padding: 4px 6px 20px; }
.brand img { height: auto; width: 100%; border-radius: 10px; }
.brand span { font-size: 11px; opacity: .7; padding-left: 4px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  color: #c9d4ee; padding: 10px 12px; border-radius: 10px;
  display: flex; align-items: center; gap: 10px; font-family: var(--font); font-weight: 500; font-size: 14px;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover, .nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.nav a.active { box-shadow: inset 3px 0 0 var(--orange); }
.sidebar .grow { flex: 1; }
.userbox { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.userbox button { background: none; border: 0; color: #ffc59a; cursor: pointer; font-weight: 600; }
.main {
  padding: calc(28px + env(safe-area-inset-top, 0px)) 32px 80px;
  min-width: 0;
}
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar h1 { font-size: 28px; }
.topbar p { color: var(--muted); margin-top: 4px; font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  border: 0; border-radius: 10px; padding: 10px 14px; cursor: pointer; font-family: var(--font); font-weight: 600; font-size: 14px;
  background: var(--navy); color: #fff; display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { background: var(--navy-2); }
.btn.primary { background: var(--orange); color: #fff; }
.btn.primary:hover { background: var(--orange-2); }
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.sm { padding: 7px 10px; font-size: 13px; border-radius: 8px; }
.grid { display: grid; gap: 16px; }
.metrics { grid-template-columns: repeat(4, 1fr); }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.metric .label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.metric .value { font-family: var(--font); font-size: 30px; font-weight: 700; color: var(--navy); margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
.metric .sub { font-size: 13px; color: var(--muted); }
.metric.owed .value { color: var(--orange); }
.pill { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; font-family: var(--font); }
.st-booked { background: #e8eef8; color: var(--navy); }
.st-awaiting_parts { background: #fff6db; color: var(--warn); }
.st-en_route { background: var(--orange-soft); color: var(--orange-2); }
.st-ongoing { background: #e7f1ff; color: #1d4f91; }
.st-complete { background: var(--ok-soft); color: var(--ok); }
.st-cancelled { background: #eee; color: #666; }
.st-paid { background: var(--ok-soft); color: var(--ok); }
.st-partial { background: #fff6db; color: var(--warn); }
.st-overdue, .st-declined { background: var(--danger-soft); color: var(--danger); }
.st-sent, .st-accepted, .st-draft, .st-converted { background: #eef2ff; color: var(--navy); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 12px 10px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
tr.click:hover { background: #f7f9fc; cursor: pointer; }
.mono { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--navy); }
.right { text-align: right; }
.muted { color: var(--muted); }
.reg { font-family: var(--font); font-weight: 700; letter-spacing: .04em; background: #111; color: #f7d34a; padding: 2px 7px; border-radius: 4px; font-size: 12px; }
.reg-input {
  font-family: var(--font); font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select, .field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff;
}
.filters input { min-width: 220px; }
.filters input[type="date"] { min-width: 150px; }
.pill[data-go] { cursor: pointer; }
.form { display: grid; gap: 14px; }
.form.two { grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--navy); text-transform: uppercase; letter-spacing: .05em; }
.field.span { grid-column: 1 / -1; }
.field textarea { min-height: 90px; resize: vertical; }
.split { display: grid; grid-template-columns: 1.4fr .9fr; gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stepper { display: flex; gap: 6px; flex-wrap: wrap; }
.notice {
  background: var(--orange-soft); border: 1px solid #ffd7bf; border-radius: 12px; padding: 14px 16px;
}
.time-form .btn { width: 100%; justify-content: center; min-height: 44px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal .dow { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 0 4px; }
.day { background: #fff; border: 1px solid var(--line); border-radius: 12px; min-height: 108px; padding: 8px; }
.day.empty { background: transparent; border-color: transparent; }
.day.today { border-color: var(--orange); box-shadow: 0 0 0 1px var(--orange); }
.day .n { font-family: var(--font); font-weight: 700; color: var(--navy); font-size: 13px; }
.chip { display: block; font-size: 11px; padding: 3px 6px; border-radius: 6px; margin-top: 4px; background: var(--navy); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.en_route, .chip.ongoing { background: var(--orange); }
.chip.awaiting_parts { background: var(--warn); }
.chip.complete { background: var(--ok); }
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--navy); color: #fff;
  padding: 12px 16px; border-radius: 12px; z-index: 50; box-shadow: var(--shadow); pointer-events: none;
}
.modal {
  display: none;
  position: fixed; inset: 0; background: rgba(10, 20, 45, .45);
  place-items: center; z-index: 40; padding: 20px;
}
.modal.is-open { display: grid; }
.modal-card { background: #fff; border-radius: 18px; padding: 22px; width: min(520px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-card h3 { margin-bottom: 14px; }
.mobile-nav { display: none; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; }
.low { color: var(--danger); font-weight: 700; }
.print-head { display: flex; justify-content: space-between; gap: 20px; align-items: start; margin-bottom: 24px; }
.print-head img { height: 56px; }
.badge-sms-off {
  display: inline-flex; align-items: center; margin-left: 6px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: #eee; color: #555; vertical-align: middle;
}
.job-map { height: 220px; border-radius: 12px; overflow: hidden; background: #e8eef8; }
.travel-card .job-map { margin-top: 4px; }
.photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 10px;
}
.photo-grid figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.photo-grid img { width: 100%; height: 120px; object-fit: cover; border-radius: 10px; background: #f3f5f8; }
.photo-upload { position: relative; overflow: hidden; }
.photo-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.note-booking { margin: 8px 0 12px; white-space: pre-wrap; }
.note-log { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.note-item { padding: 10px 0; border-top: 1px solid var(--line); }
.pay-choices { display: grid; gap: 8px; margin: 14px 0; }
.pay-choice {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 600;
}
.pay-choice:has(input:checked) { border-color: var(--orange); background: var(--orange-soft); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 8px 0 12px; }
.check input { width: 18px; height: 18px; }
.day-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 8px; margin-left: 6px;
  border-radius: 999px; background: var(--navy); color: #fff;
  font-size: 14px; vertical-align: middle;
}
.day-list { display: flex; flex-direction: column; gap: 10px; }
.day-card {
  display: flex; flex-direction: column; gap: 12px;
  background: var(--white);
  border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
  box-shadow: var(--shadow); color: inherit;
}
.day-open {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto 18px;
  gap: 12px; align-items: center; color: inherit;
}
.who-bubble {
  width: 36px; height: 36px; border-radius: 50%; background: var(--navy); color: #fff;
  display: grid; place-items: center; font-family: var(--font); font-weight: 700;
  font-size: 12px; letter-spacing: 0.02em; flex: none;
}
.who-bubble.empty { background: #e8eef8; color: #8b97b3; }
.who-bubble.who-sm { background: var(--orange); }
.who-chip.who-dc { background: #e8eef8; color: var(--navy); }
.who-chip.who-dc:hover { background: #d5e0f4; }
.who-chip.who-dc.on, .who-chip.who-dc.on:hover { background: var(--navy); color: #fff; }
.who-chip.who-sm { background: var(--orange-soft); color: var(--orange-2); }
.who-chip.who-sm:hover { background: #ffe4d4; }
.who-chip.who-sm.on, .who-chip.who-sm.on:hover { background: var(--orange); color: #fff; }
a.call-now { background: var(--orange); color: #fff; justify-content: center; min-height: 44px; }
a.call-now:hover { background: var(--orange-2); color: #fff; }
.day-card > a.call-now,
.card > a.call-now { width: 100%; }
td a.call-now { width: auto; margin-top: 8px; }
.day-card:hover { border-color: #c9d4ee; }
.day-mark {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--navy);
  display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700;
}
.day-card.en_route .day-mark, .day-card.ongoing .day-mark { background: var(--orange); border-color: var(--orange); }
.day-card.awaiting_parts .day-mark { background: var(--warn); border-color: var(--warn); }
.day-card.complete { background: #f7f8fb; }
.day-card.complete .day-mark { background: var(--ok); border-color: var(--ok); }
.day-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.day-body strong { color: var(--navy); font-family: var(--font); }
.day-body .muted, .day-when { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge-am {
  background: var(--orange-soft); color: var(--orange-2);
  font-family: var(--font); font-weight: 700; font-size: 12px;
  padding: 4px 8px; border-radius: 8px;
}
.day-go { color: var(--navy); font-size: 22px; line-height: 1; }
.jobs-cards { display: none; }
@media (max-width: 860px) {
  .dense-list .topbar { margin-bottom: 10px; }
  .dense-list .topbar h1 { font-size: 22px; }
  .dense-list .topbar p { font-size: 12px; margin-top: 2px; }
  .dense-list .day-count { min-width: 22px; height: 22px; font-size: 12px; }
  .dense-list .actions .btn { padding: 8px 10px; font-size: 13px; }
  .dense-list .filters { gap: 6px; margin-bottom: 8px; }
  .dense-list .filters .btn.sm,
  .dense-list .who-chip { padding: 5px 8px; font-size: 12px; }
  .dense-list .filters input { padding: 6px 8px; font-size: 13px; min-width: 0; }
  .dense-list .day-list { gap: 6px; }
  .dense-list .day-card { padding: 8px 10px; gap: 6px; border-radius: 12px; box-shadow: none; }
  .dense-list .day-open { gap: 8px; grid-template-columns: 16px minmax(0, 1fr) auto auto 12px; }
  .dense-list .day-body strong { font-size: 15px; line-height: 1.2; }
  .dense-list .day-body .muted, .dense-list .day-when { font-size: 12px; }
  .dense-list .who-bubble { width: 28px; height: 28px; font-size: 11px; }
  .dense-list .day-mark { width: 16px; height: 16px; }
  .dense-list .day-go { font-size: 18px; }
  .dense-list .badge-am { font-size: 11px; padding: 2px 6px; }
  .dense-list .pill { font-size: 11px; padding: 2px 7px; }
  .dense-list .day-card > a.call-now { min-height: 32px; padding: 4px 10px; font-size: 13px; }
  .jobs-table { display: none; }
  .jobs-cards { display: flex; }
}
@media (max-width: 1100px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .split, .form.two { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main {
    padding:
      calc(16px + env(safe-area-inset-top, 0px))
      max(16px, env(safe-area-inset-right, 0px))
      96px
      max(16px, env(safe-area-inset-left, 0px));
  }
  .metrics { grid-template-columns: 1fr; }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--navy);
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); gap: 4px; z-index: 30;
  }
  .mobile-nav a { flex: 1; color: #c9d4ee; text-align: center; font-size: 11px; font-family: var(--font); padding: 8px 4px; border-radius: 10px; }
  .mobile-nav a.active { background: rgba(255,255,255,.12); color: #fff; }
  .hol-cal { gap: 4px; }
  .hol-cal .day { min-height: 64px; padding: 4px; }
  .hol-cal .chip { font-size: 10px; padding: 2px 4px; }
}
@media print {
  .sidebar, .mobile-nav, .topbar .actions, .filters, .btn, .toast, .modal { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
}
