:root {
  --blue: #075eae;
  --blue-dark: #0a315d;
  --ink: #132238;
  --text: #2c4059;
  --muted: #65758a;
  --line: #ccdaea;
  --soft-line: #e4ebf3;
  --bg: #f3f7fb;
  --green: #16784a;
  --amber: #a65b00;
  --red: #b42318;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; color: var(--text); background: var(--bg); font-family: "Segoe UI", Arial, sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(410px, 100%); padding: 36px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 22px 60px rgba(22, 43, 70, .1); }
.login-card img { display: block; height: 64px; margin: 0 auto 22px; }
.login-card h1, .login-card p { text-align: center; }
.login-card p { color: var(--muted); }
.login-card form { display: grid; gap: 14px; margin-top: 22px; }
.login-card label, .form-grid label { display: grid; gap: 6px; color: #40536b; font-size: 12px; font-weight: 750; }

.topbar { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 24px; border-bottom: 1px solid var(--line); background: #fff; }
.topbar-brand, .topbar-actions { display: flex; align-items: center; gap: 13px; }
.topbar-brand img { height: 48px; }
.topbar-brand > span { width: 1px; height: 32px; background: var(--line); }
.session-pill { padding: 7px 11px; border-radius: 999px; color: var(--blue); background: #eaf4ff; font-size: 12px; font-weight: 750; }

.vehicles-shell { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 190px minmax(0, 1fr); }
.side-nav { display: flex; flex-direction: column; justify-content: space-between; gap: 24px; padding: 22px 15px; border-right: 1px solid var(--line); background: #fff; }
.side-nav nav { display: grid; gap: 6px; }
.side-nav a { min-height: 42px; display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 9px; padding: 8px 9px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 13px; font-weight: 700; }
.side-nav a > span { width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 6px; font-size: 9px; }
.side-nav a:hover, .side-nav a.active { color: var(--blue); background: #edf5fd; }
.side-status { padding: 12px; border: 1px solid var(--soft-line); border-radius: 6px; }
.side-status small, .side-status strong { display: block; }
.side-status small { color: var(--muted); font-size: 10px; }
.side-status strong { margin-top: 4px; color: var(--green); font-size: 12px; }

.content-area { min-width: 0; padding: 24px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.page-heading h1 { margin: 0; color: var(--ink); font-size: 28px; }
.page-heading p:not(.eyebrow) { margin: 6px 0 0; color: var(--muted); }
.eyebrow { margin: 0 0 5px; color: var(--blue); font-size: 11px; font-weight: 850; letter-spacing: .1em; }

.primary-button, .secondary-button, .danger-button { min-height: 38px; padding: 8px 13px; border-radius: 6px; font-weight: 750; }
.primary-button { border: 1px solid var(--blue); color: #fff; background: var(--blue); }
.secondary-button { border: 1px solid var(--line); color: var(--blue-dark); background: #fff; }
.danger-button { border: 1px solid #efb5af; color: var(--red); background: #fff7f6; }
.primary-button:disabled, .secondary-button:disabled, .danger-button:disabled { cursor: not-allowed; opacity: .5; }

.critical-banner { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 15px; padding: 15px 17px; border: 1px solid #efb5af; border-left: 5px solid var(--red); border-radius: 7px; background: #fff8f7; }
.critical-banner strong { color: var(--red); }
.critical-banner p { margin: 4px 0 0; color: #7c3530; font-size: 12px; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 11px; margin-bottom: 15px; }
.metric-card { min-width: 0; padding: 14px; border: 1px solid var(--line); border-top: 3px solid var(--blue); border-radius: 7px; background: #fff; }
.metric-card.good { border-top-color: var(--green); }
.metric-card.warning { border-top-color: var(--amber); }
.metric-card.danger { border-top-color: var(--red); }
.metric-card small, .metric-card strong, .metric-card span { display: block; }
.metric-card small { color: var(--muted); font-size: 11px; font-weight: 700; }
.metric-card strong { margin-top: 7px; color: var(--ink); font-size: 22px; }
.metric-card span { margin-top: 3px; color: var(--muted); font-size: 10px; }

.filter-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 15px; padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.filter-bar label { min-width: 175px; display: grid; flex: 1 1 200px; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 750; }
input, select, textarea { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid #bdcde0; border-radius: 5px; color: var(--text); background: #fff; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b7d9f7; border-color: var(--blue); }

.vehicle-workspace { min-width: 0; display: grid; grid-template-columns: minmax(290px, .75fr) minmax(0, 1.75fr); gap: 14px; }
.panel { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.panel-heading { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.panel-heading h2 { margin: 0; color: var(--ink); font-size: 17px; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.fleet-panel { align-self: start; }
.vehicle-list { display: grid; gap: 8px; max-height: calc(100vh - 360px); overflow-y: auto; padding-right: 3px; }
.vehicle-card { width: 100%; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 4px 9px; padding: 12px; border: 1px solid var(--soft-line); border-radius: 6px; color: var(--text); background: #fff; text-align: left; }
.vehicle-card:hover, .vehicle-card.selected { border-color: #78addc; background: #f1f8ff; }
.vehicle-card .state-dot { grid-row: span 2; width: 9px; height: 9px; margin-top: 4px; border-radius: 50%; background: var(--green); }
.vehicle-card.warning .state-dot { background: var(--amber); }
.vehicle-card.danger .state-dot, .vehicle-card.inactive .state-dot { background: var(--red); }
.vehicle-card strong { color: var(--ink); font-size: 14px; }
.vehicle-card small { color: var(--muted); font-size: 10px; }
.vehicle-card .status-chip { grid-row: span 2; padding: 4px 7px; border-radius: 999px; color: var(--green); background: #e5f5ec; font-size: 9px; font-weight: 800; }
.vehicle-card.warning .status-chip { color: #825000; background: #fff2d7; }
.vehicle-card.danger .status-chip, .vehicle-card.inactive .status-chip { color: var(--red); background: #fde8e6; }

.empty-state { min-height: 160px; display: grid; place-items: center; padding: 24px; color: var(--muted); text-align: center; }
.vehicle-detail-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--soft-line); }
.vehicle-detail-heading h2 { margin: 3px 0; color: var(--ink); font-size: 23px; }
.vehicle-detail-heading p, .vehicle-detail-heading small { margin: 0; color: var(--muted); }
.vehicle-detail-heading small { color: var(--blue); font-size: 10px; font-weight: 850; }
.action-bar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }

.document-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.document-card { padding: 12px; border: 1px solid var(--soft-line); border-left: 4px solid var(--green); border-radius: 6px; background: #fbfdff; }
.document-card.warning { border-left-color: var(--amber); background: #fffdf8; }
.document-card.danger { border-left-color: var(--red); background: #fff9f8; }
.document-card header { display: flex; justify-content: space-between; gap: 10px; }
.document-card h3 { margin: 0; color: var(--ink); font-size: 13px; }
.document-card strong { color: var(--green); font-size: 10px; }
.document-card.warning strong { color: var(--amber); }
.document-card.danger strong { color: var(--red); }
.document-card p { margin: 7px 0 0; color: var(--muted); font-size: 10px; }

.detail-tabs { display: flex; gap: 3px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.detail-tabs button { flex: 0 0 auto; padding: 9px 11px; border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: transparent; font-size: 11px; font-weight: 750; }
.detail-tabs button.active { border-bottom-color: var(--blue); color: var(--blue); }
.detail-content { min-width: 0; padding-top: 14px; }
.fuel-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.fuel-summary > div { min-width: 0; padding: 11px; border: 1px solid var(--soft-line); border-radius: 6px; background: #f8fbfe; }
.fuel-summary small, .fuel-summary strong { display: block; }
.fuel-summary small { color: var(--muted); font-size: 10px; }
.fuel-summary strong { margin-top: 5px; overflow-wrap: anywhere; color: var(--ink); font-size: 13px; }
.project-cost-list { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.project-cost-list article { padding: 7px 9px; border-left: 3px solid var(--blue); border-radius: 4px; background: #eef6fd; }
.project-cost-list strong, .project-cost-list span { display: block; }
.project-cost-list strong { color: var(--ink); font-size: 11px; }
.project-cost-list span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.data-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.data-grid > div { min-width: 0; padding: 11px; border: 1px solid var(--soft-line); border-radius: 5px; }
.data-grid small, .data-grid strong { display: block; }
.data-grid small { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.data-grid strong { margin-top: 4px; overflow-wrap: anywhere; color: var(--ink); font-size: 12px; }
.table-scroll { width: 100%; overflow-x: auto; }
.data-table { width: 100%; min-width: 690px; border-collapse: collapse; font-size: 11px; }
.data-table th { padding: 8px; border-bottom: 2px solid var(--line); color: var(--muted); text-align: left; white-space: nowrap; }
.data-table td { padding: 9px 8px; border-bottom: 1px solid var(--soft-line); vertical-align: top; }
.data-table a { color: var(--blue); font-weight: 750; }
.status-label { display: inline-flex; padding: 3px 6px; border-radius: 999px; color: var(--green); background: #e5f5ec; font-size: 9px; font-weight: 800; }
.status-label.warning { color: var(--amber); background: #fff2d7; }
.status-label.danger { color: var(--red); background: #fde8e6; }

.form-dialog { width: min(760px, calc(100vw - 30px)); max-height: calc(100vh - 30px); padding: 0; overflow: hidden; border: 0; border-radius: 9px; box-shadow: 0 22px 80px rgba(12, 31, 55, .28); }
.form-dialog::backdrop { background: rgba(10, 25, 45, .48); }
.compact-dialog { width: min(590px, calc(100vw - 30px)); }
.form-dialog form { max-height: calc(100vh - 30px); display: flex; flex-direction: column; }
.form-dialog header, .form-dialog footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; }
.form-dialog header { border-bottom: 1px solid var(--line); }
.form-dialog footer { justify-content: flex-end; border-top: 1px solid var(--line); }
.form-dialog header small { color: var(--blue); font-size: 9px; font-weight: 850; }
.form-dialog header h2 { margin: 3px 0 0; color: var(--ink); font-size: 19px; }
.dialog-close { width: 34px; height: 34px; border: 0; border-radius: 50%; color: var(--muted); background: #edf2f7; font-size: 22px; }
.form-grid { min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; overflow-y: auto; padding: 18px; }
.form-grid .wide { grid-column: 1 / -1; }
.check-field { display: flex !important; grid-template-columns: auto 1fr !important; align-items: center; align-self: end; min-height: 38px; }
.check-field input { width: auto; min-height: auto; }
.form-message { display: block; min-height: 18px; padding: 0 18px 8px; color: var(--red); font-size: 11px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 100; max-width: min(430px, calc(100vw - 40px)); padding: 12px 15px; border-radius: 6px; color: #fff; background: var(--ink); box-shadow: 0 15px 40px rgba(0, 0, 0, .2); }
.toast.error { background: var(--red); }

@media (max-width: 1280px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .vehicle-workspace { grid-template-columns: minmax(260px, .65fr) minmax(0, 1.35fr); }
  .vehicle-detail-heading { flex-direction: column; }
  .action-bar { justify-content: flex-start; }
}

@media (max-width: 980px) {
  .vehicles-shell { display: block; }
  .side-nav { padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-nav nav { display: flex; overflow-x: auto; }
  .side-nav a { flex: 0 0 auto; }
  .side-status { display: none; }
  .vehicle-workspace { grid-template-columns: 1fr; }
  .vehicle-list { max-height: 360px; }
}

@media (max-width: 680px) {
  .topbar { flex-wrap: wrap; padding: 9px 12px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .session-pill { display: none; }
  .content-area { padding: 14px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading h1 { font-size: 23px; }
  .critical-banner { align-items: stretch; flex-direction: column; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar label { flex-basis: 100%; }
  .document-cards, .data-grid, .fuel-summary { grid-template-columns: 1fr; }
  .action-bar button { flex: 1 1 45%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
}

@media (max-width: 430px) {
  .metric-grid { grid-template-columns: 1fr; }
  .panel { padding: 12px; }
  .action-bar button { flex-basis: 100%; }
}
