/* Mobile-first PWA styles. Single column, large touch targets, no horizontal scroll. */
:root {
  --brand: #1a4a7a;
  --brand-dark: #143a60;
  --bg: #f3f5f8;
  --card: #ffffff;
  --line: #d7dee8;
  --text: #1c2733;
  --muted: #6b7785;
  --grey-prev: #9aa6b2;
  --red: #d32f2f;
  --green: #2a7a3b;
  --radius: 12px;
  --tap: 48px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', Roboto, system-ui, Arial, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 16px; line-height: 1.4;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; padding-top: calc(12px + env(safe-area-inset-top));
}
.topbar .title { font-size: 27px; font-weight: 600; flex: 1; min-width: 0; }
.topbar .sub { font-size: 20px; opacity: .85; }
.topbar .sub2 { font-size: 13px; opacity: .7; font-weight: 400; margin-top: 1px; }
.topbar-right { font-size: 26px; font-weight: 600; text-align: right; max-width: 52%; line-height: 1.2; }
.topbar button.back {
  background: rgba(255,255,255,.18); color: #fff; border: 0;
  width: 40px; height: 40px; border-radius: 10px; font-size: 20px;
}
.content { padding: 12px; }

/* Buttons */
button { font-family: inherit; cursor: pointer; }
.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: var(--tap); border: 0; border-radius: var(--radius);
  background: var(--brand); color: #fff; font-size: 17px; font-weight: 600;
  padding: 0 16px;
}
.btn:active { background: var(--brand-dark); }
.btn.secondary { background: #e7ecf3; color: var(--brand); }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn[disabled] { opacity: .5; }

/* Sticky bottom action */
.sticky-action {
  position: sticky; bottom: 0;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
}
.sticky-action.two-btn { display: flex; gap: 10px; }
.sticky-action.two-btn .btn { flex: 1; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.card h2 { font-size: 21px; margin: 0 0 8px; color: var(--brand); text-transform: uppercase; letter-spacing: .03em; }
.works-link { display: inline-block; color: var(--brand); font-weight: 600; text-decoration: none; padding: 8px 0; }

/* Forms */
label.field { display: block; margin-bottom: 12px; }
label.field .lbl { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; font-size: 26px; font-family: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 12px; background: #fff;
  min-height: var(--tap);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
/* Light green = unsaved change, committed on Bekreft. */
textarea.changed, select.changed, input.changed { background: #edfaf0; border-color: #9fd9ad; }
/* Invalid value (e.g. DOT out of range) */
input.invalid { border-color: var(--red); color: var(--red); background: #fdecea; }

/* Password field with show/hide eye toggle */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 52px; }
.pw-toggle { position: absolute; right: 4px; top: 0; height: 100%; width: 46px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; color: var(--muted); }
.pw-toggle:active { color: var(--brand); }

/* Brand combobox dropdown (custom — native <datalist> can render white-on-white) */
.combo-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; margin-top: 2px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; max-height: 220px; overflow-y: auto;
  box-shadow: 0 8px 20px rgba(0,0,0,.14); }
.combo-opt { padding: 9px 12px; color: var(--text); font-size: 17px; border-bottom: 1px solid var(--line); }
.combo-opt:last-child { border-bottom: 0; }
.combo-opt:active { background: #eef3f9; }
/* Compact tire-info form (Merke/Dimensjon/DOT) — not part of the enlarged måling fields */
#tireForm input { font-size: 18px; min-height: 42px; padding: 8px 10px; }
#tireForm .lbl { font-size: 12px; margin-bottom: 4px; }
#tireForm .card { padding: 10px; margin-bottom: 8px; }
/* Notat textarea back to normal size */
#comment { font-size: 17px; }

/* Tread-depth colour by value (StoreSettings thresholds): worn / warning / good — both the
   entered value and the previous (grey) value get a soft background so wear is visible at a glance. */
.axle-row input.d-red,    .axle-row .prev.d-red    { background: #f6c7cb; }
.axle-row input.d-orange, .axle-row .prev.d-orange { background: #ffe3b0; }
.axle-row input.d-green,  .axle-row .prev.d-green  { background: #c6ebcf; }
.axle-row .prev.d-red, .axle-row .prev.d-orange, .axle-row .prev.d-green { border-radius: 6px; padding: 2px 0; color: var(--text); }

/* Warning: scanned wheelset is registered out (no storage location) */
.warn-out { display: flex; gap: 10px; align-items: center; background: #fdf6e3; border: 1px solid #e8a000;
  border-left: 4px solid #e8a000; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px;
  color: #6a4b00; font-size: 16px; }
.warn-out svg { flex: 0 0 auto; }
.warn-out b { color: #6a4b00; }
/* Stronger (red) variant — e.g. the car is deleted */
.warn-out.warn-strong { border-color: var(--red); border-left-color: var(--red); background: #fdecea; color: var(--red); }
.warn-out.warn-strong b { color: var(--red); }
/* Informational note (e.g. measured recently) */
.warn-info { background: #edf3fb; border: 1px solid #1a4a7a; border-left: 4px solid #1a4a7a; border-radius: 10px;
  padding: 10px 14px; margin-bottom: 12px; color: #1a4a7a; font-size: 15px; }

/* Deleted wheelset — big red warning + Av-slett */
.deleted-banner { background: #fdecea; border: 2px solid var(--red); border-radius: 12px; padding: 14px; margin-bottom: 12px; text-align: center; }
.deleted-banner .del-title { color: var(--red); font-weight: 800; font-size: 34px; letter-spacing: .08em; }
.deleted-banner .del-sub { color: var(--red); font-size: 16px; margin: 4px 0 12px; }
.deleted-banner .btn { background: var(--red); }
.deleted-banner .btn:active { background: #a31515; }

/* "Which wheelset?" chooser + yes/no confirm overlay */
.choose-overlay { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: rgba(20,40,70,.5); padding: 22px; }
.choose-card { background: #fff; border-radius: 16px; padding: 20px; width: 100%; max-width: 360px;
  box-shadow: 0 14px 36px rgba(0,0,0,.28); }
.choose-title { font-size: 20px; font-weight: 700; color: var(--text); text-align: center; }
.choose-sub { font-size: 16px; color: var(--muted); text-align: center; margin: 4px 0 14px; }
.choose-btn { justify-content: space-between; margin-bottom: 10px; text-align: left; }
.choose-loc { font-size: 13px; font-weight: 600; opacity: .9; }

/* Save confirmation splash (after Bekreft) */
.saved-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(20,40,70,.45); padding: 24px; }
.saved-card { background: #fff; border-radius: 18px; padding: 28px 34px; text-align: center;
  box-shadow: 0 14px 36px rgba(0,0,0,.28); animation: saved-pop .18s ease-out; }
.saved-card svg { display: block; margin: 0 auto 10px; }
.saved-title { font-size: 23px; font-weight: 700; color: var(--text); }
.saved-sub { font-size: 18px; color: var(--green); font-weight: 600; margin-top: 4px; }
@keyframes saved-pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Menu hub */
.menu-grid { display: flex; flex-direction: column; gap: 14px; }
.menu-btn {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 18px; text-align: left; min-height: 84px;
}
.menu-btn .ic { font-size: 30px; width: 44px; text-align: center; }
.menu-btn .mlbl { font-size: 19px; font-weight: 600; color: var(--text); }
.menu-btn .mdesc { font-size: 13px; color: var(--muted); }
.menu-btn:active { border-color: var(--brand); }
.menu-btn[disabled] { opacity: .55; }
.menu-btn[disabled] .mlbl { color: var(--muted); }
.badge-soon { font-size: 11px; background: #e7ecf3; color: var(--muted); border-radius: 999px; padding: 3px 8px; margin-left: auto; }

/* Header (compact car info) */
.wheel-type { text-align: center; font-weight: 800; font-size: 26px; letter-spacing: .25em;
  color: var(--brand); text-transform: uppercase; margin: 2px 0 12px; }
.car-head .headline { font-size: 24px; font-weight: 700; color: var(--text); }
.car-head .reg { font-size: 44px; font-weight: 700; letter-spacing: .04em; }
.car-head .loc { font-size: 28px; color: var(--brand); font-weight: 600; }
.car-head .specs { font-size: 20px; color: var(--muted); margin-top: 6px; }
.car-head .specs b { color: var(--text); font-weight: 600; }
/* Tire info is a tappable link to its edit page. */
.tireinfo-edit { display: block; position: relative; text-decoration: none; color: inherit; margin-top: 4px; padding-right: 22px; }
.tireinfo-edit .edit-ic { position: absolute; right: 0; top: 0; color: var(--brand); font-size: 21px; }
.tireinfo-edit.add { color: var(--brand); font-weight: 600; padding-right: 0; }
.car-head .specs.unverified, .car-head .specs.unverified b { color: var(--grey-prev); font-weight: 400; }
.unverified-note { color: var(--grey-prev); font-size: 18px; font-style: italic; margin-top: 2px; }
/* Hotel category line (tappable to its edit page). */
.cat-link { display: block; margin-top: 10px; font-size: 20px; font-weight: 600; color: var(--brand); text-decoration: none; }

/* Wheel diagram */
/* Compact one-row-per-axle layout: label · prev · input | input · prev · label */
.axle-row { display: grid; grid-template-columns: 30px 56px 1fr 1fr 56px 30px; gap: 4px; align-items: center; margin-bottom: 10px; }
.axle-row .wlbl { font-size: 18px; color: var(--muted); font-weight: 600; }
.axle-row > .wlbl:first-child { text-align: right; }
.axle-row > .wlbl:last-child { text-align: left; }
.axle-row .prev { font-size: 26px; color: var(--grey-prev); text-align: center; }
.axle-row input { min-height: 58px; text-align: center; font-size: 34px; font-weight: 600; padding: 6px 4px; }
.topbar-right a, .loc-link { color: #fff; text-decoration: underline; }
.axle { display: grid; grid-template-columns: 1fr 56px 1fr; gap: 8px; align-items: center; margin-bottom: 14px; }
.car-spine { background: #e7ecf3; border-radius: 8px; align-self: stretch; min-height: 64px; }
.wheel { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wheel .wlbl { font-size: 11px; color: var(--muted); }
.wheel .prev { font-size: 12px; color: var(--grey-prev); min-height: 15px; }
.wheel input { text-align: center; font-size: 18px; font-weight: 600; }
.wheel input.rise { color: var(--red); border-color: var(--red); }
/* Red font when the entered depth is HIGHER than the previous reading (tread only wears down → likely a typo). */
.axle-row input.rise { color: var(--red); border-color: var(--red); font-weight: 700; }
.wheel.right { order: 3; }
.spine-wrap { order: 2; align-self: stretch; display: flex; align-items: center; }
.spine-wrap .label { writing-mode: vertical-rl; text-align: center; font-size: 10px; color: var(--muted); width: 100%; }

/* Works list — kept at original size on the måling page (excluded from the +50% bump). */
.works h2 { font-size: 14px; }
.works table { width: 100%; border-collapse: collapse; font-size: 13px; }
.works th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 6px; border-bottom: 1px solid var(--line); }
.works td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.works .empty { color: var(--muted); padding: 10px 0; }
.works .work-row { cursor: pointer; }
.works .work-row:active { background: #f0f4f9; }

.note { font-size: 13px; color: var(--muted); margin: 8px 0; }
.error { background: #fdecea; color: var(--red); border: 1px solid #f5c6c2; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.scan-view { position: relative; width: 100%; aspect-ratio: 3/4; background: #000; border-radius: var(--radius); overflow: hidden; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-start { position: absolute; inset: 0; margin: auto; width: 78%; height: 52px; border: 0; border-radius: 12px;
  background: rgba(255,255,255,.94); color: var(--brand); font-weight: 700; font-size: 16px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* Wheelset pictures ("Bilder") */
.btn.danger { background: var(--red); color: #fff; border: 0; }
.btn.danger:active { background: #a31515; }
.pictures .pic-add { margin-top: 12px; }
.pic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.pic-tile { position: relative; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: #f1f4f8; aspect-ratio: 1/1; }
.pic-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pic-tile.uploading { opacity: .7; }
.pic-tile.failed { border-color: var(--red); }
.pic-status { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px; font-size: 12px; font-weight: 700;
  text-align: center; background: rgba(20,40,70,.62); color: #fff; }
.pic-overlay { position: fixed; inset: 0; z-index: 70; background: rgba(8,16,28,.94);
  display: flex; flex-direction: column; }
.pic-overlay-bar { display: flex; gap: 10px; padding: 14px; }
.pic-overlay-bar .btn { flex: 1; }
.pic-overlay-bar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.5); }
.pic-full { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
