:root {
  color-scheme: light;
  --ink: #142b2b;
  --muted: #647777;
  --paper: #f5f7f4;
  --card: #fff;
  --green: #2c765f;
  --green-dark: #1d5b49;
  --mint: #e4f2eb;
  --line: #e1e9e4;
  --orange: #e58b50;
  font-family: "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.shell { max-width: 960px; min-height: 100vh; margin: auto; padding: 0 28px 48px; }
.topbar { height: 82px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; font: 800 20px Manrope, sans-serif; letter-spacing: -.8px; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 11px; background: var(--green); color: white; font: 800 19px Manrope, sans-serif; }
.brand-dot { color: var(--orange); }
.icon-button { border: 0; background: transparent; color: var(--ink); font-size: 24px; width: 42px; height: 42px; border-radius: 50%; }
.icon-button:hover { background: var(--mint); }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: "Segoe UI", Arial, sans-serif; letter-spacing: -.7px; }
h1 { margin-bottom: 12px; font-size: clamp(29px, 5vw, 42px); line-height: 1.15; }
h2 { margin-bottom: 0; font-size: 20px; }
h3 { font-size: 16px; }
.eyebrow { margin-bottom: 8px; color: var(--green); font-size: 10px; font-weight: 700; letter-spacing: 1.5px; }
.muted { color: var(--muted); line-height: 1.55; }
.auth-view { display: grid; grid-template-columns: 1.1fr .9fr; gap: 42px; align-items: center; max-width: 830px; margin: 68px auto 28px; }
.auth-intro h1 { font-size: clamp(34px, 5vw, 50px); }
.auth-intro h1 span { color: var(--green); }
.auth-intro > p:last-child { max-width: 380px; color: var(--muted); line-height: 1.65; }
.panel, .active-trip, .start-trip, .content-panel, .trip-card, .vehicle-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
.panel { padding: 26px; box-shadow: 0 16px 50px #193b2e0a; }
.form-stack { display: flex; flex-direction: column; gap: 15px; }
.form-stack h2 { margin: 0; }
label { display: flex; flex-direction: column; gap: 7px; color: #35504b; font-size: 13px; font-weight: 600; }
input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #d6e0da; border-radius: 10px; background: #fff; color: var(--ink); outline: none; }
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px #2c765f20; }
input:disabled { background: #f1f4f1; }
.button { min-height: 44px; padding: 11px 16px; border: 1px solid transparent; border-radius: 10px; font-weight: 700; transition: background .15s, transform .15s; }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button-primary { background: var(--green); color: white; }
.button-primary:hover:not(:disabled) { background: var(--green-dark); }
.button-dark { background: var(--ink); color: #fff; }
.button-outline { border-color: #b7ccc0; background: white; color: var(--green-dark); }
.button-outline:hover { background: var(--mint); }
.button-quiet { background: #f1f4f1; color: #455e57; }
.button-wide { width: 100%; }
.form-foot { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--green); font-weight: 700; }
.privacy-note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.auth-view > .privacy-note { grid-column: 1 / -1; max-width: 590px; margin: -20px auto 0; text-align: center; }
.welcome-row { display: flex; align-items: center; justify-content: space-between; padding: 38px 0 24px; }
.welcome-row h1 { margin: 0; font-size: 30px; }
.welcome-row h1 span { color: var(--green); }
.welcome-row .button span { margin-right: 7px; font-size: 18px; }
.active-trip, .start-trip { margin-bottom: 22px; padding: 22px; }
.active-trip { border-color: #b7d7c6; background: linear-gradient(135deg, #f8fffb, #eff9f3); }
.active-heading { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--green-dark); font-size: 10px; font-weight: 800; letter-spacing: 1.2px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #35a06d; box-shadow: 0 0 0 4px #35a06d20; }
.active-time { margin-left: auto; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.active-trip h2 { margin-bottom: 4px; }
.active-trip > p { margin-bottom: 12px; font-size: 13px; }
.tracking-note { padding: 10px 12px; border-radius: 9px; background: #e7f2eb; color: #3c6252; font-size: 12px !important; }
.map { height: 260px; margin: 14px 0; border-radius: 12px; overflow: hidden; background: #e9f0e9; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-title h2 { font-size: 19px; }
.start-trip .section-title { margin-bottom: 4px; }
.consent-row { display: grid; grid-template-columns: 20px 1fr; align-items: start; gap: 10px; margin: 16px 0; color: #526a62; font-size: 12px; font-weight: 400; line-height: 1.5; }
.consent-row input { width: 18px; min-height: 18px; margin: 1px 0 0; accent-color: var(--green); }
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); }
.tab { position: relative; padding: 12px 1px; border: 0; background: transparent; color: #778681; font-weight: 600; }
.tab.active { color: var(--green-dark); }
.tab.active::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--green); content: ""; }
.content-panel { margin-top: 20px; padding: 22px; }
.count-pill { display: grid; min-width: 30px; height: 28px; place-items: center; padding: 0 8px; border-radius: 20px; background: var(--mint); color: var(--green-dark); font-size: 12px; font-weight: 700; }
.card-list { display: grid; gap: 10px; }
.trip-card, .vehicle-card { padding: 16px; }
.trip-card { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: start; }
.trip-main { min-width: 0; }
.trip-top, .vehicle-top { display: flex; align-items: center; gap: 9px; }
.vehicle-icon { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border-radius: 12px; background: var(--mint); color: var(--green); font-size: 18px; }
.trip-card h3, .vehicle-card h3 { margin: 0 0 3px; }
.trip-meta, .trip-address, .vehicle-meta { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.trip-date { margin-top: 10px; }
.trip-address { margin-top: 10px; }
.trip-badge { display: inline-block; margin-top: 9px; padding: 4px 8px; border-radius: 20px; background: #e8f4ec; color: #347352; font-size: 10px; font-weight: 700; }
.trip-badge.open { background: #fff3e6; color: #9c6030; }
.trip-map { height: 190px; grid-column: 1 / -1; border-radius: 10px; }
.trip-actions, .vehicle-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.small-button { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--green-dark); font-size: 12px; font-weight: 700; }
.small-button:hover { background: var(--mint); }
.vehicle-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; }
.vehicle-meta { margin-left: 47px; }
.vehicle-actions { justify-content: flex-end; }
.empty-state { padding: 38px 16px; text-align: center; }
.empty-state h3 { margin: 12px 0 6px; }
.empty-state p { max-width: 320px; margin: 0 auto 16px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.empty-icon { display: grid; width: 48px; height: 48px; margin: auto; place-items: center; border-radius: 16px; background: var(--mint); color: var(--green); font-size: 26px; }
.dialog { width: min(460px, calc(100% - 28px)); max-height: min(90vh, 760px); padding: 24px; border: 1px solid var(--line); border-radius: 18px; color: var(--ink); box-shadow: 0 20px 70px #102a2a30; }
.dialog::backdrop { background: #102a2a80; backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-heading h2 { margin: 0; }
.dialog-heading .icon-button { margin: -10px -8px 0 0; font-size: 28px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.qr-dialog { text-align: center; }
.qr-dialog .dialog-heading { text-align: left; }
.qr-image { display: block; width: min(260px, 80%); aspect-ratio: 1; margin: 14px auto; }
.scanner-region { display: grid; min-height: 190px; margin: 14px 0; place-items: center; overflow: hidden; border-radius: 12px; background: #f0f5f1; text-align: center; }
.scanner-region p { max-width: 260px; margin: 14px; font-size: 13px; }
#scanner-video { width: 100%; max-height: 300px; object-fit: cover; }
#manual-scan-form { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.toast { position: fixed; z-index: 1000; right: 20px; bottom: 20px; max-width: min(380px, calc(100vw - 40px)); padding: 13px 16px; border-radius: 11px; background: var(--ink); color: white; box-shadow: 0 10px 30px #102a2a30; font-size: 13px; opacity: 0; pointer-events: none; transform: translateY(10px); transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.footer { padding: 30px 0 10px; color: #87958f; font-size: 11px; text-align: center; }

@media (max-width: 680px) {
  .shell { padding: 0 17px 32px; }
  .topbar { height: 68px; }
  .auth-view { grid-template-columns: 1fr; gap: 20px; margin: 36px auto 20px; }
  .auth-intro h1 { font-size: 38px; }
  .auth-intro > p:last-child { margin-bottom: 0; }
  .panel { padding: 20px; }
  .auth-view > .privacy-note { margin: 0; }
  .welcome-row { padding: 28px 0 18px; }
  .welcome-row h1 { font-size: 25px; }
  .welcome-row .button { padding: 10px 12px; }
  .active-trip, .start-trip, .content-panel { padding: 17px; }
  .vehicle-card { grid-template-columns: 1fr; }
  .vehicle-actions { margin-left: 47px; justify-content: flex-start; }
  .trip-card { grid-template-columns: 1fr; }
  .trip-actions { grid-row: 2; }
  .field-row { grid-template-columns: 1fr 1fr; gap: 9px; }
}

@media print {
  body * { visibility: hidden; }
  #qr-dialog, #qr-dialog * { visibility: visible; }
  #qr-dialog { position: absolute; inset: 0; width: 100%; border: 0; box-shadow: none; }
  #qr-dialog .icon-button, #print-qr, #qr-dialog .muted { display: none; }
}
