:root {
  --navy: #12233f;
  --navy-deep: #071b34;
  --blue: #1267d6;
  --blue-dark: #0b55b7;
  --blue-soft: #eaf2ff;
  --red: #d9232e;
  --red-dark: #b91f28;
  --red-soft: #fff0f1;
  --amber: #d97808;
  --amber-soft: #fff6e8;
  --green: #23845d;
  --green-soft: #eaf7f1;
  --text: #152037;
  --muted: #667085;
  --line: #d9dee7;
  --line-dark: #c6ccd6;
  --surface: #ffffff;
  --canvas: #f6f8fb;
  --sidebar: 224px;
  --topbar: 68px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--canvas); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.icon { width: 22px; height: 22px; flex: 0 0 auto; }

.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; display: flex; width: var(--sidebar); flex-direction: column; color: #fff; background: var(--navy-deep); }
.brand { display: flex; height: var(--topbar); align-items: center; padding: 0 24px; font-size: 26px; letter-spacing: -.8px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand strong { margin-right: 4px; font-style: italic; letter-spacing: -1.4px; }
.main-nav { padding: 12px 0; }
.nav-link { position: relative; display: flex; align-items: center; gap: 14px; min-height: 54px; padding: 0 24px; color: rgba(255,255,255,.9); font-weight: 600; text-decoration: none; }
.nav-link:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav-link.active { color: #fff; background: #0e477f; }
.nav-link.active::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: #65c4ff; }
.nav-link .icon { width: 21px; }
.sidebar-help { margin-top: auto; padding: 20px 24px; color: rgba(255,255,255,.6); font-size: 12px; }

.app-shell { min-height: 100vh; margin-left: var(--sidebar); }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; height: var(--topbar); align-items: center; justify-content: space-between; padding: 0 28px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 22px; line-height: 1; letter-spacing: -.4px; }
.mobile-title { display: none; }
.user-menu { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.user-menu form { margin-left: 10px; padding-left: 14px; border-left: 1px solid var(--line); }
.text-button { display: inline-flex; align-items: center; gap: 7px; padding: 8px; color: var(--text); border: 0; background: transparent; cursor: pointer; }
.text-button .icon { width: 18px; }
.content { width: min(100%, 1500px); margin: 0 auto; padding: 20px 26px 52px; }

.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border: 1px solid transparent; border-radius: 7px; font-size: 14px; font-weight: 700; line-height: 1.1; cursor: pointer; text-decoration: none; transition: border-color .16s, background .16s, transform .16s; }
.button:hover { text-decoration: none; transform: translateY(-1px); }
.button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid rgba(18,103,214,.24); outline-offset: 2px; }
.button-primary { color: #fff; background: var(--blue); border-color: var(--blue); }
.button-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.button-secondary { color: var(--blue); background: #fff; border-color: var(--blue); }
.button-secondary:hover { background: var(--blue-soft); }
.button-small { min-height: 34px; padding: 7px 13px; font-size: 12px; }
.button[disabled] { color: #fff; background: #98a2b3; border-color: #98a2b3; cursor: not-allowed; transform: none; }
.icon-button { display: inline-grid; width: 42px; height: 42px; place-items: center; padding: 0; border: 0; background: transparent; cursor: pointer; }
.mobile-only, .bottom-nav { display: none; }

.lookup-panel, .stats-strip, .data-section, .activity-section, .page-tools, .vehicle-identity, .defects-panel, .workflow-panel, .report-panel, .vehicle-side section, .report-summary, .simple-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.lookup-panel { padding: 17px 18px; }
.lookup-form > label { display: block; margin-bottom: 10px; font-size: 15px; font-weight: 700; }
.lookup-controls { display: grid; grid-template-columns: minmax(280px, 1fr) 200px 300px; gap: 14px; align-items: stretch; }
.input-with-icon { position: relative; display: flex; align-items: center; }
.input-with-icon .icon { position: absolute; left: 14px; width: 19px; color: var(--muted); pointer-events: none; }
.input-with-icon input { width: 100%; height: 48px; padding: 0 14px 0 44px; background: #fff; border: 1px solid var(--line-dark); border-radius: 7px; }
.registration-input input { padding-right: 52px; }
.embedded-camera { position: absolute; right: 5px; display: grid; width: 40px; height: 38px; place-items: center; padding: 0; color: var(--navy); background: #fff; border: 0; border-left: 1px solid var(--line); cursor: pointer; }
.embedded-camera .icon { position: static; width: 21px; color: inherit; }
.scan-action { display: flex; align-items: center; justify-content: center; gap: 13px; padding: 0 16px; color: var(--blue); background: #fff; border: 0; border-left: 1px solid var(--line); cursor: pointer; text-align: left; }
.scan-action .icon { width: 32px; height: 32px; }
.scan-action span { display: flex; flex-direction: column; }
.scan-action small { color: var(--muted); font-size: 12px; font-weight: 500; }

.stats-strip { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 14px; padding: 10px 0; }
.stat { display: flex; min-height: 88px; align-items: center; gap: 15px; padding: 12px 24px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat-icon { display: grid; width: 50px; height: 50px; place-items: center; border-radius: 50%; background: var(--blue-soft); color: var(--blue); }
.stat-red .stat-icon { color: var(--red); background: var(--red-soft); }
.stat-amber .stat-icon { color: var(--amber); background: var(--amber-soft); }
.stat > span:last-child { display: grid; }
.stat small { color: var(--text); font-size: 12px; font-weight: 700; }
.stat strong { color: var(--blue); font-size: 26px; line-height: 1.15; }
.stat-red strong { color: var(--red); }
.stat-amber strong { color: var(--amber); }
.stat em { color: var(--muted); font-size: 12px; font-style: normal; }

.data-section { margin-top: 14px; overflow: hidden; }
.data-section > h2, .section-heading { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: 10px; margin: 0; padding: 10px 16px; }
.data-section > h2 { color: #fff; background: var(--red); font-size: 15px; }
.data-section > h2 { justify-content: flex-start; }
.data-section > h2 .icon { width: 18px; }
.section-heading h2 { margin: 0; font-size: 15px; }
.section-heading a { font-size: 12px; font-weight: 700; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { height: 42px; padding: 8px 14px; border-top: 1px solid var(--line); text-align: left; }
th { color: #313b4f; background: #fafbfc; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
td { font-size: 13px; }
.registration { color: var(--text); font-weight: 800; }
.status, .severity { display: inline-block; padding: 3px 8px; border: 1px solid; border-radius: 4px; font-size: 11px; font-weight: 700; }
.status-ready { color: var(--green); border-color: #6cb89b; background: var(--green-soft); }
.status-attention { color: var(--red); border-color: #f08d92; background: var(--red-soft); }
.text-danger { color: var(--red); font-weight: 800; }
.text-success { color: var(--green); font-weight: 800; }

.activity-section { margin-top: 14px; overflow: hidden; }
.activity-row { display: grid; grid-template-columns: 28px 1fr auto 130px; align-items: center; gap: 10px; min-height: 46px; padding: 8px 16px; border-top: 1px solid var(--line); }
.activity-row .icon { width: 20px; color: var(--blue); }
.activity-row.priority-critical .icon { color: var(--red); }
.activity-row time, .activity-row small { color: var(--muted); font-size: 12px; }

.flash { margin-bottom: 14px; padding: 12px 15px; border: 1px solid; border-radius: 7px; font-weight: 600; }
.flash-success { color: #12613f; background: var(--green-soft); border-color: #99cfb9; }
.flash-error { color: #8c1720; background: var(--red-soft); border-color: #f0a2a7; }
.flash-warning { color: #7c4804; background: var(--amber-soft); border-color: #e9bf80; }

.page-tools { padding: 14px; }
.page-tools form { display: flex; gap: 10px; }
.page-tools .input-with-icon { flex: 1; max-width: 620px; }
.vehicle-list-section { margin-top: 14px; }

.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; font-weight: 700; }
.back-link .icon { width: 18px; }
.vehicle-identity { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; }
.vehicle-identity h2 { margin: 0; font-size: 34px; line-height: 1.1; letter-spacing: -.8px; }
.vehicle-identity p { margin: 5px 0 0; color: var(--muted); font-size: 17px; }
.vehicle-meta { display: flex; gap: 10px; }
.vehicle-meta span { padding: 6px 10px; color: var(--muted); background: #f4f6f9; border: 1px solid var(--line); border-radius: 5px; font-size: 12px; font-weight: 700; }
.defect-banner { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 13px 18px; color: #fff; background: var(--amber); border-radius: 7px; font-size: 16px; }
.defect-banner.critical { background: var(--red); }
.vehicle-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; margin-top: 16px; }
.vehicle-main { display: grid; gap: 16px; min-width: 0; }
.defects-panel, .workflow-panel { overflow: hidden; }
.defects-panel .section-heading { padding: 13px 18px; }
.defect-row { display: grid; grid-template-columns: 48px 1fr; gap: 14px; padding: 16px 18px; border-top: 1px solid var(--line); }
.defect-symbol { display: grid; width: 44px; height: 44px; place-items: center; color: var(--amber); background: var(--amber-soft); border-radius: 8px; }
.defect-critical .defect-symbol { color: var(--red); background: var(--red-soft); }
.defect-minor .defect-symbol { color: var(--blue); background: var(--blue-soft); }
.defect-copy h3 { margin: 0; font-size: 16px; }
.defect-copy p { margin: 4px 0 9px; color: var(--muted); }
.defect-copy > div { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 12px; }
.severity-critical { color: var(--red); border-color: #f08d92; background: var(--red-soft); }
.severity-important { color: var(--amber); border-color: #e8ad5d; background: var(--amber-soft); }
.severity-minor { color: var(--blue); border-color: #8eb9ef; background: var(--blue-soft); }
.drive-block { display: block; margin-top: 10px; padding: 9px 11px; color: var(--red-dark); background: var(--red-soft); border: 1px solid #f2afb3; border-radius: 6px; }
.drive-block.large { margin: 0; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 38px 20px; color: var(--muted); }
.empty-state .icon { width: 32px; height: 32px; color: var(--green); }
.empty-state strong { color: var(--text); }

.workflow-panel { padding: 18px; }
.workflow-panel h2 { margin: 0 0 5px; font-size: 19px; }
.workflow-panel > p { margin: 0 0 15px; color: var(--muted); }
.inline-warning { display: grid; gap: 4px; margin: 12px 0 16px; padding: 12px; color: #794600; background: var(--amber-soft); border: 1px solid #e6b56c; border-radius: 7px; }
.stack-form { display: grid; gap: 14px; }
.stack-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; }
.stack-form input:not([type="checkbox"]):not([type="file"]), .stack-form select, .stack-form textarea { width: 100%; min-height: 44px; padding: 10px 12px; background: #fff; border: 1px solid var(--line-dark); border-radius: 7px; }
.stack-form textarea { resize: vertical; }
.check-label { display: grid !important; grid-template-columns: 22px 1fr; align-items: start; gap: 10px !important; }
.check-label input { width: 22px; height: 22px; margin: 0; accent-color: var(--blue); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.report-panel { overflow: hidden; }
.report-panel summary { display: flex; align-items: center; gap: 8px; padding: 16px 18px; color: var(--blue); font-size: 16px; font-weight: 800; cursor: pointer; list-style: none; }
.report-panel summary::-webkit-details-marker { display: none; }
.report-panel[open] summary { border-bottom: 1px solid var(--line); }
.report-panel form { padding: 18px; }
.photo-upload { display: flex !important; align-items: center; grid-template-columns: 28px 1fr; padding: 12px; color: var(--blue); border: 1px dashed #82afe8; border-radius: 7px; cursor: pointer; }
.photo-upload span { display: grid; }
.photo-upload small { color: var(--muted); font-weight: 500; }
.photo-upload input { grid-column: 1 / -1; width: 100%; color: var(--muted); }

.vehicle-side { display: grid; align-content: start; gap: 16px; }
.vehicle-side section { padding: 16px; }
.vehicle-side h2 { margin: 0 0 12px; font-size: 16px; }
dl { margin: 0; }
dl > div { display: flex; justify-content: space-between; gap: 15px; padding: 9px 0; border-top: 1px solid var(--line); }
dl > div:first-child { border-top: 0; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 700; text-align: right; }
.history-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.history-list li { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--line); }
.history-list li:first-child { border-top: 0; }
.history-list span, .history-list small { color: var(--muted); }

.report-summary { display: flex; align-items: center; gap: 40px; padding: 18px; }
.report-summary > div { display: grid; }
.report-summary small { color: var(--muted); }
.report-summary strong { font-size: 24px; }
.report-summary .button { margin-left: auto; }
.simple-panel { max-width: 820px; padding: 24px; }
.simple-panel h2 { margin-top: 0; }

.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: var(--navy-deep); }
.auth-panel { width: min(100%, 430px); padding: 32px; background: #fff; border-radius: 12px; box-shadow: 0 24px 80px rgba(0,0,0,.24); }
.auth-brand { color: var(--navy); font-size: 30px; letter-spacing: -1px; }
.auth-brand strong { font-style: italic; }
.auth-panel h1 { margin: 26px 0 5px; font-size: 28px; }
.auth-panel > p { margin: 0 0 22px; color: var(--muted); }
.auth-panel .button { width: 100%; }
.setup-panel { width: min(100%, 760px); }
.setup-panel fieldset { display: grid; gap: 12px; margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 8px; }
.setup-panel legend { padding: 0 7px; font-size: 14px; font-weight: 800; }
.setup-success { display: grid; width: 58px; height: 58px; place-items: center; margin: 28px auto 0; color: #fff; background: var(--green); border-radius: 50%; }
.setup-success svg { width: 34px; fill: none; stroke: currentColor; stroke-width: 2; }

.scanner-dialog { width: min(92vw, 540px); padding: 0; background: #fff; border: 0; border-radius: 12px; box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.scanner-dialog::backdrop { background: rgba(3,13,28,.78); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 18px; }
.dialog-header button { width: 36px; height: 36px; padding: 0; background: transparent; border: 0; font-size: 28px; cursor: pointer; }
.scanner-dialog video { display: block; width: calc(100% - 32px); aspect-ratio: 4 / 3; margin: 16px; object-fit: cover; background: #071b34; border-radius: 8px; }
.scanner-dialog p { padding: 0 18px; color: var(--muted); }
.scanner-dialog > .button { margin: 0 18px 18px; }
.sidebar-backdrop { display: none; }

@media (max-width: 1100px) {
  .lookup-controls { grid-template-columns: minmax(280px, 1fr) 170px; }
  .scan-action { grid-column: 1 / -1; min-height: 54px; border-top: 1px solid var(--line); border-left: 0; }
  .stats-strip { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .vehicle-layout { grid-template-columns: 1fr; }
  .vehicle-side { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  :root { --topbar: 60px; }
  body { padding-bottom: 72px; background: #fff; }
  .sidebar { transform: translateX(-102%); transition: transform .2s ease; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(3,13,28,.55); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .app-shell { margin-left: 0; }
  .topbar { color: #fff; background: var(--navy); border-bottom: 0; padding: 0 14px; }
  .topbar h1 { font-size: 20px; }
  .desktop-title { display: none; }
  .mobile-title { display: inline; }
  .topbar .mobile-only { display: inline-grid; color: #fff; }
  .user-menu > span, .user-menu form { display: none; }
  .user-menu > .icon { display: block; width: 29px; height: 29px; padding: 4px; border: 2px solid #fff; border-radius: 50%; }
  .content { padding: 14px 0 26px; }
  .content > .flash { margin: 0 14px 12px; }
  .bottom-nav { position: fixed; inset: auto 0 0; z-index: 40; display: grid; grid-template-columns: repeat(4, 1fr); height: 72px; padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line); }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #6b7078; background: transparent; border: 0; font-size: 11px; font-weight: 600; text-decoration: none; }
  .bottom-nav .icon { width: 24px; height: 24px; }
  .bottom-nav .active, .bottom-nav button { color: var(--blue); }
  .lookup-panel, .stats-strip, .data-section, .activity-section, .page-tools, .vehicle-identity, .defects-panel, .workflow-panel, .report-panel, .vehicle-side section, .report-summary, .simple-panel { border-right: 0; border-left: 0; border-radius: 0; box-shadow: none; }
  .lookup-panel { padding: 14px; }
  .lookup-controls { display: grid; grid-template-columns: 1fr; }
  .lookup-controls .button { width: 100%; }
  .scan-action { grid-column: auto; min-height: 52px; border: 1px solid var(--blue); border-radius: 7px; }
  .stats-strip { grid-template-columns: 1fr 1fr; margin-top: 10px; padding: 0; }
  .stat { min-height: 82px; padding: 10px 14px; }
  .stat-icon { width: 38px; height: 38px; }
  .stat-icon .icon { width: 20px; }
  .stat strong { font-size: 22px; }
  .stat em { display: none; }
  .data-section, .activity-section { margin-top: 10px; }
  .attention-section .table-wrap, .vehicle-list-section .table-wrap { overflow: visible; }
  .attention-section table, .vehicle-list-section table { white-space: normal; }
  .attention-section thead, .vehicle-list-section thead { display: none; }
  .attention-section tbody, .vehicle-list-section tbody { display: grid; }
  .attention-section tr, .vehicle-list-section tr { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; padding: 13px 14px; border-top: 1px solid var(--line); }
  .attention-section td, .vehicle-list-section td { height: auto; padding: 0; border: 0; }
  .attention-section td:nth-child(1), .vehicle-list-section td:nth-child(1) { font-size: 16px; }
  .attention-section td:nth-child(2), .attention-section td:nth-child(3), .attention-section td:nth-child(4), .vehicle-list-section td:nth-child(2), .vehicle-list-section td:nth-child(3), .vehicle-list-section td:nth-child(4) { grid-column: 1; color: var(--muted); font-size: 12px; }
  .attention-section td:nth-child(5), .vehicle-list-section td:nth-child(5) { grid-column: 2; grid-row: 1; }
  .attention-section td:nth-child(6), .vehicle-list-section td:nth-child(6) { grid-column: 2; grid-row: 2; }
  .attention-section td:nth-child(7), .vehicle-list-section td:nth-child(7) { grid-column: 2; grid-row: 3 / span 2; align-self: end; }
  .activity-row { grid-template-columns: 24px 1fr; padding: 10px 14px; }
  .activity-row time, .activity-row small { grid-column: 2; }
  .page-tools { padding: 12px 14px; }
  .page-tools form { display: grid; }
  .vehicle-identity { display: block; padding: 23px 38px 26px; }
  .vehicle-identity h2 { font-size: 36px; }
  .vehicle-identity p { font-size: 17px; }
  .vehicle-meta { margin-top: 15px; }
  .back-link { margin: 0 28px 14px; }
  .defect-banner { margin: 0; padding: 15px 38px; border-radius: 0; font-size: 16px; }
  .vehicle-layout { gap: 12px; margin-top: 0; }
  .vehicle-main { gap: 12px; }
  .defects-panel .section-heading { padding: 16px 38px; }
  .defect-row { grid-template-columns: 48px 1fr; padding: 16px 38px; }
  .workflow-panel, .report-panel form { padding: 20px 38px; }
  .report-panel summary { padding: 16px 38px; }
  .vehicle-side { grid-template-columns: 1fr; gap: 12px; }
  .vehicle-side section { padding: 20px 38px; }
  .form-grid { grid-template-columns: 1fr; }
  .page-tools form .button { width: 100%; }
  .report-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 16px; }
  .report-summary .button { grid-column: 1 / -1; width: 100%; margin: 0; }
  .simple-panel { padding: 22px; }
}

@media (max-width: 430px) {
  .vehicle-identity { padding-right: 24px; padding-left: 24px; }
  .defect-banner, .defects-panel .section-heading, .defect-row, .workflow-panel, .report-panel form, .report-panel summary, .vehicle-side section { padding-right: 24px; padding-left: 24px; }
  .defect-row { grid-template-columns: 42px 1fr; gap: 10px; }
  .defect-symbol { width: 40px; height: 40px; }
  .stats-strip { grid-template-columns: 1fr 1fr; }
  .stat { gap: 8px; padding: 9px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
