/* ==========================================================================
   دريب اكوا — نظام إدخال الإنتاج
   الهوية: كحلي #192132 · أزرق أساسي #044277 · فولاذي #3A6FA0 · سماوي #9FC4DE
           ضبابي #EAF1F6 · رمادي #5B626E · خط Firjar + Bahnschrift للأرقام
   ========================================================================== */

/* ملف Firjar لا يحتوي رسومات للأرقام اللاتينية وبعض الرموز (% – × + …)،
   لذلك نستثنيها هنا فيعرضها المتصفح بخط Bahnschrift كما يحدد دليل الهوية للأرقام.
   وحرف k الصغير (U+006B) رسمته في Firjar تالفة (كتلة مصمتة) فيُستثنى أيضاً ويُعرض بـBahnschrift. */
@font-face {
  font-family: "Firjar";
  src: url("../fonts/Firjar-VF.ttf") format("truetype");
  font-weight: 100 900;
  font-stretch: 75% 125%;
  font-display: swap;
  unicode-range: U+0000-0023, U+0027-002A, U+002C-002F, U+003A-003B, U+003F, U+0041-005D, U+005F, U+0061-006A, U+006C-007B,
    U+007D, U+007F-00A1, U+00A4, U+00A6-00A8, U+00AA-00AD, U+00AF, U+00B1-00D6, U+00D8-00F6, U+00F8-0608,
    U+060A-060C, U+060E-0669, U+066D-06D3, U+06D5-2012, U+2015-2021, U+2023-20AB, U+20AD-2121, U+2123-2211,
    U+2213-FD3D, U+FD40-10FFFF;
}

:root {
  color-scheme: light;
  --navy: #192132;
  --blue: #044277;
  --steel: #3a6fa0;
  --sky: #9fc4de;
  --mist: #eaf1f6;
  --graphite: #5b626e;

  --bg: #eef3f7;
  --surface: #ffffff;
  --surface-2: #f6f9fb;
  --surface-3: #ebf1f6;
  --line: #e0e8ef;
  --line-2: #cbd7e2;
  --text: #192132;
  --text-2: #4d5665;
  --text-3: #7c8695;
  --primary: #044277;
  --primary-2: #0a5594;
  --primary-ink: #ffffff;
  --primary-soft: #e6eff7;
  --sel-ink: #044277;
  --ring: 0 0 0 3px rgba(58, 111, 160, 0.28);
  --ok: #17835a;
  --ok-soft: #e2f3eb;
  --warn: #9a620a;
  --warn-soft: #fcf1dc;
  --warn-line: #f0d49c;
  --bad: #c0392b;
  --bad-soft: #fbe9e7;
  --thread: #22a35a;

  --shadow-1: 0 1px 2px rgba(25, 33, 50, 0.05);
  --shadow-2: 0 1px 2px rgba(25, 33, 50, 0.04), 0 6px 20px rgba(25, 33, 50, 0.06);
  --shadow-3: 0 24px 64px rgba(12, 18, 30, 0.28);

  --sidebar: #192132;
  --sidebar-2: #202a3e;
  --sidebar-ink: #c5d2df;
  --sidebar-ink-2: #7f90a5;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --font: "Firjar", "Bahnschrift", "Segoe UI", Tahoma, system-ui, sans-serif;
  --font-num: "Bahnschrift", "Segoe UI", "Firjar", system-ui, sans-serif;
  --topbar-h: 68px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d131d;
  --surface: #141c29;
  --surface-2: #19222f;
  --surface-3: #202b3b;
  --line: #243044;
  --line-2: #33425a;
  --text: #e6edf5;
  --text-2: #aab7c7;
  --text-3: #7b899b;
  --primary: #3a78b5;
  --primary-2: #4686c4;
  --primary-soft: rgba(111, 168, 220, 0.13);
  --sel-ink: #cfe3f4;
  --ring: 0 0 0 3px rgba(111, 168, 220, 0.35);
  --ok: #3cc48a;
  --ok-soft: rgba(60, 196, 138, 0.12);
  --warn: #f0b95b;
  --warn-soft: rgba(240, 185, 91, 0.1);
  --warn-line: rgba(240, 185, 91, 0.3);
  --bad: #ff7b6e;
  --bad-soft: rgba(255, 123, 110, 0.1);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  --sidebar: #0a0f17;
  --sidebar-2: #131b28;
}

/* ———— الأساسيات ———— */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
@media (pointer: coarse) { html { font-size: 16px; } }
body {
  margin: 0;
  font-family: var(--font);
  font-stretch: 100%;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); }
::selection { background: rgba(58, 111, 160, 0.25); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.ic { display: inline-grid; place-items: center; width: 20px; height: 20px; flex: none; }
.ic svg { width: 100%; height: 100%; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 24px; height: 24px; }

/* ———— شاشة التحميل ———— */
.boot { min-height: 100vh; display: grid; place-items: center; background: var(--sidebar); }
.boot-drop { width: 34px; fill: var(--sky); animation: drip 1.4s var(--ease) infinite; }
@keyframes drip {
  0% { transform: translateY(-8px) scale(0.9); opacity: 0.2; }
  50% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(8px) scale(0.9); opacity: 0.2; }
}

/* ———— الأزرار ———— */
.btn {
  height: 44px;
  padding: 0 18px;
  border-radius: var(--r);
  border: 1px solid transparent;
  background: none;
  font-weight: 600;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.08s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; }
.btn-primary {
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 6px 16px rgba(4, 66, 119, 0.22);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-2); }
.btn-outline { background: var(--surface); border-color: var(--line-2); color: var(--text); }
.btn-outline:hover:not(:disabled) { border-color: var(--steel); background: var(--surface-2); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.06); }
.btn-soft { background: var(--primary-soft); color: var(--sel-ink); }
.btn-soft:hover:not(:disabled) { filter: brightness(0.97); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 0.85rem; border-radius: 10px; gap: 6px; }
.btn-lg { height: 54px; font-size: 1.05rem; border-radius: 14px; padding: 0 22px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }
.btn .spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
kbd {
  font: 600 0.7rem var(--font-num);
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.18);
  direction: ltr;
}
.btn-outline kbd, .btn-ghost kbd { background: var(--surface-3); border-color: var(--line); color: var(--text-3); }

/* ———— الحقول ———— */
.field { display: grid; gap: 8px; min-width: 0; }
.label-row { display: flex; align-items: center; gap: 8px; min-height: 22px; flex-wrap: wrap; }
.label { font-weight: 600; font-size: 0.93rem; color: var(--text); }
.req { color: var(--bad); font-weight: 700; }
.tag-opt { font-size: 0.75rem; color: var(--text-3); background: var(--surface-3); border-radius: 99px; padding: 1px 8px; }
.tag-req { font-size: 0.72rem; color: var(--bad); background: var(--bad-soft); border-radius: 99px; padding: 1px 8px; font-weight: 600; }
.label-actions { margin-inline-start: auto; display: flex; gap: 6px; }
.hint { font-size: 0.8rem; color: var(--text-3); }
.error-msg { font-size: 0.82rem; color: var(--bad); display: flex; align-items: center; gap: 6px; font-weight: 600; min-height: 0; }
.error-msg:empty { display: none; }
.field.shake { animation: shake 0.35s; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

.input-wrap {
  display: flex;
  align-items: stretch;
  height: 54px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.input-wrap:hover { border-color: #aebfd0; }
[data-theme="dark"] .input-wrap:hover { border-color: #43536c; }
.input-wrap:focus-within { border-color: var(--steel); box-shadow: var(--ring); }
.input-wrap input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0 14px;
  font-family: var(--font-num);
  font-weight: 600;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  text-align: right;
}
.input-wrap input::placeholder { color: var(--text-3); opacity: 0.55; font-weight: 400; }
.input-wrap .unit {
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--text-3);
  font: 600 0.85rem var(--font-num);
  background: var(--surface-2);
  border-inline-start: 1px solid var(--line);
  min-width: 52px;
  justify-content: center;
}
.input-wrap .step {
  width: 52px;
  border: 0;
  background: var(--surface-2);
  color: var(--text-2);
  display: grid;
  place-items: center;
  transition: background 0.12s, color 0.12s;
}
.input-wrap .step:hover { background: var(--surface-3); color: var(--text); }
.input-wrap .step:first-child { border-inline-end: 1px solid var(--line); }
.input-wrap .step:last-child { border-inline-start: 1px solid var(--line); }
.field.invalid .input-wrap, .field.invalid .textarea { border-color: var(--bad); }
.field.invalid .input-wrap:focus-within { box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.18); }
.field.tone-danger.has-value .input-wrap { border-color: #e7a79f; background: var(--bad-soft); }
.field.tone-danger.has-value .input-wrap .unit { background: transparent; }

.text-input {
  height: 48px;
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface);
  padding: 0 14px;
  outline: 0;
  font-size: 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.text-input:focus { border-color: var(--steel); box-shadow: var(--ring); }
.field.invalid .text-input { border-color: var(--bad); }
.pw-wrap { position: relative; }
.pw-wrap .text-input { padding-inline-end: 48px; }
/* حقل كلمة المرور LTR داخل واجهة RTL: زر الإظهار على اليسار، فالحشوة في بداية الحقل (يساره) لا نهايته */
.pw-wrap .text-input[dir="ltr"] { padding-inline-end: 12px; padding-inline-start: 48px; }
.pw-wrap .pw-toggle { position: absolute; inset-inline-end: 4px; top: 4px; bottom: 4px; width: 40px; border: 0; background: none; color: var(--text-3); border-radius: 9px; }
.pw-wrap .pw-toggle:hover { color: var(--text); background: var(--surface-3); }

.textarea {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface);
  padding: 12px 14px;
  outline: 0;
  font-size: 1rem;
  line-height: 1.7;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea:focus { border-color: var(--steel); box-shadow: var(--ring); }
.textarea-foot { display: flex; align-items: center; gap: 10px; }
.counter { margin-inline-start: auto; font: 500 0.75rem var(--font-num); color: var(--text-3); }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 0.92rem; color: var(--text-2); }
.check input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }

.switch { position: relative; width: 42px; height: 24px; flex: none; border-radius: 99px; background: var(--line-2); border: 0; padding: 0; transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: inset-inline-start 0.2s var(--ease); }
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"]::after { inset-inline-start: 21px; }

/* ———— الخيارات (Chips) ———— */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  position: relative;
  min-height: 48px;
  padding: 8px 16px;
  border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: border-color 0.12s, background 0.12s, color 0.12s, box-shadow 0.12s, transform 0.08s;
  user-select: none;
}
.chip:hover { border-color: var(--steel); background: var(--surface-2); }
.chip:active { transform: scale(0.98); }
.chip[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--sel-ink);
  box-shadow: inset 0 0 0 1px var(--primary);
}
[data-theme="dark"] .chip[aria-pressed="true"] { border-color: #6fa8dc; box-shadow: inset 0 0 0 1px #6fa8dc; }
.chip .tick {
  position: absolute;
  top: -7px;
  inset-inline-end: -7px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  transform: scale(0);
  transition: transform 0.18s var(--ease);
  box-shadow: 0 0 0 2px var(--surface);
}
[data-theme="dark"] .chip .tick { background: #6fa8dc; color: #0d131d; }
.chip .tick svg { width: 12px; height: 12px; stroke-width: 3; }
.chip[aria-pressed="true"] .tick { transform: scale(1); }
.chip .big { font-family: var(--font-num); font-weight: 700; font-size: 1.35rem; line-height: 1.1; direction: ltr; unicode-bidi: isolate; }
.chip .small { font-size: 0.76rem; color: var(--text-2); font-weight: 500; line-height: 1.2; }
.chip[aria-pressed="true"] .small { color: inherit; opacity: 0.85; }
.chips-size .chip { flex-direction: column; gap: 3px; min-width: 96px; min-height: 72px; padding: 10px 14px; }
.chips-code .chip { flex-direction: column; gap: 2px; min-width: 76px; min-height: 64px; padding: 8px 12px; }
.chips-code .chip .big { font-size: 1.2rem; }
.chips-big .chip { min-width: 104px; min-height: 76px; font-family: var(--font-num); font-size: 1.9rem; font-weight: 700; }
.chip .swatch { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5); flex: none; }
.chip .swatch.thread { width: 22px; height: 8px; border-radius: 99px; background: repeating-linear-gradient(-60deg, var(--thread) 0 5px, #188046 5px 8px); }
.chip-other .ic { color: var(--text-3); }
.chip-other[aria-pressed="true"] .ic { color: inherit; }
.chip.inactive { opacity: 0.6; border-style: dashed; }
.other-input { width: 190px; }
.other-input .input-wrap { height: 48px; }
.other-input .input-wrap input { font-size: 1.05rem; }
.field.invalid .chips .chip:not([aria-pressed="true"]) { border-color: #e5b3ad; }
[data-theme="dark"] .field.invalid .chips .chip:not([aria-pressed="true"]) { border-color: rgba(255, 123, 110, 0.4); }

.mini-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mini-chip {
  height: 32px;
  padding: 0 12px;
  border-radius: 99px;
  border: 1px dashed var(--line-2);
  background: transparent;
  color: var(--text-2);
  font-size: 0.83rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.12s;
}
.mini-chip:hover { border-style: solid; border-color: var(--steel); color: var(--text); background: var(--surface-2); }
.mini-chip.used { border-style: solid; background: var(--primary-soft); color: var(--sel-ink); border-color: transparent; }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 12px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  border: 0;
  background: transparent;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
[data-theme="dark"] .seg button[aria-pressed="true"] { background: var(--surface-3); box-shadow: 0 0 0 1px var(--line-2); }

/* ———— شارات ———— */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 0.75rem; font-weight: 600; background: var(--surface-3); color: var(--text-2); 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-blue { background: var(--primary-soft); color: var(--sel-ink); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ———— البطاقات ———— */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.9rem;
}
.banner-info { background: var(--primary-soft); border-color: transparent; color: var(--sel-ink); }
.banner-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.banner .grow { flex: 1; min-width: 0; }
.banner .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ==========================================================================
   شاشات الدخول والإعداد
   ========================================================================== */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 1fr) minmax(0, 1.15fr); background: var(--surface); }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: min(400px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 40px; }
.auth-card h1 { font-size: 1.75rem; font-weight: 800; margin: 0 0 6px; letter-spacing: 0; }
.auth-card .lead { color: var(--text-2); margin: 0 0 28px; }
.auth-card form { display: grid; gap: 18px; }
.auth-foot { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 0.85rem; }
.form-error { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--bad-soft); color: var(--bad); font-size: 0.9rem; font-weight: 600; }
.form-error:empty { display: none; }

.auth-visual {
  position: relative;
  overflow: hidden;
  background: radial-gradient(120% 90% at 85% 10%, #1f3a5c 0%, transparent 55%), radial-gradient(90% 80% at 10% 100%, #0b3a66 0%, transparent 60%), var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px 56px;
}
.auth-visual .grid-bg {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(159, 196, 222, 0.07) 1px, transparent 1px), linear-gradient(90deg, rgba(159, 196, 222, 0.07) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 75%);
}
.auth-visual .drop-xl { position: absolute; width: 520px; left: -120px; bottom: -170px; fill: rgba(159, 196, 222, 0.07); }
.auth-visual .drop-sm { position: absolute; width: 90px; left: 22%; top: 18%; fill: rgba(159, 196, 222, 0.12); }
.auth-visual > * { position: relative; }
.av-top { display: flex; justify-content: space-between; align-items: center; font: 600 0.78rem var(--font-num); letter-spacing: 0.18em; color: var(--sky); }
.av-mid .eyebrow { display: inline-block; font-size: 0.9rem; color: var(--sky); margin-bottom: 14px; }
.av-mid h2 { font-size: clamp(2rem, 3.4vw, 3rem); font-weight: 800; line-height: 1.25; margin: 0 0 18px; }
.av-mid h2 .hl { color: var(--sky); }
.av-mid p { color: #b6c6d8; max-width: 440px; margin: 0; font-size: 1rem; }
.av-clock { display: flex; align-items: flex-end; gap: 22px; flex-wrap: wrap; }
.av-clock .time { font: 700 3.4rem/1 var(--font-num); letter-spacing: -0.01em; }
.av-clock .date { color: #b6c6d8; font-size: 0.95rem; margin-top: 8px; }
.shift-pill { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 14px; background: rgba(159, 196, 222, 0.1); border: 1px solid rgba(159, 196, 222, 0.18); color: #e6eef6; font-weight: 600; }
.shift-pill .ic { color: var(--sky); }
.shift-pill small { color: #9fb2c6; font-weight: 500; }

/* ———— الشعار ———— */
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: none;
  background: linear-gradient(150deg, #0d5a9c, #044277 60%, #03335d);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 6px 14px rgba(4, 66, 119, 0.3);
}
.brand-mark svg { width: 15px; fill: #fff; }
.brand-name { font-weight: 800; font-size: 1.15rem; line-height: 1.2; }
.brand-sub { font-size: 0.76rem; color: var(--text-3); font-weight: 500; }

/* ==========================================================================
   هيكل التطبيق
   ========================================================================== */
.app { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  padding: 18px 14px 14px;
  overflow: hidden auto;
  z-index: 40;
  scrollbar-width: thin;
  scrollbar-color: #33425a transparent;
}
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; }
.sidebar .brand-name { color: #fff; }
.sidebar .brand-sub { color: var(--sidebar-ink-2); }
.sidebar .drop-wm { position: absolute; width: 230px; left: -70px; bottom: -80px; fill: rgba(159, 196, 222, 0.035); pointer-events: none; }
.nav { display: grid; gap: 2px; position: relative; }
.nav-label { font-size: 0.72rem; font-weight: 600; color: var(--sidebar-ink-2); padding: 16px 12px 6px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sidebar-ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.93rem;
  transition: background 0.15s, color 0.15s;
}
.nav-item .ic { color: var(--sidebar-ink-2); transition: color 0.15s; }
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav-item:hover .ic { color: var(--sky); }
.nav-item.active { background: rgba(159, 196, 222, 0.13); color: #fff; }
.nav-item.active .ic { color: var(--sky); }
.nav-item.active::before { content: ""; position: absolute; inset-inline-start: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--sky); }
.nav-item .sub { display: block; font-size: 0.72rem; font-weight: 500; color: var(--sidebar-ink-2); margin-top: 1px; }
.nav-item .grow { flex: 1; min-width: 0; line-height: 1.3; }
.nav-item.disabled { opacity: 0.55; pointer-events: none; }
.nav-item .soon { font-size: 0.68rem; padding: 2px 8px; border-radius: 99px; background: rgba(159, 196, 222, 0.12); color: var(--sky); font-weight: 600; }
.nav-item .count { font: 600 0.72rem var(--font-num); padding: 1px 7px; border-radius: 99px; background: rgba(159, 196, 222, 0.14); color: #dce7f1; }

.side-foot { margin-top: auto; display: grid; gap: 10px; padding-top: 16px; position: relative; }
.lan-card { border-radius: 12px; background: var(--sidebar-2); border: 1px solid rgba(159, 196, 222, 0.1); padding: 12px; font-size: 0.8rem; }
.lan-card .t { display: flex; align-items: center; gap: 8px; color: #dce7f1; font-weight: 600; margin-bottom: 6px; }
.lan-card .t .ic { color: #3cc48a; width: 16px; height: 16px; }
.lan-card .url { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.lan-card code { flex: 1; min-width: 0; direction: ltr; text-align: left; font: 600 0.78rem var(--font-num); color: var(--sky); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: rgba(0, 0, 0, 0.2); padding: 6px 8px; border-radius: 8px; }
.lan-card button { border: 0; background: rgba(159, 196, 222, 0.1); color: var(--sidebar-ink); width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.lan-card button:hover { background: rgba(159, 196, 222, 0.2); color: #fff; }
.lan-card .ic { width: 15px; height: 15px; }
.lan-card .note { color: var(--sidebar-ink-2); margin-top: 6px; line-height: 1.5; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--sidebar-2); }
.user-card .who { flex: 1; min-width: 0; line-height: 1.3; }
.user-card .who b { display: block; color: #fff; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .who span { font-size: 0.74rem; color: var(--sidebar-ink-2); }
.user-card button { border: 0; background: transparent; color: var(--sidebar-ink-2); width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; }
.user-card button:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  background: var(--steel);
}
.avatar-sm { width: 28px; height: 28px; border-radius: 8px; font-size: 0.8rem; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 28px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .menu-btn { display: none; }
.page-title { min-width: 0; line-height: 1.25; }
.page-title .crumb { font-size: 0.76rem; color: var(--text-3); font-weight: 500; }
.page-title h1 { margin: 0; font-size: 1.2rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }
.clock-chip { display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 14px; padding-inline-start: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.clock-chip .shift-badge { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 10px; background: var(--primary-soft); color: var(--sel-ink); font-weight: 700; font-size: 0.85rem; white-space: nowrap; }
.clock-chip .shift-badge.night { background: #1f2a44; color: #d4e2f0; }
[data-theme="dark"] .clock-chip .shift-badge.night { background: #26324a; }
.clock-chip .t { font: 700 1.05rem var(--font-num); line-height: 1.1; white-space: nowrap; }
.clock-chip .d { font-size: 0.72rem; color: var(--text-3); white-space: nowrap; }
.shift-meter { width: 64px; height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 4px; }
.shift-meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--steel), var(--primary)); border-radius: 99px; }
[data-theme="dark"] .shift-meter i { background: var(--sky); }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); display: grid; place-items: center; box-shadow: var(--shadow-1); transition: all 0.15s; }
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }

.content { padding: 24px 28px 64px; width: 100%; max-width: 1480px; margin-inline: auto; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 1.45rem; font-weight: 800; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.page-head .actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.scrim { position: fixed; inset: 0; background: rgba(8, 12, 20, 0.5); z-index: 35; opacity: 0; pointer-events: none; transition: opacity 0.2s; }

/* ==========================================================================
   لوحة الإدخال
   ========================================================================== */
.entry-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.form-col { display: grid; gap: 16px; min-width: 0; }

.meta-card { overflow: hidden; }
.meta-head { display: flex; align-items: center; gap: 14px; padding: 16px 20px; flex-wrap: wrap; }
.meta-shift { display: flex; align-items: center; gap: 12px; min-width: 0; }
.meta-shift .sico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(150deg, #fff4d6, #ffe3a3); color: #b7791f; flex: none; }
.meta-shift .sico.night { background: linear-gradient(150deg, #27365a, #192132); color: #cfe0f2; }
.meta-shift .sico .ic { width: 24px; height: 24px; }
.meta-shift b { font-size: 1.1rem; font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meta-shift .range { font-size: 0.82rem; color: var(--text-3); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meta-shift .shift-meter { width: 90px; margin: 0; }
.meta-target { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meta-target .lbl { font-size: 0.8rem; color: var(--text-3); }
.meta-custom { display: flex; gap: 8px; align-items: center; padding: 0 20px 14px; flex-wrap: wrap; }
.meta-custom input[type="date"] { height: 38px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); padding: 0 10px; font-family: var(--font-num); }
.meta-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); background: var(--surface-2); }
.meta-item { padding: 12px 20px; min-width: 0; }
.meta-item + .meta-item { border-inline-start: 1px solid var(--line); }
.meta-item .k { font-size: 0.75rem; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.meta-item .k .ic { width: 14px; height: 14px; }
.meta-item .v { font-weight: 700; font-size: 1rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta-item .v.num { font-size: 1.08rem; }

.section { padding: 20px 22px 22px; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.section-num {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--primary-soft);
  color: var(--sel-ink);
  font: 700 0.85rem var(--font-num);
  transition: background 0.2s, color 0.2s;
}
.section.done .section-num { background: var(--ok); color: #fff; }
.section-title { font-weight: 800; font-size: 1.05rem; line-height: 1.3; }
.section-hint { font-size: 0.8rem; color: var(--text-3); }
.section-actions { margin-inline-start: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.section-body { display: grid; gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }

.insight { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px dashed var(--line-2); font-size: 0.88rem; color: var(--text-2); }
.insight .ic { color: var(--steel); }
[data-theme="dark"] .insight .ic { color: var(--sky); }
.insight b { font-family: var(--font-num); color: var(--text); font-weight: 700; }
.insight .sep { width: 4px; height: 4px; border-radius: 50%; background: var(--line-2); }
.insight.warn { background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--warn); }
.insight.warn .ic, .insight.warn b { color: var(--warn); }

.workers-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 180px; max-width: 320px; }
.search .ic { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 18px; height: 18px; pointer-events: none; }
.search input { width: 100%; height: 40px; border: 1px solid var(--line-2); border-radius: 11px; background: var(--surface); padding: 0 14px; padding-inline-start: 38px; outline: 0; font-size: 0.92rem; }
.search input:focus { border-color: var(--steel); box-shadow: var(--ring); }
.chips-workers .chip { justify-content: flex-start; padding-inline: 8px 14px; min-width: 150px; }
.chips-workers .chip .avatar { width: 30px; height: 30px; border-radius: 9px; font-size: 0.82rem; }
.empty-inline { padding: 18px; border: 1px dashed var(--line-2); border-radius: var(--r); text-align: center; color: var(--text-3); display: grid; gap: 10px; justify-items: center; }
.add-inline { display: flex; gap: 8px; width: min(420px, 100%); }
.add-inline .text-input { height: 42px; }

/* ———— لوحة الملخص ———— */
.summary { position: sticky; top: calc(var(--topbar-h) + 20px); display: grid; gap: 16px; }
.sum-card { padding: 18px; }
.sum-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.sum-head h3 { margin: 0; font-size: 1rem; font-weight: 800; }
.sum-shift { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 12px; font-size: 0.86rem; }
.sum-shift .ic { color: var(--steel); }
.sum-shift b { display: block; font-size: 0.92rem; }
.sum-spec { display: grid; gap: 0; margin: 0 0 14px; }
.sum-spec div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 2px; border-bottom: 1px dashed var(--line); font-size: 0.88rem; }
.sum-spec div:last-child { border-bottom: 0; }
.sum-spec dt { color: var(--text-3); }
.sum-spec dd { margin: 0; font-weight: 700; text-align: left; }
.sum-spec dd.empty { color: var(--line-2); font-weight: 500; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.kpi { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 10px 9px; min-width: 0; }
.kpi .v { font: 700 1.25rem/1.15 var(--font-num); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .u { font: 600 0.7rem var(--font-num); color: var(--text-3); margin-inline-start: 3px; }
.kpi .l { font-size: 0.72rem; color: var(--text-3); margin-top: 2px; white-space: nowrap; }
.sum-lines { display: grid; gap: 6px; font-size: 0.86rem; margin-bottom: 14px; }
.sum-lines div { display: flex; justify-content: space-between; gap: 10px; }
.sum-lines span { color: var(--text-3); }
.sum-lines b { font-family: var(--font-num); }
.sum-warn { display: grid; gap: 8px; margin-bottom: 14px; }
.sum-warn .w { display: flex; gap: 8px; align-items: flex-start; font-size: 0.82rem; color: var(--warn); background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: 10px; padding: 8px 10px; line-height: 1.5; }
.progress-row { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-3); margin-bottom: 6px; }
.progress-row b { color: var(--text); font-family: var(--font-num); }
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-bottom: 16px; }
.progress i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--steel), var(--primary)); transition: width 0.35s var(--ease); }
.progress.full i { background: var(--ok); }
.sum-actions { display: grid; gap: 8px; }
.saved-tag { font-size: 0.75rem; color: var(--text-3); display: inline-flex; align-items: center; gap: 5px; }
.saved-tag .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }

.shift-list-card { padding: 16px 18px; }
.shift-list-card h4 { margin: 0 0 10px; font-size: 0.92rem; display: flex; align-items: center; gap: 8px; }
.shift-list { display: grid; gap: 8px; }
.shift-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-size: 0.84rem; text-align: start; width: 100%; transition: border-color 0.15s; }
button.shift-row:hover { border-color: var(--line-2); }
.shift-row .id { font: 700 0.78rem var(--font-num); color: var(--text-3); }
.shift-row .grow { flex: 1; min-width: 0; }
.shift-row .grow b { display: block; font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shift-row .grow span { color: var(--text-3); font-size: 0.78rem; }
.shift-row .nums { text-align: left; font-family: var(--font-num); font-weight: 700; white-space: nowrap; }
.shift-row .nums small { display: block; color: var(--text-3); font-weight: 500; }
.shift-row.fresh { animation: fresh 1.6s var(--ease); }
@keyframes fresh { 0% { background: var(--ok-soft); border-color: var(--ok); } 100% { background: var(--surface-2); } }
.empty-note { color: var(--text-3); font-size: 0.84rem; padding: 6px 2px; }

.bottom-bar {
  display: none;
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 25;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(25, 33, 50, 0.08);
  align-items: center;
  gap: 14px;
}
.bottom-bar .bb-info { flex: 1; min-width: 0; font-size: 0.82rem; color: var(--text-3); line-height: 1.35; }
.bottom-bar .bb-info b { color: var(--text); font-family: var(--font-num); font-size: 0.95rem; }
.bottom-bar .progress { margin: 6px 0 0; max-width: 240px; }

/* ==========================================================================
   السجل
   ========================================================================== */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px; margin-bottom: 18px; }
.toolbar .search { max-width: 280px; }
.toolbar .spacer { flex: 1; }
.toolbar input[type="date"] { height: 38px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); padding: 0 10px; font-family: var(--font-num); }
.range-custom { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-3); }

.group { margin-bottom: 18px; overflow: hidden; }
.group-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; background: var(--surface-2); }
.group-head .gico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: #fff4d6; color: #b7791f; flex: none; }
.group-head .gico.night { background: #1f2a44; color: #cfe0f2; }
[data-theme="dark"] .group-head .gico { background: rgba(240, 185, 91, 0.12); }
[data-theme="dark"] .group-head .gico.night { background: #26324a; }
.group-head .gt { font-weight: 800; }
.group-head .gd { font-size: 0.8rem; color: var(--text-3); }
.group-stats { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.stat-pill { display: inline-flex; align-items: baseline; gap: 5px; padding: 5px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 0.78rem; color: var(--text-3); }
.stat-pill b { font: 700 0.92rem var(--font-num); color: var(--text); }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th { text-align: start; font-weight: 600; font-size: 0.76rem; color: var(--text-3); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { cursor: pointer; transition: background 0.12s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.n { font-family: var(--font-num); font-weight: 600; white-space: nowrap; }
table.data td.muted { color: var(--text-3); }
.cell-spec b { display: block; font-weight: 700; white-space: nowrap; }
.cell-spec span { font-size: 0.78rem; color: var(--text-3); white-space: nowrap; }
.cell-workers { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.code-badge { display: inline-grid; place-items: center; min-width: 30px; height: 26px; padding: 0 8px; border-radius: 8px; background: var(--surface-3); font: 700 0.85rem var(--font-num); }
.pressure-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 6px; vertical-align: middle; }
.code-tag { display: inline-block; font: 700 0.74rem var(--font-num); direction: ltr; unicode-bidi: isolate; color: var(--sel-ink); background: var(--primary-soft); padding: 1px 7px; border-radius: 6px; margin-inline-end: 6px; }
table.data td.w-warn { color: var(--warn); }
table.data td.w-warn .ic { vertical-align: -3px; margin-inline-end: 4px; }
.stat-pill.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); align-items: center; }
.stat-pill.warn b { color: var(--warn); }

.empty-state { padding: 56px 24px; text-align: center; color: var(--text-3); display: grid; justify-items: center; gap: 10px; }
.empty-state .eico { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-3); display: grid; place-items: center; color: var(--text-3); }
.empty-state .eico .ic { width: 26px; height: 26px; }
.empty-state h3 { margin: 4px 0 0; color: var(--text); font-size: 1.05rem; }
.empty-state p { margin: 0; max-width: 380px; }

.skeleton { border-radius: 10px; background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ==========================================================================
   النوافذ والدرج والتنبيهات
   ========================================================================== */
dialog { color: var(--text); }
dialog.modal {
  border: 0;
  padding: 0;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  width: min(580px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
}
dialog.modal.wide { width: min(720px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(8, 12, 20, 0.5); backdrop-filter: blur(3px); }
dialog[open].modal { animation: pop 0.22s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.modal-head { display: flex; align-items: flex-start; gap: 14px; padding: 22px 24px 0; }
.modal-head .mico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--primary-soft); color: var(--sel-ink); flex: none; }
.modal-head .mico.bad { background: var(--bad-soft); color: var(--bad); }
.modal-head .mico.ok { background: var(--ok-soft); color: var(--ok); }
.modal-head h3 { margin: 0; font-size: 1.2rem; font-weight: 800; }
.modal-head p { margin: 4px 0 0; color: var(--text-2); font-size: 0.92rem; }
.modal-head .x { margin-inline-start: auto; }
.modal-body { padding: 20px 24px; display: grid; gap: 16px; }
.modal-foot { display: flex; gap: 10px; padding: 16px 24px 22px; justify-content: flex-start; flex-wrap: wrap; border-top: 1px solid var(--line); background: var(--surface-2); }
.modal-foot .spacer { flex: 1; }

.review-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.review-kpis .kpi .v { font-size: 1.5rem; }
.review-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.review-grid div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 0.9rem; }
.review-grid dt { color: var(--text-3); }
.review-grid dd { margin: 0; font-weight: 700; text-align: left; }
.review-block { font-size: 0.9rem; }
.review-block .k { color: var(--text-3); font-size: 0.8rem; margin-bottom: 4px; }
.review-block .v { font-weight: 600; line-height: 1.7; white-space: pre-wrap; }

dialog.drawer {
  margin: 0;
  margin-inline-end: auto;
  inset-inline-start: auto;
  border: 0;
  padding: 0;
  height: 100%;
  max-height: 100%;
  width: min(520px, 100vw);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  display: none;
  flex-direction: column;
}
dialog.drawer[open] { display: flex; animation: slide 0.26s var(--ease); }
@keyframes slide { from { transform: translateX(-40px); opacity: 0; } }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; font-size: 1.15rem; font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.drawer-head p { margin: 4px 0 0; font-size: 0.85rem; color: var(--text-3); }
.drawer-head .x { margin-inline-start: auto; }
.drawer-body { flex: 1; overflow: auto; padding: 18px 22px; display: grid; gap: 18px; align-content: start; }
.drawer-foot { display: flex; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.dl { display: grid; gap: 0; margin: 0; }
.dl div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; font-weight: 700; text-align: left; }
.dl-title { font-size: 0.78rem; font-weight: 700; color: var(--text-3); margin: 0 0 4px; }
.timeline { display: grid; gap: 12px; }
.tl-item { display: flex; gap: 12px; font-size: 0.85rem; }
.tl-item .tdot { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: none; }
.tl-item .tdot .ic { width: 15px; height: 15px; }
.tl-item .tdot.ok { background: var(--ok-soft); color: var(--ok); }
.tl-item .tdot.bad { background: var(--bad-soft); color: var(--bad); }
.tl-item .tdot.blue { background: var(--primary-soft); color: var(--sel-ink); }
.tl-item b { display: block; }
.tl-item span { color: var(--text-3); }
.tl-item ul { margin: 6px 0 0; padding-inline-start: 18px; color: var(--text-2); }

.toasts { position: fixed; bottom: 24px; left: 24px; z-index: 1000; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #192132;
  color: #eef3f8;
  box-shadow: 0 14px 40px rgba(8, 12, 20, 0.3);
  font-size: 0.92rem;
  animation: toast-in 0.3s var(--ease);
  border: 1px solid rgba(159, 196, 222, 0.14);
}
.toast .ic { margin-top: 1px; }
.toast.ok .ic { color: #4ad69a; }
.toast.bad .ic { color: #ff8a7e; }
.toast.info .ic { color: var(--sky); }
.toast .grow { flex: 1; min-width: 0; }
.toast b { display: block; }
.toast span { color: #b3c3d4; font-size: 0.84rem; }
.toast.out { animation: toast-out 0.25s forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ==========================================================================
   الإدارة
   ========================================================================== */
.lists-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; }
.lists-nav { padding: 8px; display: grid; gap: 2px; position: sticky; top: calc(var(--topbar-h) + 20px); }
.lists-nav button { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 0; background: transparent; text-align: start; font-weight: 600; font-size: 0.92rem; color: var(--text-2); }
.lists-nav button:hover { background: var(--surface-2); color: var(--text); }
.lists-nav button[aria-current="true"] { background: var(--primary-soft); color: var(--sel-ink); }
.lists-nav button .grow { flex: 1; }
.lists-nav button .count { font: 600 0.75rem var(--font-num); color: var(--text-3); }
.lists-editor { padding: 20px 22px; }
.le-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.le-head h3 { margin: 0; font-size: 1.15rem; font-weight: 800; }
.le-head p { margin: 4px 0 0; color: var(--text-3); font-size: 0.86rem; max-width: 560px; }
.le-add { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 18px; flex-wrap: wrap; }
.le-add .text-input, .le-add textarea { flex: 1; min-width: 220px; }
.le-add textarea { min-height: 48px; height: 48px; resize: vertical; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); outline: 0; font-size: 1rem; }
.le-add textarea:focus { border-color: var(--steel); box-shadow: var(--ring); }
.le-items { display: grid; gap: 8px; }
.le-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); transition: opacity 0.2s, background 0.2s; }
.le-item.off { background: var(--surface-2); }
.le-item.off .le-label { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--line-2); }
.le-item .order { display: flex; flex-direction: column; }
.le-item .order button { border: 0; background: transparent; color: var(--text-3); width: 26px; height: 18px; display: grid; place-items: center; border-radius: 6px; }
.le-item .order button:hover:not(:disabled) { color: var(--text); background: var(--surface-3); }
.le-item .order button:disabled { opacity: 0.3; }
.le-item .order .ic { width: 14px; height: 14px; }
.le-label { flex: 1; min-width: 0; height: 38px; border: 1px solid transparent; border-radius: 9px; background: transparent; padding: 0 10px; font-size: 0.95rem; font-weight: 600; outline: 0; }
.le-label:hover { border-color: var(--line); }
.le-label:focus { border-color: var(--steel); box-shadow: var(--ring); background: var(--surface); }
.le-label[readonly] { cursor: default; }
.le-label[readonly]:hover { border-color: transparent; }
/* عنوان القسم ووصفه في محرر اللوحة: بعرض مكانهما لا بالعرض الافتراضي للحقل (كان يوسّع الصفحة على الجوال) */
.section-head .le-label { display: block; width: 100%; }
.le-head-main { flex: 1; min-width: 0; }
@media (max-width: 640px) {
  /* على الجوال تنزل أزرار القسم (ترتيب/حذف) لسطر خاص فيأخذ العنوان العرض كله */
  .section-head.le-head { flex-wrap: wrap; }
  .le-head-main { flex: 1 1 60%; }
}
.le-item .state { font-size: 0.75rem; color: var(--text-3); white-space: nowrap; }

/* ———— الأصناف ———— */
.item-code { display: inline-block; font: 700 1rem var(--font-num); direction: ltr; unicode-bidi: isolate; color: var(--sel-ink); background: var(--primary-soft); padding: 3px 10px; border-radius: 8px; letter-spacing: 0.02em; white-space: nowrap; }
.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.item-card { padding: 16px; display: grid; gap: 10px; align-content: start; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.item-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); }
.item-card.off { opacity: 0.62; }
.item-card.off .item-code { background: var(--surface-3); color: var(--text-2); }
.ic-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ic-top .spacer { flex: 1; }
.ic-name { font-weight: 800; line-height: 1.4; }
.ic-spec { display: flex; flex-wrap: wrap; gap: 6px; }
.spec-tag { font-size: 0.78rem; padding: 2px 9px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); font-weight: 600; }
.ic-weight { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 0.84rem; color: var(--text-3); }
.ic-weight b { font: 700 1.15rem var(--font-num); color: var(--text); }
.ic-weight .tol { font-family: var(--font-num); margin-inline-start: auto; }
.ic-notes { font-size: 0.8rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.warn-text { color: var(--warn); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }

.settings-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 14px; }
.settings-bar .sb-ico { width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft); color: var(--sel-ink); display: grid; place-items: center; flex: none; }
.settings-bar b.big { font: 700 1.2rem var(--font-num); }

.unknown-card { padding: 16px 18px; margin-bottom: 14px; border-color: var(--warn-line); }
.uc-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.uc-head > .ic { color: var(--warn); margin-top: 2px; }
.uc-head b { display: block; }
.uc-head span { font-size: 0.85rem; color: var(--text-3); }
.uc-list { display: grid; gap: 8px; }
.uc-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); flex-wrap: wrap; }
.uc-row .grow { flex: 1; min-width: 200px; }
.uc-row b { display: block; font-size: 0.92rem; }
.uc-row span { font-size: 0.8rem; color: var(--text-3); }

.code-strip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-radius: var(--r); background: var(--primary-soft); color: var(--sel-ink); font-size: 0.9rem; }
.code-strip .item-code { background: var(--surface); }
.code-strip .cs-w { margin-inline-start: auto; }
.code-strip .cs-w b { font-family: var(--font-num); }
.code-strip.unknown { background: var(--surface-2); color: var(--text-2); border: 1px dashed var(--line-2); }
.code-strip .grow { flex: 1; min-width: 180px; }

.chips-compact { gap: 8px; }
.chips-compact .chip { min-height: 40px; padding: 6px 12px; font-size: 0.88rem; }
.dim-block { display: grid; gap: 6px; }
.dim-block .dim-title { font-size: 0.8rem; color: var(--text-3); font-weight: 600; }
.import-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.import-errors { max-height: 240px; overflow: auto; display: grid; gap: 6px; font-size: 0.85rem; }
.import-errors div { padding: 6px 10px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); }

.settings-bar .sb-stat { min-width: 150px; }
.settings-bar .sb-stat .muted { font-size: 0.78rem; }
.settings-bar .spacer { flex: 1; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 18px; }

/* ———— حقل مقفل (قيمة ثابتة يحددها المدير) ———— */
.input-wrap.locked { background: var(--surface-2); border-style: dashed; }
.input-wrap.locked input { color: var(--text-2); cursor: default; }
.input-wrap.locked .lock-ic { display: grid; place-items: center; padding-inline: 12px 0; color: var(--text-3); }

/* ———— الاتصال اللحظي والجرس والطابور في الشريط العلوي ———— */
.conn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: 99px; font-size: 0.78rem; font-weight: 600; border: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.conn .ic { display: none; }
.conn.online { color: var(--ok); }
.conn.connecting { color: var(--warn); }
.conn.connecting::before { animation: blink 1s infinite; }
.conn.offline { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.conn.offline .ic { display: inline-grid; }
.conn.offline::before { display: none; }
@keyframes blink { 50% { opacity: 0.25; } }
.bell { position: relative; text-decoration: none; }
.bell-badge { position: absolute; top: -6px; inset-inline-end: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--bad); color: #fff; font: 700 0.7rem/20px var(--font-num); text-align: center; box-shadow: 0 0 0 2px var(--bg); }
.outbox-chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--warn-line); background: var(--warn-soft); color: var(--warn); font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
.nav-item .count { background: var(--bad); color: #fff; }

.toast.clickable { cursor: pointer; }
.toast.warn .ic { color: #f0b95b; }
.toast.critical { border-color: rgba(255, 123, 110, 0.5); background: #3a1d1f; }
.toast.critical .ic { color: #ff8a7e; }

/* ———— مركز التنبيهات ———— */
.alert-group { margin-bottom: 18px; }
.ag-title { font-size: 0.82rem; font-weight: 700; color: var(--text-2); margin: 0 4px 8px; }
.alert-list { overflow: hidden; }
.alert-row { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); text-align: start; position: relative; transition: background 0.12s; }
.alert-row:last-child { border-bottom: 0; }
.alert-row:hover { background: var(--surface-2); }
.alert-row::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--line-2); }
.alert-row.sev-warn::before { background: var(--warn); }
.alert-row.sev-critical::before { background: var(--bad); }
.alert-row.sev-info::before { background: var(--steel); }
.alert-row.unread { background: var(--primary-soft); }
.alert-row.unread:hover { filter: brightness(0.985); }
.alert-row.handled { opacity: 0.72; }
.alert-row.fresh { animation: fresh 1.8s var(--ease); }
.al-ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.sev-warn .al-ico { background: var(--warn-soft); color: var(--warn); }
.sev-critical .al-ico { background: var(--bad-soft); color: var(--bad); }
.sev-info .al-ico { background: var(--primary-soft); color: var(--sel-ink); }
.al-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.al-title { font-weight: 800; display: flex; align-items: center; gap: 8px; line-height: 1.4; }
.udot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: none; }
[data-theme="dark"] .udot { background: var(--sky); }
.al-body { font-size: 0.85rem; color: var(--text-2); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.al-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.76rem; color: var(--text-3); margin-top: 2px; }
.sev-badge.info { background: var(--primary-soft); color: var(--sel-ink); }
.sev-badge.warn { background: var(--warn-soft); color: var(--warn); }
.sev-badge.critical { background: var(--bad-soft); color: var(--bad); }
.alert-hero { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); }
.alert-hero > div { flex: 1; min-width: 0; }
.alert-hero.sev-critical { border-color: rgba(192, 57, 43, 0.35); }
.alert-hero.sev-warn { border-color: var(--warn-line); }

.rules-list { display: grid; gap: 8px; }
.rule-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; }
.rule-row.off { opacity: 0.6; }
.rule-main { flex: 1; min-width: 200px; display: grid; gap: 2px; }
.rule-main span { font-size: 0.8rem; color: var(--text-3); }
.rule-ctl { display: flex; gap: 8px; flex-wrap: wrap; }
.rule-ctl .seg button { min-height: 30px; padding: 0 10px; font-size: 0.8rem; }

/* ==========================================================================
   لوحة الإدخال السريع للعمال (نمط الكاشير): سؤال في كل شاشة، أزرار كبيرة للإصبع
   ========================================================================== */
.ic.flip svg { transform: scaleX(-1); }
.quick { max-width: 760px; margin-inline: auto; }
.q-screen { display: grid; gap: 16px; padding-bottom: 96px; }
.q-head { display: grid; gap: 10px; }
.q-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.q-shift { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 0.86rem; color: var(--text-2); }
.q-shift.late { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }
.q-count { font: 700 0.95rem var(--font-num); color: var(--text-3); }
.q-progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.q-progress i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--steel), var(--primary)); transition: width 0.3s var(--ease); }
.q-title { margin: 6px 0 0; font-size: clamp(1.5rem, 4.5vw, 2rem); font-weight: 800; line-height: 1.3; }
.q-sub { margin: -4px 0 0; color: var(--text-3); font-size: 0.95rem; }
.q-body { display: grid; gap: 14px; }

.q-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.q-choice {
  position: relative; min-height: 96px; padding: 14px 12px; border-radius: 18px; border: 2px solid var(--line-2); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  font-weight: 700; font-size: 1.25rem; color: var(--text); box-shadow: var(--shadow-1);
  transition: border-color 0.12s, background 0.12s, transform 0.08s;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.q-choice:active { transform: scale(0.97); }
.q-choice[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--sel-ink); box-shadow: inset 0 0 0 1px var(--primary); }
[data-theme="dark"] .q-choice[aria-pressed="true"] { border-color: #6fa8dc; box-shadow: inset 0 0 0 1px #6fa8dc; }
.q-choice .big { font: 800 2rem/1.1 var(--font-num); direction: ltr; unicode-bidi: isolate; }
.q-choice .small { font-size: 0.85rem; color: var(--text-2); font-weight: 600; }
.q-choice .lbl { line-height: 1.35; }
.q-choice .swatch.thread { width: 34px; height: 10px; border-radius: 99px; background: repeating-linear-gradient(-60deg, var(--thread) 0 5px, #188046 5px 8px); }
.q-big .q-choice { min-height: 120px; font: 800 2.6rem var(--font-num); }
.q-other { border-style: dashed; color: var(--text-2); font-size: 1rem; }
.q-people { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.q-people .q-choice { flex-direction: row; justify-content: flex-start; min-height: 72px; font-size: 1.05rem; padding-inline: 12px; }
.q-people .avatar { width: 40px; height: 40px; border-radius: 12px; }
.q-tags .q-choice { min-height: 64px; font-size: 1rem; }
.q-repeat { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border-radius: 16px; border: 1px solid transparent; background: var(--primary-soft); color: var(--sel-ink); text-align: start; }
.q-repeat .rt { flex: 1; min-width: 0; display: grid; gap: 2px; }
.q-repeat b { font-size: 1.05rem; }
.q-repeat .rt span { font-size: 0.9rem; opacity: 0.85; }
.q-note { color: var(--text-3); font-size: 0.9rem; text-align: center; }

.q-num { display: grid; gap: 14px; }
.q-display { display: flex; align-items: baseline; justify-content: center; gap: 10px; padding: 18px; border-radius: 18px; background: var(--surface); border: 2px solid var(--steel); box-shadow: var(--ring); direction: ltr; }
.q-val { font: 800 clamp(2.6rem, 11vw, 3.6rem)/1 var(--font-num); letter-spacing: 0.01em; }
.q-val.placeholder { color: var(--text-3); opacity: 0.4; }
.q-unit { font: 700 1.2rem var(--font-num); color: var(--text-3); }
.q-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.q-key { height: 72px; border-radius: 16px; border: 1px solid var(--line-2); background: var(--surface); font: 700 1.9rem var(--font-num); color: var(--text); box-shadow: var(--shadow-1); touch-action: manipulation; transition: background 0.1s, transform 0.08s; }
.q-key:active { transform: scale(0.96); background: var(--surface-3); }
.q-del { color: var(--text-2); display: grid; place-items: center; }
.q-del .ic { width: 30px; height: 30px; }
.q-zero { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 64px; border-radius: 16px; border: 2px dashed var(--line-2); background: var(--surface-2); font-weight: 800; font-size: 1.15rem; color: var(--text-2); }
.q-live { display: grid; gap: 8px; }
.q-live:empty { display: none; }
.q-warn { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--warn); font-weight: 600; line-height: 1.6; }
.q-error { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--bad-soft); color: var(--bad); font-weight: 700; }

.q-actions {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 25; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(25, 33, 50, 0.08);
}
@media (min-width: 961px) { .q-actions { inset-inline-start: 272px; } }
.q-actions .spacer { flex: 1; }
.q-actions .btn-lg { min-width: 120px; }
.q-next, .q-save { min-width: 170px !important; }
.has-qbar .toasts { bottom: 100px; }

.q-summary { display: grid; gap: 12px; padding: 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.q-spec { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 800; font-size: 1.2rem; justify-content: center; text-align: center; }
.q-rows { display: grid; gap: 6px; }
.q-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); text-align: start; }
.q-row .k { color: var(--text-3); font-size: 0.9rem; min-width: 120px; }
.q-row .v { flex: 1; font-weight: 700; font-size: 1.05rem; }
.q-row .v.empty { color: var(--line-2); }
.q-row .ic { color: var(--text-3); }
.q-row.bad { border-color: var(--bad); background: var(--bad-soft); }
.q-row.locked { background: var(--surface-2); cursor: default; }

.q-success { text-align: center; justify-items: center; padding-top: 24px; }
.q-ok { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; background: var(--ok); color: #fff; box-shadow: 0 18px 40px rgba(23, 131, 90, 0.35); animation: pop 0.35s var(--ease); }
.q-ok .ic { width: 64px; height: 64px; }
.q-ok .ic svg { stroke-width: 2.6; }
.q-success.queued .q-ok { background: var(--warn); box-shadow: 0 18px 40px rgba(154, 98, 10, 0.3); }
.q-success h2 { margin: 6px 0 0; font-size: 2.2rem; font-weight: 800; }
.q-success p { margin: 0; color: var(--text-2); font-size: 1.05rem; }
.q-success .q-no { font: 800 1.4rem var(--font-num); color: var(--text); }
.q-again { min-width: 240px; height: 64px; font-size: 1.2rem; }
.q-timer { width: 240px; height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.q-timer i { display: block; width: 100%; height: 100%; background: var(--ok); transition: width linear; }

@media (max-width: 640px) {
  .q-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .q-people { grid-template-columns: minmax(0, 1fr); }
  .q-choice { min-height: 84px; font-size: 1.1rem; }
  .q-key { height: 64px; }
  .q-actions .btn-lg { min-width: 0; padding: 0 16px; }
  .q-next, .q-save { min-width: 0 !important; flex: 1; }
  .q-row .k { min-width: 96px; }
}

/* ==========================================================================
   لوحة الخلط: حقل «مواد وكميات» + لوحة الكاشير + شاشة المطابقة
   ========================================================================== */
.chips-mats { gap: 8px; }
.chips-mats .chip { min-height: 44px; padding: 6px 12px; font-size: 0.9rem; }
.mat-rows { display: grid; gap: 8px; }
.mat-rows[hidden] { display: none; }
.mat-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(140px, 200px) auto; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.mat-row .mat-name { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.mat-row .input-wrap { height: 44px; }
.mat-total { font-size: 0.88rem; color: var(--text-2); }
.mat-total:empty { display: none; }
.mat-total b { font-family: var(--font-num); color: var(--text); }

.q-mats .q-choice { min-height: 84px; font-size: 1.1rem; }
.q-mats .q-choice .small { font-family: var(--font-num); }
.q-matbar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.q-matchip { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 0.9rem; color: var(--text-2); white-space: nowrap; }
.q-matchip b { font-family: var(--font-num); color: var(--ok); }
.q-matchip.on { border-color: var(--primary); background: var(--primary-soft); color: var(--sel-ink); }
[data-theme="dark"] .q-matchip.on { border-color: #6fa8dc; }

.stat-pill.link { color: var(--sel-ink); background: var(--primary-soft); border-color: transparent; text-decoration: none; align-items: center; font-weight: 700; }
.stat-pill.link:hover { filter: brightness(0.97); }
.mix-kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.mix-kpis .kpi .l { white-space: normal; line-height: 1.4; }
/* أرقام الخلط قد تكون سالبة (الفارق): اتجاه LTR حتى لا تنتقل إشارة السالب لليمين، مع بقاء المحاذاة يميناً */
.kpi .v[dir="ltr"] { text-align: right; }
.kpi.kpi-warn { background: var(--warn-soft); border-color: var(--warn-line); }
.kpi.kpi-warn .v, .kpi.kpi-warn .l { color: var(--warn); }
.mix-table td { padding: 10px 12px; }
/* أسعار المواد */
.prices-top { display: flex; gap: 12px 16px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.prices-top .field { flex: 0 1 240px; min-width: 0; }
.prices-foot { display: flex; gap: 12px 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 14px; }
.prices-table td { padding: 8px 12px; vertical-align: middle; }
.prices-table tbody tr { cursor: default; }
.prices-table tbody tr:hover { background: none; }
.prices-table .price-in { height: 42px; min-width: 150px; max-width: 200px; }
.input-wrap.bad { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
@media (max-width: 640px) {
  /* الجوال: كل مادة سطران — الاسم والسعر الساري، ثم حقل السعر الجديد والسجل (بلا تمرير أفقي) */
  .prices-table thead { display: none; }
  .prices-table, .prices-table tbody { display: block; }
  .prices-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .prices-table tr:last-child { border-bottom: 0; }
  table.data.prices-table td { display: block; padding: 0; border: 0; }
  table.data.prices-table td:nth-child(3), table.data.prices-table td:empty { display: none; }
  .prices-table td:nth-child(4):has(+ td:empty) { grid-column: 1 / -1; }
  .prices-table .price-in { min-width: 0; max-width: none; }
}
.mix-table tr.shift-first td { border-top: 2px solid var(--line-2); }
.mix-table tbody tr:first-child td { border-top: 0; }
.mix-table td.muted { white-space: nowrap; font-size: 0.82rem; }
.mix-table td.muted b { color: var(--text); }

@media (max-width: 640px) {
  .mat-row { grid-template-columns: minmax(0, 1fr) auto; }
  .mat-row .input-wrap { grid-column: 1 / -1; grid-row: 2; }
  .mix-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.users-grid { overflow: hidden; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell b { display: block; }
.user-cell span { font-size: 0.8rem; color: var(--text-3); direction: ltr; unicode-bidi: isolate; }
.form-grid { display: grid; gap: 16px; }

/* ==========================================================================
   الصلاحيات (P6): المستخدمون بتبويبات · مصفوفة الصلاحيات · الأدوار · الأجهزة · زر التبديل
   ========================================================================== */
.user-dialog { display: grid; gap: 16px; }
.seg.tabs { width: 100%; }
.seg.tabs button { flex: 1 1 auto; justify-content: center; }
.tab-body { min-height: 180px; }
.role-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.role-opt { display: flex; align-items: flex-start; gap: 10px; text-align: start; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); }
.role-opt b { display: block; color: var(--text); }
.role-opt small { display: block; font-size: 0.78rem; line-height: 1.5; margin-top: 2px; }
.role-opt[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); background: var(--primary-soft); }
.role-opt:disabled { opacity: 0.5; }
.cap-matrix { display: grid; gap: 14px; }
.cap-group { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cap-group-title { display: flex; align-items: center; gap: 8px; padding: 9px 14px; background: var(--surface-2); font-weight: 800; font-size: 0.9rem; }
.cap-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 86px; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.cap-row:first-of-type { border-top: 0; }
.cap-main b { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.9rem; }
.cap-main span { display: block; font-size: 0.78rem; color: var(--text-3); line-height: 1.5; }
.cap-ctl .seg button { min-height: 30px; padding: 0 10px; font-size: 0.8rem; }
.cap-state { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; font-weight: 700; justify-content: flex-end; }
.cap-state.yes { color: var(--ok); }
.cap-state.no { color: var(--text-3); }
.cap-row.fixed { opacity: 0.7; }
.access-summary { border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); padding: 12px 14px; }
.as-title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 0.9rem; margin-bottom: 6px; }
.access-summary ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.access-summary li { display: flex; align-items: flex-start; gap: 8px; font-size: 0.86rem; color: var(--text-2); line-height: 1.6; }
.access-summary li .ic { margin-top: 3px; color: var(--text-3); }
.access-summary li.tone-warn { color: var(--warn); }
.access-summary li.tone-ok { color: var(--ok); }
.panel-scope { display: grid; gap: 6px; margin-top: 12px; }
.ps-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; flex-wrap: wrap; }
.ps-row small { color: var(--text-3); }
.ps-row .seg button { min-height: 30px; padding: 0 10px; font-size: 0.8rem; }
.users-table td { vertical-align: middle; }
.roles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.role-card { padding: 16px; display: grid; gap: 12px; align-content: start; }
.rc-head { display: flex; align-items: flex-start; gap: 12px; }
.rc-head b { display: block; font-size: 1.02rem; }
.rc-head span:not(.badge) { display: block; font-size: 0.82rem; color: var(--text-3); line-height: 1.6; }
.rc-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--sel-ink); flex: none; }
.rc-caps { display: flex; flex-wrap: wrap; gap: 6px; }
.spec-tag.off { opacity: 0.45; }
.rc-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; }
.rc-foot .spacer { flex: 1; }
.inline-save { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.devices { display: grid; gap: 8px; }
.device-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.device-row.current { border-color: var(--ok); background: var(--ok-soft); }
.dev-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); flex: none; }
.dev-main { flex: 1; min-width: 0; }
.dev-main b { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dev-main span { display: block; font-size: 0.8rem; line-height: 1.6; }
.item-card.readonly { cursor: default; }
/* زر التبديل بين الوضعين: كبير يُلمس بسهولة، في رأس الشاشة الثابت فلا يزيح أزرار الخطوة */
.mode-switch { min-height: 40px; }
.meta-note { margin: 0 20px 12px; padding: 8px 12px; border-radius: 10px; background: var(--primary-soft); color: var(--sel-ink); font-size: 0.86rem; font-weight: 600; }
.meta-note.warn { background: var(--warn-soft); color: var(--warn); }
.q-mode { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--primary); background: var(--primary-soft); color: var(--sel-ink); font-weight: 700; font-size: 0.86rem; margin-inline-start: auto; }
.q-mode + .q-count { margin-inline-start: 0; }
.q-shift:disabled { opacity: 1; cursor: default; }

/* ==========================================================================
   الاستجابة لأحجام الشاشات
   ========================================================================== */
@media (max-width: 1240px) {
  .entry-grid { grid-template-columns: minmax(0, 1fr); }
  .summary .sum-card { display: none; }
  .summary { position: static; }
  .bottom-bar { display: flex; }
  .entry-page { padding-bottom: 96px; }
  .toasts { bottom: 96px; }
}
@media (max-width: 1100px) {
  .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meta-item:nth-child(3) { border-inline-start: 0; }
  .meta-item:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .clock-chip .d { display: none; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 284px; transform: translateX(100%); transition: transform 0.28s var(--ease); box-shadow: var(--shadow-3); }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { opacity: 1; pointer-events: auto; }
  .topbar { padding: 0 16px; }
  .topbar .menu-btn { display: grid; }
  .content { padding: 18px 16px 48px; }
  .lists-layout { grid-template-columns: minmax(0, 1fr); }
  .lists-nav { position: static; display: flex; overflow-x: auto; }
  .lists-nav button { white-space: nowrap; }
  .lists-nav button .count { display: none; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-visual { display: none; }
}
@media (max-width: 640px) {
  .cap-row { grid-template-columns: minmax(0, 1fr) auto; }
  .cap-ctl { grid-column: 1 / -1; grid-row: 2; }
  .seg.tabs button { flex: 1 1 40%; }
  .role-pick { grid-template-columns: minmax(0, 1fr); }
  .meta-note { margin: 0 16px 12px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .section { padding: 16px; }
  .clock-chip { padding: 4px; }
  .clock-chip .clock-text { display: none; }
  .page-title h1 { font-size: 1.05rem; }
  .meta-head { padding: 14px 16px; }
  .meta-item { padding: 10px 16px; }
  .chips-size .chip { min-width: calc(33.33% - 7px); }
  .chips-workers .chip { min-width: calc(50% - 5px); }
  .review-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi .v { font-size: 1.1rem; }
  .group-stats { margin-inline-start: 0; width: 100%; }
  .toasts { left: 16px; }
  .bottom-bar .progress { display: none; }
  .import-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .code-strip .cs-w { margin-inline-start: 0; width: 100%; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .page-title .crumb { display: none; }
  .clock-chip .shift-badge { font-size: 0; gap: 0; padding: 7px 9px; }
  .conn .conn-text { display: none; }
  .conn { padding: 0 8px; }
  .outbox-chip { font-size: 0; gap: 0; padding: 0 10px; }
  .outbox-chip .ic { font-size: 1rem; }
  .top-actions { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ———— الأونلاين (v1.7.0): أشرطة التنبيه، الدخول بخطوتين، حسابي وأجهزتي، تثبيت التطبيق ———— */
.app-notices { display: grid; gap: 8px; padding: 12px 24px 0; }
.app-notice { align-items: center; margin: 0; }
.app-notice .btn { flex: none; }
.code-input { font-family: var(--font-num); font-size: 1.5rem; letter-spacing: 0.3em; text-align: center; }
.auth-links { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.auth-install { margin-top: 14px; width: 100%; justify-content: center; }
.account-sec { display: grid; gap: 12px; }
.sec-block { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; background: var(--surface-2); }
.sec-block p { margin: 6px 0 10px; font-size: 0.86rem; line-height: 1.7; }
.sec-block code { font-family: ui-monospace, Consolas, monospace; font-size: 0.84rem; background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }
.sec-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sec-head .grow { flex: 1; min-width: 200px; }
.sec-head .grow b { display: block; }
.sec-head .grow span { display: block; font-size: 0.84rem; line-height: 1.7; }
.sec-head .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sec-title { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 1rem; }
.sec-desc { margin: -6px 0 0; font-size: 0.84rem; }
.sec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 16px; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.recovery-codes code, .totp-key {
  font-family: ui-monospace, Consolas, monospace; font-size: 1rem; padding: 8px 10px; border-radius: var(--r-sm);
  background: var(--surface-3); border: 1px solid var(--line); text-align: center; display: block;
}
.totp-grid { display: grid; grid-template-columns: 200px 1fr; gap: 18px; align-items: start; margin-top: 12px; }
.totp-qr { width: 200px; height: 200px; border-radius: var(--r); border: 1px solid var(--line); background: #fff; image-rendering: pixelated; }
.steps { margin: 0; padding-inline-start: 22px; display: grid; gap: 8px; line-height: 1.8; }
.steps code { font-family: ui-monospace, Consolas, monospace; font-size: 0.86rem; background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }
.ui-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: var(--primary-soft);
  color: var(--sel-ink); font-weight: 600; font-size: 0.86rem; vertical-align: middle; white-space: nowrap;
}
.install { display: grid; gap: 14px; }
.install-now { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; border-radius: var(--r); background: var(--primary-soft); }
.install-now .grow { flex: 1; min-width: 200px; }
.install-now .grow b, .install-now .grow span { display: block; }
.install-card { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; display: grid; gap: 10px; }
.install-card.mine { border-color: var(--steel); box-shadow: var(--shadow-2); }
.install-card:not(.mine) { opacity: 0.9; }
.ic-head { display: flex; align-items: center; gap: 10px; }
.ic-head b { font-size: 1.02rem; }
@media (max-width: 640px) {
  .app-notices { padding: 10px 16px 0; }
  .app-notice { flex-wrap: wrap; }
  .totp-grid { grid-template-columns: 1fr; justify-items: center; }
  .recovery-codes { grid-template-columns: 1fr; }
}
