/* نظام إدارة الأسطول والمواقع الزراعية — الأنماط */
:root {
  --palm: #1E4636;      /* الأخضر الداكن: القائمة والأزرار الرئيسية */
  --palm-2: #2A5A46;
  --palm-ink: #E4EFE7;
  --leaf: #CFE3D4;
  --bg: #EEF1EE;        /* سطح رمادي مخضر هادئ */
  --panel: #FFFFFF;
  --ink: #17201B;
  --muted: #5F6B64;
  --line: #DCE2DD;
  --ok: #2F7D4F;
  --warn: #A86A12;
  --bad: #B3261E;
  --idle: #8A938D;
  --warn-bg: #FBF1DF;
  --bad-bg: #FBE7E5;
  --r: 12px;
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --side: 264px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font); }
h1, h2 { margin: 0; line-height: 1.3; }
h1 { font-size: 1.45rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 600; }
a { color: var(--palm); }
.num, .plate { font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
.code { display: inline-block; direction: ltr; unicode-bidi: isolate; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pad { padding: 12px 16px; margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ic { width: 22px; height: 22px; flex: none; }
:focus-visible { outline: 3px solid #6FA884; outline-offset: 2px; }

/* أزرار وحقول */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--palm); border-color: var(--palm); color: #fff; }
.btn-primary:hover { background: var(--palm-2); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn-lg { min-height: 52px; font-size: 1.05rem; }
.wide { width: 100%; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
.field { display: grid; gap: 6px; font-weight: 500; }
input, select { font: inherit; min-height: 46px; padding: 0 12px; border: 1px solid #C8D0CA; border-radius: 10px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus { outline: 3px solid #A9CDB4; border-color: var(--palm); }
.form-error { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--bad-bg); color: var(--bad); font-weight: 500; }

/* الهيكل */
.layout { min-height: 100dvh; }
.sidebar { display: none; }
.main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: 1fr auto; gap: 10px 12px; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--panel); border-bottom: 1px solid var(--line); }
.tb-title { display: grid; min-width: 0; }
.tb-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-meta { display: flex; gap: 10px; color: var(--muted); font-size: .85rem; }
.tb-actions { display: flex; gap: 8px; align-items: center; grid-row: 1; grid-column: 2; }
.btn-add span { display: none; }
.btn-add { padding: 0 12px; }
.search { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid #C8D0CA; border-radius: 10px; background: #F7F9F7; }
.search input { border: 0; background: transparent; min-height: 44px; padding: 0; }
.search input:focus { outline: none; }
.search:focus-within { outline: 3px solid #A9CDB4; border-color: var(--palm); }
.badge { position: absolute; top: -6px; inset-inline-start: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--bad); color: #fff; font-size: .75rem; line-height: 20px; font-weight: 700; }

.pop-wrap { position: relative; }
.pop { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 40; width: min(320px, 86vw); max-height: 70vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 12px 32px rgba(23, 32, 27, .16); }
.pop-item { display: block; padding: 12px 16px; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.pop-item:hover { background: #F3F6F3; }
.alert-item b { display: block; }
.alert-item span { color: var(--muted); font-size: .88rem; }
.pop-head { padding: 12px 16px; font-weight: 700; border-bottom: 1px solid var(--line); }
.pop-foot { display: block; padding: 12px 16px; font-weight: 600; text-decoration: none; }

.tabbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom); background: var(--palm); }
.tab { display: grid; justify-items: center; gap: 2px; padding: 8px 2px 10px; color: #B9D2C0; text-decoration: none; font: inherit;
  font-size: .75rem; background: none; border: 0; cursor: pointer; }
.tab.active { color: #fff; box-shadow: inset 0 3px 0 var(--leaf); }

.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(23, 32, 27, .45); display: flex; align-items: flex-end; }
.sheet[hidden] { display: none; }
.sheet-panel { width: 100%; max-height: 88dvh; overflow: auto; background: var(--panel); border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 0 12px; }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.nav-link.sheet-link { min-height: 56px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); }
.nav-link.sheet-link.active { border-color: var(--palm); background: #E6EFE8; }

.nav-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: #CFE0D4; text-decoration: none;
  font: inherit; background: none; border: 0; width: 100%; cursor: pointer; text-align: start; }

/* الصفحة */
.page { padding: 16px; max-width: 1280px; margin: 0 auto; outline: none; }
.page-head { display: grid; gap: 12px; margin-bottom: 16px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
.stepper { display: grid; grid-template-columns: 44px 1fr 44px; border: 1px solid #C8D0CA; border-radius: 10px; background: #fff; overflow: hidden; }
.stepper input { border: 0; border-radius: 0; text-align: center; min-height: 44px; padding: 0 4px; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step { border: 0; background: #F3F6F3; color: var(--palm); font: 700 1.3rem/1 var(--font); cursor: pointer; }
.step:active { background: #E1EAE3; }
.loading { padding: 40px 16px; text-align: center; color: var(--muted); }
.boot { min-height: 100dvh; display: grid; place-items: center; }

.panels { display: grid; gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.panel header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.link { font-weight: 600; text-decoration: none; font-size: .9rem; }
.big { display: grid; gap: 4px; margin-bottom: 14px; }
.big .num { font-size: 2.6rem; font-weight: 700; line-height: 1; color: var(--palm); }
.big small { color: var(--muted); }
.segbar { display: flex; gap: 3px; height: 14px; border-radius: 7px; overflow: hidden; margin-bottom: 10px; }
.seg { min-width: 6px; }
.empty-seg { background: var(--line); }
.st-working { background: var(--ok); } .st-stopped { background: var(--idle); }
.st-under_maintenance { background: var(--warn); } .st-accident_damaged { background: var(--bad); }
.legend { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: .92rem; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend b { margin-inline-start: auto; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.kv { list-style: none; margin: 0; padding: 0; }
.kv li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.kv li b { font-size: 1.1rem; }
.kv.three { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.kv.three li { display: grid; gap: 2px; justify-items: center; font-size: .85rem; color: var(--muted); }
.kv.three b { color: var(--ink); }
.kv .is-bad b { color: var(--bad); } .kv .is-warn b { color: var(--warn); }

/* سجل المتابعة */
.followups { margin-top: 20px; }
.sec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.count { min-width: 28px; padding: 0 8px; border-radius: 14px; background: var(--palm); color: #fff; font-weight: 700; text-align: center; font-size: .85rem; line-height: 24px; }
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.log { width: 100%; border-collapse: collapse; }
.log thead { display: none; }
.log tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line);
  border-inline-start: 5px solid transparent; }
.log tbody tr:last-child { border-bottom: 0; }
.log td { display: block; padding: 0; }
.log td[data-l]::before { content: none; }
.log td:not(.remain):not(.act) { grid-column: 1; }
.log td.num[data-l] { color: var(--muted); font-size: .9rem; }
.log td.nodate { display: none; }
.log td small { display: block; color: var(--muted); font-size: .82rem; }
.log .remain { grid-column: 2; grid-row: 1; font-weight: 700; text-align: end; }
.log .act { grid-column: 2; grid-row: 2 / span 3; align-self: end; }
.log tr.sev-1 { border-inline-start-color: var(--bad); }
.log tr.sev-1 .remain { color: var(--bad); }
.log tr.sev-2 { border-inline-start-color: var(--warn); }
.log tr.sev-2 .remain { color: var(--warn); }
.log tr.sev-3 { border-inline-start-color: var(--idle); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 12px; color: #fff; font-size: .82rem; font-weight: 600; }
.empty { padding: 32px 16px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.empty.soft { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--r); color: var(--muted); }
.empty.error h1 { color: var(--bad); }
.upcoming { display: flex; gap: 16px; align-items: flex-start; padding: 20px; margin-bottom: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.upcoming p { margin: 0 0 6px; }
.up-ic { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 12px; background: #E6EFE8; color: var(--palm); flex: none; }

/* تسجيل الدخول */
.login { min-height: 100dvh; display: grid; }
.login-side { display: none; }
.login-card { align-self: center; justify-self: center; width: min(420px, 100%); display: grid; gap: 14px; padding: 32px 20px; }
.login-card h1 { font-size: 1.6rem; }
.login-card p { margin: 0; }
.login-brand { width: 60px; height: 60px; display: grid; place-items: center; border-radius: 16px; background: var(--palm); color: var(--leaf); }
.brand-ic { width: 32px; height: 32px; }

.toast { position: fixed; inset-inline: 16px; bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 60; padding: 14px 16px; border-radius: 12px;
  color: #fff; font-weight: 600; transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { transform: none; opacity: 1; }
.toast-ok { background: var(--palm); } .toast-error { background: var(--bad); }

/* شاشات أوسع */
@media (min-width: 640px) {
  .filters { grid-template-columns: 1.4fr 1.4fr .7fr .8fr; }
  .btn-add span { display: inline; }
  .log thead { display: table-header-group; }
  .log tr { display: table-row; border-inline-start: 0; }
  .log td, .log th { display: table-cell; padding: 12px 14px; text-align: start; vertical-align: middle; }
  .log th { font-size: .85rem; color: var(--muted); font-weight: 600; background: #F5F7F5; border-bottom: 1px solid var(--line); }
  .log td:first-child { box-shadow: inset -5px 0 0 transparent; }
  .log tr.sev-1 td:first-child { box-shadow: inset -5px 0 0 var(--bad); }
  .log tr.sev-2 td:first-child { box-shadow: inset -5px 0 0 var(--warn); }
  .log tr.sev-3 td:first-child { box-shadow: inset -5px 0 0 var(--idle); }
  .log .remain { text-align: start; }
  .log td.num[data-l] { color: var(--ink); font-size: 1rem; }
  .log td.nodate { display: table-cell; }
  .log .act { text-align: end; }
}
@media (min-width: 1000px) {
  .layout { display: grid; grid-template-columns: var(--side) 1fr; }
  .sidebar { display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; overflow: auto; padding: 18px 12px; background: var(--palm); color: #fff; }
  .brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; color: var(--leaf); }
  .brand b { display: block; color: #fff; } .brand small { color: #B9D2C0; }
  .nav { display: grid; gap: 2px; }
  .nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
  .nav-link.active { background: var(--palm-ink); color: var(--palm); font-weight: 600; }
  .signout { margin-top: auto; }
  .main { padding-bottom: 0; min-width: 0; }
  .tabbar, .sheet { display: none !important; }
  .topbar { grid-template-columns: auto 1fr auto; padding: 12px 24px; }
  .tb-actions { grid-row: auto; grid-column: auto; }
  .search { grid-column: auto; max-width: 520px; }
  .page { padding: 24px; }
  .page-head { grid-template-columns: auto 1fr; align-items: end; }
  .filters { justify-self: end; width: min(640px, 100%); }
  .panels { grid-template-columns: 1.15fr 1fr 1fr; }
  .toast { inset-inline: auto 24px; bottom: 24px; max-width: 420px; }
  .login { grid-template-columns: 1fr 1fr; }
  .login-side { display: block; background: var(--palm); position: relative; overflow: hidden; }
  .rows { position: absolute; inset: -20% -10%; display: grid; gap: 34px; transform: rotate(-24deg); }
  .rows span { display: block; height: 14px; border-radius: 7px; background: repeating-linear-gradient(90deg, #2F6650 0 26px, transparent 26px 40px); }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media print { .sidebar, .topbar, .tabbar { display: none !important; } body { background: #fff; } }

/* ===================== المرحلة الثالثة: الصفحات والنماذج ===================== */
.page-head.row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.page-head.row h1 { display: flex; align-items: center; gap: 10px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.note { margin: -6px 0 14px; font-size: .9rem; }
.strong { font-weight: 700; }
.wide-filters { grid-template-columns: 1fr 1fr; margin-bottom: 14px; }
.wide-filters .grow { grid-column: 1 / -1; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 10px; text-decoration: none; font-weight: 600; }
.back .ic { width: 18px; height: 18px; }

/* الشارات */
.tag { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: .8rem; font-weight: 600; background: #EEF1EE; color: var(--muted); white-space: nowrap; }
td .tag, td small { margin-inline-start: 4px; }
.t-valid, .t-not_due, .t-emp-active { background: #E3F1E8; color: var(--ok); }
.t-expiring, .t-soon, .t-emp-on_leave { background: var(--warn-bg); color: var(--warn); }
.t-expired, .t-overdue, .t-due, .t-not_authorized, .t-missing { background: var(--bad-bg); color: var(--bad); }
.t-no_date, .t-no_record, .t-no_driver, .t-emp-terminated, .t-emp-other { background: #ECEEEC; color: #59615C; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { padding: 4px 12px; border-radius: 14px; font-size: .88rem; font-weight: 600; }

/* جداول البيانات: بطاقات على الجوال وجدول على الشاشات الأوسع */
.rtable { width: 100%; border-collapse: collapse; }
.rtable thead { display: none; }
.rtable tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 14px; border-bottom: 1px solid var(--line); }
.rtable tbody tr:last-child { border-bottom: 0; }
.rtable td { display: block; min-width: 0; overflow-wrap: anywhere; }
.rtable td[data-l]::before { content: attr(data-l); display: block; font-size: .75rem; color: var(--muted); }
.rtable td:first-child, .rtable td.act { grid-column: 1 / -1; }
.rtable td small { display: block; margin: 2px 0 0; }
.rtable td small.tag { display: inline-block; }
.rtable .act { display: flex; gap: 8px; flex-wrap: wrap; }
.sort { all: unset; cursor: pointer; font-weight: 600; }
.sort:focus-visible { outline: 3px solid #6FA884; }

/* ملف السيارة والموظف */
.vhead { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.vhead-main { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 12px; }
.vhead-main h1 { font-size: 1.25rem; }
.vhead-main p { margin: 2px 0 0; }
.vhead-main > .pill, .vhead-main > .tag { margin-inline-start: auto; }
.plate-big { padding: 8px 14px; border: 2px solid var(--ink); border-radius: 8px; font-weight: 700; font-size: 1.2rem; background: #fff; }
.avatar { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: #E6EFE8; color: var(--palm); font-weight: 700; font-size: 1.4rem; }
.vfacts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0 0 14px; }
.vfacts dt, .dl dt { font-size: .78rem; color: var(--muted); }
.vfacts dd, .dl dd { margin: 0; font-weight: 600; }
.vactions { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
.vactions::-webkit-scrollbar { display: none; }
.vactions .btn { flex: none; }
.vactions .btn { min-height: 42px; padding: 0 12px; font-size: .9rem; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabbtn { flex: none; min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel); font: inherit; font-size: .9rem; color: var(--ink); cursor: pointer; }
.tabbtn.on { background: var(--palm); border-color: var(--palm); color: #fff; font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.on { display: block; }
.tab-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.sub { margin: 18px 0 8px; font-size: .95rem; font-weight: 600; }
.dl { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0; }
.dl > div { min-width: 0; overflow-wrap: anywhere; }
.panel + .panel { margin-top: 12px; }
.person { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.warn-box, .bad-box, .later { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; margin: 0 0 12px; }
.warn-box { background: var(--warn-bg); color: #7A4E0E; }
.bad-box { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.later { background: #F1F4F1; color: var(--muted); font-size: .9rem; }
.doc-cards { display: grid; gap: 10px; }
.doc-card { display: grid; gap: 6px; padding: 14px; border: 1px solid var(--line); border-inline-start-width: 5px; border-radius: 10px; }
.doc-card > div:first-child { display: flex; justify-content: space-between; gap: 8px; }
.doc-card .btn { justify-self: start; }
.s-valid { border-inline-start-color: var(--ok); } .s-expiring { border-inline-start-color: var(--warn); }
.s-expired, .s-missing { border-inline-start-color: var(--bad); } .s-no_date { border-inline-start-color: var(--idle); }
.company.inactive, .site-list li.inactive { opacity: .65; }
.company header small { display: block; }
.site-list { list-style: none; margin: 0; padding: 0; }
.site-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.site-list li .btn { grid-row: 1 / span 2; grid-column: 2; }

/* النوافذ والنماذج */
body.modal-open { overflow: hidden; }
.modal { position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-end; background: rgba(23, 32, 27, .5); }
.modal-panel { width: 100%; max-height: 94dvh; display: flex; flex-direction: column; background: var(--panel); border-radius: 18px 18px 0 0; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.1rem; }
.modal-body { padding: 16px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-start; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.modal-foot .btn-primary { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-sec { grid-column: 1 / -1; margin: 8px 0 -4px; font-size: .95rem; color: var(--palm); border-top: 1px solid var(--line); padding-top: 14px; }
.form-grid .form-sec:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.intro { margin: 0; padding: 10px 12px; background: #F1F4F1; border-radius: 10px; font-size: .9rem; color: var(--muted); }
.req { color: var(--bad); margin-inline-start: 3px; }
.help { color: var(--muted); font-weight: 400; font-size: .8rem; }
textarea { font: inherit; padding: 10px 12px; border: 1px solid #C8D0CA; border-radius: 10px; width: 100%; resize: vertical; }
textarea:focus { outline: 3px solid #A9CDB4; border-color: var(--palm); }
.check { display: flex; align-items: center; gap: 10px; min-height: 46px; font-weight: 500; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--palm); }
.date-in { display: grid; grid-template-columns: 1fr 46px; border: 1px solid #C8D0CA; border-radius: 10px; overflow: hidden; background: #fff; position: relative; }
.date-in input[type=text] { border: 0; border-radius: 0; text-align: right; }
.date-in:focus-within { outline: 3px solid #A9CDB4; border-color: var(--palm); }
.date-in input:focus { outline: none; }
.cal { border: 0; background: #F3F6F3; color: var(--palm); cursor: pointer; display: grid; place-items: center; }
.native { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; bottom: 0; left: 0; }

@media (min-width: 640px) {
  .wide-filters { grid-template-columns: 2fr repeat(4, 1fr); }
  .wide-filters .grow { grid-column: auto; }
  .rtable thead { display: table-header-group; }
  .rtable tr { display: table-row; }
  .rtable td, .rtable th { display: table-cell; padding: 11px 12px; text-align: start; vertical-align: top; border-bottom: 1px solid var(--line); }
  .rtable td[data-l]::before { content: none; }
  .rtable th { font-size: .82rem; color: var(--muted); font-weight: 600; background: #F5F7F5; white-space: nowrap; }
  .rtable .act { display: table-cell; white-space: nowrap; }
  .rtable .act .btn + .btn { margin-inline-start: 6px; }
  .vfacts { grid-template-columns: repeat(4, 1fr); }
  .vactions { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
  .dl { grid-template-columns: repeat(3, 1fr); }
  .doc-cards { grid-template-columns: repeat(3, 1fr); }
  .modal { align-items: center; justify-content: center; padding: 24px; }
  .modal-panel { width: min(720px, 100%); border-radius: 16px; max-height: 90dvh; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .modal-foot { justify-content: flex-end; }
  .modal-foot .btn-primary { flex: none; min-width: 140px; }
}
@media print {
  .no-print, .back, .modal, .toast { display: none !important; }
  .tab-panel { display: block !important; break-inside: avoid-page; border: 0; padding: 8px 0; }
  .page { padding: 0; max-width: none; }
  .vhead { border: 0; padding: 0; }
  .rtable thead { display: table-header-group; }
  .rtable tr { display: table-row; }
  .rtable td, .rtable th { display: table-cell; padding: 4px 6px; border-bottom: 1px solid #ccc; }
  .rtable td[data-l]::before { content: none; }
}

.center { text-align: center; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* المرحلة الرابعة: حقول إضافية */
.dt-in { display: grid; grid-template-columns: 1fr 96px; gap: 8px; }
.time-in { text-align: center; }
.items { display: grid; gap: 8px; }
.items-rows { display: grid; gap: 8px; }
.item-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #FAFBFA; position: relative; }
.item-row [name=it_desc] { grid-column: 1 / -1; }
.item-row [name=it_kind] { grid-column: 1 / -1; padding-inline-end: 52px; }
.item-row [data-del-item] { position: absolute; top: 10px; inset-inline-end: 10px; width: 46px; height: 46px; }
.icon-btn.sm .ic { width: 18px; height: 18px; }
.live { padding: 12px 14px; border-radius: 10px; background: #EEF5F0; color: var(--palm); }
.live:empty { display: none; }
.live dl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin: 0; }
.live dt { font-size: .78rem; color: var(--muted); }
.live dd { margin: 0; font-weight: 700; }
.live .big-total { grid-column: 1 / -1; font-size: 1.2rem; }
.status-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
@media (min-width: 640px) {
  .modal.wide .modal-panel { width: min(900px, 100%); }
  .item-row { grid-template-columns: 130px 1fr 90px 120px 46px; align-items: center; padding: 6px; }
  .item-row [name=it_desc], .item-row [name=it_kind] { grid-column: auto; padding-inline-end: 12px; }
  .item-row [data-del-item] { position: static; }
}

.list-total { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.rtable small.code { display: block; }
.t-pay-paid, .t-acc-completed, .t-ho-approved { background: #E3F1E8; color: var(--ok); }
.t-pay-partially_paid, .t-acc-awaiting_estimate, .t-acc-awaiting_repair, .t-acc-repairing, .t-ho-draft { background: var(--warn-bg); color: var(--warn); }
.t-pay-unpaid, .t-acc-new { background: var(--bad-bg); color: var(--bad); }
.t-ho-cancelled { background: #ECEEEC; color: #59615C; }

/* النموذج الرسمي للطباعة */
.print-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.official { background: #fff; color: #000; border: 1px solid var(--line); border-radius: 8px; padding: 24px; max-width: 800px; margin: 0 auto; }
.off-head { display: grid; gap: 10px; border-bottom: 3px double #000; padding-bottom: 12px; margin-bottom: 8px; }
.off-head > div:first-child { display: grid; }
.off-company { font-size: 1.15rem; }
.off-title { text-align: center; }
.off-title h1 { font-size: 1.4rem; }
.off-state { display: inline-block; margin-top: 4px; padding: 2px 10px; border: 1px solid var(--bad); color: var(--bad); border-radius: 6px; font-weight: 700; }
.off-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; }
.official h2 { font-size: 1rem; margin: 16px 0 6px; }
.off-table { width: 100%; border-collapse: collapse; }
.off-table th, .off-table td { border: 1px solid #999; padding: 6px 10px; text-align: start; vertical-align: top; }
.off-table th { width: 34%; background: #F2F4F2; font-weight: 600; }
.signs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 28px; }
.signs div { display: grid; gap: 4px; text-align: center; }
.signs span { font-weight: 700; }
.signs i { display: block; height: 56px; border-bottom: 1px solid #000; }
.off-foot { margin-top: 20px; font-size: .75rem; color: #555; text-align: center; }
@media (min-width: 640px) { .off-head { grid-template-columns: 1fr auto 1fr; align-items: center; } .off-meta { flex-direction: column; align-items: flex-end; } }
@media print {
  .official { border: 0; padding: 0; max-width: none; }
  .off-head { grid-template-columns: 1fr auto 1fr; align-items: center; }
  .off-meta { flex-direction: column; align-items: flex-end; }
  .print-bar { display: none !important; }
  @page { size: A4; margin: 14mm; }
}

.mini { display: grid; gap: 2px; font-size: .75rem; color: var(--muted); }
.line-total { grid-column: 1 / -1; text-align: end; font-weight: 700; color: var(--palm); font-size: .9rem; }
.line-total:empty { display: none; }
@media (min-width: 640px) {
  .item-row { grid-template-columns: 130px 1fr 90px 130px 110px 46px; align-items: end; }
  .line-total { grid-column: auto; display: block !important; padding-bottom: 12px; }
}

/* المرحلة الخامسة: المرفقات والملخصات */
.up-row { margin-bottom: 12px; }
.att-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.att { margin: 0; display: grid; grid-template-rows: auto 1fr; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.att-open { all: unset; cursor: pointer; display: block; aspect-ratio: 4 / 3; background: #EEF1EE; }
.att-open:focus-visible { outline: 3px solid #6FA884; }
.att-open img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-ph { display: grid; place-items: center; width: 100%; height: 100%; color: var(--muted); font-weight: 700; }
.thumb-ph.pdf { color: var(--bad); font-size: 1.3rem; }
.att figcaption { display: grid; gap: 2px; padding: 8px 10px; font-size: .88rem; min-width: 0; }
.att figcaption > * { overflow-wrap: anywhere; }
.att-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.file-chip { display: inline-block; margin: 2px; padding: 2px 8px; border-radius: 8px; background: #fff; border: 1px solid var(--line); font-size: .8rem; }
.sums { display: grid; gap: 10px; margin-bottom: 12px; }
.sum-block { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.sum-block h3 { font-size: .9rem; margin: 0 0 6px; color: var(--palm); }
.sum-block ul { list-style: none; margin: 0; padding: 0; }
.sum-block li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.sum-block li:first-child { border-top: 0; }
@media (min-width: 640px) {
  .att-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .sums { grid-template-columns: repeat(3, 1fr); }
}

/* المرحلة السادسة */
.howto summary { cursor: pointer; padding: 4px 0; }
.howto ol { margin: 10px 0; padding-inline-start: 22px; display: grid; gap: 6px; }
.users { display: grid; gap: 12px; }
.user header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.user footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.user.inactive { opacity: .7; }
.perm-chips { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.perm-chips li { padding: 2px 10px; border-radius: 12px; font-size: .8rem; background: #F1F3F1; color: #9AA29D; text-decoration: line-through; }
.perm-chips li.on { background: #E3F1E8; color: var(--ok); text-decoration: none; font-weight: 600; }
.ok-box { background: #E3F1E8; color: var(--ok); }
.backup p { margin: 0 0 10px; }
.backup-nudge { display: flex; text-decoration: none; margin-bottom: 12px; }
.audit { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.audit li { background: var(--panel); border: 1px solid var(--line); border-inline-start: 5px solid var(--idle); border-radius: 10px; padding: 10px 12px; }
.audit li.a-INSERT { border-inline-start-color: var(--ok); } .audit li.a-UPDATE { border-inline-start-color: #3D6FB6; }
.audit li.a-ARCHIVE { border-inline-start-color: var(--bad); } .audit li.a-IMPORT { border-inline-start-color: var(--warn); }
.a-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.diff { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: .88rem; }
.diff th { text-align: start; font-weight: 600; color: var(--muted); padding: 4px 0; width: 32%; vertical-align: top; }
.diff td { padding: 4px 6px; vertical-align: top; overflow-wrap: anywhere; }
.diff .old { color: var(--bad); text-decoration: line-through; }
.diff .new { color: var(--ok); font-weight: 600; }
.diff .arrow { color: var(--muted); width: 1em; }
@media (min-width: 640px) { .users { grid-template-columns: 1fr 1fr; } }

/* المرحلة السابعة: Excel */
.exp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.exp-grid .btn { justify-content: flex-start; }
.steps-list { margin: 0 0 12px; padding-inline-start: 22px; display: grid; gap: 6px; }
.imp-box { margin-top: 14px; }
.imp-chips .chip { border: 0; font: inherit; cursor: pointer; }
.imp-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.imp-list > li { border: 1px solid var(--line); border-inline-start: 5px solid var(--idle); border-radius: 10px; padding: 10px 12px; background: #fff; }
.imp-list > li.imp-new { border-inline-start-color: var(--ok); } .imp-list > li.imp-update { border-inline-start-color: var(--warn); } .imp-list > li.imp-error { border-inline-start-color: var(--bad); }
.errs { margin: 6px 0 0; padding-inline-start: 20px; color: var(--bad); font-size: .9rem; }
.imp-actions { display: grid; gap: 8px; }
@media (min-width: 640px) { .exp-grid { grid-template-columns: repeat(5, 1fr); } }
.ok-box { background: #E4F2E8; color: #1F5C37; }
.btn.wide { width: 100%; justify-content: center; margin-top: 4px; }
.diff { border-collapse: collapse; margin-top: 8px; font-size: .9rem; width: 100%; }
.diff th { text-align: start; font-weight: 600; color: var(--muted); padding: 3px 8px 3px 0; white-space: nowrap; width: 1%; }
.diff td { padding: 3px 6px; overflow-wrap: anywhere; }
.diff .old { color: var(--muted); text-decoration: line-through; }
.diff .new { font-weight: 600; }
.diff .arrow { color: var(--idle); width: 1%; }

/* المرحلة السابعة: التقارير والرسوم البيانية — ألوان الفئات مُتحقق منها لعمى الألوان، والترتيب ثابت */
:root { --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; }
.rep-filters { width: 100% !important; grid-template-columns: 1fr 1fr; margin-bottom: 14px; }
.rep-filters .grow, .rep-filters .quick { grid-column: 1 / -1; }
.rep-filters select, .rep-filters input { width: 100%; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick .chip { border: 1px solid var(--line); background: #fff; font: inherit; font-size: .85rem; cursor: pointer; color: var(--ink); }
.report { padding: 16px; }
.rep-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.rep-head h2 { font-size: 1.15rem; }
.rep-head p { margin: 4px 0 0; }
.rep-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 14px; }
.rep-stats div { background: #F5F7F5; border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; }
.rep-stats span { font-size: .8rem; color: var(--muted); }
.rep-stats b { font-size: 1.1rem; }
.chart { margin: 0 0 16px; }
.hbars { display: grid; gap: 4px; }
.hb { display: grid; grid-template-columns: minmax(90px, 32%) 1fr auto; gap: 10px; align-items: center; padding: 3px 4px; border-radius: 6px; font-size: .88rem; cursor: default; outline: none; }
.hb:hover, .hb:focus-visible { background: #F1F4F1; }
.hb-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { display: block; height: 14px; }
.hb-bar { display: block; height: 100%; background: var(--s1); border-radius: 4px 0 0 4px; min-width: 2px; }
.hb-v { color: var(--ink); white-space: nowrap; font-size: .85rem; }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
.legend-row span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.sw.s1 { background: var(--s1); } .sw.s2 { background: var(--s2); } .sw.s3 { background: var(--s3); } .sw.s4 { background: var(--s4); } .sw.s5 { background: var(--s5); }
.stack rect.s1 { fill: var(--s1); } .stack rect.s2 { fill: var(--s2); } .stack rect.s3 { fill: var(--s3); } .stack rect.s4 { fill: var(--s4); } .stack rect.s5 { fill: var(--s5); }
.svg-scroll { overflow-x: auto; direction: rtl; }
.stack { display: block; max-width: none; }
.stack .base { stroke: var(--line); stroke-width: 1; }
.stack .hit { fill: transparent; }
.stack .col:hover .hit { fill: rgba(30, 70, 54, .06); }
.stack .ax { font-size: 10px; fill: var(--muted); font-family: var(--font); }
.tip { position: absolute; z-index: 60; pointer-events: none; background: var(--ink); color: #fff; padding: 6px 10px; border-radius: 8px; font-size: .82rem; white-space: pre-line; max-width: 280px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.print-only { display: none; }
@media (min-width: 640px) { .rep-filters { grid-template-columns: 2fr 1fr 1fr; } .rep-filters .grow { grid-column: auto; } }
@media (min-width: 1000px) { .rep-filters { grid-template-columns: 2fr repeat(4, 1fr); } .rep-filters label:nth-of-type(6), .rep-filters label:nth-of-type(7) { grid-column: span 1; } }
@media print {
  .no-print, .tip, .toast { display: none !important; }
  .print-only { display: block; }
  .page { padding: 0 !important; }
  .report { border: 0; box-shadow: none; padding: 0; }
  .rep-stats div { border: 1px solid #ccc; }
  .chart, tr { break-inside: avoid; }
  .hb-bar, .sw, .stack rect { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rep-table thead { display: table-header-group !important; }
  .rep-table tr { display: table-row !important; }
  .rep-table td, .rep-table th { display: table-cell !important; border-bottom: 1px solid #ddd; padding: 4px 6px; font-size: 11px; text-align: start; }
  .rep-table td[data-l]::before { display: none; }
}
.more-rows { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; padding: 14px; }

/* طلبات الصيانة */
.t-mr-progress { background: #E4EEFB; color: #1F5FAF; }
.t-mr-done { background: #DDEFE4; color: #1F5C37; }
.chip.t-mr-progress, .chip.t-mr-done { border: 0; }
.mr-head { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #F7F9F7; }
.mr-head dt { font-size: .78rem; color: var(--muted); }
.mr-head dd { margin: 2px 0 0; font-weight: 600; }
.mr-bar { flex-wrap: wrap; gap: 10px; }
.mr-bar .btn-row { justify-content: flex-end; }
.mr-sheet .off-title .mr-state { border-color: #555; color: #333; }
.off-grid { width: 100%; border-collapse: collapse; margin: 12px 0 4px; table-layout: fixed; }
.off-grid th, .off-grid td { border: 1px solid #999; padding: 7px 10px; text-align: start; vertical-align: top; overflow-wrap: anywhere; }
.off-grid th { background: #F2F4F2; font-weight: 600; width: 18%; }
.mr-box { border: 1px solid #999; border-radius: 4px; margin-top: 10px; }
.mr-box h3 { margin: 0; padding: 5px 10px; font-size: .95rem; background: #F2F4F2; border-bottom: 1px solid #999; }
.mr-box p { margin: 0; padding: 8px 10px; min-height: 64px; white-space: pre-wrap; overflow-wrap: anywhere; }
.mr-box.small-box p { min-height: 0; }
.mr-signs { grid-template-columns: 1fr 1fr; }
.mr-signs em { font-style: normal; font-weight: 600; }
.mr-signs small { color: #555; }
.mr-hist { font-size: .8rem; color: #444; margin: 14px 0 0; }
.mr-track .tab-head { align-items: center; }
.mr-steps { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.mr-steps li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 8px; background: #F3F5F3; color: var(--muted); border-inline-start: 4px solid var(--line); }
.mr-steps li.done { background: #E3F1E8; color: var(--ink); border-inline-start-color: var(--ok); }
.mr-steps li.bad { background: var(--bad-bg); border-inline-start-color: var(--bad); }
.sub-head { margin-top: 18px; }
.sub-head h3 { margin: 0; font-size: 1rem; }
@media (max-width: 639px) {
  .off-grid, .off-grid tbody, .off-grid tr { display: block; width: 100%; }
  .off-grid tr { display: grid; grid-template-columns: 38% 62%; }
  .off-grid th, .off-grid td { width: auto; }
  .off-grid td[colspan] { grid-column: auto; }
  .mr-head { grid-template-columns: 1fr 1fr; }
}
@media print {
  .mr-sheet { font-size: 12.5px; }
  .mr-sheet .off-grid tr { display: table-row !important; }
  .mr-sheet .off-grid, .mr-sheet .off-grid tbody { display: table !important; width: 100%; }
  .mr-sheet .off-grid tbody { display: table-row-group !important; }
  .mr-box, .mr-signs { break-inside: avoid; }
  .mr-box p { min-height: 70px; }
  @page { size: A4; margin: 12mm; }
}
@media print { .layout { display: block !important; } .main { padding: 0 !important; } .page { padding: 0 !important; } }

/* حقل صورة الفاتورة داخل النموذج + وثائق السائق */
.file-field .btn-row { margin-top: 4px; }
.file-field label.btn { cursor: pointer; }
.file-prev:empty { display: none; }
.file-chip-prev { display: flex; gap: 12px; align-items: center; margin: 8px 0 0; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.file-chip-prev img, .file-chip-prev .thumb-ph { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; flex: none; display: grid; place-items: center; background: #EEF1EE; font-weight: 700; }
.file-chip-prev figcaption { display: grid; gap: 4px; min-width: 0; }
.file-chip-prev b { overflow-wrap: anywhere; font-size: .9rem; }
.driver-docs { margin: 16px 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #FAFBFA; }
.driver-docs h3 { margin: 0; font-size: 1rem; }

/* جوال مستخدم السيارة */
.mobile-cell { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.mobile-cell bdi { font-weight: 600; letter-spacing: .02em; user-select: all; }
.btn-wa { color: #0F7A3E; border-color: #9FD7B4; }
.field-check { display: block; min-height: 1em; font-size: .8rem; margin-top: 2px; }
.field-check.ok { color: var(--ok); }
.field-check.bad { color: var(--bad); }
