:root {
  --navy: #1b2a4a;
  --navy-dark: #121d33;
  --blue: #2563eb;
  --brand-blue: #1b6fb5;
  --gold: #f2b705;
  --gold-dark: #c78f04;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1e2433;
  --muted: #6b7280;
  --border: #e2e8f0;
  --green: #15803d;
  --amber: #b45309;
  --red: #b91c1c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}
.topbar { background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 60%, #24365e 100%); color: #fff; border-bottom: 3px solid var(--gold); }
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 10px 20px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand-logo { height: 44px; width: auto; background: #fff; border-radius: 10px; padding: 4px 10px; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.brand span { font-weight: 400; opacity: .8; }
.usernav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.usernav .btn-ghost { color: #dbe4f5; border: 1px solid transparent; border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.usernav .btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(242,183,5,.5); }
.usernav .who { margin: 0 8px; opacity: .85; font-size: 14px; }
.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0 0 4px; font-size: 28px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(16,24,40,.06);
}
.card.narrow { max-width: 440px; margin: 40px auto; }
.login-card { text-align: center; border-top: 4px solid var(--gold); }
.login-logo { max-width: 220px; height: auto; margin: 4px auto 8px; display: block; }
.login-card .form { text-align: left; }
.card h2 { margin-top: 0; font-size: 19px; }
.card-link { text-decoration: none; color: inherit; display: block; transition: box-shadow .15s; }
.card-link:hover { box-shadow: 0 4px 14px rgba(16,24,40,.12); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-top h2 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } .page-head { flex-direction: column; } }
.stats { display: flex; gap: 20px; margin: 12px 0; }
.stat { text-align: center; }
.stat strong { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px;
  background: #eef2ff; color: var(--navy); text-transform: capitalize; font-weight: 600;
}
.badge-active, .badge-approved, .badge-paid, .badge-closed { background: #dcfce7; color: var(--green); }
.badge-pending, .badge-open, .badge-not_requested { background: #fef3c7; color: var(--amber); }
.badge-on_hold { background: #f1f5f9; color: var(--muted); }
.badge-submitted, .badge-sent_to_party, .badge-response_drafted, .badge-resubmitted { background: #dbeafe; color: var(--blue); }
.badge-waived { background: #f1f5f9; color: var(--muted); }
.badge-draft { background: #f1f5f9; color: var(--muted); }
.badge-in_review { background: #dbeafe; color: var(--blue); }
.badge-final { background: #dcfce7; color: var(--green); }
.badge-flagged { background: #fee2e2; color: var(--red); }
tr.row-flagged { background: #fef2f2; }
.form-inline { display: flex; gap: 6px; align-items: center; }
.form-inline input { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }
.btn {
  display: inline-block; border: none; border-radius: 8px; padding: 12px 20px;
  font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-secondary { background: #eef2ff; color: var(--navy); }
.btn-ghost { background: transparent; color: var(--navy); border: 1px solid var(--border); }
.btn-small { padding: 8px 12px; font-size: 13px; }
.usernav .btn-ghost { color: #fff; border-color: rgba(255,255,255,.4); padding: 8px 14px; }
.form label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
.form input, .form select {
  display: block; width: 100%; margin-top: 6px; padding: 12px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 15px;
}
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .form .row { grid-template-columns: 1fr; } }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 13px; margin-top: 4px; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 8px; }
.team-row {
  display: grid; grid-template-columns: 130px 1fr 1fr; gap: 12px;
  padding: 14px; border: 1px dashed var(--border); border-radius: 8px; margin-bottom: 12px;
}
.team-row label { margin-bottom: 0; }
@media (max-width: 720px) { .team-row { grid-template-columns: 1fr; } }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.alert-error { background: #fee2e2; color: var(--red); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.table tr.dimmed td { opacity: .45; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form select { padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.dl { display: grid; grid-template-columns: 180px 1fr; gap: 8px 12px; margin: 0; }
.dl dt { color: var(--muted); font-size: 14px; }
.dl dd { margin: 0; font-weight: 600; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: none; }

/* ---- Module 2: Jobsite/QC (mobile-first) ---- */
.touch-actions { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.touch-btn {
  display: block; width: 100%; padding: 16px 20px; font-size: 17px; min-height: 56px;
}
.touch-mini { min-height: 44px; min-width: 64px; font-size: 15px; }
.touch-select { padding: 12px; font-size: 15px; min-height: 48px; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px 4px; border-bottom: 1px solid var(--border);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-main { flex: 1; min-width: 0; }
.checklist-done .checklist-main strong { text-decoration: line-through; color: var(--muted); }
.checklist-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.source { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 4px; }
.photo-thumb { max-width: 100%; height: auto; border-radius: 8px; margin-top: 8px; }
.add-form { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border); }
.badge-resolved, .badge-done { background: #dcfce7; color: var(--green); }
.badge-skipped { background: #f1f5f9; color: var(--muted); }
.badge-passed { background: #dcfce7; color: var(--green); }
.badge-failed { background: #fee2e2; color: var(--red); }
.badge-scheduled { background: #dbeafe; color: var(--blue); }
@media (max-width: 480px) {
  .container { padding: 16px 12px 48px; }
  .card { padding: 16px; }
  .page-head h1 { font-size: 22px; }
}

/* ============ Procurement — Excel-identical tracker ============ */

/* Sheet tabs (like Excel sheet tabs) */
.sheet-tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; border-bottom: 2px solid #cbd5e1; padding-bottom: 0; }
.sheet-tab {
  padding: 9px 18px; font-size: 14px; font-weight: 600; color: #475569; text-decoration: none;
  background: #e8edf4; border: 1px solid #cbd5e1; border-bottom: none; border-radius: 8px 8px 0 0;
}
.sheet-tab:hover { background: #dde5f0; color: #1e293b; }
.sheet-tab.active { background: #fff; color: var(--navy); border-top: 3px solid var(--gold); padding-top: 7px; }

/* Excel grid table */
.sheet-wrap { overflow-x: auto; background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; }
.tracker-wrap { max-height: 72vh; overflow: auto; }
.excel-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; min-width: 2100px; }
.excel-table th, .excel-table td { border-right: 1px solid #d9dee7; border-bottom: 1px solid #d9dee7; padding: 7px 9px; text-align: left; vertical-align: middle; background: #fff; }
.excel-table thead th {
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(#f8fafc, #eef2f7); color: #1e293b; font-weight: 700; font-size: 12px;
  text-transform: none; white-space: nowrap;
}
.excel-table thead tr.filter-row th { top: 34px; z-index: 5; background: #f1f5f9; padding: 4px 6px; }
.excel-table .filter-row input, .excel-table .filter-row select {
  width: 100%; min-width: 70px; font-size: 12px; padding: 4px 6px;
  border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; color: #1e293b;
}
.excel-table .filter-row input::placeholder { color: #94a3b8; }
/* Frozen panes: first two columns sticky */
.excel-table .sticky-col { position: sticky; z-index: 2; background: #fff; }
.excel-table .col-cat { left: 0; min-width: 170px; max-width: 170px; }
.excel-table .col-item { left: 170px; min-width: 230px; max-width: 230px; }
.excel-table thead .sticky-col { z-index: 6; background: linear-gradient(#f8fafc, #eef2f7); }
.excel-table thead tr.filter-row .sticky-col { background: #f1f5f9; }
/* Zebra striping (applied to visible rows by JS) */
.excel-table tbody tr.stripe td { background: #f8fafc; }
.excel-table tbody tr.stripe td.sticky-col { background: #f8fafc; }
/* Yellow = hand-entered cells (Excel rule), white = computed */
.excel-table td.cell-yellow { background: #fffbe8; }
.excel-table tbody tr.stripe td.cell-yellow { background: #fdf6dd; }
.excel-table td.cell-edit { cursor: pointer; }
.excel-table td.cell-edit:hover { outline: 2px solid var(--brand-blue); outline-offset: -2px; }
.excel-table td.saving { opacity: .55; }
.cell-input { width: 100%; font-size: 13px; padding: 4px 6px; border: 2px solid var(--brand-blue); border-radius: 4px; }
/* Numbers, negatives, status pills */
.excel-table td.num, .excel-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.excel-table td.neg { color: #b91c1c; font-weight: 700; }
.status-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
/* Slim action column (approval) — the one deliberate deviation from the Excel */
.excel-table .act-col { min-width: 86px; }
.approval-btn { font-size: 12px !important; padding: 4px 8px !important; white-space: nowrap; }
/* Dashboard TOTAL row */
.excel-table tr.total-row td { background: #eef2f7; border-top: 2px solid #94a3b8; font-size: 14px; }
.st-overdue { color: #b91c1c; } .st-soon { color: #b45309; } .st-track { color: #15803d; }
.st-ordered { color: #1d4ed8; } .st-received { color: #475569; }
/* Tracker title like the Excel title rows */
.tracker-head h1 { margin: 0 0 4px; font-size: 24px; }
.tracker-head p { margin: 0 0 12px; }
/* Help */
.help-list li { margin-bottom: 10px; line-height: 1.55; }
.cell-legend { display: inline-block; padding: 2px 10px; border-radius: 4px; border: 1px solid #cbd5e1; font-weight: 600; }
.legend-yellow { background: #fffbe8; } .legend-white { background: #fff; }

@media (max-width: 900px) {
  .excel-table { min-width: 1600px; font-size: 12px; }
}
.source-badge { display: inline-block; font-size: 10px; font-weight: 700; color: #1d4ed8; background: #dbeafe; border-radius: 999px; padding: 1px 7px; margin-left: 6px; vertical-align: middle; white-space: nowrap; }
