/* Palette synced to the app's design tokens (constants/colors.ts). */
:root {
  --blue: #0066FF; --blue-dark: #0052CC; --blue-light: #E9F1FF;
  --navy: #0A2A5E; --ink: #10203D; --muted: #5C6B85; --disabled: #9AA7BE;
  --line: #E1E8F4; --line-dark: #C7D3E8; --bg: #F4F7FC; --card: #FFFFFF;
  --surface-alt: #F7F9FD; --mist: #EEF2F9;
  --radius: 14px; --green: #0B8A43; --red: #E5484D; --red-light: #FDEBEC;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

/* ── Top bar ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 900px; margin: 0 auto; padding: 0 20px; height: 60px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.tabs { display: flex; gap: 4px; }
.tab {
  padding: 7px 14px; border-radius: 9px; font-size: 14px; font-weight: 600;
  color: var(--muted); background: none; border: none;
}
.tab:hover { color: var(--ink); background: var(--mist); text-decoration: none; }
.tab.active { color: var(--blue); background: var(--blue-light); }
.signout { font-size: 13px; color: var(--muted); background: none; border: none; }
.signout:hover { color: var(--red); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-link { font-size: 13px; font-weight: 600; color: var(--muted); }
.topbar-link:hover { color: var(--ink); text-decoration: none; }

/* ── Settings (mirrors the app: section headers + cards + rows) ─── */
.set-section { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 22px 0 6px; }
.set-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: 0 1px 3px rgba(11,27,51,.05); }
.set-pad { padding: 16px; }
/* Let fixed-width item rows scroll instead of being clipped on narrow screens. */
.set-panel { overflow-x: auto; }
.set-note { color: var(--muted); font-size: 13.5px; margin-bottom: 10px; }

/* Profile header */
.set-profile { display: flex; align-items: center; gap: 14px; padding: 16px; }
.set-avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--blue-light); color: var(--blue); font-weight: 700; font-size: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.set-profile-name { font-size: 15px; font-weight: 600; color: var(--ink); word-break: break-all; }
.set-profile-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Tappable rows (change password, legal links) */
.set-linkrow { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 15px 16px; border-top: 1px solid var(--line); background: none; border-left: none; border-right: none; border-bottom: none; font-size: 15px; font-weight: 500; color: var(--ink); text-align: left; cursor: pointer; }
.set-linkrow:hover { background: var(--surface-alt); text-decoration: none; }
.set-chev { color: var(--muted); font-size: 20px; line-height: 1; }

/* Reveal (password form) */
.set-reveal { padding: 4px 16px 16px; border-top: 1px solid var(--line); }
.set-fieldlabel { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; }
.set-input { width: 100%; padding: 10px 12px; font-size: 15px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface-alt); color: var(--ink); }
.set-input:focus { outline: none; border-color: var(--blue); background: #fff; }
.set-savebtn { margin-top: 16px; padding: 11px 18px; font-size: 14px; font-weight: 700; color: #fff; background: var(--blue); border: none; border-radius: 10px; cursor: pointer; }
.set-savebtn:hover { background: var(--blue-dark); }

/* Sub-tabs (Businesses / Cars / Teams) */
.set-subtabs { display: flex; border-bottom: 1px solid var(--line); }
.set-subtab { flex: 1; padding: 12px 4px; font-size: 14px; font-weight: 500; color: var(--muted); background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; }
.set-subtab:hover { color: var(--ink); }
.set-subtab.active { color: var(--blue); font-weight: 700; border-bottom-color: var(--blue); }

/* Inline management rows */
.set-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
/* Item rows keep the name + type selector + action buttons on one line. The
   name takes the big flexible portion; the type selector and buttons are fixed. */
.set-item { flex-wrap: nowrap; }
.set-item .set-inline { min-width: 0; }
.set-item .biz-type, .set-item .set-mini { flex-shrink: 0; }
.set-name { flex: 1 1 0; min-width: 60px; }
.biz-type { flex: 0 0 130px; min-width: 0; }
/* Fixed column widths + matching height so every item row's boxes line up
   vertically (the Save/Deactivate/Activate buttons vary in text width). */
.set-item .inp { height: 40px; }
.set-item .btn.set-mini { flex: 0 0 108px; width: 108px; height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; }
.set-add { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.set-inline { width: auto; flex: 1; min-width: 140px; margin: 0; }
/* Higher specificity than the later `.btn { width:100% }` so mini buttons stay
   inline and auto-width instead of stacking full-width. */
.btn.set-mini { width: auto; margin-top: 0; padding: 8px 14px; font-size: 13px; }
.set-tag { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--mist); border-radius: 6px; padding: 3px 8px; text-transform: capitalize; }
.set-danger { color: var(--red); }
.set-danger:hover { background: var(--red-light); }

/* Plan comparison */
.plan-table td, .plan-table th { white-space: nowrap; }
.plan-table .ta-c { text-align: center; }
.plan-cur { background: var(--blue-light); }
.plan-badge { display: block; font-size: 10px; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: .4px; }

/* ── Layout ──────────────────────────────────────────────── */
.wrap { max-width: 900px; margin: 0 auto; padding: 26px 20px 60px; }
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -.3px; margin-bottom: 4px; }
.page-sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

/* ── Cards / list rows ───────────────────────────────────── */
.row {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 10px; color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
a.row, button.row { cursor: pointer; }
a.row:hover, button.row:hover { border-color: var(--line-dark); box-shadow: 0 2px 10px rgba(11,27,51,.06); text-decoration: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.row-amount { font-weight: 700; font-size: 15px; white-space: nowrap; }
.amount-income { color: var(--green); }
.thumb {
  width: 44px; height: 44px; border-radius: 9px; background: var(--mist); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 18px;
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ── Detail ──────────────────────────────────────────────── */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; font-weight: 600; margin-bottom: 16px; background: none; border: none; }
.back:hover { color: var(--ink); text-decoration: none; }
.detail-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
/* top: 74px — the sticky topbar is 60px tall (top: 0) plus a 14px gap, so
   this sticks just below it instead of being covered by it. */
.save-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: #FDF0D5; border: 1px solid #E8C98A; border-radius: 10px;
  padding: 10px 14px; margin-bottom: 14px; position: sticky; top: 74px; z-index: 10;
}
.save-bar .msg { margin-top: 0; text-align: left; }
.detail-img { width: 100%; max-height: 460px; object-fit: contain; border-radius: 10px; background: var(--mist); margin-bottom: 18px; }
.detail-note { color: var(--muted); font-size: 13px; background: var(--mist); border-radius: 10px; padding: 12px 14px; margin-bottom: 18px; }
.email-frame { width: 100%; height: 420px; border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-bottom: 18px; }
.trip-map { width: 100%; height: 260px; border: 1px solid var(--line); border-radius: 10px; background: var(--mist); margin-bottom: 18px; }
.field { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
.field:first-child { border-top: none; }
.field-label { color: var(--muted); flex-shrink: 0; }
.field-val { text-align: right; font-weight: 600; }

/* ── Login ───────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px 28px; box-shadow: 0 4px 24px rgba(11,27,51,.06); }
.login-logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; margin-bottom: 6px; justify-content: center; }
.login-logo img { width: 32px; height: 32px; border-radius: 8px; }
.login-sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 22px; }
label.fld { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
input.inp, select.inp {
  width: 100%; padding: 11px 13px; font-size: 15px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface-alt); color: var(--ink);
}
input.inp:focus, select.inp:focus { outline: none; border-color: var(--blue); background: #fff; }
.btn { width: 100%; padding: 12px; font-size: 15px; font-weight: 700; border: none; border-radius: 10px; background: var(--blue); color: #fff; margin-top: 18px; }
.btn:hover { background: var(--blue-dark); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: none; color: var(--blue); border: 1px solid var(--line); margin-top: 10px; }
.btn-ghost:hover { background: var(--surface-alt); }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: var(--ink); border: 1px solid var(--line); margin-top: 0; font-weight: 600; }
.btn-google:hover { background: var(--surface-alt); }
.btn-google svg { flex-shrink: 0; }
.or-div { display: flex; align-items: center; gap: 12px; margin: 18px 0 4px; color: var(--muted); font-size: 12.5px; }
.or-div::before, .or-div::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.msg { font-size: 13.5px; margin-top: 14px; text-align: center; }
.msg-err { color: var(--red); }
.msg-ok { color: var(--green); }

/* ── States ──────────────────────────────────────────────── */
.center { text-align: center; color: var(--muted); padding: 48px 20px; font-size: 15px; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.filterbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { padding: 6px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); background: var(--card); border: 1px solid var(--line); }
.chip:hover { border-color: var(--line-dark); }
.chip.active { color: #fff; background: var(--blue); border-color: var(--blue); }
.loadmore { display: block; margin: 8px auto 0; padding: 10px 22px; font-size: 14px; font-weight: 600; color: var(--blue); background: none; border: 1px solid var(--line); border-radius: 10px; }
.loadmore:hover { background: var(--surface-alt); }

/* ── Reports ──────────────────────────────────────────────── */
.report-controls { margin-bottom: 22px; }
.report-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.select { width: auto; min-width: 170px; padding: 9px 12px; font-size: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-alt); color: var(--ink); }
.btn-run { width: auto; margin-top: 0; padding: 10px 20px; }
.report-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.report-h2 { font-size: 19px; font-weight: 800; }
.report-range { color: var(--muted); font-size: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 26px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat-val { font-size: 20px; font-weight: 800; margin-top: 4px; letter-spacing: -.3px; }
.stat-val.big { color: var(--blue); }
.stat-val.income { color: var(--green); }
.stat-sub { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.report-section { margin-bottom: 28px; }
.report-h3 { font-size: 15px; font-weight: 700; margin-bottom: 12px; color: var(--navy); }
.catrow { margin-bottom: 12px; }
.catrow-top { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.bar { height: 8px; background: var(--mist); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--blue); border-radius: 6px; }

/* ── Report charts ─────────────────────────────────────────── */
.metric-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 680px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.chart-empty { color: var(--muted); font-size: 13.5px; padding: 24px 0; text-align: center; }
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut { width: 140px; height: 140px; flex-shrink: 0; }
.lg { flex: 1; min-width: 140px; display: flex; flex-direction: column; gap: 6px; }
.lg-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.lg-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.lg-name { flex: 1; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-val { font-weight: 600; color: var(--muted); }
.bars-wrap { width: 100%; overflow-x: auto; }
.bars { width: 100%; min-width: 240px; height: 150px; }
.bars .bar-rect { fill: var(--blue); }
.bars .bar-lbl { font-size: 9px; fill: var(--muted); }
.bars .bar-val { font-size: 8.5px; fill: var(--muted); font-weight: 600; }
.report-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 26px; }
/* Detail tables: kept out of the on-screen report, still included in Print/PDF. */
.print-only { display: none; }
@media print { .print-only { display: block; } }
/* Split PDF-with-receipts parts (large exports). */
.rcpt-parts { margin: 4px 0 20px; }
.rcpt-parts-note { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.rcpt-parts-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.rcpt-done { opacity: .55; }
.rtable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rtable th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 8px 10px; border-bottom: 1.5px solid var(--line); }
.rtable td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.rtable .ta-r { text-align: right; }

/* ── Unsaved-changes confirm modal ───────────────────────── */
.confirm-overlay {
  position: fixed; inset: 0; background: rgba(11,27,51,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
}
.confirm-card {
  background: var(--card); border-radius: var(--radius); padding: 22px;
  max-width: 360px; width: 100%; box-shadow: 0 12px 40px rgba(11,27,51,.18);
}
.confirm-text { font-size: 15px; color: var(--ink); margin-bottom: 18px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.confirm-actions .btn, .confirm-actions .btn-ghost { width: auto; padding: 10px 18px; }

@media print {
  .topbar, .no-print, .report-actions { display: none !important; }
  body { background: #fff; }
  .wrap { max-width: 100%; padding: 0; }
  .stat, .rtable, .detail-card { break-inside: avoid; }
  .bar-fill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
