/* Petroleum — "Refinery" design system.
   Deep petrol blue for structure, amber fuel for action, warm sand paper. Tank gauges are the signature.
   Written with logical properties so Arabic (RTL) mirrors cleanly. Phone: bottom tab bar, card lists, bottom sheets. */

@font-face { font-family: 'Instrument Sans'; font-style: normal; font-display: swap; font-weight: 400 700; font-stretch: 75% 100%;
  src: url(../fonts/instrument-sans-latin-wdth-normal.woff2) format('woff2-variations'), url(../fonts/instrument-sans-latin-wdth-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Instrument Sans'; font-style: normal; font-display: swap; font-weight: 400 700; font-stretch: 75% 100%;
  src: url(../fonts/instrument-sans-latin-ext-wdth-normal.woff2) format('woff2-variations'), url(../fonts/instrument-sans-latin-ext-wdth-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }

:root {
  --bg: #f5f2ea; --surface: #ffffff; --surface-2: #faf8f3; --surface-3: #efeadf; --hover: #f7f3ea;
  --ink: #13212a; --ink-2: #3d4b55; --ink-3: #69757e; --ink-4: #9ba4aa;
  --line: #e9e3d6; --line-2: #d8cfbf;
  --petrol: #0b2530; --petrol-2: #113847; --petrol-3: #1a4b5e; --on-petrol: #eef5f7; --on-petrol-2: #9fb9c3;
  --primary: #0f5a6e; --primary-soft: #e2eff2;
  --amber: #f5a30a; --amber-2: #ffc94a; --amber-deep: #e07800; --amber-ink: #2b1a00; --amber-soft: #fff3d6;
  --green: #1f8a5b; --blue: #2f62c4; --red: #c63d2b; --violet: #6f48c2; --teal: #0f7f8a; --orange: #d9730d;
  --green-bg: #e2f4ea; --blue-bg: #e7eefb; --amber-bg: #fdf0d5; --red-bg: #fbe6e2; --violet-bg: #efe9fb; --gray-bg: #efebe3; --teal-bg: #def2f3;
  --shadow-1: 0 1px 2px rgb(19 33 42 / .06), 0 1px 1px rgb(19 33 42 / .03);
  --shadow-2: 0 8px 24px -6px rgb(19 33 42 / .14);
  --shadow-3: 0 24px 64px -12px rgb(11 37 48 / .35);
  --glow: 0 6px 20px -6px rgb(240 140 0 / .55);
  --r-sm: 8px; --r: 10px; --r-lg: 16px; --r-xl: 22px;
  --font: 'Instrument Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --side-w: 248px; --tabbar-h: 64px;
  color-scheme: light;
}
:root[lang="ar"] { --font: 'Segoe UI', Tahoma, 'Noto Sans Arabic', 'Instrument Sans', system-ui, sans-serif; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #081218; --surface: #0f1d25; --surface-2: #13232c; --surface-3: #1a2d37; --hover: #162832;
  --ink: #e8eff2; --ink-2: #b5c3c9; --ink-3: #8597a0; --ink-4: #5f717a; --line: #1e3039; --line-2: #2b414c;
  --petrol: #06151c; --petrol-2: #0d2733; --petrol-3: #163b4b;
  --primary: #6cc4d6; --primary-soft: #12313b; --amber-soft: #3a2a07;
  --green: #5cd096; --blue: #82a8f5; --red: #f2897a; --violet: #b69df5; --teal: #5ccbd4; --orange: #f0a35a;
  --green-bg: #12301f; --blue-bg: #17263e; --amber-bg: #362808; --red-bg: #3a1a15; --violet-bg: #251d3b; --gray-bg: #1a2a32; --teal-bg: #0f3033;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .45); --shadow-2: 0 10px 30px -8px rgb(0 0 0 / .6); --shadow-3: 0 28px 70px -10px rgb(0 0 0 / .75);
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #081218; --surface: #0f1d25; --surface-2: #13232c; --surface-3: #1a2d37; --hover: #162832;
  --ink: #e8eff2; --ink-2: #b5c3c9; --ink-3: #8597a0; --ink-4: #5f717a; --line: #1e3039; --line-2: #2b414c;
  --petrol: #06151c; --petrol-2: #0d2733; --petrol-3: #163b4b;
  --primary: #6cc4d6; --primary-soft: #12313b; --amber-soft: #3a2a07;
  --green: #5cd096; --blue: #82a8f5; --red: #f2897a; --violet: #b69df5; --teal: #5ccbd4; --orange: #f0a35a;
  --green-bg: #12301f; --blue-bg: #17263e; --amber-bg: #362808; --red-bg: #3a1a15; --violet-bg: #251d3b; --gray-bg: #1a2a32; --teal-bg: #0f3033;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .45); --shadow-2: 0 10px 30px -8px rgb(0 0 0 / .6); --shadow-3: 0 28px 70px -10px rgb(0 0 0 / .75);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 30px; line-height: 1.12; font-weight: 660; font-stretch: 80%; letter-spacing: -.025em; }
h2 { font-size: 15.5px; line-height: 1.3; font-weight: 640; letter-spacing: -.005em; }
h3 { font-size: 15px; font-weight: 640; }
:root[lang="ar"] h1, :root[lang="ar"] h2, :root[lang="ar"] h3 { letter-spacing: 0; font-stretch: 100%; }
:root[lang="ar"] h1 { font-weight: 700; line-height: 1.3; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--amber-2); color: var(--amber-ink); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.strong { font-weight: 620; }
.nowrap { white-space: nowrap; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.link { color: var(--primary); font-weight: 600; }
.link:hover { text-decoration: underline; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 28px; height: 28px; }
.spacer { flex: 1; }
[hidden] { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: grid; gap: 14px; align-content: start; }
.mobile-only { display: none !important; }

/* ---------- Boot ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--ink-3); text-align: center; padding: 24px; }
.boot img { width: 52px; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) scale(.94); } }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 680; font-size: 19px; letter-spacing: -.02em; font-stretch: 86%; min-width: 0; }
.brand img { width: 32px; height: 32px; flex-shrink: 0; filter: drop-shadow(0 4px 10px rgb(240 140 0 / .25)); }

/* ---------- Sign-in ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(400px, 1fr); background: var(--surface); }
.auth-art { position: relative; overflow: hidden; color: var(--on-petrol); padding: 40px 56px; display: flex; flex-direction: column; gap: 24px;
  background: radial-gradient(120% 80% at 85% 15%, rgb(245 163 10 / .22), transparent 55%), radial-gradient(90% 70% at 0% 100%, var(--petrol-3), transparent 60%), var(--petrol); }
.auth-art .tank-art { position: absolute; inset-inline-end: -40px; top: 50%; transform: translateY(-50%); width: min(520px, 62%); height: auto; color: #fff; opacity: .95; pointer-events: none; }
.auth-copy { margin-top: auto; position: relative; max-width: 28em; }
.auth-art h1 { font-size: clamp(38px, 4.6vw, 62px); font-stretch: 76%; line-height: 1.02; letter-spacing: -.035em; font-weight: 680; }
:root[lang="ar"] .auth-art h1 { line-height: 1.35; font-size: clamp(32px, 3.6vw, 48px); }
.auth-art p { color: var(--on-petrol-2); margin-top: 16px; font-size: 15.5px; line-height: 1.7; }
.auth-art .foot { color: #6f8e9a; font-size: 12.5px; position: relative; }
.auth-panel { display: grid; grid-template-rows: auto 1fr; padding: 20px 28px 40px; }
.auth-top { display: flex; align-items: center; gap: 10px; }
.auth-form { width: 100%; max-width: 370px; display: grid; gap: 16px; place-self: center; }
.auth-form h2 { font-size: 30px; font-stretch: 82%; font-weight: 680; letter-spacing: -.02em; }
:root[lang="ar"] .auth-form h2 { font-size: 26px; }
.auth-form .lede { color: var(--ink-3); margin-top: -8px; }
.form-error { color: var(--red); background: var(--red-bg); padding: 9px 12px; border-radius: var(--r); font-size: 13px; }
.form-error:empty { display: none; }

/* Tank art animation (sign-in) */
.fuel-wave { animation: wave 7s linear infinite; }
.fuel-wave.slow { animation-duration: 11s; animation-direction: reverse; }
@keyframes wave { to { transform: translateX(220px); } }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; color: var(--on-petrol-2); display: flex; flex-direction: column; padding: 18px 14px; gap: 4px; overflow-y: auto; z-index: 30;
  background: radial-gradient(140% 50% at 0% 0%, var(--petrol-2), transparent 70%), var(--petrol); scrollbar-width: thin; }
.sidebar .brand { color: var(--on-petrol); padding: 4px 8px 18px; }
.nav { display: grid; gap: 2px; }
.nav-group { font-size: 11px; color: #5e7d89; padding: 16px 12px 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
:root[lang="ar"] .nav-group { text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; font-size: 14px; color: var(--on-petrol-2); position: relative; transition: background .12s, color .12s; }
.nav a:hover { background: rgb(255 255 255 / .05); color: var(--on-petrol); }
.nav a.active { background: linear-gradient(90deg, rgb(245 163 10 / .18), rgb(245 163 10 / .04)); color: #fff; font-weight: 600; }
:root[dir="rtl"] .nav a.active { background: linear-gradient(270deg, rgb(245 163 10 / .18), rgb(245 163 10 / .04)); }
.nav a.active .icon { color: var(--amber-2); }
.nav a.active::before { content: ''; position: absolute; inset-inline-start: -14px; top: 9px; bottom: 9px; width: 4px; border-start-end-radius: 4px; border-end-end-radius: 4px; background: var(--amber); box-shadow: var(--glow); }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid rgb(255 255 255 / .07); }
.me { display: flex; align-items: center; gap: 10px; padding: 6px 4px 2px 8px; color: var(--on-petrol); }
.me .meta { flex: 1; min-width: 0; display: grid; }
.me small { color: var(--on-petrol-2); font-size: 11.5px; }
.me strong { font-size: 13px; font-weight: 600; }
.me .icon-btn { color: var(--on-petrol-2); }
.me .icon-btn:hover { background: rgb(255 255 255 / .07); color: #fff; }
.avatar { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(135deg, var(--amber-2), var(--amber-deep)); color: var(--amber-ink); font-weight: 750; font-size: 14px; flex-shrink: 0; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 12px 32px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); }
.top-brand, .top-title { display: none; }
.page { padding: 8px 32px 64px; display: grid; gap: 20px; align-content: start; width: 100%; margin-inline: auto; }
.tabbar { display: none; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; font-size: 13.5px; white-space: nowrap; box-shadow: var(--shadow-1); transition: background .12s, border-color .12s, transform .08s, box-shadow .12s; }
.btn:hover { background: var(--hover); border-color: var(--ink-4); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, var(--amber-2), var(--amber)); border-color: #e59500; color: var(--amber-ink); box-shadow: var(--glow), inset 0 1px 0 rgb(255 255 255 / .5); }
.btn.primary:hover { background: linear-gradient(180deg, #ffd365, #f7ab1c); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn.lg { height: 48px; font-size: 15px; border-radius: 12px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--r); color: var(--ink-2); transition: background .12s, color .12s; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.danger:hover { color: var(--red); background: var(--red-bg); }

/* ---------- Page pieces ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }
.ph-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow-1); min-width: 0; }
.card.flush { padding: 0; overflow-x: auto; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card > h2 { margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 12px; overflow-x: auto; scrollbar-width: none; inline-size: 100%; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1; text-align: center; padding: 8px 14px; border-radius: 9px; color: var(--ink-3); font-weight: 600; white-space: nowrap; font-size: 13.5px; transition: background .12s, color .12s; }
.tab:hover { color: var(--ink); }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 650; background: var(--gray-bg); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.amber { background: var(--amber-bg); color: var(--orange); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.teal { background: var(--teal-bg); color: var(--teal); }
.badge.violet { background: var(--violet-bg); color: var(--violet); }
.empty { display: grid; justify-items: center; gap: 12px; padding: 56px 20px; color: var(--ink-3); text-align: center; background: var(--surface); border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); }
.empty .icon { width: 44px; height: 44px; padding: 10px; border-radius: 14px; background: var(--amber-soft); color: var(--amber-deep); box-sizing: content-box; }

/* ---------- Filters & totals ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.ctl { display: grid; gap: 5px; font-size: 12px; color: var(--ink-3); font-weight: 600; min-width: 140px; }
.ctl.grow { flex: 1; min-width: 200px; }
.ctl.wide { min-width: 280px; }
.ctl .input { height: 38px; }
.filter-toggle { display: none; }
.search-box { position: relative; }
.search-box .icon { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-4); pointer-events: none; }
.search-box .input { padding-inline-start: 34px; }
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.totals > div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; display: grid; gap: 2px; box-shadow: var(--shadow-1); position: relative; overflow: hidden; }
.totals > div::after { content: ''; position: absolute; inset-inline-start: 0; inset-block: 12px; width: 3px; border-radius: 3px; background: var(--line-2); }
.totals > div:has(.pos)::after { background: var(--green); }
.totals > div:has(.neg)::after { background: var(--red); }
.totals span { font-size: 12px; color: var(--ink-3); font-weight: 560; }
.totals strong { font-size: 19px; font-weight: 680; font-stretch: 88%; }
:root[lang="ar"] .totals strong { font-stretch: 100%; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: start; font-weight: 640; font-size: 11.5px; color: var(--ink-3); padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; text-transform: uppercase; letter-spacing: .04em; }
:root[lang="ar"] .table th { text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover td { background: var(--hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 680; border-top: 2px solid var(--line-2); padding: 12px 16px; background: var(--surface-2); }
.table .r { text-align: end; }
.table td.num { white-space: nowrap; }
.table .acts { width: 1%; white-space: nowrap; text-align: end; }
.table tr.sub td { background: var(--surface-2); color: var(--ink-2); }
.card:not(.flush) .table th { background: transparent; }
.card:not(.flush) .table th, .card:not(.flush) .table td { padding-inline: 8px; }
.row-acts { display: inline-flex; gap: 2px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); min-width: 0; }
.input { width: 100%; height: 42px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s; font-weight: 450; color: var(--ink); }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 68px; }
.input:hover { border-color: var(--ink-4); }
.input:focus { border-color: var(--amber); box-shadow: 0 0 0 4px rgb(245 163 10 / .18); }
select.input { padding-inline-end: 28px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface-2); cursor: pointer; transition: border-color .12s, background .12s; }
.check:has(input:checked) { border-color: var(--green); background: var(--green-bg); }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--green); flex-shrink: 0; }
.check span { display: grid; gap: 2px; }
.check small { color: var(--ink-3); font-size: 12.5px; font-weight: 450; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 12px; }
.seg label { display: block; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 9px; border-radius: 9px; font-weight: 640; color: var(--ink-3); cursor: pointer; }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.seg input:focus-visible + span { outline: 2px solid var(--amber); }

/* ---------- Combo (searchable dropdown with "Add …") ---------- */
.combo { position: relative; }
.combo .combo-input { padding-inline-end: 32px; }
.combo-caret { position: absolute; inset-inline-end: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-4); pointer-events: none; }
.ctl .combo-caret { top: 19px; }
.combo-list { position: absolute; z-index: 60; inset-inline: 0; top: calc(100% + 6px); max-height: 270px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow-2); padding: 5px; }
.combo-opt { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 11px; border-radius: 8px; text-align: start; font-weight: 500; color: var(--ink); }
.combo-opt small { margin-inline-start: auto; color: var(--ink-3); direction: ltr; }
.combo-opt.active, .combo-opt:hover { background: var(--hover); }
.combo-opt.add { color: var(--amber-deep); font-weight: 680; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; margin-top: 3px; }
.combo-opt.add .icon { background: var(--amber-soft); border-radius: 6px; padding: 2px; box-sizing: content-box; }
.combo-empty { padding: 12px; color: var(--ink-3); font-size: 13px; }

/* ---------- Dialogs ---------- */
dialog { border: 0; padding: 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3); }
dialog::backdrop { background: rgb(6 21 28 / .5); backdrop-filter: blur(3px); }
dialog.modal { border-radius: var(--r-xl); width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); overflow: visible; }
dialog.modal[open] { animation: pop .18s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
dialog.modal.wide { width: min(800px, calc(100vw - 24px)); }
dialog > form, dialog { display: flex; flex-direction: column; }
dialog:not([open]) { display: none; }
.dlg-grip { display: none; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 8px; }
.dlg-head h2 { font-size: 19px; font-stretch: 86%; font-weight: 680; }
:root[lang="ar"] .dlg-head h2 { font-stretch: 100%; }
.dlg-body { padding: 8px 20px 18px; display: grid; gap: 14px; overflow: visible; }
.dlg-foot { display: flex; gap: 8px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); }

/* More sheet (phone) */
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.more-item { display: grid; justify-items: center; gap: 8px; padding: 16px 8px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; font-size: 13px; text-align: center; }
.more-item.active { border-color: var(--amber); background: var(--amber-soft); }
.mi-ic { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--petrol); color: var(--amber-2); }
.more-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.more-row .btn { height: 46px; }
.me-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.me-card .meta { flex: 1; display: grid; min-width: 0; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 100; inset-block-end: 22px; inset-inline-start: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 24px)); }
:root[dir="rtl"] .toasts { transform: translateX(50%); }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; background: var(--petrol); color: var(--on-petrol); border-radius: 14px; box-shadow: var(--shadow-2); font-size: 13.5px; font-weight: 520; animation: up .2s ease-out; border-inline-start: 4px solid var(--amber); }
.toast span { flex: 1; }
.toast.err { background: var(--red); color: #fff; border-color: #7a1d10; }
.toast .x { color: inherit; opacity: .7; display: grid; }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Tank gauge (signature) ---------- */
.gauge { position: relative; width: 48px; height: 76px; border-radius: 14px; background: var(--surface-3); border: 2px solid var(--line-2); overflow: hidden; flex-shrink: 0; box-shadow: inset 0 2px 6px rgb(0 0 0 / .06); }
.gauge.lg { width: 76px; height: 124px; border-radius: 20px; }
.gauge-fill { position: absolute; inset-inline: 0; bottom: 0; background: linear-gradient(180deg, var(--amber-2), var(--amber-deep)); transition: block-size .6s cubic-bezier(.2, .8, .2, 1); }
.gauge-fill i { position: absolute; top: -6px; inset-inline-start: -50%; width: 200%; height: 12px; background: radial-gradient(10px 7px at 10px 7px, var(--amber-2) 98%, transparent) 0 0 / 20px 12px repeat-x; animation: slosh 3s linear infinite; }
.gauge.mid .gauge-fill { background: linear-gradient(180deg, #ffb35c, var(--orange)); }
.gauge.mid .gauge-fill i { background-image: radial-gradient(10px 7px at 10px 7px, #ffb35c 98%, transparent); }
.gauge.low .gauge-fill { background: linear-gradient(180deg, #f59a8d, var(--red)); }
.gauge.low .gauge-fill i { background-image: radial-gradient(10px 7px at 10px 7px, #f59a8d 98%, transparent); }
.gauge-ticks { position: absolute; inset-block: 12% 12%; inset-inline-end: 6px; width: 7px; background: repeating-linear-gradient(180deg, rgb(19 33 42 / .25) 0 1.5px, transparent 1.5px 25%); pointer-events: none; }
@keyframes slosh { to { transform: translateX(20px); } }

/* ---------- Dashboard ---------- */
.hero { position: relative; overflow: hidden; border-radius: var(--r-xl); padding: 28px 30px; color: var(--on-petrol); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: end; box-shadow: var(--shadow-2);
  background: radial-gradient(70% 120% at 100% 0%, rgb(245 163 10 / .28), transparent 60%), radial-gradient(60% 90% at 0% 100%, var(--petrol-3), transparent 70%), var(--petrol); }
:root[dir="rtl"] .hero { background: radial-gradient(70% 120% at 0% 0%, rgb(245 163 10 / .28), transparent 60%), radial-gradient(60% 90% at 100% 100%, var(--petrol-3), transparent 70%), var(--petrol); }
.hero::after { content: ""; position: absolute; inset-inline: 0; bottom: -1px; height: 14px; opacity: .1; pointer-events: none; z-index: 0;
  background: radial-gradient(60px 14px at 60px 14px, #ffc94a 98%, transparent) 0 0 / 120px 28px repeat-x; animation: slosh-wide 9s linear infinite; }
@keyframes slosh-wide { to { background-position-x: 120px; } }
.hero-date { color: var(--on-petrol-2); font-size: 13px; font-weight: 560; }
.hero h1 { font-size: 34px; margin-top: 4px; color: #fff; }
.hero-balances { display: flex; flex-wrap: wrap; gap: 10px 0; margin-top: 22px; }
.hero-balances a { display: grid; gap: 2px; padding-inline: 0 26px; margin-inline-end: 26px; border-inline-end: 1px solid rgb(255 255 255 / .12); }
.hero-balances a:last-child { border: 0; margin: 0; padding: 0; }
.hero-balances small { color: var(--on-petrol-2); font-size: 12.5px; font-weight: 560; }
.hero-balances strong { font-size: 26px; font-weight: 680; font-stretch: 82%; color: #fff; }
.hero-balances a:first-child strong { color: var(--amber-2); }
.hero-actions { display: grid; grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 8px; position: relative; z-index: 1; }
.qa { display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 10px; border-radius: 14px; background: rgb(255 255 255 / .07); border: 1px solid rgb(255 255 255 / .1); color: #fff; font-weight: 600; font-size: 13px; text-align: start; transition: background .12s, transform .08s; }
.qa:hover { background: rgb(255 255 255 / .13); }
.qa:active { transform: scale(.98); }
.qa span { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(180deg, var(--amber-2), var(--amber)); color: var(--amber-ink); flex-shrink: 0; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow-1); transition: border-color .12s, transform .12s; }
.stat:hover { border-color: var(--line-2); transform: translateY(-1px); }
.stat-ic { grid-row: span 2; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.stat.pos .stat-ic { background: var(--green-bg); color: var(--green); }
.stat.neg .stat-ic { background: var(--red-bg); color: var(--red); }
.stat small { color: var(--ink-3); font-size: 12px; font-weight: 560; }
.stat strong { font-size: 20px; font-weight: 680; font-stretch: 86%; }
.stat.pos strong { color: var(--green); }
.stat.neg strong { color: var(--red); }
:root[lang="ar"] .stat strong, :root[lang="ar"] .hero-balances strong { font-stretch: 100%; }
.tanks { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.tank-item { display: flex; align-items: flex-end; gap: 12px; padding: 12px 18px 12px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); min-width: 190px; transition: border-color .12s; }
.tank-item:hover { border-color: var(--amber); }
.tank-item div { display: grid; min-width: 0; }
.tank-item span { font-size: 18px; font-weight: 680; font-stretch: 88%; }
.dash { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dash-side { display: grid; gap: 16px; }
.feed { list-style: none; margin: 0; padding: 0; display: grid; }
.feed li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.feed li:last-child { border-bottom: 0; }
.feed-main { flex: 1; min-width: 0; display: grid; }
.feed-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; background: var(--gray-bg); color: var(--ink-2); }
.feed-ic.green { background: var(--green-bg); color: var(--green); } .feed-ic.blue { background: var(--blue-bg); color: var(--blue); }
.feed-ic.red { background: var(--red-bg); color: var(--red); } .feed-ic.amber { background: var(--amber-bg); color: var(--orange); }
.feed-ic.teal { background: var(--teal-bg); color: var(--teal); } .feed-ic.violet { background: var(--violet-bg); color: var(--violet); }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.rank a { display: flex; gap: 10px; align-items: baseline; }
.rank-name { flex: 1; font-weight: 560; }
.rank-bar { display: block; height: 6px; border-radius: 3px; background: var(--surface-3); margin-top: 6px; overflow: hidden; }
.rank-bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--amber), var(--amber-2)); }
.settled { display: flex; align-items: center; gap: 6px; }
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.bars { display: grid; gap: 14px; }
.bar-row { display: grid; gap: 6px; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--amber-deep), var(--amber-2)); }
:root[dir="rtl"] .bar i, :root[dir="rtl"] .rank-bar i { background: linear-gradient(270deg, var(--amber-deep), var(--amber-2)); }

/* ---------- Inventory ---------- */
.stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.stock-card { display: flex; gap: 18px; align-items: stretch; }
.stock-info { flex: 1; min-width: 0; display: grid; gap: 10px; align-content: start; }
.stock-card .big { font-size: 30px; font-weight: 700; font-stretch: 80%; line-height: 1.1; }
:root[lang="ar"] .stock-card .big { font-stretch: 100%; font-size: 26px; }
.mini { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.mini.three { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.mini dt { font-size: 12px; color: var(--ink-3); font-weight: 560; }
.mini dd { margin: 0; font-weight: 640; }

/* ---------- Expenses, reports, settings ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.printable { display: grid; gap: 16px; }
.printable.narrow { max-width: none; }
.print-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 14px; border-bottom: 2px solid var(--ink); }
.print-head > div:last-child { text-align: end; }
.print-head h2 { font-size: 20px; font-stretch: 86%; }
.print-head p { color: var(--ink-3); margin-top: 2px; }
.print-foot { display: none; }
.pnl td { padding: 12px 16px; font-size: 14.5px; }
.page-reports .printable.card { padding: 28px 32px; }
.page-reports .filters { justify-content: center; }
.pnl tr.head td { font-weight: 680; }
.pnl tr.indent td:first-child { padding-inline-start: 28px; color: var(--ink-2); }
.pnl tr.total td { font-weight: 680; border-top: 1px solid var(--line-2); }
.pnl tr.grand td { font-size: 20px; font-weight: 750; border-top: 2px solid var(--ink); padding-block: 16px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.settings-grid > section { grid-column: 1 / -1; }

/* Numbers and dates stay left-to-right inside Arabic text. */
:root[dir="rtl"] .num, :root[dir="rtl"] td.nowrap { unicode-bidi: isolate; }
:root[dir="rtl"] input[type="date"], :root[dir="rtl"] input[type="number"] { text-align: right; }

/* ---------- Medium screens ---------- */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { grid-template-columns: 1fr; }
  .hero-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dash { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) { .auth { grid-template-columns: 1fr 1fr; } .auth-art { padding: 32px; } }

/* ---------- Phone & small tablet ---------- */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .shell { display: block; }
  .sidebar { display: none; }
  .topbar { padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); gap: 6px; border-bottom: 1px solid var(--line); }
  .top-brand { display: grid; }
  .top-brand img { width: 30px; height: 30px; }
  .top-title { display: block; font-size: 18px; font-weight: 700; font-stretch: 86%; margin-inline-start: 4px; }
  .lang span { display: none; }
  .lang { width: 38px; padding: 0; }
  .page { padding: 14px 14px calc(var(--tabbar-h) + 96px + env(safe-area-inset-bottom)); gap: 14px; }
  .page-head .ph-title { display: none; }
  .page-head { justify-content: flex-start; }
  .page-head:not(:has(.ph-acts > :not(.primary))) { display: contents; }
  /* The page's main action floats above the tab bar. */
  .ph-acts .btn.primary { position: fixed; z-index: 35; inset-inline-end: 16px; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); height: 54px; padding: 0 20px; border-radius: 18px; font-size: 15px; box-shadow: 0 10px 28px -6px rgb(224 120 0 / .65), inset 0 1px 0 rgb(255 255 255 / .5); }
  .ph-acts .btn.primary .icon { width: 20px; height: 20px; }

  /* Bottom tab bar */
  .tabbar { position: fixed; z-index: 40; inset-inline: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--petrol) 94%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid rgb(255 255 255 / .06); }
  .tabbar > a, .tabbar > button { display: grid; justify-items: center; align-content: center; gap: 3px; color: var(--on-petrol-2); font-size: 11px; font-weight: 600; min-width: 0; }
  .tb-ic { width: 46px; height: 28px; border-radius: 14px; display: grid; place-items: center; transition: background .15s; }
  .tabbar .active { color: #fff; }
  .tabbar .active .tb-ic { background: linear-gradient(180deg, var(--amber-2), var(--amber)); color: var(--amber-ink); box-shadow: var(--glow); }
  .tb-l { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-inline: 2px; }

  h1 { font-size: 26px; }
  .card, .page-reports .printable.card { padding: 16px; border-radius: 14px; }
  .input { height: 46px; font-size: 16px; }
  textarea.input { font-size: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .tabs { inline-size: auto; }
  .tab { flex: 1; text-align: center; padding: 9px 10px; }

  /* Filters: search stays, the rest folds behind "Filters". */
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .filters .ctl { min-width: 0; }
  .filters .ctl.grow, .filters .ctl.wide { grid-column: 1 / -1; }
  .filters:has(.filter-toggle) { grid-template-columns: 1fr auto; }
  .filters:has(.filter-toggle) .ctl.grow { grid-column: 1; grid-row: 1; }
  .filter-toggle { display: inline-flex; height: 46px; align-self: end; grid-column: 2; grid-row: 1; }
  .filters:not(:has(.ctl.grow)) .filter-toggle { grid-column: 1 / -1; }
  .filter-toggle[aria-expanded="true"] { border-color: var(--amber); background: var(--amber-soft); }
  .filters:has(.filter-toggle) .ctl:not(.grow):not(.wide) { display: none; }
  .filters-open .filters:has(.filter-toggle) .ctl:not(.grow):not(.wide) { display: grid; grid-column: 1 / -1; }
  .totals { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-inline: -14px; padding: 2px 14px 4px; scroll-snap-type: x proximity; }
  .totals::-webkit-scrollbar { display: none; }
  .totals > div { flex: 0 0 auto; min-width: 128px; scroll-snap-align: start; }
  .filters .ctl.grow > span { display: none; }
  .card .totals { margin-inline: -16px; padding-inline: 16px; }
  .totals > div { padding: 10px 12px; }
  .totals strong { font-size: 16px; }

  /* Tables become cards */
  .card.flush:has(.cardify) { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .table.cardify, .table.cardify tbody, .table.cardify tfoot { display: block; }
  .table.cardify thead { display: none; }
  .table.cardify tr { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; position: relative; padding: 12px 14px; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-1); }
  .table.cardify tr.sub { background: var(--surface-2); }
  .table.cardify td { display: grid; align-content: start; gap: 0; padding: 3px 0; border: 0; text-align: start; min-width: 0; background: transparent !important; white-space: normal; }
  .table.cardify td[data-label]::before { content: attr(data-label); font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
  .table.cardify td:empty { display: none; }
  .table.cardify td.strong:first-child, .table.cardify td.strong:nth-child(2) { grid-column: 1 / -1; font-size: 16px; }
  .table.cardify td.acts { position: absolute; top: 8px; inset-inline-end: 8px; width: auto; padding: 0; }
  .table.cardify td.acts::before { display: none; }
  .table.cardify tr:has(td.acts .row-acts) td:first-child { padding-inline-end: 72px; }
  .table.cardify td.r { text-align: start; }
  .table.cardify tfoot tr { background: var(--petrol); color: var(--on-petrol); border: 0; }
  .table.cardify tfoot td { background: transparent; }
  .table.cardify tfoot td::before { color: var(--on-petrol-2); }
  .card:not(.flush) .table.cardify tr { box-shadow: none; background: var(--surface-2); }
  .card:not(.flush) .table.cardify tfoot tr { background: var(--petrol); }
  .card:not(.flush) .table.cardify td { padding-inline: 0; }

  /* Bottom sheets */
  dialog.modal, dialog.modal.wide { width: 100%; max-width: none; margin: auto 0 0; border-radius: 22px 22px 0 0; max-height: 92dvh; overflow: hidden; }
  dialog.modal[open] { animation: sheet .24s cubic-bezier(.2, .9, .3, 1); }
  dialog.modal > form { min-height: 0; flex: 1; display: flex; flex-direction: column; }
  .dlg-grip { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 8px auto 0; flex-shrink: 0; }
  .dlg-head { padding: 8px 18px 6px; }
  .dlg-body { overflow-y: auto; padding: 8px 18px 20px; overscroll-behavior: contain; flex: 1; min-height: 0; }
  .dlg-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-radius: 0; }
  .dlg-body:last-child { padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
  .dlg-foot .btn { height: 48px; flex: 1; font-size: 15px; }
  .dlg-foot .spacer { display: none; }
  .combo-list { max-height: 220px; }
  .toasts { inset-block-end: calc(var(--tabbar-h) + 84px + env(safe-area-inset-bottom)); }

  /* Dashboard */
  .hero { padding: 22px 18px 18px; border-radius: 20px; gap: 18px; }
  .hero h1 { font-size: 28px; }
  .hero-balances { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
  .hero-balances a, .hero-balances a:last-child { border: 0; margin: 0; padding: 0; }
  .hero-balances a:first-child { grid-column: 1 / -1; }
  .hero-balances a:first-child strong { font-size: 34px; }
  .hero-balances strong { font-size: 20px; }
  .hero-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .qa { flex-direction: column; text-align: center; padding: 10px 4px; gap: 6px; font-size: 11.5px; line-height: 1.25; }
  .qa span { width: 40px; height: 40px; border-radius: 12px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { grid-template-columns: 1fr; padding: 14px; row-gap: 2px; }
  .stat-ic { grid-row: auto; width: 34px; height: 34px; margin-bottom: 6px; }
  .stat strong { font-size: 17px; }
  .tank-item { min-width: 160px; }

  /* Inventory, reports, settings */
  .stock-grid { grid-template-columns: 1fr; }
  .two, .settings-grid { grid-template-columns: 1fr; }
  .print-head { flex-direction: column; }
  .print-head > div:last-child { text-align: start; }
  .ctl.wide { min-width: 0; }
  .mobile-only { display: flex !important; }
}
@keyframes sheet { from { transform: translateY(40%); opacity: .4; } }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-panel { min-height: 100vh; background: radial-gradient(100% 40% at 50% 0%, rgb(245 163 10 / .16), transparent 70%), var(--surface); }
  .auth-panel .brand.mobile-only { display: flex !important; }
  .auth-form .input { height: 48px; font-size: 16px; }
}
@media (max-width: 380px) { .hero-actions .qa { font-size: 10.5px; } .tb-l { font-size: 10px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; } }

/* ---------- Print ---------- */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; color: #000; font-size: 12px; }
  .sidebar, .topbar, .tabbar, .tabs, .no-print, .page-head, .row-acts, .toasts, .filters { display: none !important; }
  .shell { display: block; }
  .page { padding: 0; }
  .card, .page-reports .printable.card { border: 0; box-shadow: none; padding: 0; }
  .print-foot { display: block; }
  .table th { background: #f2f2f2 !important; color: #000; }
  .totals > div { box-shadow: none; }
  .pos, .neg { color: #000; }
}
