/* TruTruck — app.css (mobile-first, offline, no web fonts) */
:root {
  --navy: #0B1F3A;
  --navy-2: #132C4F;
  --amber: #F5A623;
  --amber-dark: #D98E0F;
  --bg: #F2F4F8;
  --card: #FFFFFF;
  --ink: #17233A;
  --muted: #6B7791;
  --line: #E3E8F0;
  --green: #1E9E5A;
  --red: #D64545;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; }
a { color: var(--navy); }

.app-root { min-height: 100vh; }

/* ---------- header ---------- */
.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px calc(10px);
  padding-top: calc(10px + env(safe-area-inset-top));
  box-shadow: 0 2px 10px rgba(11, 31, 58, .25);
}
.header-left { width: 40px; display: flex; }
.header-mid { flex: 1; min-width: 0; }
.header-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-sub { font-size: 11px; opacity: .75; }
.header-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; color: inherit;
}
.icon-btn:hover { background: rgba(255, 255, 255, .12); }
.content .icon-btn:hover { background: var(--line); }

.sync-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #8a93a6; display: inline-block; cursor: pointer;
}
.sync-dot.ok { background: #37d67a; box-shadow: 0 0 6px rgba(55, 214, 122, .8); }
.sync-dot.err { background: #ff6b6b; box-shadow: 0 0 6px rgba(255, 107, 107, .8); }
.sync-dot.idle { background: var(--amber); }
.sync-dot.off { background: #4c5a75; }

/* ---------- layout ---------- */
.content {
  padding: 16px 14px 96px;
  max-width: 760px; margin: 0 auto;
  padding-top: calc(68px + env(safe-area-inset-top));
}
h2 { font-size: 20px; letter-spacing: -.2px; }
h3 { font-size: 14px; margin: 18px 2px 8px; color: var(--navy); text-transform: uppercase; letter-spacing: .4px; }
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.page-head h2 { flex: 1; }
.page-head .icon-btn { color: var(--navy); }
.mt16 { margin-top: 16px; }
.mt8 { margin-top: 8px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small-text { font-size: 12px; }
.red-text { color: var(--red); }
.green-text { color: var(--green); }
.amber { color: var(--amber-dark); }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- cards & stats ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(23, 35, 58, .08);
  border: 1px solid var(--line);
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stats.wide { grid-template-columns: repeat(3, 1fr); }
.stat {
  background: var(--card); border-radius: var(--radius); border: 1px solid var(--line);
  padding: 12px 10px; text-align: center;
  display: flex; flex-direction: column; gap: 4px;
}
.stat.big { background: var(--navy); border-color: var(--navy); }
.stat.big .stat-v { color: #fff; font-size: 18px; }
.stat.big .stat-l { color: rgba(255, 255, 255, .75); }
.stat.big.green-ok .stat-v { color: #5be3a0; }
.stat-v { font-weight: 800; font-size: 16px; line-height: 1.2; word-break: break-word; }
.stat-v.green { color: var(--green); }
.stat-v.red { color: var(--red); }
.stat-l { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  min-height: 44px; transition: transform .06s ease, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--amber); color: var(--navy); }
.btn.primary:hover { background: var(--amber-dark); color: #fff; }
.btn.ghost { background: var(--card); color: var(--navy); border: 1.5px solid var(--line); }
.btn.ghost:hover { border-color: var(--navy); }
.btn.danger { background: var(--red); color: #fff; }
.btn.block { width: 100%; }
.btn.small { padding: 8px 12px; min-height: 38px; font-size: 13px; }
.btn:disabled { opacity: .6; pointer-events: none; }
.row-actions { display: flex; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.row-actions.col { flex-direction: column; }
.row-actions .btn { flex: 1; }

.mini-link { color: var(--navy); font-size: 12px; font-weight: 600; text-decoration: underline; padding: 4px 2px; }
.danger-link { color: var(--red); }

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; }
.chip {
  background: var(--card); border: 1.5px solid var(--line); color: var(--muted);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; text-align: left; display: block; width: 100%;
}
.list-item:hover { border-color: var(--navy); }
.li-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.li-title { font-weight: 700; font-size: 14px; }
.li-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
}
.badge.green { background: #E1F5EA; color: var(--green); }
.badge.amber { background: #FDEFD8; color: var(--amber-dark); }
.badge.red { background: #FBE3E3; color: var(--red); }
.badge.grey { background: #EAEFF5; color: var(--muted); }

/* ---------- key-value ---------- */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv span { color: var(--muted); }
.kv b { text-align: right; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); margin-bottom: 6px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  background: var(--navy); color: #fff; text-align: left;
  padding: 9px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
  white-space: nowrap;
}
.tbl td { padding: 9px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:nth-child(even) { background: #F8FAFD; }
.balance-total { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 14px; }

/* ---------- forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--navy); }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  min-height: 46px;
}
.field textarea { min-height: 0; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--amber); }
.req { color: var(--red); }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.4; }
.hint.pad { margin: 0 2px 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.filter-card .btn { margin-top: 4px; }
.with-add { display: flex; align-items: center; gap: 10px; }
.with-add select, .with-add input { flex: 1; }

/* ---------- trip expense rows ---------- */
.exp-row {
  background: #F8FAFD; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px; margin-bottom: 10px;
}
.exp-line1 { display: flex; gap: 8px; }
.exp-line1 input { min-width: 0; padding: 10px; border-radius: 10px; border: 1.5px solid var(--line); }
.exp-line1 .er-desc { flex: 1.4; }
.exp-line1 .er-amt { flex: 1; }
.exp-line2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.exp-line2 select { width: 100%; padding: 10px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; }
.exp-line3 { display: flex; gap: 14px; margin-top: 6px; }
.trip-mini { background: #FDEFD8; border-radius: 10px; padding: 9px 12px; font-size: 13px; margin-bottom: 12px; color: #7A5200; }

/* ---------- banners ---------- */
.banner {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 13px; border-radius: 12px; font-size: 13px; font-weight: 600;
  margin-bottom: 12px; line-height: 1.35;
}
.banner svg { flex-shrink: 0; }
.banner.ok { background: #E1F5EA; color: #14713F; }
.banner.warn { background: #FDEFD8; color: #7A5200; }
.banner.err { background: #FBE3E3; color: #8F2626; }

/* ---------- menu grid (admin) ---------- */
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.menu-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 14px; text-align: left; font-weight: 600; font-size: 12.5px; min-height: 84px;
}
.menu-card:hover { border-color: var(--amber); }
.menu-icon { color: var(--amber-dark); }

/* ---------- trucks ---------- */
.truck-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.truck-card { text-align: left; }
.truck-card:hover { border-color: var(--amber); }
.truck-plate {
  font-weight: 800; font-size: 16px; color: #fff; background: var(--navy);
  display: inline-block; padding: 4px 12px; border-radius: 8px; letter-spacing: .5px;
}
.truck-name { font-weight: 600; margin-top: 6px; }

/* ---------- tabs ---------- */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: var(--navy); display: flex;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: #8FA0BD; padding: 6px 2px; border-radius: 10px; font-size: 10.5px; font-weight: 600;
}
.tab.active { color: var(--amber); }
.tab.active svg { filter: drop-shadow(0 0 5px rgba(245, 166, 35, .45)); }

/* ---------- modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(9, 18, 33, .55);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .16s ease;
}
.modal-sheet {
  background: #fff; width: 100%; max-width: 760px;
  border-radius: 18px 18px 0 0; max-height: 92vh; overflow-y: auto;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  animation: slideUp .18s ease;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal-sheet { border-radius: 18px; }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-title { font-weight: 800; font-size: 17px; }
.modal-head .icon-btn { color: var(--muted); }
.modal-foot { margin-top: 8px; }
.confirm-msg { font-size: 14px; line-height: 1.5; padding: 4px 0 8px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }

/* ---------- toasts ---------- */
#toast-root { position: fixed; bottom: 90px; left: 0; right: 0; z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 600; max-width: 88vw; opacity: 0; transform: translateY(8px);
  transition: all .25s ease; box-shadow: 0 6px 20px rgba(9, 18, 33, .35);
}
.toast.show { opacity: 1; transform: none; }
.toast.warn { background: var(--amber-dark); }
.toast.err { background: var(--red); }

/* ---------- gate screens (init / login / lock) ---------- */
.gate-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 60%, #1C3A66 100%); }
.gate-card {
  background: #fff; border-radius: 22px; padding: 26px 22px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(4, 10, 22, .5);
}
.gate-logo {
  width: 64px; height: 64px; border-radius: 16px; background: var(--navy); color: var(--amber);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 12px;
}
.gate-logo.lock { background: #FBE3E3; color: var(--red); }
.gate-card h1 { text-align: center; font-size: 22px; color: var(--navy); margin-bottom: 4px; }
.gate-card > p, .gate-card .muted { text-align: center; }
.gate-card .btn { margin-top: 10px; }
.gate-foot { font-size: 11.5px; margin-top: 14px; }
.gate-foot.center { text-align: center; }
.gate-foot .mini-link { font-size: 13px; }
.gate-card .card { margin-top: 14px; }
.gate-card .field label { text-align: left; }
.gate-card .hint { text-align: left; }
.steps { display: flex; justify-content: center; gap: 8px; margin: 14px 0; }
.step { width: 28px; height: 6px; border-radius: 999px; background: var(--line); }
.step.active { background: var(--amber); }
.step.now { box-shadow: 0 0 0 3px #FDEFD8; }

.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.empty p { margin-top: 10px; font-size: 13.5px; }
.empty svg { opacity: .4; }

.center-card { text-align: center; }
.center-card h3 { text-align: center; }
.center-card .kv { text-align: left; }

.loc-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.loc-row:last-of-type { border-bottom: none; }
.loc-row svg { color: var(--amber-dark); flex-shrink: 0; }
.loc-row span { flex: 1; }

@media (max-width: 420px) {
  .row3 { grid-template-columns: 1fr; }
  .menu-grid { grid-template-columns: repeat(2, 1fr); }
  .stats.wide { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 640px) {
  .content { padding-left: 24px; padding-right: 24px; }
}

/* ---------- PWA Install / Download card ---------- */
.install-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 12px 0 16px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0B1F3A 0%, #1C3A66 100%);
  color: #fff;
  border: none;
  box-shadow: 0 8px 24px rgba(11, 31, 58, .25);
}
.install-card > svg { flex-shrink: 0; color: var(--amber); margin-top: 2px; }
.install-card .install-body { flex: 1; min-width: 0; }
.install-card b { display: block; font-size: 14.5px; margin-bottom: 2px; color: #fff; }
.install-card .muted { color: rgba(255,255,255,.72); font-size: 12.5px; line-height: 1.35; margin-bottom: 10px; }
.install-card .btn {
  margin-top: 2px;
  background: var(--amber);
  color: var(--navy);
  border: none;
  font-weight: 700;
}
.install-card .btn:active { opacity: .9; }
.install-card.ok {
  background: #E8F6EE;
  color: var(--navy);
  box-shadow: none;
  border: 1px solid #B7E0C7;
}
.install-card.ok > svg { color: #1B7A45; }
.install-card.ok b { color: #0B3D22; }
.install-card.ok .muted { color: var(--muted); margin-bottom: 0; }

.install-steps {
  margin: 10px 0 14px 18px;
  padding: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
}
.install-steps li { margin-bottom: 6px; }
.install-steps b { color: var(--navy); }

/* ---------- trip two-menu + balance sheet ---------- */
.trip-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 14px;
}
.trip-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 14px 12px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: #fff;
  box-shadow: 0 2px 10px rgba(9, 18, 33, .06);
  cursor: pointer;
}
.trip-action.exp {
  border-color: #E8A0A0;
  background: #FFF5F5;
}
.trip-action.inc {
  border-color: #9AD4B0;
  background: #F2FBF5;
}
.trip-action .ta-label {
  font-weight: 700;
  font-size: 15px;
  color: var(--navy);
}
.trip-action .ta-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin: 2px 0 8px;
  line-height: 1.3;
}
.trip-action .ta-amt {
  font-size: 16px;
  font-weight: 700;
}
.trip-action .ta-amt.red { color: var(--red); }
.trip-action .ta-amt.green { color: #1B7A45; }
.trip-action:active { transform: scale(.98); }

.balance-sheet {
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  margin: 0 0 16px;
  border: 1px solid var(--line);
}
.bs-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13.5px;
  border-bottom: 1px dashed var(--line);
}
.bs-row:last-child { border-bottom: none; }
.bs-row span { color: var(--muted); }
.bs-row b { font-size: 14.5px; }
.bs-row.bs-total {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 2px solid var(--navy);
  border-bottom: none;
}
.bs-row.bs-total span { color: var(--navy); font-weight: 600; }
.bs-row.bs-total b { font-size: 17px; }
.trip-meta { margin-bottom: 4px; }
.mt16 { margin-top: 16px; }

/* ---------- fast expense entry (type + amount only) ---------- */
.fast-exp-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 4px;
  max-height: 46vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.fast-exp {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #F7F9FC;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.fast-exp .fe-name {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.25;
}
.fast-exp .fe-amt {
  width: 110px;
  flex-shrink: 0;
  text-align: right;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}
.fast-exp .fe-amt:focus {
  border-color: var(--amber);
  outline: none;
  box-shadow: 0 0 0 3px #FDEFD8;
}

/* remove (retire) a cash-out row straight inside the form */
.fe-x {
  flex-shrink: 0;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  font-weight: 700;
}
.fe-x:hover { color: var(--red); border-color: var(--line); background: #fff; }
.fast-exp.is-new .fe-name { color: var(--amber-dark); }

/* Books teaser on Home — math is one conscious tap away */
.books-teaser {
  display: flex; align-items: center; gap: 12px; width: 100%;
  text-align: left; padding: 14px 16px; margin: 12px 0;
}
.books-teaser > svg:first-child { color: var(--amber-dark); flex-shrink: 0; }
.books-teaser > svg:last-child { transform: rotate(180deg); color: var(--muted); flex-shrink: 0; }
.books-teaser-body { flex: 1; min-width: 0; }
.books-teaser-body b { font-size: 14.5px; color: var(--navy); }
.books-teaser-body .muted { font-size: 12.5px; line-height: 1.35; margin-top: 2px; }
.books-teaser:hover { border-color: var(--amber); }

/* day book / daily report */
.day-link { text-decoration: underline; font-weight: 700; color: var(--navy); background: none; padding: 2px 4px; white-space: nowrap; }
.day-link:hover { color: var(--amber-dark); }
.report-sub { font-size: 12px; color: var(--muted); margin-bottom: 10px; line-height: 1.4; }
