:root {
  --bg: #f2f2f7; --card: #ffffff; --label: #1c1c1e; --muted: #636366; --faint: #8e8e93; --sep: #d8d8dd;
  --tint: #0a5fc4; --tint-soft: #e5effb; --danger: #c4161c; --danger-soft: #fdecec; --warn: #9a5b00; --warn-soft: #fff4dc;
  --fuel: #2f6fe4; --other: #e08a00; --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: light;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--label); font: 17px/1.4 var(--font); padding: env(safe-area-inset-top) 0 0; min-height: 100vh; }
body.modal-open { overflow: hidden; }
main { max-width: 640px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--tint) 55%, transparent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 0 10px; min-height: 64px; }
.top h1 { font-size: 32px; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.top .back + h1 { font-size: 22px; flex: 1; text-align: right; }
.icon-btn { background: none; border: 0; color: var(--muted); width: 44px; height: 44px; display: grid; place-items: center; border-radius: 22px; }
.back { background: none; border: 0; color: var(--tint); display: flex; align-items: center; font-size: 17px; min-height: 44px; padding: 0 8px 0 0; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--sep); background: var(--card); border-radius: 18px; min-height: 36px; padding: 6px 14px; font-size: 15px; }
.chip.on { background: var(--label); color: #fff; border-color: var(--label); font-weight: 600; }
.chip.small { min-height: 32px; padding: 4px 12px; font-size: 14px; }

.card, .tile, .group, .chart-card, .aut { background: var(--card); border-radius: var(--radius); }
.card { padding: 16px; margin-bottom: 12px; }
.label { display: block; font-size: 13px; color: var(--muted); font-weight: 500; }
.big { font-size: 56px; font-weight: 700; letter-spacing: -.03em; line-height: 1.05; margin: 6px 0 4px; }
.mid { font-size: 26px; font-weight: 650; letter-spacing: -.01em; margin: 4px 0 2px; }
.big small, .mid small { font-size: .42em; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.sub { margin: 0; color: var(--muted); font-size: 14px; }
.quick { display: grid; gap: 10px; margin-top: 18px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 0; background: var(--card); color: var(--tint); font-weight: 600; font-size: 17px; text-align: center; }
.group .btn, .sheet-b .btn:not(.primary):not(.danger) { background: var(--tint-soft); }
.btn.primary { background: var(--tint); color: #fff; }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.big { min-height: 54px; font-size: 18px; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 15px; background: var(--card); }
.btn.small.primary { background: var(--tint); }
.btn.full { width: 100%; margin-top: 10px; }
.btn:disabled { opacity: .4; }
.link { background: none; border: 0; color: var(--tint); font-size: 17px; min-height: 44px; padding: 0 4px; }
.link.strong { font-weight: 600; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; font-size: 0; cursor: pointer; }

.banner { border-radius: var(--radius); padding: 12px 14px; margin: 0 0 12px; font-size: 15px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.banner p { margin: 0; flex: 1 1 220px; }
.banner.info { background: var(--tint-soft); }
.banner.soft { background: var(--warn-soft); color: #4d3200; }
.banner.warn { background: var(--warn-soft); }
.banner.error { background: var(--danger-soft); color: #5c0a0d; }
.banner-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.crash { position: fixed; left: 12px; right: 12px; top: calc(8px + env(safe-area-inset-top)); z-index: 60; box-shadow: 0 6px 24px rgba(0,0,0,.18); }

.empty { text-align: center; padding: 48px 12px; }
.empty h2 { font-size: 22px; margin: 0 0 8px; }
.empty p { color: var(--muted); margin: 0 0 20px; }
.empty-line { color: var(--muted); font-size: 15px; padding: 18px 4px; margin: 0; text-align: center; }
.muted { color: var(--muted); font-size: 14px; }

.filters { display: grid; gap: 8px; margin-bottom: 12px; }
.field { width: 100%; min-height: 44px; border: 1px solid var(--sep); border-radius: 10px; background: var(--card); padding: 9px 12px; font-size: 17px; appearance: none; -webkit-appearance: none; }
select.field { background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input[type=date].field { display: block; min-width: 0; text-align: left; }
input[type=date]::-webkit-date-and-time-value { text-align: left; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg { display: flex; background: #e3e3e8; border-radius: 10px; padding: 2px; gap: 2px; }
.seg-b { flex: 1; border: 0; background: none; border-radius: 8px; min-height: 36px; font-size: 15px; font-weight: 500; color: var(--label); }
.seg-b.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.14); font-weight: 600; }
.seg.wide { margin-bottom: 10px; }
.seg.big .seg-b { min-height: 44px; font-size: 16px; }
.seg.big .seg-b.on { background: var(--tint); color: #fff; }

.tbl-wrap { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 10px 6px 6px; border-bottom: 1px solid var(--sep); }
.tbl td { padding: 10px 6px; border-bottom: 1px solid #ececf0; vertical-align: top; }
.tbl th:first-child, .tbl td:first-child { padding-left: 12px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 12px; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:not(.static) { cursor: pointer; }
.tbl tbody tr:not(.static):active { background: #f0f0f4; }
.tbl .r { text-align: right; white-space: nowrap; }
.tbl .strong { font-weight: 650; }
.tbl .desc { word-break: break-word; }
.tbl tr.gap td { background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.tbl tr.gap svg { vertical-align: -3px; }
.tag { display: block; width: max-content; font-size: 11px; color: var(--muted); background: #ececf0; border-radius: 4px; padding: 0 5px; margin-top: 3px; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.on { display: inline-block; background: var(--tint-soft); color: var(--tint); margin: 0 0 0 4px; vertical-align: 1px; }
.r .tag { margin-left: auto; }
.foot { color: var(--muted); font-size: 13px; margin: 8px 4px 16px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { padding: 12px 14px; min-width: 0; }
.tile.span2 { grid-column: span 2; }
.tile .mid { font-size: 22px; overflow-wrap: anywhere; }
.aut { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 8px; padding: 10px 14px; margin-top: 10px; font-size: 15px; }
.aut b { font-size: 17px; }
.aut p { grid-column: span 2; margin: 0; color: var(--muted); font-size: 13px; }
.notes { margin: 12px 4px 4px; padding-left: 18px; color: var(--muted); font-size: 13px; }
.notes li { margin-bottom: 4px; }

.chart-card { padding: 14px 0 6px; margin-top: 14px; }
.chart-card h2 { font-size: 17px; margin: 0 14px 8px; }
.chart-card .foot, .chart-card .tbl-wrap, .chart-card .empty-line { margin-left: 14px; margin-right: 14px; }
.chart-card .tbl-wrap { border: 1px solid #ececf0; }
.chart { padding: 0 6px; overflow: hidden; }
.chart.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart svg { display: block; }
.chart .grid { stroke: #e8e8ed; stroke-width: 1; }
.chart .ylab, .chart .xlab { font-size: 11px; fill: var(--muted); font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .line { stroke: var(--fuel); stroke-width: 2; }
.chart .line-c { stroke-width: 2; }
.chart .pt { fill: var(--fuel); stroke: #fff; stroke-width: 1.5; }
.chart .pt.hollow { fill: #fff; stroke: var(--fuel); stroke-width: 2; }
.chart .pt-c { stroke: #fff; stroke-width: 1.5; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart circle.hit.sel { fill: rgba(10,95,196,.14); }
.chart rect.hit.sel { fill: rgba(10,95,196,.07); }
.chart .bar-fuel { fill: var(--fuel); }
.chart .bar-other { fill: var(--other); }
.chart .bar-zero { stroke: #c8c8ce; stroke-width: 2; }
.cap { margin: 6px 14px 8px; font-size: 14px; min-height: 2.8em; color: var(--label); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 14px 6px; font-size: 13px; color: var(--muted); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: 0; }
.sw.fuel { background: var(--fuel); }
.sw.other { background: var(--other); }

.sec { font-size: 13px; font-weight: 500; color: var(--muted); margin: 22px 16px 6px; }
.group { overflow: hidden; }
.group.pad { padding: 12px 16px 16px; }
.group.pad p { margin: 0 0 8px; }
.cell { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; text-align: left; background: none; border: 0; border-bottom: 1px solid #ececf0; padding: 11px 16px; min-height: 48px; }
.cell:last-child { border-bottom: 0; }
.cell small { display: block; color: var(--muted); font-size: 13px; }
.cell i { color: var(--faint); font-style: normal; font-size: 22px; }
.cell.add { color: var(--tint); font-weight: 600; }
.cell-text { margin: 0; padding: 12px 16px; color: var(--muted); font-size: 14px; }
.copy { border-top: 1px solid #ececf0; padding-top: 10px; margin-top: 10px; }
.copy p { margin: 0 0 8px; }
.spacer { height: 20px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(249,249,251,.94); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--sep); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
.tabbar button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--faint); font-size: 11px; font-weight: 500; min-height: 50px; padding: 4px 0; }
.tabbar button.on { color: var(--tint); }
.tabbar .add-btn { color: var(--tint); }
.tabbar .plus { display: grid; place-items: center; width: 34px; height: 30px; border-radius: 9px; background: var(--tint); color: #fff; }
.tabbar .add-btn:disabled { opacity: .4; }

.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.32); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-in { background: var(--bg); min-height: calc(100% - 10px - env(safe-area-inset-top)); margin-top: calc(10px + env(safe-area-inset-top)); border-radius: 14px 14px 0 0; max-width: 640px; margin-left: auto; margin-right: auto; }
.sheet-h { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 6px 10px; background: rgba(242,242,247,.96); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-bottom: 1px solid var(--sep); border-radius: 14px 14px 0 0; }
.sheet-h h2 { font-size: 17px; margin: 0; text-align: center; }
.sheet-h .link:first-child { justify-self: start; }
.sheet-h > :last-child { justify-self: end; }
.sheet-b { padding: 14px 16px calc(40px + env(safe-area-inset-bottom)); }
.fl { display: block; margin-bottom: 14px; }
.fl > span { display: block; font-size: 14px; font-weight: 600; margin: 0 0 5px 2px; }
.fl em { font-style: normal; font-weight: 400; color: var(--muted); }
.hint { display: block; color: var(--muted); font-size: 13px; margin: 5px 2px 0; }
.calc { background: var(--card); border-radius: 10px; padding: 10px 12px; margin: -4px 0 14px; font-size: 15px; }
.calc small { color: var(--muted); }
.note { background: var(--tint-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 0 0 14px; }
.sugg { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 4px; }
.errs { background: var(--danger-soft); color: #5c0a0d; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 15px; }
.errs p { margin: 0 0 4px; }
.errs ul { margin: 0; padding-left: 18px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 11px 16px; border-bottom: 1px solid #ececf0; font-size: 16px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 500; text-align: right; overflow-wrap: anywhere; }

.action-sheet { position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); display: grid; gap: 1px; max-width: 520px; margin: 0 auto; }
.as-b { background: rgba(255,255,255,.97); border: 0; min-height: 57px; font-size: 19px; color: var(--tint); }
.as-b:first-child { border-radius: 14px 14px 0 0; }
.as-b.minor { font-size: 16px; color: var(--label); border-radius: 0 0 14px 14px; }
.as-b.cancel { margin-top: 8px; border-radius: 14px; font-weight: 600; }

.dialog { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.4); display: grid; place-items: center; padding: 20px; }
.dialog[hidden] { display: none; }
.dlg { background: #fff; border-radius: 16px; width: 100%; max-width: 380px; max-height: 86vh; overflow-y: auto; padding: 20px 18px 12px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.dlg h2 { font-size: 18px; margin: 0 0 8px; text-align: center; }
.dlg-body { font-size: 15px; }
.dlg-body p { margin: 0 0 10px; }
.dlg-body ul { padding-left: 18px; margin: 0 0 10px; }
.dlg .field { margin-bottom: 10px; }
.dlg-btns { display: grid; gap: 8px; margin-top: 6px; }
.dlg-btn { min-height: 46px; border: 0; border-radius: 12px; background: #eef0f4; color: var(--tint); font-size: 17px; }
.dlg-btn.strong { background: var(--tint); color: #fff; font-weight: 600; }
.dlg-btn.danger { background: var(--danger); color: #fff; font-weight: 600; }
.dlg-btn:disabled { opacity: .35; }

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(28,28,30,.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px; max-width: calc(100% - 32px); z-index: 70; opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media (max-width: 360px) { .tbl { font-size: 13px; } .tbl th, .tbl td { padding-left: 4px; padding-right: 4px; } .big { font-size: 46px; } }
