/* نظام المنصرفات — component sheet extracted from the approved Claude Design
   (docs/design/expenses.dc.html). Values mirror the design's inline styles 1:1. */

:root {
  --bg: #F5F4EF;
  --ink: #1B1E19;
  --ink-2: #3E423A;
  --muted: #6B6F66;
  --muted-2: #8B8E86;
  --th: #5E6259;
  --surface: #fff;
  --surface-2: #FBFAF7;
  --surface-3: #F7F6F2;
  --line: #E6E3DA;
  --line-2: #F0EEE8;
  --line-3: #EEECE5;
  --input: #DCD9CF;
  --track: #F0EEE8;
  --primary: #0E5A4A;
  --primary-2: #0A4236;
  --accent: #2F8A70;
  --accent-soft: #E3EFEA;
  --tag: #EEF3F0;
  --side: #13231E;
  --side-ink: #E6EDE8;
  --side-muted: #8FA59B;
  --side-nav: #B9C7C0;
  --side-bar: #6FCFAE;
  --amber: #E0A53A;
  --danger: #A2352A;
  --danger-line: #C9574A;
  --danger-soft: #F8E1DE;
  --warn-bg: #FBF3E2;
  --warn-line: #F0DDB2;
  --warn-ink: #8A5A00;
  --warn-ink-2: #5E3E00;
  --veh-bg: #F1F7F4;
  --veh-line: #BFDCCF;
  --veh-ink: #3F6E5F;
  --r-lg: 14px;
  --r-md: 12px;
  --r-sm: 10px;
  --r-btn: 9px;
  --r-in: 8px;
  --font: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --focus: 0 0 0 3px rgba(47, 138, 112, .35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); }
a:hover { color: var(--primary-2); }
input, select, textarea, button { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
[hidden] { display: none !important; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; inset-inline-start: 8px; top: -60px; z-index: 100; background: var(--primary); color: #fff; padding: 10px 14px; border-radius: var(--r-in); }
.skip-link:focus { top: 8px; color: #fff; }
:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex: none; position: sticky; top: 0; height: 100vh; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 22px 14px; gap: 24px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand__logo { width: 34px; height: 34px; border-radius: 9px; display: block; object-fit: cover; flex: none; }
.brand__logo--lg { width: 48px; height: 48px; border-radius: 12px; }
.brand__text { display: flex; flex-direction: column; }
.brand__name { font-weight: 700; font-size: 15px; }
.brand__sub { font-size: 12px; color: var(--side-muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--side-nav); text-decoration: none; font-size: 14px; }
.nav__item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav__item.is-active { background: rgba(255,255,255,.09); color: #fff; font-weight: 600; }
.nav__bar { width: 4px; height: 16px; border-radius: 2px; background: transparent; flex: none; }
.nav__item.is-active .nav__bar { background: var(--side-bar); }
.nav__badge { margin-inline-start: auto; font-size: 11px; background: var(--amber); color: var(--ink); border-radius: 10px; padding: 0 7px; font-weight: 700; }
.sidebar__user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #2A3D36; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex: none; color: #fff; }
.sidebar__who { display: flex; flex-direction: column; font-size: 13px; min-width: 0; }
.sidebar__who b { font-weight: 600; }
.sidebar__who span { color: var(--side-muted); font-size: 12px; }
.sidebar__links { display: flex; gap: 6px; padding: 0 8px; }
.sidebar__links a, .sidebar__links button { all: unset; cursor: pointer; font-size: 12px; color: var(--side-muted); padding: 4px 6px; border-radius: 6px; }
.sidebar__links a:hover, .sidebar__links button:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar__links :focus-visible { box-shadow: var(--focus); }

.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; position: sticky; top: 0; z-index: 20; background: var(--side); color: #fff; align-items: center; gap: 12px; padding: 10px 14px; }
.topbar__title { font-weight: 700; font-size: 16px; }
.topbar .avatar { margin-inline-start: auto; background: var(--accent); }
.burger { all: unset; cursor: pointer; width: 44px; height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border-radius: 8px; }
.burger span { width: 20px; height: 2px; background: #fff; border-radius: 2px; }
.burger:focus-visible { box-shadow: var(--focus); }
.main { padding: clamp(16px, 3vw, 36px); width: 100%; max-width: 1380px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }

/* Mobile menu (slide-in from the right, RTL) */
.mmenu__overlay { position: fixed; inset: 0; background: rgba(10,20,16,.45); z-index: 40; }
.mmenu { position: fixed; top: 0; bottom: 0; right: 0; width: min(290px, 85vw); background: var(--side); color: var(--side-ink); z-index: 41; padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.mmenu .nav__item { min-height: 46px; padding: 0 12px; }
.mmenu__close { all: unset; cursor: pointer; margin-inline-start: auto; width: 44px; height: 44px; text-align: center; line-height: 44px; font-size: 20px; border-radius: 8px; }
.mmenu__close:focus-visible { box-shadow: var(--focus); }

.fab { display: none; position: fixed; bottom: 20px; left: 20px; width: 58px; height: 58px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 28px; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(14,90,74,.35); z-index: 30; text-decoration: none; }
.fab:hover { color: #fff; background: var(--primary-2); }

/* ---------- Page head ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.page-head__titles { display: flex; flex-direction: column; gap: 2px; }
.page-head__sub { color: var(--muted); font-size: 13px; }
.page-title { font-size: clamp(22px, 3vw, 28px); font-weight: 700; }
.page-actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { color: var(--muted); font-size: 13px; text-decoration: none; }
.back-link:hover { color: var(--ink); }

/* ---------- Buttons ---------- */
.btn { appearance: none; border: 1px solid transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 16px; border-radius: var(--r-btn); font-weight: 500; text-decoration: none; background: var(--surface); color: var(--ink); white-space: nowrap; }
.btn:hover { color: var(--ink); }
.btn--primary { background: var(--primary); color: #fff; font-weight: 600; padding: 0 18px; }
.btn--primary:hover { background: var(--primary-2); color: #fff; }
.btn--outline { border-color: var(--input); background: var(--surface); }
.btn--outline:hover { background: var(--surface-3); }
.btn--dark { background: var(--side); color: #fff; }
.btn--dark:hover { color: #fff; background: #0c1814; }
.btn--danger { border-color: #E5B8B1; color: var(--danger); background: var(--surface); font-weight: 600; }
.btn--danger:hover { background: #FDF3F1; color: var(--danger); }
.btn--block { width: 100%; }
.btn--lg { height: 48px; border-radius: var(--r-sm); font-weight: 600; }
.btn--sm { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn__plus { font-size: 18px; line-height: 1; }
.btn[disabled], .btn.is-loading { opacity: .6; cursor: progress; }
.link-btn { appearance: none; border: 0; background: none; padding: 0; cursor: pointer; color: var(--primary); font-weight: 600; font-size: 13px; text-decoration: none; }
.link-btn:hover { color: var(--primary-2); text-decoration: underline; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card--pad { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.card--flush { overflow: hidden; }
.card__head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card__head h2, .card__title { font-size: 16px; font-weight: 600; }
.card__head .link-btn { margin-inline-start: auto; }
.section-title { font-size: 15px; font-weight: 600; }

/* ---------- Dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); }
.kpi__label { font-size: 13px; color: var(--muted); }
.kpi__value { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; overflow-wrap: anywhere; }
.kpi__unit { font-size: 14px; font-weight: 500; color: var(--muted); }
.kpi__meta { font-size: 12px; color: var(--muted); }
.kpi--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.kpi--primary .kpi__label, .kpi--primary .kpi__meta { color: #BFE0D4; }
.kpi--primary .kpi__unit { color: #fff; }
.kpi--pending { background: var(--warn-bg); border-color: var(--warn-line); }
.kpi--pending:hover { border-color: var(--amber); color: var(--ink); }
.kpi--pending .kpi__label, .kpi--pending .kpi__meta { color: var(--warn-ink); }
.kpi--pending .kpi__value { color: var(--warn-ink-2); }

.paycards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.paycard { border: 1px solid var(--line-3); border-radius: var(--r-sm); padding: 14px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.paycard__top { display: flex; justify-content: space-between; align-items: center; }
.paycard__name { font-weight: 600; }
.paycard__pct { font-size: 12px; color: var(--muted); }
.paycard__total { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: #ECEAE3; border-radius: 3px; overflow: hidden; }
.bar__fill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; }
.bar--thick { height: 10px; border-radius: 5px; background: var(--track); }
.bar--thick .bar__fill { background: var(--primary); border-radius: 5px; }
.bar--flex { flex: 1; background: var(--track); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; }
.catbars { display: flex; flex-direction: column; gap: 14px; }
.catbar { display: grid; grid-template-columns: 80px 1fr auto; gap: 12px; align-items: center; }
.catbar__name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catbar__total { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 64px; text-align: left; }

.recent { display: flex; flex-direction: column; gap: 0; }
.recent__item { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 8px; border-bottom: 1px solid var(--line-2); text-decoration: none; color: var(--ink); }
.recent__item:hover { background: var(--surface-3); color: var(--ink); }
.recent__ico { width: 38px; height: 38px; border-radius: 9px; background: var(--accent-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; }
.recent__body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.recent__desc { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent__meta { font-size: 12px; color: var(--muted); }
.recent__side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.recent__total { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Badges & tags ---------- */
.badge { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 10px; white-space: nowrap; }
.badge--sm { font-size: 11px; padding: 1px 8px; }
.badge--draft { background: #EEEDE8; color: #57594F; }
.badge--submitted { background: #FBF0D9; color: #8A5A00; }
.badge--approved { background: #DDEFE7; color: #0B5B47; }
.badge--rejected { background: var(--danger-soft); color: var(--danger); }
.badge--cancelled { background: #EEEDE8; color: #8B8E86; text-decoration: line-through; }
.badge--active { background: #DDEFE7; color: #0B5B47; }
.badge--inactive { background: #EEEDE8; color: #57594F; }
.tag { background: var(--tag); color: var(--primary); padding: 2px 9px; border-radius: 6px; white-space: nowrap; font-size: 13px; display: inline-block; }
.tag--sm { font-size: 12px; }
.plate { border: 1.5px solid var(--ink); border-radius: 5px; padding: 1px 10px; font-weight: 600; font-size: 13px; letter-spacing: .5px; white-space: nowrap; }

/* ---------- Filters & fields ---------- */
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.filters__wide { grid-column: span 2; min-width: 0; }
.filters__actions { display: flex; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.filters .field { gap: 4px; }
.field__label { font-size: 13px; color: var(--th); font-weight: 500; }
.filters .field__label { font-size: 12px; color: var(--muted); font-weight: 400; }
.field__hint { font-size: 11px; color: var(--muted-2); }
.field__error { font-size: 12px; color: var(--danger); min-height: 0; }
.req { color: var(--danger); }
.input, .select, .textarea { height: 44px; border: 1px solid var(--input); border-radius: var(--r-in); padding: 0 12px; background: var(--surface); outline: none; min-width: 0; width: 100%; }
.select { padding: 0 10px; }
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
.filters .input, .filters .select { height: 42px; background: var(--surface-2); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: var(--focus); }
.is-invalid .input, .is-invalid .select, .is-invalid .textarea, .input.is-invalid, .select.is-invalid { border-color: var(--danger-line); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px; }

.sumline { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; font-size: 13px; color: var(--muted); }
.sumline b { color: var(--ink); font-variant-numeric: tabular-nums; }
.sumline .sumline__total { color: var(--primary); font-size: 15px; }
.sumline .link-btn { margin-inline-start: auto; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table--md { font-size: 14px; }
.table th { background: var(--surface-3); color: var(--th); text-align: right; font-weight: 600; padding: 12px 10px; white-space: nowrap; }
.table td { padding: 12px 10px; border-top: 1px solid var(--line-2); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-inline-start: 20px; }
.table th:last-child, .table td:last-child { padding-inline-end: 20px; }
.table .num { text-align: left; font-variant-numeric: tabular-nums; }
.table .nowrap { white-space: nowrap; }
.table .strong { font-weight: 700; }
.table .dim { color: var(--muted); }
.table tr.is-link { cursor: pointer; }
.table tr.is-link:hover { background: #FAF9F5; }
.table tr.is-link:focus-within { background: #FAF9F5; }
.table .row-link { color: inherit; text-decoration: none; }
.table .desc { max-width: 240px; }
.table tfoot td, .table tr.total td { border-top: 2px solid var(--ink); background: var(--surface-3); font-weight: 700; padding-top: 14px; padding-bottom: 14px; }
.table tr.total .num:last-child, .table tfoot .num:last-child { color: var(--primary); }
.table--list { min-width: 1040px; }
.th-sort { color: inherit; text-decoration: none; display: inline-flex; gap: 4px; align-items: center; }
.th-sort:hover { color: var(--ink); }
.th-sort__ind { font-size: 10px; color: var(--accent); }
.time { color: var(--muted-2); }

.mcards { display: none; flex-direction: column; gap: 10px; }
.mcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--ink); }
.mcard:hover { color: var(--ink); border-color: var(--input); }
.mcard__top { display: flex; align-items: center; gap: 8px; }
.mcard__date { font-size: 12px; color: var(--muted); }
.mcard__top .badge { margin-inline-start: auto; }
.mcard__desc { font-weight: 600; }
.mcard__meta { font-size: 12px; color: var(--muted); }
.mcard__foot { display: flex; align-items: baseline; gap: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.mcard__foot .muted { font-size: 12px; }
.mcard__tax { margin-inline-start: auto; }
.mcard__total { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }

.empty { padding: 40px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--input); border-radius: var(--r-lg); }
.empty--inline { border: 0; background: none; padding: 30px; }

.pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; font-size: 13px; }
.pager a, .pager span { min-width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 10px; border-radius: 8px; border: 1px solid var(--input); background: var(--surface); color: var(--ink); text-decoration: none; }
.pager a:hover { background: var(--surface-3); }
.pager .is-current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pager .is-disabled { color: var(--muted-2); background: transparent; }
.pager__info { border: 0 !important; background: none !important; color: var(--muted) !important; }

/* ---------- Expense form ---------- */
.form-layout { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.form-main { flex: 1 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.form-aside { flex: 1 1 300px; min-width: 0; position: sticky; top: 20px; display: flex; flex-direction: column; gap: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { min-height: 40px; padding: 0 16px; display: flex; align-items: center; border-radius: 20px; border: 1px solid var(--input); background: var(--surface); color: var(--ink); font-weight: 500; cursor: pointer; user-select: none; }
.chip input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip input:focus-visible + span { box-shadow: var(--focus); }
.chip--method span { min-height: 48px; justify-content: center; border-radius: var(--r-sm); font-weight: 600; }
.chips--methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.chips.is-invalid .chip span { border-color: var(--danger-line); }
.fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.fieldset legend { padding: 0; margin-bottom: 8px; }

.veh-card { background: var(--veh-bg); border: 1px solid var(--veh-line); border-radius: var(--r-lg); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.veh-card .section-title { color: var(--primary-2); }
.veh-card .field__label { color: var(--veh-ink); }
.veh-card__sub { font-size: 12px; color: var(--veh-ink); }
.veh-card--optional { background: var(--surface); border-color: var(--line); }
.veh-card--optional .section-title { color: var(--ink); }
.veh-card--optional .field__label { color: var(--th); }
.veh-card--optional .veh-card__sub { color: var(--muted); }
.veh-card--optional .req { display: none; }

.seg { display: flex; background: #F2F1EC; border-radius: var(--r-sm); padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { min-height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 7px; padding: 0 10px; text-align: center; cursor: pointer; }
.seg input:checked + span { background: var(--surface); font-weight: 600; }
.seg input:focus-visible + span { box-shadow: var(--focus); }
.amount { display: flex; align-items: center; border: 1px solid var(--input); border-radius: var(--r-in); background: var(--surface); height: 52px; padding: 0 14px; gap: 8px; }
.amount:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.amount.is-invalid { border-color: var(--danger-line); }
.amount input { all: unset; flex: 1; min-width: 0; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.amount__cur { color: var(--muted); }
.rate-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--th); }
.rate-row .select { width: auto; height: 36px; }

.dropzone { border: 1.5px dashed #CFCCC2; background: var(--surface-2); border-radius: var(--r-md); padding: 22px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; cursor: pointer; position: relative; }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); }
.dropzone.has-files { border-color: var(--accent); background: var(--veh-bg); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone:focus-within { box-shadow: var(--focus); }
.dropzone__title { font-weight: 600; }
.dropzone.has-files .dropzone__title { color: var(--primary); }
.dropzone__sub { font-size: 12px; color: var(--muted); }
.files { display: flex; flex-direction: column; gap: 6px; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: var(--r-in); font-size: 13px; }
.file-row a { text-decoration: none; }
.file-row__size { color: var(--muted); font-size: 12px; margin-inline-start: auto; }

.summary { background: var(--side); color: var(--side-ink); border-radius: var(--r-lg); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.summary__label { font-size: 13px; color: var(--side-muted); }
.summary__row { display: flex; justify-content: space-between; gap: 10px; }
.summary__row span:last-child { font-variant-numeric: tabular-nums; }
.summary__sep { height: 1px; background: rgba(255,255,255,.12); }
.summary__total { display: flex; justify-content: space-between; align-items: baseline; }
.summary__total b { font-weight: 600; }
.summary__big { font-size: 30px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.summary__big small { font-size: 13px; color: var(--side-muted); font-weight: 400; }
.summary__hint { font-size: 12px; color: var(--side-muted); }
.flow-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.flow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.flow .badge { padding: 3px 10px; }
.flow__sep { color: #B4B6AE; }
.flow-note { font-size: 11px; color: var(--muted-2); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; border-bottom: 1px solid #E1DED4; }
.tabs a { white-space: nowrap; padding: 12px 14px; border-bottom: 2px solid transparent; color: var(--th); font-weight: 500; text-decoration: none; }
.tabs a:hover { color: var(--ink); }
.tabs a.is-active { border-bottom-color: var(--primary); color: var(--primary); font-weight: 700; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { min-height: 40px; padding: 0 16px; display: inline-flex; align-items: center; border-radius: 20px; border: 1px solid var(--input); background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; }
.pill:hover { color: var(--ink); border-color: var(--muted-2); }
.pill.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Reports ---------- */
.rep-head { padding: 20px; border-bottom: 1px solid var(--line-2); display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; }
.rep-head h2 { font-size: 18px; font-weight: 700; }
.rep-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-bottom: 1px solid var(--line-2); }
.rep-stat { padding: 16px 20px; display: flex; flex-direction: column; gap: 2px; border-inline-start: 1px solid var(--line-2); }
.rep-stat span { font-size: 12px; color: var(--muted); }
.rep-stat b { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rep-stat--total { background: var(--veh-bg); }
.rep-stat--total span { color: var(--veh-ink); }
.rep-stat--total b { color: var(--primary); }
.rep-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.rep-filters .field { flex: 0 1 180px; }
.rep-filters .input, .rep-filters .select { height: 40px; background: var(--surface); }
.hero { background: var(--side); color: #fff; border-radius: var(--r-lg); padding: 22px; display: flex; flex-wrap: wrap; gap: 16px 40px; align-items: center; }
.hero__item { display: flex; flex-direction: column; }
.hero__item span { font-size: 12px; color: var(--side-muted); }
.hero__item b { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card__h3 { padding: 16px 20px; font-size: 15px; font-weight: 600; border-bottom: 1px solid var(--line-2); }
.pct-cell { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.pct-cell__n { font-size: 12px; color: var(--muted); width: 36px; }
.vehcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 14px; }
.vehcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.vehcard__top { display: flex; align-items: center; gap: 10px; }
.vehcard__name { font-weight: 700; font-size: 17px; }
.vehcard__top .plate { margin-inline-start: auto; }
.stack { display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--track); }
.stack__seg { height: 100%; width: 0; }
.legend { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.legend__row { display: flex; align-items: center; gap: 8px; }
.legend__dot { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.legend__row b { margin-inline-start: auto; font-weight: 400; font-variant-numeric: tabular-nums; }
.vehcard__total { display: flex; border-top: 1px solid var(--line-2); padding-top: 10px; font-weight: 700; }
.vehcard__total span:last-child { margin-inline-start: auto; color: var(--primary); font-variant-numeric: tabular-nums; }
.c0 { background: #0E5A4A; } .c1 { background: #6FB59E; } .c2 { background: #E0A53A; } .c3 { background: #2F8A70; }
.c4 { background: #A2352A; } .c5 { background: #57594F; } .c6 { background: #BFDCCF; } .c7 { background: #8A5A00; }
.print-head { display: none; }

/* ---------- Settings ---------- */
.notice { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink-2); border-radius: var(--r-sm); padding: 12px 16px; font-size: 13px; }
.notice--error { background: var(--danger-soft); border-color: #E5B8B1; color: var(--danger); }
.notice--success { background: var(--veh-bg); border-color: var(--veh-line); color: var(--primary-2); }
.addbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.addbar .input { flex: 1 1 220px; width: auto; }
.addbar .check { height: 44px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.list-row:last-child { border-bottom: 0; }
.list-row.is-off { opacity: .6; }
.list-row__body { display: flex; flex-direction: column; min-width: 0; flex: 1 1 200px; }
.list-row__name { font-weight: 600; }
.list-row__meta { font-size: 12px; color: var(--muted); }
.list-row__state { font-size: 12px; color: #0B5B47; }
.list-row.is-off .list-row__state { color: var(--muted-2); }
.inline-edit { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex: 1 1 100%; padding-top: 4px; }
.inline-edit .input { height: 38px; flex: 1 1 180px; width: auto; }
.inline-edit .input--sm { flex: 0 0 90px; }
.switch { appearance: none; border: 0; cursor: pointer; width: 46px; height: 26px; border-radius: 13px; background: #CFCCC2; display: flex; align-items: center; justify-content: flex-start; padding: 3px; flex: none; }
.switch::after { content: ''; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch[aria-checked="true"] { background: var(--accent); justify-content: flex-end; }
.switch[disabled] { cursor: not-allowed; opacity: .75; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.proj-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.proj-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.proj-card__top { display: flex; align-items: center; gap: 8px; }
.proj-card__code { font-size: 12px; color: var(--muted); font-family: ui-monospace, monospace; }
.proj-card__top .badge { margin-inline-start: auto; }
.proj-card__name { font-size: 17px; font-weight: 700; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; font-size: 13px; }
.kv > div { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.kv span { color: var(--muted); font-size: 12px; }
.kv .span-2 { grid-column: span 2; }
.proj-card__actions { display: flex; gap: 8px; border-top: 1px solid var(--line-2); padding-top: 12px; }
.proj-card__actions > * { flex: 1; }
.proj-card__actions form { display: flex; }
.proj-card__actions .btn { flex: 1; height: 40px; border-radius: 8px; }
.gen-row { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.gen-row:last-child { border-bottom: 0; }
.gen-row__body { display: flex; flex-direction: column; flex: 1; min-width: 200px; }
.gen-row__body b { font-weight: 600; }
.gen-row__body span { font-size: 12px; color: var(--muted); }
.pct-input { display: flex; align-items: center; border: 1px solid var(--input); border-radius: 8px; height: 40px; padding: 0 12px; gap: 6px; font-weight: 700; background: var(--surface); }
.pct-input input { all: unset; width: 70px; text-align: center; direction: ltr; font-variant-numeric: tabular-nums; }
.pct-input:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.pct-input span { color: var(--muted); font-weight: 400; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }

/* ---------- Drawer (detail panel, slides from the left in RTL) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10,20,16,.45); z-index: 50; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(480px, 100%); background: var(--surface); z-index: 51; overflow-y: auto; display: flex; flex-direction: column; box-shadow: 0 0 40px rgba(0,0,0,.15); }
.drawer:focus { outline: none; }
.detail__head { padding: 18px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 10px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.detail__id { font-size: 12px; color: var(--muted); font-family: ui-monospace, monospace; }
.detail__close { appearance: none; border: 0; background: none; cursor: pointer; margin-inline-start: auto; width: 44px; height: 44px; font-size: 22px; color: var(--muted); border-radius: 8px; }
.detail__body { padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.detail__title { display: flex; flex-direction: column; gap: 4px; }
.detail__title span { font-size: 13px; color: var(--muted); }
.detail__title b { font-size: 19px; font-weight: 700; overflow-wrap: anywhere; }
.amounts3 { background: var(--surface-3); border-radius: var(--r-md); padding: 16px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; text-align: center; }
.amounts3 div { display: flex; flex-direction: column; }
.amounts3 span { font-size: 12px; color: var(--muted); }
.amounts3 b { font-weight: 600; font-variant-numeric: tabular-nums; }
.amounts3 .is-total { font-weight: 700; color: var(--primary); font-size: 17px; }
.receipts { display: flex; flex-direction: column; gap: 8px; }
.receipt-img { display: block; width: 100%; max-height: 260px; object-fit: contain; border-radius: var(--r-md); background: var(--surface-3); border: 1px solid var(--line-2); }
.receipt-none { height: 140px; border-radius: var(--r-md); background: repeating-linear-gradient(45deg, #F2F1EC 0 10px, #EAE8E1 10px 20px); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.timeline { display: flex; flex-direction: column; }
.timeline__title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.tl { display: flex; gap: 12px; }
.tl__rail { display: flex; flex-direction: column; align-items: center; }
.tl__dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: #B4B6AE; flex: none; }
.tl__line { flex: 1; width: 1px; background: var(--line); }
.tl__body { display: flex; flex-direction: column; padding-bottom: 14px; min-width: 0; }
.tl__what { font-weight: 600; font-size: 13px; }
.tl__who { font-size: 12px; color: var(--muted); }
.tl__why { font-size: 12px; color: var(--ink-2); background: var(--surface-3); border-radius: 6px; padding: 4px 8px; margin-top: 4px; }
.dot--submitted { background: var(--amber); } .dot--approved { background: var(--accent); } .dot--rejected { background: var(--danger); }
.dot--cancelled { background: #57594F; } .dot--draft { background: #B4B6AE; } .dot--edit { background: #6FB59E; }
.detail__foot { margin-top: auto; padding: 16px 20px; border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 10px; position: sticky; bottom: 0; background: var(--surface); }
.detail__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.detail__actions > * { flex: 1 1 140px; display: flex; }
.detail__actions .btn { flex: 1; }
.detail__note { font-size: 11px; color: var(--muted-2); text-align: center; }
.reason { display: flex; flex-direction: column; gap: 8px; }
.reason .textarea { min-height: 70px; }
.page-detail { max-width: 640px; }
.page-detail .detail__head, .page-detail .detail__foot { position: static; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--side); color: #fff; padding: 12px 20px; border-radius: var(--r-sm); z-index: 60; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 90vw; }
.toast--error { background: var(--danger); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--bg); }
.login__card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.login__brand { display: flex; align-items: center; gap: 10px; }
.login__brand .brand__sub { color: var(--muted); }
.error-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.error-card { width: min(480px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 28px; display: flex; flex-direction: column; gap: 12px; text-align: center; align-items: center; }
.error-card__code { font-size: 44px; font-weight: 700; color: var(--primary); }
.error-card small { color: var(--muted-2); font-family: ui-monospace, monospace; }

/* ---------- Audit ---------- */
.json { font-family: ui-monospace, monospace; font-size: 12px; color: var(--ink-2); white-space: pre-wrap; word-break: break-word; max-width: 420px; direction: ltr; text-align: left; }

/* ---------- Responsive: same 900px breakpoint as the design ---------- */
.only-mobile { display: none; }
@media (max-width: 899.98px) {
  .sidebar { display: none; }
  .topbar { display: flex; }
  .fab { display: flex; }
  .only-desktop { display: none !important; }
  .only-mobile { display: flex; }
  .mcards { display: flex; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; }
  .filters__wide { grid-column: 1 / -1; }
  .rep-filters .field { flex: 1 1 140px; }
  .form-aside { position: static; }
  .kpi__value { font-size: 26px; }
  .amounts3 { grid-template-columns: 1fr 1fr 1fr; padding: 12px; }
  .page-actions { margin-inline-start: 0; width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
}
@media (max-width: 420px) {
  .catbar { grid-template-columns: 64px 1fr auto; gap: 8px; }
  .kv { grid-template-columns: 1fr; }
  .kv .span-2 { grid-column: auto; }
}

/* ---------- Print ---------- */
@media print {
  .np, .sidebar, .topbar, .fab, .toast, .mmenu, .mmenu__overlay, .pager, .tabs, .pills, .rep-filters, .filters { display: none !important; }
  body, .app { background: #fff; }
  .main { padding: 0; max-width: none; }
  .card, .table-wrap { border-color: #ccc; }
  .table-wrap { overflow: visible; }
  .table--list { min-width: 0; }
  .only-desktop { display: block !important; }
  .mcards { display: none !important; }
  .print-head { display: block; font-size: 12px; color: #333; }
  a { color: inherit; text-decoration: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .drawer { animation: drawer-in .18s ease-out; }
  .mmenu { animation: menu-in .18s ease-out; }
  @keyframes drawer-in { from { transform: translateX(-24px); opacity: .6; } to { transform: none; opacity: 1; } }
  @keyframes menu-in { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
}
.error-card__actions { display: flex; gap: 8px; }

/* reports */
.rep-chips { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.rep-chip { padding: 8px 14px; border: 1px solid var(--input); border-radius: 8px; background: var(--surface); }
.rep-filters__check { height: 40px; }
.table-scroll { overflow-x: auto; }
.rep-table { min-width: 560px; }
.table .strong-500 { font-weight: 500; }
.table .pct-col { width: 28%; }
.table tr.group-row th { background: var(--surface-2); color: var(--ink); font-weight: 700; border-top: 1px solid var(--line); }
.table tr.subtotal td { background: var(--surface-3); font-weight: 600; border-top: 1px solid var(--line); }
.table .num-ltr { direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }
@media print {
  .rep-chips { display: none !important; }
  .hero { background: #fff; color: #000; border: 1px solid #ccc; }
  .hero__item span { color: #444; }
  .rep-table { min-width: 0; }
  .stack__seg, .legend__dot { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* settings */
.addbar .select { flex: 1 1 180px; width: auto; }
.inline-edit .select { height: 38px; flex: 1 1 160px; width: auto; }
.list-row .plate { font-size: 12px; margin-inline-start: 6px; }
.list-row .avatar { background: var(--accent-soft); color: var(--primary); }
.own-tag { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--primary); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.own-tag--supplier { background: var(--warn-bg); color: var(--warn-ink); }
.gen-row__body label { cursor: pointer; }
.gen-row.is-invalid .pct-input { border-color: var(--danger-line); }
.checks .check { align-items: flex-start; line-height: 1.4; }
.checks .check input { margin-top: 1px; flex: none; }
.fieldset.is-invalid .checks { outline: 1px solid var(--danger-line); outline-offset: 6px; border-radius: 4px; }

/* Account balances (opening balance per payment method) */
.rep-stats--balance { background: var(--surface-2); }
.rep-stat b.is-neg, .paycard__balance.is-neg b { color: var(--danger); }
.rep-note { margin: 0; padding: 8px 20px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line-2); }
.paycard__balance { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line-3); padding-top: 8px; }
.paycard__balance b { font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
.opening-fields { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.opening-fields .input { flex: 0 1 170px; }
.rep-section { margin-top: 20px; }
.rep-section__title { font-size: 16px; font-weight: 700; margin: 0 0 10px; }
.rep-table td.is-neg { color: var(--danger); }
