* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: #1a1a2e;
  background: #f5f7fa;
}

/* Nav */
nav {
  background: #1a1a2e;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
}
.nav-brand a { color: white; font-weight: 700; font-size: 16px; text-decoration: none; }
.nav-links a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  margin-left: 20px;
  font-size: 13px;
}
.nav-links a:hover { color: white; }

/* Nav dropdowns */
.nav-links { display: flex; align-items: stretch; align-self: stretch; }
.nav-links > a { display: flex; align-items: center; }
.nav-dropdown {
  position: relative;
  display: flex;
  align-items: center;
  margin-left: 20px;
}
.nav-dropdown-trigger {
  color: rgba(255,255,255,0.8);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.nav-dropdown:hover .nav-dropdown-trigger { color: white; }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: #1a1a2e;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 0 0 6px 6px;
  padding: 4px 0;
  min-width: 160px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.nav-dropdown:hover .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  padding: 8px 16px;
  font-size: 13px;
  margin-left: 0;
  white-space: nowrap;
}
.nav-dropdown-menu a:hover { color: white; background: rgba(255,255,255,0.08); }

/* Main */
main { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }

h1 { font-size: 24px; font-weight: 700; margin-bottom: 20px; }
h2 { font-size: 18px; font-weight: 600; margin: 24px 0 12px; }

/* Flash */
.flash {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 13px;
}
.flash-notice { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-alert  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* Page header */
.page-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.page-header h1 { margin-bottom: 0; }

/* Buttons */
.btn, input[type=submit], button[type=submit] {
  display: inline-block;
  background: #3b82f6;
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover, input[type=submit]:hover { background: #2563eb; color: white; }
/* Use double-class selectors to beat the button[type=submit] attribute specificity */
.btn.btn-secondary, a.btn-secondary { background: #6b7280; }
.btn.btn-secondary:hover, a.btn-secondary:hover { background: #4b5563; color: white; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn.btn-danger, a.btn-danger { background: #dc2626; }
.btn.btn-danger:hover, a.btn-danger:hover { background: #b91c1c; color: white; }

/* Sortable table headers */
th .sort-link {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
th .sort-link:hover { color: #374151; }
th .sort-link.sort-active { color: #1a1a2e; }

/* Action column cells */
td.col-actions { white-space: nowrap; text-align: right; }

/* Forms */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 500; margin-bottom: 4px; font-size: 13px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
}
.filter-form { background: white; padding: 20px; border-radius: 8px; border: 1px solid #e5e7eb; margin-bottom: 24px; }
.filter-fields { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.filter-fields .field { margin-bottom: 0; min-width: 180px; }
.import-form { background: white; padding: 20px; border-radius: 8px; border: 1px solid #e5e7eb; max-width: 480px; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; border: 1px solid #e5e7eb; }
th { background: #f9fafb; text-align: left; padding: 10px 14px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: #6b7280; border-bottom: 1px solid #e5e7eb; }
td { padding: 10px 14px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.row-matched { }
tr.row-unmatched { background: #fffbeb; }
.mono { font-family: monospace; font-size: 12px; }

/* Summary cards */
.vehicle-summary { margin-bottom: 24px; }
.summary-cards { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px 20px;
  min-width: 160px;
}
.card-warning { border-color: #fbbf24; background: #fffbeb; }
.card-label { font-size: 12px; color: #6b7280; font-weight: 500; margin-bottom: 4px; }
.card-value { font-size: 22px; font-weight: 700; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-blue   { background: #dbeafe; color: #1e40af; }

/* Detail list */
dl.detail-list { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin-bottom: 24px; background: white; padding: 16px 20px; border-radius: 8px; border: 1px solid #e5e7eb; }
dl.detail-list dt { font-weight: 600; font-size: 13px; color: #6b7280; }
dl.detail-list dd { font-size: 13px; }

/* Misc */
.muted { color: #9ca3af; }
.empty-state { color: #6b7280; padding: 40px 0; text-align: center; }
.error-log { background: #1a1a2e; color: #f87171; padding: 16px; border-radius: 6px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; }
.import-instructions { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 6px; padding: 14px 16px; margin-bottom: 20px; color: #1e40af; font-size: 13px; line-height: 1.6; }
.recent-imports { margin-top: 32px; }

a { color: #3b82f6; }
a:hover { color: #1d4ed8; }

/* ── Billing Report ─────────────────────────────────────────────────────── */

.report-summary {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 20px;
  margin-bottom: 20px;
  font-size: 14px;
  color: #374151;
}

.billing-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 24px;
  overflow: hidden;
  page-break-inside: avoid;
  break-inside: avoid;
}

.billing-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding: 16px 20px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.billing-customer-block { flex: 1; }
.billing-customer-name  { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.billing-customer-detail { font-size: 13px; color: #6b7280; }

.billing-rental-meta { text-align: right; font-size: 13px; line-height: 2; }
.billing-rental-meta .meta-label {
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
  margin-right: 4px;
}

.billing-table              { border: none; border-radius: 0; }
.billing-table th           { background: #f3f4f6; }
.amount-col                 { text-align: right; width: 120px; }

.billing-subtotal-row td    { background: #f9fafb; border-top: 2px solid #e5e7eb; font-size: 13px; }
.subtotal-label             { text-align: right; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; font-size: 12px; color: #374151; }
.subtotal-amount            { font-weight: 700; }

.billing-grand-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  font-size: 18px;
  font-weight: 700;
  border-top: 3px solid #1a1a2e;
  margin-top: 8px;
  page-break-inside: avoid;
  break-inside: avoid;
}

/* Login page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}
.login-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 40px 48px;
  text-align: center;
  max-width: 400px;
  width: 100%;
}
.login-brand    { font-size: 22px; font-weight: 800; color: #1a1a2e; margin-bottom: 6px; }
.login-subtitle { font-size: 14px; color: #6b7280; margin-bottom: 28px; }
button.login-google-btn, .login-google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
}
.login-google-btn:hover { background: #f9fafb; border-color: #9ca3af; }
form:has(> .login-google-btn) { width: 100%; }
.login-warning {
  font-size: 13px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 12px 14px;
  text-align: left;
  line-height: 1.5;
}
.login-warning code { background: #fef3c7; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 16px;
  color: #9ca3af;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: #e5e7eb; }
.login-dev-btn { width: 100%; }

/* Nav user menu */
.nav-user { display: flex; align-items: center; gap: 8px; }
.nav-avatar { width: 24px; height: 24px; border-radius: 50%; }
.nav-user-email {
  display: block;
  padding: 8px 16px 6px;
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  white-space: nowrap;
}
.nav-signout-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 16px;
  font-size: 13px;
  color: rgba(255,255,255,0.8);
  background: none;
  border: none;
  cursor: pointer;
}
.nav-signout-btn:hover { color: white; background: rgba(255,255,255,0.08); }

/* Dashboard overview */
.metric-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.metric-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px 18px;
  display: block;
  text-decoration: none;
  color: inherit;
}
.metric-card-link:hover { border-color: #9ca3af; }
.metric-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; margin-bottom: 6px; }
.metric-value { font-size: 26px; font-weight: 700; color: #111827; }
.metric-note  { font-size: 12px; color: #6b7280; margin-top: 4px; }
.metric-warn  { color: #92400e; font-weight: 600; }
.metric-alert { color: #991b1b; font-weight: 600; }

.dash-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.dash-panel {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px 20px;
}
.dash-panel-full { margin-bottom: 20px; }
.dash-panel-title { font-size: 14px; font-weight: 700; margin: 0 0 12px; text-transform: uppercase; letter-spacing: 0.04em; color: #374151; }

.attention-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}
.attention-row:last-child { border-bottom: none; }
.attention-text { color: #374151; }
.attention-link { color: #2563eb; text-decoration: none; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.attention-link:hover { text-decoration: underline; }

.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 150px;
  padding: 0 4px;
}
.trend-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  height: 100%;
}
.trend-amount { font-size: 11px; color: #6b7280; }
.trend-bar {
  width: 100%;
  max-width: 48px;
  background: #4f7cf7;
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}
.trend-month { font-size: 11px; color: #6b7280; }

.top-vehicle-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 0;
  font-size: 13px;
}
.top-vehicle-name { width: 320px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-vehicle-name a { color: #111827; text-decoration: none; }
.top-vehicle-name a:hover { text-decoration: underline; }
.top-vehicle-track {
  flex: 1;
  height: 14px;
  background: #f3f4f6;
  border-radius: 4px;
  overflow: hidden;
}
.top-vehicle-bar { height: 100%; background: #1d9e75; border-radius: 4px 0 0 4px; }
.top-vehicle-amount { width: 80px; text-align: right; font-weight: 600; flex-shrink: 0; }

/* Toll Billing Status */
.billing-card-billed { border-left: 4px solid #10b981; }
.billing-status-bar {
  padding: 12px 20px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.billing-status-billed {
  color: #065f46;
  font-weight: 600;
  font-size: 14px;
  background: #d1fae5;
  border: 1px solid #6ee7b7;
  border-radius: 6px;
  padding: 8px 14px;
  flex: 1;
}
.billing-notes-text { font-weight: 400; color: #374151; }
.billing-card-underbilled { border-left: 4px solid #f59e0b; }
.billing-status-underbilled {
  color: #92400e;
  font-weight: 600;
  font-size: 14px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 8px 14px;
  flex: 1;
}
.billing-clear-btn  { flex-shrink: 0; }
.billing-mark-form  { flex: 1; }
.billing-mark-fields {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.billing-mark-fields .field { margin-bottom: 0; }
.billing-mark-fields .field label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; }
.billing-mark-fields .field input { font-size: 13px; padding: 6px 10px; }
.field-amount { width: 90px; }
.field-checkbox { display: flex; align-items: center; gap: 6px; }
.field-checkbox input[type=checkbox] { width: auto; margin: 0; }
.field-checkbox label { margin: 0; font-weight: 400; }
.btn-success { background: #10b981; color: white; border: none; }
.btn.btn-success:hover { background: #059669; }
.badge-billed { background: #d1fae5; color: #065f46; }
.summary-billed { color: #065f46; font-weight: 600; }
.detail-section { margin-top: 32px; padding-top: 24px; border-top: 1px solid #e5e7eb; }

/* Pagination */
.pagination-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}
.pagination-info { font-size: 13px; color: #6b7280; }
.btn-disabled { opacity: 0.4; pointer-events: none; }

/* Customer Statement */
.statement-rental { border-top: 1px solid #e5e7eb; }
.statement-rental-header {
  padding: 12px 20px;
  background: #f9fafb;
  font-size: 13px;
  color: #374151;
}

/* Vehicle Toll Report */
.vtr-table th, .vtr-table td { font-size: 13px; }
.vtr-vehicle-header { margin-bottom: 16px; }
.vtr-vehicle-name   { font-size: 16px; font-weight: 700; }
.vtr-bill-to        { font-size: 13px; color: #374151; margin-top: 4px; }
.vtr-subtotal-row td { font-size: 12px; padding: 4px 16px; border-top: 1px solid #e5e7eb; }
.summary-unmatched  { color: #92400e; }
.print-only         { display: none; }

/* Fleet Toll Audit */
.audit-vehicle-section {
  margin-bottom: 32px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}
.audit-vehicle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: #1a1a2e;
  color: white;
}
.audit-vehicle-name  { font-size: 15px; font-weight: 700; }
.audit-vehicle-stats { display: flex; gap: 20px; font-size: 13px; color: rgba(255,255,255,0.85); align-items: center; }
.audit-uncovered-stat { color: #fbbf24; font-weight: 600; }
.audit-covered-stat   { color: #6ee7b7; }
.audit-table th, .audit-table td { font-size: 13px; }
.audit-uncovered-total {
  display: flex;
  justify-content: space-between;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  margin-top: 4px;
}

/* Print-only header and summary — invisible on screen */
.print-header  { display: none; }
.print-summary { display: none; }

/* ── @media print ───────────────────────────────────────────────────────── */
@media print {
  nav, .no-print, .flash { display: none !important; }

  .print-summary { display: block; margin-bottom: 24px; }

  .print-header {
    display: block;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #000;
  }
  .print-header-title     { font-size: 20px; font-weight: 700; }
  .print-header-meta      { font-size: 12px; color: #444; display: flex; gap: 32px; margin-top: 4px; }

  body  { background: white; font-size: 12px; color: #000; }
  main  { max-width: 100%; padding: 12px; }

  .billing-card           { border: 1px solid #bbb; border-radius: 0; margin-bottom: 14px; break-before: page; }
  .billing-card-header    { background: #efefef !important; padding: 10px 14px; }
  .billing-customer-name  { font-size: 14px; }

  table        { border: 1px solid #bbb; }
  th           { background: #e4e4e4 !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  td, th       { padding: 5px 10px; border-bottom: 1px solid #ddd; }

  .billing-subtotal-row td { background: #f0f0f0 !important; border-top: 1px solid #999; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .billing-grand-total    { border-top: 2px solid #000; font-size: 14px; }

  /* Fleet Toll Audit print styles */
  .audit-vehicle-section  { border: 1px solid #bbb; border-radius: 0; margin-bottom: 20px; break-inside: avoid; }
  .audit-vehicle-header   { background: #1a1a2e !important; color: white !important; padding: 8px 14px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .audit-vehicle-name     { font-size: 13px; }
  .audit-vehicle-stats    { font-size: 11px; gap: 14px; }
  .audit-uncovered-stat   { color: #fbbf24 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .audit-covered-stat     { color: #6ee7b7 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .audit-uncovered-total  { background: #fff8e1 !important; border: 1px solid #ddd; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* Vehicle Toll Report print styles */
  .vtr-vehicle-header   { display: block !important; margin-bottom: 16px; }
  .vtr-vehicle-name     { font-size: 15px; font-weight: 700; }
  .vtr-bill-to          { font-size: 12px; margin-top: 3px; }
  .vtr-print-vehicle    { font-size: 14px; font-weight: 600; margin-top: 4px; }
  .print-only           { display: inline !important; }
  .row-unmatched        { background: #fff8e1 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .vtr-subtotal-row td  { font-size: 11px; }

  /* Don't print link URLs after every <a> */
  a::after { content: none !important; }
}
