*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0d1117; --surface: #161b22; --surface2: #21262d; --border: #30363d;
  --text: #f0f6fc; --muted: #8b949e; --pass: #58a6ff; --fail: #ff7b72;
  --warn: #f59e0b; --info: #79c0ff; --accent: #a371f7; --radius: 10px;
}
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; padding: 24px 16px; overflow-x: hidden; }
.container { max-width: 1100px; margin: 0 auto; width: 100%; }
header { text-align: center; margin-bottom: 16px; }
header h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.5px; }
header p { color: var(--muted); margin-top: 4px; font-size: 0.9rem; }
.input-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 24px; }
.input-card label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
textarea { width: 100%; height: 160px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-family: monospace; font-size: 0.8rem; padding: 10px; resize: vertical; outline: none; transition: border-color 0.2s; }
textarea:focus { border-color: var(--accent); }
.btn-row { display: flex; gap: 10px; margin-top: 12px; }
button { padding: 9px 22px; border-radius: 6px; font-size: 0.9rem; font-weight: 600; cursor: pointer; border: none; transition: opacity 0.15s; }
button:hover { opacity: 0.85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; contain: layout style; }
@media (max-width: 700px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-card .val { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-card .lbl { font-size: 0.75rem; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-pass { color: var(--pass); } .stat-fail { color: var(--fail); } .stat-info { color: var(--info); } .stat-warn { color: var(--warn); } .stat-accent { color: var(--accent); }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-card h2 { font-size: 0.9rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 16px; }
.chart-wrap { position: relative; height: 240px; width: 100%; contain: layout size style; }
.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 12px; }
.section h2 { font-size: 0.9rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th { text-align: left; padding: 8px 12px; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); }
td { padding: 9px 12px; border-bottom: 1px solid rgba(51,65,85,0.5); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.73rem; font-weight: 700; letter-spacing: 0.04em; }
.badge-pass { background: rgba(88,166,255,0.25); color: #58a6ff; }
.badge-fail { background: rgba(255,123,114,0.25); color: #ff7b72; }
.badge-dangerous { background: rgba(255,123,114,0.35); color: #ffa198; border: 1px solid #ff7b72; }
.badge-major { background: rgba(255,123,114,0.25); color: #ff7b72; }
.badge-minor { background: rgba(245,158,11,0.25); color: #f59e0b; }
.badge-advisory { background: rgba(56,189,248,0.25); color: var(--info); }
.defect-list { list-style: none; }
.defect-list li { padding: 4px 0; border-bottom: 1px solid rgba(51,65,85,0.3); font-size: 0.83rem; color: var(--text); }
.defect-list li:last-child { border-bottom: none; }
.recurring-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; contain: layout style; }
.recurring-item { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; display: flex; align-items: flex-start; gap: 12px; }
.recurring-count { background: rgba(245,158,11,0.25); color: #f59e0b; font-size: 1.1rem; font-weight: 700; min-width: 36px; height: 36px; border-radius: 6px; display: flex; align-items: center; justify-content: center; }
.recurring-text { font-size: 0.83rem; color: var(--text); line-height: 1.4; }
.recurring-years { font-size: 0.75rem; color: var(--muted); margin-top: 3px; }
.timeline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tl-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tl-dot { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; font-size: 0.65rem; font-weight: 700; position: relative; }
.tl-dot.pass { background: rgba(88,166,255,0.25); border: 2px solid #58a6ff; color: #58a6ff; border-radius: 50%; }
.tl-dot.retest { width: 32px; height: 32px; background: rgba(245,158,11,0.25); border: 2px solid #f59e0b; color: #f59e0b; position: relative; display: flex; align-items: center; justify-content: center; transform: rotate(45deg); }
.tl-dot.retest::before { content: '✓'; position: absolute; transform: rotate(-45deg); }
.tl-dot.fail { background: rgba(255,123,114,0.25); border: 2px solid #ff7b72; color: #ff7b72; border-radius: 4px; }
.tl-year { font-size: 0.68rem; color: var(--muted); }
.tl-count { font-size: 0.62rem; color: #f59e0b; font-weight: 700; height: 12px; margin-top: 6px; }
.tl-sep { width: 20px; height: 2px; background: var(--border); margin-bottom: 16px; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 0.9rem; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; contain: layout style; }
.how-to { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.how-to-step { display: flex; align-items: flex-start; gap: 8px; font-size: 0.8rem; color: var(--muted); text-align: left; line-height: 1.4; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; overflow-wrap: break-word; word-break: break-word; min-width: 0; }
.how-to-step .step-num { min-width: 20px; height: 20px; border-radius: 50%; background: rgba(99,102,241,0.18); color: var(--accent); font-size: 0.68rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.how-to-step a { color: var(--info); text-decoration: underline; }
kbd { background: var(--surface2); border: 1px solid var(--border); border-radius: 3px; padding: 1px 4px; font-size: 0.7rem; font-family: monospace; color: var(--text); }
/* Chart legend */
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); margin-top: 8px; padding: 0 4px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; margin-right: 4px; }
.legend-dot-pass { border-radius: 50%; background: #58a6ff; }
.legend-dot-retest { background: #f59e0b; transform: rotate(45deg); }
.legend-dot-fail { background: #ff7b72; }
/* Hero stat card */
.stat-hero { grid-column: span 2; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 20px; text-align: left; }
.stat-hero-expired { border-color: var(--fail); background: rgba(255,123,114,0.07); }
.stat-hero-pass { border-color: var(--pass); background: rgba(88,166,255,0.05); }
.stat-hero-fail { border-color: var(--fail); background: rgba(255,123,114,0.05); }
.stat-hero .val { font-size: 2rem; letter-spacing: -1px; line-height: 1; }
.stat-hero-title { font-size: 0.95rem; font-weight: 600; color: var(--text); line-height: 1.2; }
.stat-hero-subtitle { margin-top: 3px; }
.stat-sub { font-size: 0.76rem; color: var(--muted); margin-top: 5px; }
/* Defect summary card */
.stat-defects { grid-column: span 2; text-align: left; padding: 14px 18px; }
.stat-defects-header { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.stat-defects-total { font-size: 0.82rem; color: var(--muted); }
.danger-alert { background: rgba(255,123,114,0.12); border: 1px solid rgba(255,123,114,0.35); border-radius: 6px; padding: 7px 12px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.danger-alert-icon { font-size: 0.95rem; color: #ffa198; }
.danger-alert-text { color: #ffa198; font-weight: 700; font-size: 0.87rem; }
.defect-counts { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.88rem; font-weight: 600; }
.defect-counts-sep { color: var(--border); }
.no-defects-msg { font-size: 0.88rem; color: var(--pass); font-weight: 600; }
.no-defects-cell { color: var(--muted); font-style: italic; font-size: 0.82rem; }
.missing-mileage-warning { display: none; }
.how-to-step strong { color: var(--text); }
/* Vehicle info bar */
.vehicle-info { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.reg-plate { display: inline-block; background: #FFD307; color: #000; font-family: 'UK Number Plate', 'Charles Wright', monospace; font-size: 1.15rem; font-weight: 700; letter-spacing: 1.5px; padding: 5px 14px; border-radius: 4px; border: 2px solid #000; line-height: 1.2; white-space: nowrap; }
.vi-details { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); flex: 1; justify-content: space-evenly; }
.vi-detail { white-space: nowrap; }
.vi-label { text-transform: uppercase; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.04em; color: var(--muted); margin-right: 4px; opacity: 0.7; }
.vi-sep { color: var(--border); margin: 0 2px; }
#results { display: none; }
.vehicle-tabs { display: none; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.vehicle-tabs.visible { display: flex; }
.hidden { display: none; }
.vtab { padding: 8px 18px; border-radius: 6px; font-size: 0.85rem; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--muted); transition: all 0.15s; }
.vtab:hover { border-color: var(--accent); color: var(--text); }
.vtab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (max-width: 600px) {
  body { padding: 14px 10px; }
  header h1 { font-size: 1.35rem; }
  header p { font-size: 0.82rem; }
  .input-card { padding: 14px; }
  .section { padding: 14px; }
  .chart-card { padding: 14px; }
  .chart-wrap { height: 200px; }
  th { padding: 6px 8px; font-size: 0.68rem; }
  td { padding: 6px 8px; font-size: 0.78rem; }
  .badge { font-size: 0.68rem; padding: 2px 6px; }
  .stat-card .val { font-size: 1.3rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .recurring-grid { grid-template-columns: 1fr; }
  .how-to { grid-template-columns: 1fr; }
  .how-to-step { font-size: 0.75rem; }
  .vtab { padding: 7px 12px; font-size: 0.8rem; }
  .stat-hero, .stat-defects { grid-column: span 1; }
  .vehicle-info { flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 14px; }
  .vi-details { justify-content: center; gap: 4px 12px; }
  .vi-sep { display: none; }
  .vi-detail { display: flex; flex-direction: column; align-items: center; gap: 1px; }
}
.about-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-top: 24px; }
.about-box h2 { font-size: 0.9rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.about-box p { font-size: 0.9rem; color: var(--muted); line-height: 1.5; }
.about-box ul { margin-top: 10px; padding-left: 18px; font-size: 0.9rem; color: var(--muted); line-height: 1.5; }
.about-box li { margin-bottom: 6px; }
@media print {
  .how-to, .input-card, .about-box { display: none !important; }
}
