/* Layout: شريط علوي ثابت للهوية والمحاكاة، ثم تبويبات الدور، ثم عمود محتوى بعرض الهاتف يتسع لشبكة على الشاشات الكبيرة. */
:root {
  --ink: #0a2540;          /* نص أساسي: أزرق داكن */
  --ink-2: #4b5b73;        /* نص ثانوي */
  --ground: #f4f7fb;       /* أرضية بيضاء مزرقة */
  --surface: #ffffff;
  --line: #dce3ee;
  --petrol: #1e6bff;       /* اللون المميز: أزرق */
  --petrol-soft: #e6eeff;
  --signal: #a15c00;       /* تنبيه المحاكاة */
  --signal-soft: #fbefd9;
  --ok: #12a150; --ok-soft: #e1f5ea;
  --warn: #9a5b00; --warn-soft: #fbeed6;
  --bad: #c62828; --bad-soft: #fbe3e1;
  --plate: #fafbfd;
  --shadow: 0 1px 2px rgba(10, 37, 64, .06), 0 4px 14px rgba(10, 37, 64, .07);
  --f-display: "Tajawal", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --f-body: "Tajawal", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 14px;
  --r-sm: 10px;
  --bar: #0a2540; --bar-2: #16345c; --bar-line: #2b4a75; --on-bar: #f4f7fb;
  --petrol-strong: #1557d6;  /* ضغط/تحويم الزر الأساسي */
  --on-accent: #ffffff;
  --tap: 44px;               /* أصغر مساحة لمس */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e6edf7; --ink-2: #9aa9bf; --ground: #0a1424; --surface: #111e33; --line: #22324b;
    --petrol: #6ea0ff; --petrol-soft: #15284a; --signal: #f0b54a; --signal-soft: #3a2c12;
    --ok: #4cd08a; --ok-soft: #10331f; --warn: #f0b54a; --warn-soft: #3a2c12; --bad: #ff8a80; --bad-soft: #3d1a18; --plate: #16253d; --bar: #0b1628; --bar-2: #15233a; --bar-line: #26385a; --petrol-strong: #8db5ff; --on-accent: #06142a;
    --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e6edf7; --ink-2: #9aa9bf; --ground: #0a1424; --surface: #111e33; --line: #22324b;
  --petrol: #6ea0ff; --petrol-soft: #15284a; --signal: #f0b54a; --signal-soft: #3a2c12;
  --ok: #4cd08a; --ok-soft: #10331f; --warn: #f0b54a; --warn-soft: #3a2c12; --bad: #ff8a80; --bad-soft: #3d1a18; --plate: #16253d; --bar: #0b1628; --bar-2: #15233a; --bar-line: #26385a; --petrol-strong: #8db5ff; --on-accent: #06142a;
  --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font-family: var(--f-body); font-size: 16px; line-height: 1.6; -webkit-tap-highlight-color: transparent; text-rendering: optimizeLegibility; }
button, select, summary, [data-go], [data-act] { touch-action: manipulation; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bar); }
h1, h2, h3 { font-family: var(--f-display); font-weight: 800; line-height: 1.3; text-wrap: balance; margin: 0; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; } h2 { font-size: 1.25rem; font-weight: 700; } h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--petrol); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--petrol); outline-offset: 2px; }
.num, .money, td.n { font-variant-numeric: tabular-nums; }
.money, .num { white-space: nowrap; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.mono { font-family: var(--f-mono); font-size: .85em; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }

/* شريط علوي: الهوية والإشعارات في سطر، والشخصية تحتها */
.topbar { position: relative; z-index: 5; padding-top: env(safe-area-inset-top, 0px); background: var(--bar); color: var(--on-bar); }
.topbar-in { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px 12px; padding-block: 10px 12px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); max-width: 1180px; margin-inline: auto; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo { width: 36px; height: 36px; border-radius: 10px; background: var(--petrol); color: #fff; display: grid; place-items: center; font-family: var(--f-display); font-weight: 800; font-size: 1.15rem; flex: none; }
.brand b { display: block; font-family: var(--f-display); font-weight: 800; font-size: 1.12rem; line-height: 1.2; }
.brand span:not(.logo) { display: block; font-size: .72rem; opacity: .65; line-height: 1.2; }
.persona { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.persona label { font-size: .8rem; font-weight: 500; opacity: .75; white-space: nowrap; }
.persona select { flex: 1; min-height: 40px; background: var(--bar-2); color: var(--on-bar); border: 1px solid var(--bar-line); border-radius: var(--r-sm); padding: 6px 10px; }
.iconbtn { position: relative; display: grid; place-items: center; width: var(--tap); height: var(--tap); background: var(--bar-2); border: 1px solid var(--bar-line); color: var(--on-bar); border-radius: 12px; cursor: pointer; }
.iconbtn:hover { background: var(--bar-line); }
.iconbtn .dot { position: absolute; top: -5px; inset-inline-end: -5px; min-width: 20px; height: 20px; display: grid; place-items: center; background: var(--bad); color: #fff; border-radius: 99px; font-size: .7rem; padding: 0 5px; font-weight: 700; border: 2px solid var(--bar); }
@media (min-width: 760px) {
  .topbar-in { grid-template-columns: 1fr auto auto; }
  .persona { grid-column: auto; order: 2; } .iconbtn { order: 3; }
  .persona select { min-width: 260px; }
}

/* شريط المحاكاة: سطر واحد يتوسع عند الطلب */
.simbar { background: var(--signal-soft); color: var(--ink); border-bottom: 1px solid var(--line); }
.simbar-in { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; min-height: 40px; padding-block: 6px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); max-width: 1180px; margin-inline: auto; font-size: .84rem; cursor: pointer; list-style: none; }
.simbar-in::-webkit-details-marker { display: none; }
.simtag { background: var(--signal); color: var(--ground); border-radius: 6px; padding: 0 8px; font-weight: 700; font-size: .75rem; }
.simtime { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.simmore { margin-inline-start: auto; width: 8px; height: 8px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: translateY(-2px) rotate(45deg); transition: transform .2s; }
.simbar[open] .simmore { transform: translateY(2px) rotate(-135deg); }
.simbar-body { display: grid; gap: 8px; padding-block: 0 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); max-width: 1180px; margin-inline: auto; font-size: .85rem; color: var(--ink-2); }
.chipbtn { min-height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 4px 14px; cursor: pointer; font-size: .82rem; font-weight: 600; }
.chipbtn:hover { border-color: var(--petrol); color: var(--petrol); }

/* التبويبات */
.tabs { position: sticky; top: calc(env(safe-area-inset-top, 0px)); z-index: 4; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs-in { display: flex; gap: 4px; padding-block: 8px; padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); max-width: 1180px; margin-inline: auto; }
.tab { min-height: 40px; border: 0; background: none; padding: 6px 14px; border-radius: 99px; cursor: pointer; white-space: nowrap; color: var(--ink-2); font-weight: 500; }
.tab:hover { background: var(--ground); color: var(--ink); }
.tab[aria-current="page"] { color: var(--petrol); background: var(--petrol-soft); font-weight: 700; }

main { max-width: 1180px; margin-inline: auto; padding-block: 18px 60px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 16px; }
.stack { display: grid; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.grid2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid3 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid2 > *, .grid3 > *, .stack > * { min-width: 0; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 12px; box-shadow: var(--shadow); }
.panel.flat { box-shadow: none; }
.panel.note { background: var(--petrol-soft); border-color: transparent; }
.panel.warn { background: var(--warn-soft); border-color: transparent; }
.panel.bad { background: var(--bad-soft); border-color: transparent; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.eyebrow { font-size: .78rem; color: var(--petrol); font-weight: 700; }

/* لوحة رقم الطلب — مستوحاة من لوحة السيارة */
.plate { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--ink); border-radius: 6px; padding: 0 8px; background: var(--plate); font-family: var(--f-mono); font-size: .82rem; direction: ltr; line-height: 1.7; }
.plate::before { content: "KW"; font-size: .6rem; font-weight: 700; color: var(--petrol); border-inline-end: 1px solid var(--line); padding-inline-end: 5px; }

.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 99px; padding: 2px 10px; font-size: .78rem; font-weight: 600; background: var(--petrol-soft); color: var(--petrol); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.mute { background: var(--ground); color: var(--ink-2); }
.badge.sim { background: var(--signal-soft); color: var(--signal); }

/* بطاقة العرض كعرض سعر */
.offer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); display: grid; grid-template-columns: 1fr auto; gap: 0; overflow: hidden; }
.offer { box-shadow: var(--shadow); }
.offer.best { border-color: var(--petrol); box-shadow: 0 0 0 1px var(--petrol), var(--shadow); }
.offer .body { padding: 14px 16px; display: grid; gap: 6px; min-width: 0; }
.offer .price { padding: 14px 16px; border-inline-start: 1.5px dashed var(--line); display: grid; align-content: center; justify-items: end; gap: 2px; min-width: 130px; background: var(--ground); }
.offer .total { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; font-family: var(--f-body); }
.offer .actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); }
.specs { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .86rem; color: var(--ink-2); }
.specs b { color: var(--ink); font-weight: 600; }
@media (max-width: 520px) { .offer { grid-template-columns: 1fr; } .offer .price { border-inline-start: 0; border-top: 1.5px dashed var(--line); justify-items: start; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 12px; padding: 8px 18px; cursor: pointer; font-weight: 700; }
.btn:hover { border-color: var(--petrol); color: var(--petrol); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--petrol); color: var(--on-accent); border-color: var(--petrol); box-shadow: 0 2px 8px rgba(30, 107, 255, .25); }
.btn.primary:hover { background: var(--petrol-strong); border-color: var(--petrol-strong); color: var(--on-accent); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: .86rem; border-radius: 10px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.link { background: none; border: 0; color: var(--petrol); cursor: pointer; padding: 0; text-decoration: underline; font-weight: 600; }

label { display: grid; gap: 4px; font-size: .88rem; font-weight: 600; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 500; }
input[type=text], input[type=number], input[type=password], input[type=datetime-local], select, textarea { min-height: var(--tap); border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-sm); padding: 8px 12px; width: 100%; min-width: 0; font-size: 16px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--petrol); box-shadow: 0 0 0 3px var(--petrol-soft); }
textarea { min-height: 70px; resize: vertical; }
.form { display: grid; gap: 12px; }
.form .cols { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.hint { font-size: .8rem; color: var(--ink-2); font-weight: 400; }

.cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.cat { position: relative; min-height: 64px; border: 1.5px solid var(--line); border-radius: var(--r); padding: 12px 14px; cursor: pointer; background: var(--surface); text-align: start; display: grid; gap: 2px; }
.cat[aria-pressed="true"] { border-color: var(--petrol); background: var(--petrol-soft); }
.cat[aria-pressed="true"]::after { content: ""; position: absolute; top: 10px; inset-inline-end: 10px; width: 18px; height: 18px; border-radius: 50%; background: var(--petrol) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center / 12px no-repeat; }
.cat b { font-family: var(--f-display); font-weight: 700; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 2px; box-shadow: inset 0 3px 0 var(--petrol), var(--shadow); }
.kpi .v { font-size: 1.6rem; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: .84rem; color: var(--ink-2); }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .86rem; }
th, td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--ink-2); background: var(--ground); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 14px 1fr; gap: 10px; padding-bottom: 10px; position: relative; }
.timeline li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--line); margin-top: 7px; }
.timeline li.done::before { background: var(--petrol); }
.timeline li.now::before { background: var(--signal); box-shadow: 0 0 0 4px var(--signal-soft); }
.timeline li:not(:last-child)::after { content: ""; position: absolute; inset-inline-start: 4px; top: 19px; bottom: 0; width: 2px; background: var(--line); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: .9rem; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; min-width: 0; }

.empty { text-align: center; padding: 28px 16px; color: var(--ink-2); border: 1.5px dashed var(--line); border-radius: var(--r); }
.toast { font-weight: 600; position: fixed; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); inset-inline: max(16px, env(safe-area-inset-left, 0px)); margin-inline: auto; max-width: 520px; background: var(--bar); color: var(--on-bar); padding: 12px 16px; border-radius: 12px; z-index: 20; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); color: #fff; }
.drawer { position: fixed; inset: 0; background: rgba(10, 37, 64, .45); z-index: 15; display: flex; justify-content: flex-start; }
.drawer .sheet { box-shadow: 0 10px 40px rgba(10, 37, 64, .25); background: var(--surface); width: min(420px, 100%); height: 100%; overflow-y: auto; padding: 16px; padding-top: calc(16px + env(safe-area-inset-top, 0px)); display: grid; align-content: start; gap: 10px; }
.notif { border-bottom: 1px solid var(--line); padding: 12px 0; display: grid; gap: 2px; font-size: .9rem; }
.notif.unread b { color: var(--petrol); }

.provider { max-width: 460px; margin-inline: auto; width: 100%; border: 2px dashed var(--signal); border-radius: 14px; background: var(--surface); padding: 20px; display: grid; gap: 14px; }
.provider .amount { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.details > summary { cursor: pointer; font-weight: 600; color: var(--petrol); }
.stars { display: inline-flex; gap: 2px; direction: ltr; }
.stars input { width: 34px; }
@media (prefers-reduced-motion: no-preference) { .btn, .tab, .cat, .chipbtn, .iconbtn, input, select, textarea { transition: border-color .15s, background-color .15s, color .15s, box-shadow .15s, transform .1s; } }
@media (prefers-reduced-motion: reduce) { .simmore { transition: none; } .btn:active { transform: none; } }

/* صفحة الدخول */
.login-brand { justify-content: space-between; }
.login-brand .logo { width: 48px; height: 48px; border-radius: 14px; font-size: 1.5rem; }
.card-foot { justify-content: flex-end; padding-top: 10px; border-top: 1px solid var(--line); }
.lead { font-size: 1.05rem; font-weight: 500; color: var(--ink); }
