/* ==========================================================================
   CarCare — design system
   Dark first. Light theme is a token swap. No external requests.
   ========================================================================== */

:root {
  --bg:        #080B10;
  --bg-grad:   radial-gradient(1200px 600px at 15% -10%, rgba(61,199,243,.11), transparent 60%),
               radial-gradient(900px 500px at 100% 0%, rgba(111,75,158,.14), transparent 55%);
  --surface:   #10161F;
  --surface-2: #172230;
  --surface-3: #1E2B3B;
  --line:      rgba(255,255,255,.07);
  --line-strong: rgba(255,255,255,.14);
  --text:      #E9F0F7;
  --text-dim:  #9FB0C3;
  --muted:     #6F8298;

  /* RJ's Design Studio brand gradient: cyan -> violet */
  --accent:    #3DC7F3;
  --accent-ink:#04202E;
  --accent-2:  #8E63C8;
  --brand-cyan:   #3DC7F3;
  --brand-blue:   #54A6DB;
  --brand-violet: #6F4B9E;
  --warn:      #FFB020;
  --warn-ink:  #2A1C00;
  --danger:    #FF5C6E;
  --danger-ink:#2B0A0F;
  --purple:    #A78BFA;

  --radius:    18px;
  --radius-sm: 12px;
  --radius-lg: 26px;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 12px 32px -12px rgba(0,0,0,.65);
  --shadow-lg: 0 30px 60px -20px rgba(0,0,0,.75);
  --ring:      0 0 0 3px rgba(61,199,243,.30);

  --sidebar-w: 254px;
  --header-h:  64px;
  --tabbar-h:  68px;
  /* The Arabic face is listed first but only claims Arabic codepoints, so Latin
     text is untouched and mixed strings render correctly in both scripts. */
  --font: 'CarCare Arabic', -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --bg:        #F4F7FB;
  --bg-grad:   radial-gradient(1000px 500px at 10% -10%, rgba(61,199,243,.14), transparent 60%),
               radial-gradient(800px 460px at 100% 0%, rgba(111,75,158,.12), transparent 55%);
  --surface:   #FFFFFF;
  --surface-2: #F2F6FA;
  --surface-3: #E6EDF5;
  --line:      rgba(12,26,44,.09);
  --line-strong: rgba(12,26,44,.18);
  --text:      #0C1723;
  --text-dim:  #46586C;
  --muted:     #6B7C90;
  --accent:    #1B87C0;
  --accent-ink:#FFFFFF;
  --accent-2:  #6F4B9E;
  --warn:      #B4700B;
  --warn-ink:  #FFFFFF;
  --danger:    #D42B41;
  --danger-ink:#FFFFFF;
  --shadow:    0 1px 2px rgba(16,32,52,.06), 0 12px 28px -14px rgba(16,32,52,.28);
  --shadow-lg: 0 28px 56px -22px rgba(16,32,52,.34);
  --ring:      0 0 0 3px rgba(27,135,192,.28);
}

/* ---------- brand face ----------
   Prata, self-hosted so the app makes no external requests and still works
   offline. Chosen to sit alongside the Design Studio lettering: the same
   high-contrast Didone weighting rather than a generic serif. */
@font-face {
  font-family: 'CarCare Display';
  src: url('../fonts/prata.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'CarCare Arabic';
  src: url('../fonts/plexarabic.woff2') format('woff2');
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.02em; font-weight: 650; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.18rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 .8em; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 10px; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.icon { flex: none; }

/* ---------- layout shell ---------- */
.shell { display: flex; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: blur(14px);
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 6px;
  /* The nav outgrew the viewport once Renewals, Pump prices and Service
     requests arrived — without this the lower items were unreachable. */
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 99px;
  border: 2px solid transparent; background-clip: content-box;
}
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }
/* Keep the account block at the bottom, but let it scroll away when space is tight. */
.sidebar-foot { flex: none; }
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 10px 18px; }
.brand-mark {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

/* The product name carries the studio's own typographic voice and gradient. */
.brand-name {
  font-family: 'CarCare Display', 'Didot', 'Bodoni 72', Georgia, serif;
  font-weight: 400;
  font-size: 1.44rem;
  line-height: 1.12;
  letter-spacing: .002em;
  display: block;
  background: linear-gradient(100deg, #5CD4F7 8%, #A98BE8 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
[data-theme="light"] .brand-name {
  /* the lifted pair is too pale on white — use the master artwork's own colours */
  background: linear-gradient(100deg, #1FA9DC 8%, #6F4B9E 92%);
  -webkit-background-clip: text;
  background-clip: text;
}

/* The studio logo sits under it, quieter and smaller. */
.brand-studio { display: block; opacity: .72; transition: opacity .18s ease; margin-top: 1px; }
.brand-studio img { display: block; height: auto; }
.brand:hover .brand-studio { opacity: .95; }
.brand-sub { font-size: .68rem; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; }

.nav-label {
  font-size: .66rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); padding: 16px 12px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  color: var(--text-dim); font-weight: 500;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text); }
.nav-item.is-active .icon { color: var(--accent); }
.nav-item .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--header-h); display: flex; align-items: center; gap: 12px;
  padding: 0 20px; position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.14rem; }
.topbar .spacer { flex: 1; }

.content { padding: 22px 20px 40px; width: 100%; max-width: 1240px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); font-size: .88rem; }
.page-head .spacer { flex: 1; }

/* ---------- cards ---------- */
.card {
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, transparent), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 18px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.card-head h2, .card-head h3 { font-size: .98rem; }
.card-head .spacer { flex: 1; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(275px, 1fr)); }
/* Two-column page layouts: wide content beside a narrower rail.
   Declared as classes (not inline styles) so the media queries can collapse them. */
.grid-split      { grid-template-columns: 1.45fr 1fr; align-items: start; }
.grid-split-form { grid-template-columns: 1.1fr .9fr; align-items: start; }
.span-2 { grid-column: span 2; }

/* ---------- stat tiles ---------- */
.stat { padding: 16px 17px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.stat .k { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 1.5rem; font-weight: 680; letter-spacing: -.03em; }
.stat .d { font-size: .8rem; color: var(--text-dim); }
.stat .tag { position: absolute; top: 14px; right: 14px; opacity: .5; }
.stat.accent .v { color: var(--accent); }
.stat.warn .v { color: var(--warn); }
.stat.danger .v { color: var(--danger); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; min-height: 42px;
  border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text);
  font-weight: 560; cursor: pointer; white-space: nowrap;
  transition: transform .12s ease, background .16s ease, border-color .16s ease, opacity .16s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary {
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 62%, var(--accent-2)));
  color: var(--accent-ink); border-color: transparent; font-weight: 640;
  box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--accent) 85%, transparent);
}
.btn-primary:hover { filter: brightness(1.06); background: linear-gradient(140deg, var(--accent), var(--accent-2)); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-outline { background: transparent; }
.btn-danger { background: color-mix(in srgb, var(--danger) 16%, transparent); border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 26%, transparent); }
.btn-sm { padding: 6px 11px; min-height: 34px; font-size: .84rem; border-radius: 10px; }
.btn-lg { padding: 14px 22px; min-height: 52px; font-size: 1.02rem; border-radius: 14px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field > label, .label {
  display: block; font-size: .78rem; font-weight: 600; letter-spacing: .04em;
  color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase;
}
.input, .select, .textarea {
  width: 100%; padding: 12px 14px; min-height: 46px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 12px;
  transition: border-color .16s, box-shadow .16s, background .16s;
  appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: var(--ring);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236F8298' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 38px;
}
.hint { font-size: .76rem; color: var(--muted); margin-top: 5px; }
.form-row { display: grid; gap: 0 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.input-affix { position: relative; }
.input-affix .affix {
  position: absolute; right: 13px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: .82rem; pointer-events: none;
}
.input-affix .input { padding-right: 54px; }

.check { display: flex; align-items: center; gap: 10px; padding: 10px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.check span { font-size: .92rem; color: var(--text-dim); text-transform: none; letter-spacing: 0; }

/* segmented choice cards (role picker, purpose, category) */
.choice-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice > div {
  border: 1px solid var(--line-strong); border-radius: 14px; padding: 13px 14px;
  background: var(--surface-2); transition: .16s; height: 100%;
}
.choice input:checked + div {
  border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.choice input:focus-visible + div { box-shadow: var(--ring); }
.choice .t { font-weight: 620; display: flex; align-items: center; gap: 8px; }
.choice .d { font-size: .78rem; color: var(--muted); margin-top: 3px; }

.segmented { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--line); }
.segmented a, .segmented button {
  padding: 7px 13px; border-radius: 9px; font-size: .86rem; color: var(--text-dim);
  background: transparent; border: 0; cursor: pointer; font-weight: 550;
}
.segmented .is-active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow); }

/* ---------- badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 620;
  background: var(--surface-3); color: var(--text-dim); white-space: nowrap;
}
.badge-good   { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.badge-warn   { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge-danger { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.badge-info   { background: color-mix(in srgb, var(--accent-2) 16%, transparent); color: var(--accent-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot-good { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.dot-warn { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.dot-danger { background: var(--danger); box-shadow: 0 0 10px var(--danger); }

.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface-2);
  font-size: .84rem; color: var(--text-dim); cursor: pointer; transition: .15s;
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip.is-active { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: var(--accent); color: var(--text); }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }

/* ---------- vehicle card ---------- */
.veh-card { overflow: hidden; display: flex; flex-direction: column; transition: transform .18s ease, border-color .18s; }
.veh-card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.veh-photo {
  height: 132px; background: var(--surface-2); position: relative;
  display: grid; place-items: center; overflow: hidden;
}
.veh-photo img { width: 100%; height: 100%; object-fit: cover; }
.veh-photo .plate {
  position: absolute; left: 12px; bottom: 12px; font-family: var(--mono);
  background: rgba(6,10,16,.72); backdrop-filter: blur(6px); color: #fff;
  padding: 4px 10px; border-radius: 8px; font-size: .78rem; letter-spacing: .06em;
}
.veh-photo .health { position: absolute; right: 12px; top: 12px; }
.veh-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.veh-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.veh-strip { display: flex; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: auto; }
.veh-strip > * { flex: 1; }

/* health ring */
.ring { position: relative; width: 46px; height: 46px; }
.ring svg { transform: rotate(-90deg); }
.ring .val {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: .74rem; font-weight: 700;
}

/* ---------- lists / tables ---------- */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 13px; padding: 13px 18px;
  border-bottom: 1px solid var(--line); transition: background .14s;
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .t { font-weight: 560; }
.list-row .s { font-size: .8rem; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.list-row .amt { font-weight: 640; white-space: nowrap; letter-spacing: -.02em; }
.avatar-ico {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-dim); flex: none;
}

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 560px; }
table.data th {
  text-align: left; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); font-weight: 650;
  white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- charts ---------- */
.chart { width: 100%; }
.chart .bar { transition: opacity .15s; cursor: default; }
.chart .bar:hover { opacity: .82; }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--text-dim); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; }
.spark { height: 44px; width: 100%; }

.progress { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }

/* ---------- alerts ---------- */
.alert {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 15px; border-radius: 14px; border: 1px solid var(--line-strong);
  background: var(--surface-2); font-size: .9rem; margin-bottom: 14px;
}
.alert-success { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 11%, var(--surface)); }
.alert-error   { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 11%, var(--surface)); }
.alert-warn    { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 11%, var(--surface)); }

.toast-wrap { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 18px); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast {
  padding: 12px 16px; border-radius: 14px; background: var(--surface-3);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow-lg); font-size: .9rem;
  animation: toast-in .28s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 46px 22px; color: var(--muted); }
.empty .ico {
  width: 62px; height: 62px; border-radius: 20px; margin: 0 auto 14px;
  display: grid; place-items: center; background: var(--surface-2); color: var(--accent);
}
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty p { max-width: 380px; margin: 0 auto 16px; font-size: .9rem; }

/* ---------- FAB ---------- */
.fab-wrap { position: fixed; right: 20px; bottom: calc(var(--tabbar-h) + 18px); z-index: 90; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.fab {
  width: 58px; height: 58px; border-radius: 20px; border: 0; cursor: pointer;
  background: linear-gradient(140deg, var(--brand-cyan, var(--accent)), var(--brand-violet, var(--accent-2)));
  color: #FFFFFF; display: grid; place-items: center;
  box-shadow: 0 16px 34px -12px color-mix(in srgb, var(--accent) 90%, transparent);
  transition: transform .2s cubic-bezier(.2,.9,.3,1.4);
}
.fab:active { transform: scale(.94); }
.fab.is-open { transform: rotate(45deg); }
.fab-menu { display: flex; flex-direction: column; align-items: flex-end; gap: 9px; }
.fab-menu a {
  display: flex; align-items: center; gap: 10px; padding: 10px 15px;
  background: var(--surface-3); border: 1px solid var(--line-strong);
  border-radius: 14px; box-shadow: var(--shadow); font-size: .9rem; font-weight: 550;
  animation: fab-in .22s backwards cubic-bezier(.2,.9,.3,1.2);
}
.fab-menu a:nth-child(2) { animation-delay: .04s; }
.fab-menu a:nth-child(3) { animation-delay: .08s; }
.fab-menu a:nth-child(4) { animation-delay: .12s; }
@keyframes fab-in { from { opacity: 0; transform: translateY(10px) scale(.9); } }
[hidden] { display: none !important; }

/* ---------- bottom tab bar (mobile) ---------- */
.tabbar {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}
.tabbar nav { display: flex; height: var(--tabbar-h); }
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: .66rem; color: var(--muted); font-weight: 560; letter-spacing: .01em;
}
.tabbar a.is-active { color: var(--accent); }

/* ---------- auth / marketing ---------- */
.auth-wrap { min-height: 100dvh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-art {
  padding: 46px; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(900px 500px at 20% 10%, rgba(61,199,243,.20), transparent 60%),
    radial-gradient(700px 460px at 90% 90%, rgba(111,75,158,.22), transparent 60%),
    var(--surface);
  border-right: 1px solid var(--line);
}
.auth-form { display: grid; place-items: center; padding: 34px 22px; }
.auth-card { width: min(430px, 100%); }
.auth-feature { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 18px; }
.auth-feature .ico { width: 38px; height: 38px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); display: grid; place-items: center; flex: none; }
.auth-feature .t { font-weight: 600; }
.auth-feature .d { font-size: .86rem; color: var(--text-dim); }

.hero { text-align: center; padding: 60px 20px 40px; }
.hero h1 { font-size: clamp(2rem, 5.5vw, 3.4rem); letter-spacing: -.035em; margin-bottom: 14px; }
.hero .grad {
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { font-size: clamp(1rem, 2.2vw, 1.18rem); color: var(--text-dim); max-width: 620px; margin: 0 auto 26px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  font-size: .8rem; font-weight: 600; margin-bottom: 18px;
}

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.dim { color: var(--text-dim); }
.small { font-size: .82rem; }
.tiny { font-size: .74rem; }
.strong { font-weight: 640; }
.mono { font-family: var(--mono); }
.right { text-align: right; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.gap-sm { gap: 6px; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* ---------- responsive ---------- */
/* On desktop the sidebar + header actions already cover quick-add. */
@media (min-width: 861px) {
  .fab-wrap { display: none; }
}

@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}
@media (max-width: 860px) {
  .grid-split, .grid-split-form, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .tabbar { display: block; }
  .content { padding: 16px 14px calc(var(--tabbar-h) + 92px); }
  .topbar { padding: 0 14px; }
  .grid { gap: 12px; }
  .span-2 { grid-column: span 2; }
}
@media (max-width: 560px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  h1 { font-size: 1.35rem; }
  .stat .v { font-size: 1.28rem; }
  .card-pad { padding: 15px; }
  .list-row { padding: 12px 14px; }
  /* A reminder row carries a status badge and three action buttons; on a phone
     those leave the text so little room that "Brake fluid" wraps mid-phrase and
     a date takes three lines. Give the text a floor and let the trailing
     controls drop to a second line. Rows with only a short amount (fuel,
     expenses) still fit on one line and are unaffected. */
  .list-row { flex-wrap: wrap; }
  .list-row .grow { min-width: 190px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- print (service history export) ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #fff; --surface-3: #f2f2f2; --text: #000; --text-dim: #333; --muted: #555; --line: #ddd; --line-strong: #bbb; }
  body { background: #fff; }
  .sidebar, .tabbar, .topbar, .fab-wrap, .no-print, .toast-wrap { display: none !important; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  a { color: #000; }
}

/* ---------- studio attribution ---------- */
.studio-credit {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  opacity: .78; transition: opacity .18s ease;
}
.studio-credit:hover { opacity: 1; }
.studio-credit img { height: auto; }
.lockup-product {
  display: block;
  font-weight: 600;
  font-size: .74rem;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: center;
  padding-top: 3px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}
.lockup.on-dark  { display: block; }
.lockup.on-light { display: none; }
[data-theme="light"] .lockup.on-dark  { display: none; }
[data-theme="light"] .lockup.on-light { display: block; }
.sidebar-foot .studio-credit { padding: 14px 12px 4px; opacity: .55; }
.center .studio-credit { align-items: center; display: inline-flex; }

/* ---------- install prompt ---------- */
.install-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 16px;
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.install-bar .ico { flex: none; display: grid; place-items: center; }
.install-bar .grow { flex: 1; min-width: 0; }

/* ---------- notification + import panels ---------- */
.switch-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.switch-row:last-child { border-bottom: 0; }
.switch-row .grow { flex: 1; min-width: 200px; }
[data-push][data-state="working"] { opacity: .65; }

.map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.map-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.map-row:last-child { border-bottom: 0; }
.map-row .col-name { font-family: var(--mono, monospace); font-size: .84rem; color: var(--text-dim); }
.preview-cell { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   Voice assistant
   ========================================================================== */

.voice { position: fixed; right: 20px; bottom: calc(var(--tabbar-h) + 88px); z-index: 95; }

.voice-btn {
  width: 54px; height: 54px; border-radius: 50%; border: 0; cursor: pointer; position: relative;
  background: linear-gradient(140deg, var(--brand-cyan, var(--accent)), var(--brand-violet, var(--accent-2)));
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 14px 30px -12px color-mix(in srgb, var(--brand-violet, var(--accent)) 90%, transparent);
  transition: transform .18s cubic-bezier(.2,.9,.3,1.4);
}
.voice-btn:active { transform: scale(.93); }
.voice[data-state="listening"] .voice-btn { animation: voice-breathe 1.4s ease-in-out infinite; }

.voice-pulse { position: absolute; inset: -6px; border-radius: 50%; pointer-events: none; }
.voice[data-state="listening"] .voice-pulse {
  border: 2px solid color-mix(in srgb, var(--brand-cyan, var(--accent)) 70%, transparent);
  animation: voice-ring 1.4s ease-out infinite;
}
@keyframes voice-breathe { 50% { transform: scale(1.06); } }
@keyframes voice-ring { 0% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(1.5); } }

.voice-panel {
  position: absolute; right: 0; bottom: 66px; width: min(340px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 18px;
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: voice-in .2s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes voice-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }

.voice-head {
  display: flex; align-items: center; gap: 9px; padding: 12px 14px;
  border-bottom: 1px solid var(--line); font-size: .88rem;
}
.voice-head .btn { margin-left: auto; }
.voice-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.voice[data-state="listening"] .voice-dot { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
.voice[data-state="thinking"] .voice-dot { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.voice[data-state="speaking"] .voice-dot,
.voice[data-state="done"] .voice-dot { background: var(--accent); box-shadow: 0 0 10px var(--accent); }

.voice-body { padding: 14px; min-height: 74px; }
.voice-said {
  font-size: .84rem; color: var(--muted); font-style: italic;
  margin: 0 0 8px; padding-left: 10px; border-left: 2px solid var(--line-strong);
}
.voice-reply { margin: 0; font-size: .95rem; line-height: 1.5; }
.voice-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.voice-type { display: flex; gap: 8px; padding: 0 14px 12px; }
.voice-type .input { min-height: 38px; font-size: .88rem; }

.voice-hints {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding: 11px 14px; border-top: 1px solid var(--line); background: var(--surface-2);
}
.voice-hints .chip { font-size: .74rem; padding: 4px 9px; }

/* Label-and-figure rows, used on the cost & value screen. */
.kv-list { display: flex; flex-direction: column; gap: 2px; }
.kv {
  display: flex; align-items: baseline; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.kv:last-child { border-bottom: 0; }
.kv > span { color: var(--muted); font-size: .9rem; display: flex; flex-direction: column; }
.kv > span .tiny { font-size: .72rem; }
.kv > strong { margin-left: auto; font-variant-numeric: tabular-nums; }
[dir="rtl"] .kv > strong { margin-left: 0; margin-right: auto; }
.kv > strong.danger { color: var(--danger); }

/* Which language the microphone listens for. */
.voice-lang {
  display: flex; gap: 6px; align-items: center;
  padding: 8px 14px; border-top: 1px solid var(--line);
}
.voice-lang .chip { font-size: .72rem; padding: 3px 10px; }
.voice-lang .chip.is-active { background: var(--accent); color: #fff; border-color: transparent; }

@media (max-width: 860px) {
  .voice { right: 16px; bottom: calc(var(--tabbar-h) + 80px); }
  .voice-btn { width: 48px; height: 48px; }
}
@media print { .voice { display: none !important; } }

/* ---------- feature tiers in settings ---------- */
.tier { padding: 13px 0; border-top: 1px solid var(--line); }
.tier:first-of-type { border-top: 0; padding-top: 4px; }
.tier-head { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; }
.voice-engine {
  font-family: var(--mono); font-size: .64rem; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); margin-left: auto; padding-right: 6px;
}

/* ---------- show/hide password ---------- */
.pw-wrap { position: relative; display: block; }
.pw-wrap .input { padding-right: 46px; }
.pw-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 9px; cursor: pointer;
  color: var(--muted); transition: color .15s ease, background .15s ease;
}
.pw-eye:hover { color: var(--text); background: var(--surface-3); }
.pw-eye:focus-visible { box-shadow: var(--ring); color: var(--text); }
.pw-eye[aria-pressed="true"] { color: var(--accent); }

/* ---------- offline queue indicator ---------- */
.offline-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 74px); z-index: 120;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 15px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg); font-size: .84rem; white-space: nowrap;
  max-width: calc(100vw - 32px);
}
.offline-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.offline-bar.is-offline .dot { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.offline-retry {
  background: transparent; border: 0; cursor: pointer; padding: 0 0 0 4px;
  color: var(--accent); font: inherit; font-weight: 600;
}
.offline-retry:hover { text-decoration: underline; }
@media print { .offline-bar { display: none !important; } }


/* ==========================================================================
   Right-to-left
   The layout is built on flex/grid with gap, which mirrors automatically.
   These rules cover the handful of places with a hard-coded side.
   ========================================================================== */

[dir="rtl"] .sidebar { border-right: 0; border-left: 1px solid var(--line); }
[dir="rtl"] .nav-item .badge { margin-left: 0; margin-right: auto; }
[dir="rtl"] .voice, [dir="rtl"] .fab-wrap { right: auto; left: 20px; }
[dir="rtl"] .voice-panel { right: auto; left: 0; }
[dir="rtl"] .fab-menu { align-items: flex-start; }
[dir="rtl"] .veh-photo .plate { left: auto; right: 12px; }
[dir="rtl"] .veh-photo .health { right: auto; left: 12px; }
[dir="rtl"] .input-affix .affix { right: auto; left: 13px; }
[dir="rtl"] .input-affix .input { padding-right: 14px; padding-left: 54px; }
/* The stat tile's icon, the password eye and the voice engine badge are all
   pinned to a physical edge; in Arabic the text runs to that same edge and
   collides with them. */
[dir="rtl"] .stat .tag { right: auto; left: 14px; }
[dir="rtl"] .pw-wrap .input { padding-right: 14px; padding-left: 46px; }
[dir="rtl"] .pw-eye { right: auto; left: 6px; }
[dir="rtl"] .voice-engine { margin-left: 0; margin-right: auto; padding-right: 0; padding-left: 6px; }
[dir="rtl"] .pw-wrap .input { padding-right: 14px; padding-left: 46px; }
[dir="rtl"] .pw-eye { right: auto; left: 6px; }
[dir="rtl"] .select {
  background-position: left 13px center;
  padding-right: 14px; padding-left: 38px;
}
[dir="rtl"] .voice-said { padding-left: 0; padding-right: 10px; border-left: 0; border-right: 2px solid var(--line-strong); }
[dir="rtl"] .num, [dir="rtl"] .right { text-align: left; }
[dir="rtl"] table.data th, [dir="rtl"] table.data td { text-align: right; }
[dir="rtl"] table.data th.num, [dir="rtl"] table.data td.num { text-align: left; }
[dir="rtl"] .wedge { border-left: 0; border-right: 3px solid var(--accent); }
[dir="rtl"] .note { border-left: 0; border-right: 3px solid var(--cyan, var(--accent)); }
[dir="rtl"] .list-row .amt { text-align: left; }
[dir="rtl"] .studio-credit, [dir="rtl"] .brand-text { text-align: right; }

/* Latin fragments inside Arabic — plate numbers, VINs, litres — must not flip. */
[dir="rtl"] .mono, [dir="rtl"] .plate, [dir="rtl"] input[type="email"],
[dir="rtl"] input[type="password"], [dir="rtl"] input[type="number"],
[dir="rtl"] input[type="date"], [dir="rtl"] input[type="month"] {
  direction: ltr;
  text-align: right;
}
[dir="rtl"] .brand-name { direction: ltr; text-align: right; }

/* Icons that imply direction should point the other way. */
[dir="rtl"] .btn .icon[aria-hidden="true"] { }

.lang-toggle { font-weight: 700; letter-spacing: .02em; min-width: 34px; }
