/* Ricemobile: quick to use at the pump. Asphalt bar, signal red for action, big tap targets. */

:root {
  --paper: #f3f3f0;
  --surface: #ffffff;
  --ink: #16181d;
  --asphalt: #16181d;
  --stone: #5f636b;
  --line: #d6d7d3;
  --red: #d7263d;
  --red-soft: #fbe3e6;
  --danger: #b3261e;
  --focus: #2b6cb0;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r-sm: 8px;
  --r-md: 12px;
  --top: calc(54px + env(safe-area-inset-top));
  --tabs: calc(62px + env(safe-area-inset-bottom));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1114;
    --surface: #1a1d22;
    --ink: #e8e9ec;
    --stone: #9a9ea6;
    --line: #2c3037;
    --red-soft: #3a1a1f;
    --danger: #ff8a80;
    --focus: #8ab4f8;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 17px/1.5 var(--body);
  padding-top: var(--top); padding-bottom: calc(var(--tabs) + 24px); min-height: 100dvh;
}
a { color: var(--red); text-underline-offset: 2px; }
h1, h2 { font-weight: 800; line-height: 1.15; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 .6em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--stone); }
.hint { display: block; color: var(--stone); font-size: .88rem; font-weight: 400; margin-top: .3rem; }
.center { text-align: center; }
.loading { color: var(--stone); text-align: center; padding: 32px 0; }

/* ---- top bar and tabs ---- */
.top {
  position: fixed; inset: 0 0 auto; z-index: 1000;
  height: var(--top); padding: env(safe-area-inset-top) 8px 0;
  display: flex; align-items: center; gap: 4px;
  background: var(--asphalt); color: #f3f3f0;
  border-bottom: 3px solid var(--red);
}
.title { flex: 1; font-weight: 800; font-size: 1.2rem; padding-left: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: none; border: 0; color: inherit; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; }

.tabs {
  position: fixed; inset: auto 0 0; z-index: 1000;
  height: var(--tabs); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--stone); font-size: .82rem; font-weight: 600; }
.tabs svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 1.8; fill: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.tabs svg path:not([fill]) { fill: none; }
.tabs a.on { color: var(--ink); }
.tabs a.on svg { color: var(--red); }

main { max-width: 640px; margin: 0 auto; padding: 16px; }

/* ---- buttons and forms ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 8px 16px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font: 700 1rem var(--body); text-decoration: none; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn.ghost { background: none; border-color: transparent; color: var(--stone); }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: .92rem; }
.btn.big { min-height: 54px; font-size: 1.1rem; width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .5; cursor: default; }

input, textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; min-height: 48px;
}
select:disabled, input:disabled { opacity: .7; }
input:focus, textarea:focus, select:focus { border-color: var(--red); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 22%, transparent); }
label { display: block; font-weight: 700; margin-bottom: 14px; }
label > input, label > textarea, label > select { margin-top: 5px; font-weight: 400; }
.row-buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ---- cards and lists ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; margin-bottom: 16px; }
.form .btn { margin-top: 4px; }
.section-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--stone); margin: 22px 4px 8px; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: inherit; text-decoration: none; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row span { flex: 1; min-width: 0; }
.list-row small, .person small { display: block; color: var(--stone); font-size: .88rem; overflow-wrap: anywhere; }
.chev { width: 10px; height: 10px; border-right: 2px solid var(--stone); border-top: 2px solid var(--stone); transform: rotate(45deg); }
.list-card { padding: 0 16px; }
.person { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.person span { flex: 1; min-width: 0; }

.hello { margin: 8px 4px 16px; }
.hello h1 { margin-bottom: .1em; }
.empty-card { border-style: dashed; }

/* ---- sign-in and links ---- */
.auth { max-width: 400px; margin: 20px auto; }
.auth .btn:not(.big) { width: 100%; margin-top: 8px; }
.brand-block { text-align: center; margin-bottom: 24px; }
.brand-block img { border-radius: 18px; }
.brand-block h1 { font-size: 2.4rem; margin: 10px 0 0; }
.brand-block p { color: var(--stone); }
.brand-block.small { margin-bottom: 12px; }
.auth .hint { text-align: center; margin-top: 16px; }
.code-box { font: 700 1.5rem/1.2 ui-monospace, 'SF Mono', Menlo, monospace; letter-spacing: .04em; text-align: center;
  background: var(--red-soft); border: 2px dashed var(--red); border-radius: var(--r-md); padding: 18px 8px; margin: 16px 0 6px; user-select: all; }
.link-box { font: .95rem ui-monospace, Menlo, monospace; margin-bottom: 6px; }

/* ---- sheets and toasts ---- */
dialog.sheet { border: 0; padding: 0; background: var(--surface); color: var(--ink); border-radius: 16px; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); }
dialog.sheet::backdrop { background: rgba(8, 9, 11, .55); }
.sheet-body { padding: 20px; }
.sheet-body > .btn { width: 100%; margin-bottom: 8px; }
.sheet-body p { margin-bottom: 14px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs) + 14px); z-index: 3000;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--asphalt); color: #f3f3f0; padding: 12px 18px; border-radius: var(--r-md);
  max-width: calc(100vw - 32px); width: max-content; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .toast { background: #2c3037; } .toast.error { background: #8c1d18; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- garage ---- */
.vcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 14px; overflow: hidden; }
.vcard-main { display: block; padding: 16px 16px 8px; color: inherit; text-decoration: none; }
.vcard-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.vcard-head small { display: block; color: var(--stone); font-size: .9rem; }
.vname { font-size: 1.35rem; font-weight: 800; }
.vcard-foot { color: var(--stone); font-size: .88rem; margin: 6px 0 0; }
.vcard-btn { display: flex; margin: 0 16px 16px; }
.plate { font: 800 .95rem/1 ui-monospace, Menlo, monospace; letter-spacing: .06em; border: 2px solid var(--ink); border-radius: 6px; padding: 5px 8px; white-space: nowrap; background: var(--surface); color: var(--ink); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 14px 0 0; }
.stats div { min-width: 0; }
.stats dt { color: var(--stone); font-size: .82rem; }
.stats dd { margin: 0; font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.card.stats { margin-top: 0; }
.archived { margin-top: 20px; }
.archived summary { cursor: pointer; color: var(--stone); font-weight: 700; padding: 8px 4px; }
.empty { color: var(--stone); text-align: center; padding: 24px 0; }

/* ---- vehicle ---- */
.vhead { margin: 4px 4px 14px; }
.vhead h1 { margin-bottom: 0; }
.idrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.big-plate { font-size: 1.1rem; padding: 8px 12px; cursor: pointer; display: inline-flex; align-items: baseline; gap: 8px; }
.big-plate small { font: 600 .72rem var(--body); letter-spacing: 0; color: var(--stone); }
.vin { font: .92rem ui-monospace, Menlo, monospace; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; cursor: pointer; display: inline-flex; gap: 8px; align-items: baseline; }
.vin small { font: 700 .72rem var(--body); color: var(--stone); }
.actions { display: flex; gap: 10px; margin: 0 0 16px; }
.actions .btn { flex: 1; }
.seg-links { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; margin-bottom: 8px; }
.seg-links a { flex: 1; text-align: center; padding: 9px 4px; text-decoration: none; color: var(--stone); font-weight: 700; font-size: .9rem; }
.seg-links a.on { background: var(--asphalt); color: #f3f3f0; }
.month-head { display: flex; justify-content: space-between; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--stone); margin: 18px 4px 6px; }
.hrow { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.list-card > .hrow:last-child { border-bottom: 0; }
details.hrow { display: block; }
details.hrow summary { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; }
details.hrow summary::-webkit-details-marker { display: none; }
.hmain { flex: 1; min-width: 0; }
.hmain b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hmain small { display: block; color: var(--stone); font-size: .86rem; }
.hright { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-variant-numeric: tabular-nums; }
.hicon { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; background: var(--paper) center / 20px no-repeat; border: 1px solid var(--line); }
.hicon.fuel { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d7263d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 21V5a2 2 0 012-2h7a2 2 0 012 2v16M3 21h13M7 7h5v4H7zM15 9h2a2 2 0 012 2v6a1.5 1.5 0 003 0V8l-3-3'/%3E%3C/svg%3E"); }
.hicon.wrench { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f636b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14.7 6.3a4 4 0 00-5.4 5.4L3 18l3 3 6.3-6.3a4 4 0 005.4-5.4l-2.6 2.6-2.4-.6-.6-2.4z'/%3E%3C/svg%3E"); }
.tag { font-size: .74rem; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--paper); color: var(--stone); border: 1px solid var(--line); white-space: nowrap; }
.tag.good { background: color-mix(in srgb, #2e8b57 14%, transparent); color: #2e7d4f; border-color: transparent; }
@media (prefers-color-scheme: dark) { .tag.good { color: #7fd4a0; } }
.visit-body { padding: 4px 0 4px 46px; }
.items { width: 100%; border-collapse: collapse; font-size: .92rem; }
.items td { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.items td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.notes { color: var(--stone); font-size: .92rem; margin-top: 8px; overflow-wrap: anywhere; }

/* ---- forms ---- */
.two, .three { display: grid; gap: 10px; }
.two { grid-template-columns: 1fr 1fr; }
.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 380px) { .three { grid-template-columns: 1fr 1fr; } }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
label.check input { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--red); }
.form details { margin-bottom: 12px; }
.form details summary { cursor: pointer; font-weight: 700; color: var(--stone); padding: 6px 0 10px; }
.error-text { color: var(--danger); }
.card > .btn { width: 100%; margin-top: 8px; }
.small-list { padding-left: 20px; margin: 0 0 14px; color: var(--stone); font-size: .92rem; }
.small-list li { margin-bottom: 4px; }
input[type=file] { padding: 10px; }
