:root {
  --bg: #f6f7f9;
  --panel: #fff;
  --border: #d9dee4;
  --ink: #1d2530;
  --muted: #6a7280;
  --accent: #ec1e2f;        /* Piedmont brand red */
  --accent-dark: #b8141f;
  --ok: #2f6f3a;
  --warn: #aa7700;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

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

.container { max-width: 1100px; margin: 24px auto; padding: 0 20px; }

.topnav {
  display: flex; align-items: center; gap: 24px;
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 10px 24px;
}
.topnav .brand a { display: inline-flex; align-items: center; }
.topnav .brand img { height: 26px; display: block; }
.topnav .links { display: flex; gap: 18px; flex: 1; }
.topnav .links a { color: var(--ink); padding: 6px 0; border-bottom: 2px solid transparent; }
.topnav .links a.active { border-color: var(--accent); color: var(--accent); }
.topnav .user { display: flex; align-items: center; gap: 12px; color: var(--muted); }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 24px 0 8px; }
h3 { font-size: 14px; margin: 16px 0 6px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.5px; }
h3.group { margin-top: 20px; color: var(--ink); }
.muted { color: var(--muted); }
.hint  { color: var(--muted); font-size: 13px; margin: 4px 0 12px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 18px 0; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px; color: var(--ink); }
.card .metric { font-size: 28px; font-weight: 700; }
.card .label { color: var(--muted); }

.row  { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.form { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.form.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.form label { display: block; margin: 8px 0; font-size: 13px; color: var(--muted); }
.form input, .form select, .form textarea {
  display: block; width: 100%; margin-top: 4px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; color: var(--ink); background: #fff;
}
.form input.r, input.r { text-align: right; }
.form input:disabled { background: #f1f1f4; color: var(--muted); }

button, .btn {
  display: inline-block; cursor: pointer;
  background: #fff; color: var(--ink); border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 6px; font: inherit; text-decoration: none;
}
button:hover, .btn:hover { background: #f1f3f7; }
button.primary, .btn.primary { background: var(--accent); color: #fff; border-color: var(--accent-dark); }
button.primary:hover, .btn.primary:hover { background: var(--accent-dark); }
button.link, .link { background: none; border: none; color: var(--accent); padding: 0; cursor: pointer; }
button.link.tiny { font-size: 12px; color: var(--muted); margin-left: 8px; }
.btn.small { padding: 4px 8px; font-size: 12px; }

table.data { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
table.data th, table.data td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.data thead th { background: #fafbfc; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.5px; }
table.data tr:last-child td { border-bottom: 0; }
table.data .r, th.r, td.r { text-align: right; }
table.data tr.total-row td { background: #fafbfc; font-size: 15px; }

table.data.rates input { width: 110px; padding: 6px 8px; }

.alert { background: #fdecec; border: 1px solid #f1c2c2; color: #6a1b1b; padding: 10px 12px; border-radius: 6px; margin: 10px 0; }
.alert ul { margin: 0; padding-left: 18px; }
.alert.alert-info { background: #fff8e0; border-color: #f1dc8a; color: #6a4a00; }

.filterbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin: 10px 0; }
.filterbar input, .filterbar select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff; }
.filterbar input[type=text] { min-width: 220px; }
.filterbar button { padding: 6px 12px; }

.th-sort { color: var(--ink); text-decoration: none; }
.th-sort:hover { color: var(--accent); text-decoration: none; }

.status { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.status-draft  { background: #eef0f3; color: #4b5563; }
.status-issued { background: #fff3d6; color: #7a5800; }
.status-paid   { background: #dff3e1; color: #1f5a2a; }
.status-void   { background: #f0e0e0; color: #7a3030; }

.status-job-draft       { background: #eef0f3; color: #4b5563; }
.status-job-dispatched  { background: #d8e6ff; color: #1e3a8a; }
.status-job-in_progress { background: #fff3d6; color: #7a5800; }
.status-job-review      { background: #ffe0c4; color: #7a3e00; }
.status-job-completed   { background: #dff3e1; color: #1f5a2a; }
.status-job-invoiced    { background: #e6e0ff; color: #4c1d95; }
.status-job-canceled    { background: #f0e0e0; color: #7a3030; }

/* Mobile-friendly driver "My Jobs" cards */
.job-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin: 12px 0; }
.job-card { display: block; background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 14px 16px; color: var(--ink); text-decoration: none; transition: transform 0.05s; }
.job-card:hover, .job-card:active { background: #fafbfc; text-decoration: none; }
.job-card:active { transform: scale(0.99); }
.job-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.job-card-customer { font-weight: 700; font-size: 17px; margin-bottom: 8px; }
.job-card-row { font-size: 14px; padding: 2px 0; display: flex; gap: 6px; align-items: baseline; }
.job-card-row span:first-child { min-width: 70px; flex-shrink: 0; }
.job-card-meta { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; }
.job-card-cta { font-size: 14px; font-weight: 600; color: var(--accent); margin-top: 10px; text-align: right; }
.job-card.status-job-in_progress { border-left-color: #b8870b; border-left-width: 6px; }
.job-card.status-job-dispatched  { border-left-color: #1e40af; border-left-width: 6px; }
.job-card.status-job-review      { border-left-color: #cc6600; border-left-width: 6px; }
.job-card.status-job-completed   { border-left-color: #1f5a2a; }
.job-card.status-job-invoiced    { border-left-color: #4c1d95; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin: 10px 0 14px; }
.tab { padding: 10px 16px; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -2px; font-weight: 500; font-size: 15px; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab-count { display: inline-block; min-width: 22px; text-align: center; background: #e8eaef; color: var(--ink); border-radius: 11px; padding: 1px 6px; font-size: 12px; margin-left: 4px; transition: background 0.2s; }
.tab.active .tab-count { background: var(--accent); color: #fff; }
.tab.bump { animation: tab-bump 0.5s ease; }
@keyframes tab-bump { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* Capacity display on new-job form */
.capacity-display { margin: 6px 0; }
.capacity-summary { background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 6px; padding: 8px 12px; font-size: 13px; color: var(--ink); }
.cap-meter { display: inline-block; padding: 2px 8px; border-radius: 99px; background: #e2e8f0; margin: 0 4px; }
.cap-meter.cap-warn { background: #fef3c7; color: #78350f; }
.cap-meter.cap-over { background: #fecaca; color: #7f1d1d; }
.cap-warning { background: #fef3c7; border: 1px solid #f59e0b; color: #78350f; padding: 6px 10px; border-radius: 6px; margin-top: 6px; font-size: 13px; }

/* Calendar */
.calendar-legend { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 16px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; text-align: center; padding: 6px 4px; }
.cal-cell { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; min-height: 110px; padding: 4px 6px; display: flex; flex-direction: column; }
.cal-cell.cal-empty { background: #fafbfc; border-style: dashed; }
.cal-cell.cal-today { border-color: var(--accent); border-width: 2px; }
.cal-cell.cal-cell-over { background: #fef3c7; border-color: #f59e0b; }
.cal-day-head { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted); }
.cal-day-num { font-weight: 700; color: var(--ink); font-size: 13px; }
.cal-cap { font-size: 10px; white-space: nowrap; }
.cal-chips { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; flex: 1; }
.cal-chip { display: block; padding: 2px 5px; border-radius: 3px; font-size: 10px; line-height: 1.3; color: var(--ink); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip:hover { text-decoration: none; opacity: 0.85; }
.cal-more { font-size: 10px; color: var(--muted); padding: 2px 5px; }
@media (max-width: 720px) {
  .cal-cell { min-height: 70px; padding: 2px 4px; }
  .cal-day-num { font-size: 11px; }
  .cal-cap { display: none; }
  .cal-chip { font-size: 9px; }
}

.review-panel { background: #f0fdf4; border: 1px solid #86efac; padding: 16px 20px; }
.review-panel h3 { color: #166534; }
.review-checklist { list-style: none; padding: 0; margin: 12px 0; }
.review-checklist li { padding: 6px 0; border-bottom: 1px dashed #c8e6c9; }
.review-checklist li:last-child { border-bottom: 0; }
.review-panel button[disabled] { opacity: 0.5; cursor: not-allowed; }

.live-banner { background: #fff8e0; border: 1px solid #f1dc8a; color: #6a4a00; padding: 10px 14px; border-radius: 8px; margin: 10px 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.live-banner button { background: var(--accent); color: #fff; border: 0; padding: 6px 12px; border-radius: 6px; font: inherit; cursor: pointer; }
.live-banner button:hover { background: var(--accent-dark); }

.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #4ade80; margin-left: 6px; vertical-align: middle; animation: live-pulse 2s infinite; }
.live-dot.offline { background: #d1d5db; animation: none; }
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state p { margin: 6px 0; }

pre.special-instructions { background: #fafbfc; border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; white-space: pre-wrap; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; }

.status-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }

.type-radio { border: 0; padding: 0; margin: 0; }
.type-radio legend { color: var(--muted); font-size: 13px; padding: 0; margin-bottom: 6px; }
.radio-tile { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; cursor: pointer; background: #fff; }
.radio-tile:has(input:checked) { border-color: var(--accent); background: #fff5f6; }
.radio-tile small { color: var(--muted); }

.crew-slot { display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: start; margin: 8px 0; }
.crew-slot-label { font-weight: 600; color: var(--ink); padding-top: 8px; }
.crew-slot-fields select, .crew-slot-fields input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff; }
.crew-select { font-size: 15px; }
.crew-fallback { margin-top: 6px; }
.crew-fallback summary { color: var(--muted); font-size: 12px; cursor: pointer; padding: 4px 0; }
.crew-fallback summary:hover { color: var(--accent); }
.crew-fallback input { margin-top: 4px; }
@media (max-width: 600px) {
  .crew-slot { grid-template-columns: 1fr; gap: 4px; }
  .crew-slot-label { padding-top: 6px; }
}

.sigpad { margin: 6px 0; }
.sig-canvas { display: block; width: 100%; height: 160px; background: #fff; border: 1px dashed #888; border-radius: 6px; touch-action: none; }
.sig-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }

@media (max-width: 720px) {
  .container { padding: 0 12px; margin: 12px auto; }
  .topnav { padding: 8px 12px; gap: 12px; flex-wrap: wrap; }
  .topnav .links { gap: 12px; overflow-x: auto; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  table.data { font-size: 13px; }
  table.data th, table.data td { padding: 6px 8px; }
}

.contacts { list-style: none; padding: 0; margin: 6px 0; }
.contacts li { padding: 6px 0; border-bottom: 1px dashed var(--border); }

.login-card { max-width: 380px; margin: 80px auto; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 26px; text-align: center; }
.login-card img.logo { width: 250px; max-width: 100%; margin-bottom: 4px; }
.login-card .form { text-align: left; border: 0; padding: 0; background: transparent; }
.login-card .tagline { color: var(--muted); margin: 4px 0 18px; }

details.card-block { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin: 12px 0; }
details.card-block > summary { cursor: pointer; list-style: none; }
details.card-block > summary::-webkit-details-marker { display: none; }
h2.inline, h3.inline { display: inline; font-size: inherit; margin: 0; text-transform: none; color: var(--ink); letter-spacing: 0; }
