/* FieldOps — one stylesheet for the office, the truck and the customer. */
:root {
  --navy: #1f2430; --navy-2: #2a3140; --ink: #14171f; --muted: #6b7280; --line: #e5e7eb; --line-2: #f1f3f6;
  --bg: #f5f6f8; --card: #ffffff; --blue: #2563eb; --blue-soft: #e8efff; --green: #16a34a; --green-soft: #e6f6ec;
  --amber: #d97706; --amber-soft: #fff4e0; --red: #dc2626; --red-soft: #fdecec; --purple: #7c3aed; --purple-soft: #f0e9ff;
  --radius: 12px; --shadow: 0 1px 2px rgba(20,23,31,.06), 0 6px 20px rgba(20,23,31,.06);
  --font: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 .35em; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; } .bold { font-weight: 600; }
.hidden { display: none !important; }
.right { text-align: right; } .center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 760px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ----- shell ----- */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 14px; padding: 0 16px; height: 56px; position: sticky; top: 0; z-index: 30; }
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.topbar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: #facc15; box-shadow: 0 0 0 3px rgba(250,204,21,.25); }
.topbar .brand small { font-weight: 400; opacity: .7; font-size: 12px; margin-left: 4px; }
.topbar nav { display: flex; gap: 2px; margin-left: 8px; overflow-x: auto; scrollbar-width: none; }
.topbar nav a { color: rgba(255,255,255,.75); padding: 8px 12px; border-radius: 8px; font-size: 14px; white-space: nowrap; }
.topbar nav a.active, .topbar nav a:hover { color: #fff; background: rgba(255,255,255,.1); }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; opacity: .85; display: flex; align-items: center; gap: 8px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #fff; background: var(--blue); flex: 0 0 auto; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 18px 16px 60px; }
.wrap.narrow { max-width: 720px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

/* ----- cards ----- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }
.card.pad0 { padding: 0; overflow: hidden; }
.card h2 { margin-bottom: 10px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 4px 0 8px; }

/* ----- buttons ----- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; background: var(--navy); color: #fff; padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap; transition: transform .05s, background .15s; }
.btn:hover { background: var(--navy-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--blue); } .btn.primary:hover { background: #1d4ed8; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); } .btn.ghost:hover { background: var(--line-2); }
.btn.soft { background: var(--blue-soft); color: var(--blue); } .btn.soft:hover { background: #dbe6ff; }
.btn.danger { background: var(--red-soft); color: var(--red); } .btn.danger:hover { background: #fbd9d9; }
.btn.success { background: var(--green); } .btn.success:hover { background: #15803d; }
.btn.warn { background: var(--amber); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 14px 18px; font-size: 16px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn.icon { padding: 8px; width: 36px; height: 36px; }
.btnbar { display: flex; gap: 8px; flex-wrap: wrap; }

/* ----- forms ----- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 500; color: #374151; }
.field .hint { font-size: 12px; color: var(--muted); }
input, select, textarea { font: inherit; font-size: 15px; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 9px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
textarea { min-height: 84px; resize: vertical; }
input[type=checkbox] { width: auto; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 600px) { .inline-fields { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }

/* ----- tables / lists ----- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: #fafbfd; }
.list { display: flex; flex-direction: column; }
.list .item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.list .item:last-child { border-bottom: 0; }
.list .item:hover { background: #fafbfd; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* ----- pills / status ----- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--line-2); color: #374151; white-space: nowrap; }
.pill .d { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.unscheduled { background: #f3f4f6; color: #4b5563; }
.pill.scheduled { background: var(--blue-soft); color: var(--blue); }
.pill.en_route { background: var(--purple-soft); color: var(--purple); }
.pill.on_site { background: var(--amber-soft); color: var(--amber); }
.pill.done { background: var(--green-soft); color: var(--green); }
.pill.invoiced { background: #e0f2fe; color: #0369a1; }
.pill.paid { background: var(--green-soft); color: #166534; }
.pill.cancelled, .pill.void, .pill.declined { background: var(--red-soft); color: var(--red); }
.pill.sent { background: var(--blue-soft); color: var(--blue); }
.pill.draft { background: #f3f4f6; color: #4b5563; }
.pill.approved { background: var(--green-soft); color: var(--green); }
.pill.partial { background: var(--amber-soft); color: var(--amber); }
.pill.new { background: var(--amber-soft); color: var(--amber); }
.pill.urgent { background: var(--red-soft); color: var(--red); }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.bad { background: var(--red-soft); color: var(--red); }

/* ----- stat tiles ----- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.stat .l { font-size: 12px; color: var(--muted); }

/* ----- dispatch board ----- */
.board { display: grid; grid-template-columns: 220px 1fr; gap: 12px; align-items: start; }
@media (max-width: 900px) { .board { grid-template-columns: 1fr; } }
.lane { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.lane-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfd; }
.lane-body { min-height: 64px; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.lane-body.over { background: var(--blue-soft); }
.jobcard { border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 10px; padding: 8px 10px; background: #fff; cursor: grab; font-size: 13px; }
.jobcard:active { cursor: grabbing; }
.jobcard .t { font-weight: 600; font-size: 14px; }
.jobcard .m { color: var(--muted); font-size: 12px; }
.jobcard.dragging { opacity: .5; }
.timeline { display: grid; grid-template-columns: 140px repeat(11, 1fr); border-radius: var(--radius); overflow: hidden; background: var(--card); box-shadow: var(--shadow); }
.timeline .hd { font-size: 11px; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: center; background: #fafbfd; }
.timeline .techcol { padding: 10px; border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line); font-size: 13px; }
.timeline .slots { grid-column: 2 / span 11; position: relative; border-bottom: 1px solid var(--line-2); min-height: 62px; background: repeating-linear-gradient(90deg, transparent 0, transparent calc(100%/11 - 1px), var(--line-2) calc(100%/11 - 1px), var(--line-2) calc(100%/11)); }
.timeline .slots.over { background-color: var(--blue-soft); }
.timeline .blk { position: absolute; top: 8px; height: 46px; border-radius: 8px; padding: 5px 8px; font-size: 12px; line-height: 1.25; color: #fff; overflow: hidden; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.timeline .blk .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline .blk .m { opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline .blk.en_route { outline: 2px solid var(--purple); outline-offset: -2px; }
.timeline .blk.on_site { outline: 2px solid var(--amber); outline-offset: -2px; }
.timeline .blk.done, .timeline .blk.invoiced, .timeline .blk.paid { opacity: .55; }
.timeline .now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); z-index: 2; pointer-events: none; }

/* ----- map ----- */
#map, .map { height: 380px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: #e5e7eb; }
.leaflet-container { font-family: var(--font); }
.techpin { width: 30px; height: 30px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.35); }
.techpin.stale { opacity: .55; }
.jobpin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }

/* ----- drawer / modal ----- */
.overlay { position: fixed; inset: 0; background: rgba(20,23,31,.45); z-index: 40; display: flex; justify-content: flex-end; }
.drawer { width: min(720px, 100%); height: 100%; background: var(--bg); overflow-y: auto; box-shadow: -10px 0 30px rgba(0,0,0,.2); animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { position: sticky; top: 0; background: #fff; border-bottom: 1px solid var(--line); padding: 12px 16px; display: flex; align-items: center; gap: 10px; z-index: 2; }
.drawer-body { padding: 16px; }
.modal-center { position: fixed; inset: 0; background: rgba(20,23,31,.45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: min(520px, 100%); background: #fff; border-radius: 14px; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.3); max-height: 92vh; overflow-y: auto; }

/* ----- toast ----- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 100; box-shadow: 0 8px 30px rgba(0,0,0,.3); max-width: 92vw; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

/* ----- activity ----- */
.feed { display: flex; flex-direction: column; }
.feed .ev { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.feed .ev:last-child { border-bottom: 0; }
.feed .ic { width: 26px; height: 26px; border-radius: 50%; background: var(--line-2); display: flex; align-items: center; justify-content: center; font-size: 13px; }
.feed .when { font-size: 12px; color: var(--muted); }

/* ----- tabs ----- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 9px 12px; color: var(--muted); font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--navy); font-weight: 500; }

/* ----- sign in ----- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, var(--navy) 0%, #2f3a52 100%); }
.auth .card { width: min(420px, 100%); padding: 26px; }
.auth .logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 20px; margin-bottom: 4px; }
.auth .logo .dot { width: 12px; height: 12px; border-radius: 50%; background: #facc15; }

/* ----- tech (phone) ----- */
.tech body { background: #f5f6f8; }
.tech-top { background: var(--navy); color: #fff; padding: 14px 16px; position: sticky; top: 0; z-index: 30; }
.tech-top .row { justify-content: space-between; }
.tech-wrap { padding: 14px 14px 100px; max-width: 640px; margin: 0 auto; }
.bignav { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); display: flex; z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
.bignav a { flex: 1; text-align: center; padding: 10px 4px 8px; font-size: 11px; color: var(--muted); }
.bignav a.active { color: var(--blue); }
.bignav a .i { display: block; font-size: 20px; line-height: 1.1; }
.jobrow { display: flex; gap: 12px; padding: 14px; border-bottom: 1px solid var(--line-2); align-items: flex-start; }
.jobrow .time { width: 62px; flex: 0 0 auto; font-weight: 600; font-size: 14px; }
.jobrow .time small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.statusbar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.statusbar .btn { padding: 14px 6px; font-size: 14px; flex-direction: column; gap: 2px; }
.statusbar .btn small { font-weight: 400; font-size: 11px; opacity: .8; }
.checklist .ck { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 15px; }
.checklist .ck input { width: 22px; height: 22px; margin-top: 1px; }
.checklist .ck.done span { text-decoration: line-through; color: var(--muted); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photos .ph { aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line-2); position: relative; }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .ph .x { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 50%; width: 22px; height: 22px; font-size: 13px; cursor: pointer; }
.sigpad { width: 100%; height: 160px; border: 1px dashed #9ca3af; border-radius: 10px; background: #fff; touch-action: none; }
.gps { font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.gps .d { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; }
.gps.on .d { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.3); }

/* ----- portal ----- */
.portal-head { background: var(--navy); color: #fff; padding: 22px 16px; }
.portal-head .inner { max-width: 760px; margin: 0 auto; }
.portal-head h1 { color: #fff; font-size: 20px; }
.portal-wrap { max-width: 760px; margin: 0 auto; padding: 16px; }
.lineitems td:last-child, .lineitems th:last-child { text-align: right; }
.totals { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; margin-top: 8px; font-size: 14px; }
.totals .big { font-size: 18px; font-weight: 600; }

.print-only { display: none; }
@media print { .no-print, .topbar, .bignav { display: none !important; } .print-only { display: block; } body { background: #fff; } .card { box-shadow: none; border: 1px solid var(--line); } }
