/* LogMyFleet "my logbook" area: same "navy and coral" identity as the public site
   (warm white, serif headings, round shapes, coral as the single accent). */
:root {
  --bg: #fcf9f5;
  --surface: #ffffff;
  --ink: #14213d;
  --muted: #5d6578;
  --line: #eadfd2;
  --coral: #ff6b57;
  --coral-text: #d9422c;
  --coral-soft: #ffe4df;
  --coral-deep: #a8321f;
  --accent: #ff6b57;
  --accent-ink: #14213d;
  --accent-soft: #ffe4df;
  --alt: #5d6578;
  --display: Fraunces, Georgia, "Times New Roman", serif;
  --radius: 16px;
  --shadow: 0 10px 28px rgba(20, 33, 61, .08);
  color-scheme: light;
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.5; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.1; }
h1, h2 { font-family: var(--display); font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
a { color: var(--ink); text-decoration-color: var(--coral); text-decoration-thickness: 2px; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.stack { display: grid; gap: 12px; }
.block { display: flex; width: 100%; justify-content: center; margin-top: 12px; }

/* --- Site header --- */
.topbar { position: sticky; top: 0; z-index: 5; background: rgba(252, 249, 245, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-in { width: min(960px, 100% - 32px); margin: 0 auto; min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.wordmark { font: 700 1.4rem/1 var(--display); letter-spacing: -.01em; }
.top-links { display: flex; gap: 4px; }
.top-links a { color: var(--muted); text-decoration: none; font-weight: 500; padding: 8px 14px; border-radius: 999px; }
.top-links a:hover { background: var(--coral-soft); color: var(--ink); }
.top-links a.on { background: var(--ink); color: #fff; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 500; justify-self: start; }
.back:hover { color: var(--ink); }
.back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.container { width: min(960px, 100% - 32px); margin: 0 auto; padding: 24px 0 64px; display: grid; gap: 20px; }
.container > * { min-width: 0; }
.page-title { margin-bottom: 0; }

/* --- Cards --- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h2 { margin-bottom: .75rem; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.section-head h2 { margin: 0; }
.section-head a { font-size: .9rem; font-weight: 500; }
.month { font-family: "DM Sans", sans-serif; text-transform: capitalize; font-size: .95rem; color: var(--muted); margin: 8px 0 -4px; font-weight: 600; letter-spacing: 0; }
.empty { text-align: center; color: var(--muted); }
.empty p { margin-bottom: .75rem; }

.vehicle-card { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; text-decoration: none; color: inherit; align-items: start; box-shadow: var(--shadow); }
.vehicle-card:hover { border-color: var(--coral); }
.vehicle-card .pill { grid-column: 1 / -1; justify-self: start; }
.v-icon { font-size: 2rem; line-height: 1; }
.v-main { display: grid; gap: 2px; min-width: 0; }
.v-odo { font: 600 1.7rem/1.1 var(--display); margin-top: 4px; }

.hero { text-align: center; padding: 28px 8px; }
.hero-icon { font-size: 3rem; margin-bottom: 8px; }
.hero h1 { font-size: clamp(2rem, 6vw, 3rem); }
.hero p { color: var(--muted); }

.odo-card { display: grid; gap: 8px; justify-items: start; background: var(--ink); border: 0; color: #fff; border-radius: 20px; box-shadow: var(--shadow); }
.odo-card .muted { color: #c7ccdb; }
.odo { font: 600 clamp(3rem, 9vw, 4.4rem)/1 var(--display); letter-spacing: -.01em; }
.odo span { font: 500 1.1rem "DM Sans", sans-serif; color: #c7ccdb; margin-left: 4px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; align-content: start; }
.stat-label { font-size: .82rem; color: var(--muted); font-weight: 500; }
.stat strong { font: 600 1.9rem/1.1 var(--display); }

.sale-card { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--coral-soft); border-color: transparent; }
.sale-card p { margin: 0; }

/* --- Reminders: coral = late, soft coral = soon, line = later --- */
.reminder { display: grid; gap: 4px; border-left: 6px solid var(--line); }
.reminder.lvl-over { border-left-color: var(--coral); }
.reminder.lvl-soon { border-left-color: var(--coral-soft); }
.rem-top { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.rem-when { margin: 0; font-weight: 500; }
.rem-actions { display: flex; gap: 8px; margin-top: 8px; }
.reminder .small { margin: 0; }
.pill { display: inline-block; padding: 5px 11px; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; }
.pill-over { background: var(--coral); color: var(--ink); }
.pill-soon { background: var(--coral-soft); color: var(--coral-deep); }
.pill-ok { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.done-box summary { cursor: pointer; color: var(--muted); padding: 8px 0; }
.done-box .stack { margin-top: 8px; }

/* --- Journal --- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 16px; white-space: nowrap; min-height: 40px; font-weight: 500; }
.chip:hover { background: var(--coral-soft); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.list { padding: 4px 0; }
.row-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: 0; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.row-item:last-child { border-bottom: 0; }
.row-item:hover { background: var(--coral-soft); }
.ri-icon { font-size: 1.4rem; }
.ri-main { display: grid; min-width: 0; }
.ri-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-amount { font-weight: 600; font-variant-numeric: tabular-nums; }

/* --- Charts --- */
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--coral); }
.chart .val { font-size: 8.5px; fill: var(--muted); }
.chart .lbl { font-size: 9px; fill: var(--muted); }
.chart .axis, .chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
.chart .dot { fill: #fff; stroke: var(--coral); stroke-width: 2.5; }
.chart .avg { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.big-num { font: 600 2.3rem/1.1 var(--display); margin-bottom: .5rem; }
.big-num span { font: 500 1rem "DM Sans", sans-serif; color: var(--muted); }
.big-num small { font: 400 .85rem "DM Sans", sans-serif; }
.bars-h { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; align-items: center; font-size: .9rem; }
.bar-track { background: var(--line); height: 12px; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--coral); border-radius: 99px; }
.bar-fill.alt { background: var(--ink); }

/* --- Buttons --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 22px; border: 0; border-radius: 999px; background: var(--ink); color: #fff;
  font: 600 .95rem/1 "DM Sans", sans-serif; text-decoration: none; }
.btn:hover { filter: brightness(1.2); }
.btn-sm { min-height: 40px; padding: 0 18px; font-size: .9rem; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.btn-ghost:hover { background: var(--coral-soft); filter: none; }
.btn-danger { background: transparent; color: var(--coral-deep); box-shadow: inset 0 0 0 1.5px var(--coral-deep); }
.odo-card .btn-primary { background: var(--coral); color: var(--ink); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* --- Page title and tabs --- */
.vhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.vhead h1 { margin: 0; font-size: clamp(1.9rem, 5vw, 2.6rem); }
.vhead-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tabs a { position: relative; padding: 10px 18px; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; border-radius: 999px; background: #fff; border: 1px solid var(--line); }
.tabs a:hover { background: var(--coral-soft); color: var(--ink); }
.tabs a.on { color: #fff; background: var(--ink); border-color: var(--ink); }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px; border-radius: 10px; background: var(--coral); color: var(--ink); font-size: .72rem; font-style: normal; font-weight: 700; }

/* --- Dialogs --- */
dialog {
  border: 0; padding: 0; margin: auto auto 0; width: min(560px, 100%); max-height: 92dvh; overflow: auto;
  background: var(--surface); color: var(--ink); border-radius: 24px 24px 0 0; box-shadow: 0 -10px 40px rgba(20, 33, 61, .25);
}
dialog::backdrop { background: rgba(20, 33, 61, .5); }
@media (min-width: 640px) { dialog { margin: auto; border-radius: 24px; box-shadow: 0 24px 60px rgba(20, 33, 61, .3); } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 10px 10px 22px; position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--line); z-index: 1; }
.sheet-head h2 { margin: 0; font-size: 1.4rem; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; font-size: 1.1rem; color: var(--ink); }
.icon-btn:hover { background: var(--coral-soft); }
.sheet-body { padding: 16px 22px calc(22px + env(safe-area-inset-bottom)); }
.menu { display: grid; gap: 8px; }
.menu-item { display: grid; grid-template-columns: 46px 1fr; align-items: center; gap: 12px; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 12px; }
.menu-item:hover { background: var(--coral-soft); border-color: var(--coral); }
.menu-item small { display: block; color: var(--muted); }
.menu-icon { font-size: 1.4rem; display: grid; place-items: center; width: 46px; height: 46px; background: var(--coral-soft); border-radius: 50%; }

/* --- Forms --- */
form { display: grid; gap: 12px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 4px; align-content: start; min-width: 0; }
.field label { font-size: .85rem; font-weight: 600; }
input[type=text], input[type=number], input[type=date], input:not([type]), select, textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1.5px solid #d9cdbd; border-radius: 12px; background: #fff;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--ink); outline-offset: 0; border-color: var(--ink); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--ink); }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-item input { position: absolute; opacity: 0; pointer-events: none; }
.seg-item span { display: inline-block; padding: 10px 16px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-weight: 500; }
.seg-item input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg-item input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 2px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.actions .btn-primary { flex: 1; }
.note { background: var(--coral-soft); border-radius: 12px; padding: 10px 14px; margin: 0; }

#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 999px; font-weight: 500; font-size: .92rem; transition: .25s; z-index: 50; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --- Sale file (printable, stays white) --- */
.doc-tools { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.doc { background: #fff; color: #111; border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.doc h1 { font-size: 2rem; margin-bottom: 0; }
.doc-sub { font-family: "DM Sans", sans-serif; font-weight: 500; font-size: 1.15rem; color: #444; margin-bottom: 1rem; }
.doc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; margin: 0 0 1.25rem; }
.doc-grid dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: #666; }
.doc-grid dd { margin: 0; font-weight: 600; }
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.doc-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.doc-table .nowrap { white-space: nowrap; }
.doc-table th, .doc-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #ddd; vertical-align: top; }
.doc-table th { font-size: .75rem; text-transform: uppercase; color: #666; }
.doc-table .r { text-align: right; white-space: nowrap; }
.doc-table small { color: #555; }
.doc-foot { margin-top: 1.5rem; font-size: .8rem; color: #666; }
.doc .muted { color: #666; }

@media print {
  body { background: #fff; }
  .no-print, .tabs, .topbar, #toast { display: none !important; }
  .container { padding: 0; width: auto; }
  .doc { border: 0; padding: 0; box-shadow: none; border-radius: 0; }
  tr { break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
