/* =========================================================
   هوية عالم المحمول: أزرق
   ========================================================= */
:root {
  --blue-950: #04122e;
  --blue-900: #071a40;
  --blue-800: #0b2557;
  --blue-700: #12347a;
  --blue-600: #1d4ed8;
  --blue-500: #2563eb;
  --blue-400: #60a5fa;
  --blue-300: #93c5fd;
  --blue-200: #bfdbfe;
  --blue-100: #dbeafe;
  --blue-50: #eff6ff;

  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --text: #0f1b2d;
  --text-2: #44546a;
  --muted: #7a879a;
  --border: #e3e8f0;
  --border-2: #d2dae6;

  --ok: #16a34a;
  --ok-bg: #e8f7ee;
  --ok-ink: #0f7a37;
  --warn: #e3a008;
  --warn-bg: #fff6db;
  --warn-ink: #8a5d00;
  --orange: #ea7a12;
  --orange-bg: #fff0e2;
  --orange-ink: #9a4a06;
  --bad: #dc3b2f;
  --bad-bg: #fdeceb;
  --bad-ink: #b42318;
  --violet: #6d4ee8;
  --violet-bg: #efebfe;
  --violet-ink: #4a2fc0;
  --teal: #0d9488;
  --teal-bg: #e3f6f4;
  --teal-ink: #0b6d64;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(11, 37, 87, .05), 0 6px 20px rgba(11, 37, 87, .06);
  --shadow-lg: 0 20px 60px rgba(4, 18, 46, .28);
  --font: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { color: var(--blue-500); }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; }
p { margin: 0 0 .5rem; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
img { max-width: 100%; }
.ic { width: 18px; height: 18px; flex-shrink: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }
.t-ok { color: var(--ok-ink); }
.t-bad { color: var(--bad-ink); }
.t-warn { color: var(--warn-ink); }
.t-blue { color: var(--blue-600); }
.fw { font-weight: 800; }

/* ---------------- الهيكل ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; z-index: 40;
  display: flex; flex-direction: column; color: #fff;
  background: radial-gradient(120% 55% at 100% 0%, rgba(96, 165, 250, .22), transparent 60%), linear-gradient(180deg, var(--blue-800), var(--blue-950));
  border-left: 3px solid var(--blue-500);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px 18px; border-bottom: 1px solid rgba(255, 255, 255, .08); color: #fff; }
.brand:hover { color: #fff; }
.brand-logo { width: 48px; height: 48px; background: #fff; border-radius: 13px; display: grid; place-items: center; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); color: var(--blue-600); }
.brand-logo .ic { width: 26px; height: 26px; stroke-width: 2.2; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 16px; font-weight: 800; letter-spacing: -.2px; }
.brand-text span { font-size: 12px; color: var(--blue-300); }
.nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.nav-group { font-size: 11.5px; font-weight: 700; color: rgba(255, 255, 255, .38); padding: 14px 26px 6px; }
.nav a { display: flex; align-items: center; gap: 12px; margin: 2px 12px; padding: 10px 14px; border-radius: 10px; color: rgba(255, 255, 255, .78); font-weight: 600; position: relative; transition: background .15s, color .15s; }
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(96, 165, 250, .06), rgba(96, 165, 250, .24)); color: #fff; }
.nav a.active .ic { color: var(--blue-400); }
.nav a.active::before { content: ''; position: absolute; right: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 4px 0 0 4px; background: var(--blue-400); }
.nav a span { flex: 1; }
.pill { font-style: normal; font-size: 11.5px; font-weight: 700; min-width: 22px; height: 20px; border-radius: 999px; display: inline-grid; place-items: center; padding: 0 6px; }
.pill.red { background: var(--bad); color: #fff; }
.pill.blue { background: var(--blue-500); color: #fff; }
.pill.green { background: var(--ok); color: #fff; }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, .06); }
.me .av { width: 36px; height: 36px; border-radius: 50%; background: var(--blue-500); color: #fff; display: grid; place-items: center; font-weight: 800; flex-shrink: 0; }
.me .who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.me .who a { color: #fff; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .who small { color: var(--blue-300); font-size: 11.5px; }
.me form { margin: 0; }
.me button { background: none; border: 0; color: rgba(255, 255, 255, .6); cursor: pointer; padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.me button:hover { background: rgba(255, 255, 255, .1); color: #fff; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; padding: 14px 28px; background: rgba(243, 245, 249, .9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 21px; font-weight: 800; color: var(--blue-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { margin: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.date-pill { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 13px; color: var(--blue-700); white-space: nowrap; }
.date-pill .ic { color: var(--blue-500); width: 16px; height: 16px; }
.icon-btn.menu-btn { display: none; }
.main { padding: 22px 24px 48px; display: flex; flex-direction: column; gap: 18px; }
.scrim { display: none; }

/* ---------------- الأزرار والعناصر ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: #fff; font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap; transition: transform .08s, background .15s, border-color .15s, box-shadow .15s; color: var(--text); text-decoration: none; }
.btn:hover { border-color: var(--blue-500); color: var(--blue-700); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn:focus-visible, .chip:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--blue-200); outline-offset: 1px; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn-sm .ic { width: 15px; height: 15px; }
.btn-lg { height: 50px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-primary { background: linear-gradient(180deg, var(--blue-500), var(--blue-600)); border-color: var(--blue-600); color: #fff; box-shadow: 0 2px 8px rgba(37, 99, 235, .28); }
.btn-primary:hover { background: linear-gradient(180deg, #3b74f0, var(--blue-500)); color: #fff; border-color: var(--blue-500); }
.btn-dark { background: var(--blue-800); border-color: var(--blue-800); color: #fff; }
.btn-dark:hover { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: var(--ok-ink); border-color: var(--ok-ink); color: #fff; }
.btn-wa { background: #1da851; border-color: #1da851; color: #fff; }
.btn-wa:hover { background: #17924a; color: #fff; border-color: #17924a; }
.btn-danger { color: var(--bad-ink); border-color: #f1c4bf; }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); color: var(--bad-ink); }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-solid:hover { background: var(--bad-ink); color: #fff; border-color: var(--bad-ink); }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; transition: background .15s; }
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--blue-700); }
.icon-btn.danger:hover { background: var(--bad-bg); color: var(--bad-ink); border-color: #f1c4bf; }
.link { font-size: 13px; font-weight: 700; color: var(--blue-600); display: inline-flex; align-items: center; gap: 4px; }
.link .ic { width: 14px; height: 14px; }

/* شارة المرحلة بنقطة ملونة */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; background: #eef1f5; color: var(--text-2); }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.nodot::before { display: none; }
.st-received { background: #eef1f6; color: #475569; }
.st-diagnosing { background: var(--blue-50); color: var(--blue-600); }
.st-waiting_approval { background: var(--warn-bg); color: var(--warn-ink); }
.st-waiting_parts { background: var(--orange-bg); color: var(--orange-ink); }
.st-repairing { background: var(--violet-bg); color: var(--violet-ink); }
.st-ready { background: var(--ok-bg); color: var(--ok-ink); }
.st-unrepairable, .st-rejected { background: var(--bad-bg); color: var(--bad-ink); }
.st-delivered { background: var(--teal-bg); color: var(--teal-ink); }
.pay-paid { background: var(--ok-bg); color: var(--ok-ink); }
.pay-partial { background: var(--warn-bg); color: var(--warn-ink); }
.pay-unpaid { background: var(--bad-bg); color: var(--bad-ink); }
.pay-none { background: #eef1f5; color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.tag.blue { background: var(--blue-50); border-color: var(--blue-100); color: var(--blue-700); }
.tag.ok { background: var(--ok-bg); border-color: #c4ead2; color: var(--ok-ink); }
.tag.warn { background: var(--warn-bg); border-color: #f7e2a6; color: var(--warn-ink); }
.tag .ic { width: 13px; height: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-2); background: #fff; font-weight: 700; font-size: 13.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); transition: all .15s; white-space: nowrap; }
.chip:hover { border-color: var(--blue-500); color: var(--blue-700); }
.chip.active { background: var(--blue-800); border-color: var(--blue-800); color: #fff; }
.chip .n { background: rgba(11, 37, 87, .07); border-radius: 999px; padding: 0 8px; font-size: 12px; line-height: 20px; }
.chip.active .n { background: rgba(255, 255, 255, .18); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; }
.alert .ic { margin-top: 2px; }
.alert.ok { background: var(--ok-bg); color: var(--ok-ink); border: 1px solid #c4ead2; }
.alert.err { background: var(--bad-bg); color: var(--bad-ink); border: 1px solid #f5c6c1; }
.alert.warn { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid #f7e2a6; }
.alert.info { background: var(--blue-50); color: var(--blue-700); border: 1px solid var(--blue-100); }

/* ---------------- البطاقات ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h3 { font-size: 16px; font-weight: 800; color: var(--blue-800); display: flex; align-items: center; gap: 8px; }
.card-head h3 .ic { color: var(--blue-500); }
.card-head .count { background: var(--blue-50); color: var(--blue-700); border-radius: 999px; font-size: 12px; padding: 0 9px; font-weight: 700; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 16px 20px 0; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); color: inherit; position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s; min-width: 0; }
a.stat:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(11, 37, 87, .1); color: inherit; }
.stat::after { content: ''; position: absolute; inset: auto 0 0 0; height: 3px; background: var(--blue-500); }
.stat.s-ok::after { background: var(--ok); }
.stat.s-warn::after { background: var(--warn); }
.stat.s-bad::after { background: var(--bad); }
.stat.s-violet::after { background: var(--violet); }
.stat-ic { width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center; background: var(--blue-800); color: var(--blue-300); flex-shrink: 0; }
.stat-ic .ic { width: 24px; height: 24px; }
.stat.s-ok .stat-ic { background: var(--ok-bg); color: var(--ok); }
.stat.s-warn .stat-ic { background: var(--warn-bg); color: var(--warn); }
.stat.s-bad .stat-ic { background: var(--bad-bg); color: var(--bad); }
.stat.s-violet .stat-ic { background: var(--violet-bg); color: var(--violet); }
.stat > div:last-child { display: flex; flex-direction: column; min-width: 0; }
.stat span { font-size: 13px; color: var(--text-2); font-weight: 600; }
.stat b { font-size: 28px; font-weight: 800; line-height: 1.2; color: var(--blue-800); white-space: nowrap; }
.stat.s-ok b { color: var(--ok-ink); }
.stat.s-warn b { color: var(--warn-ink); }
.stat.s-bad b { color: var(--bad-ink); }
.stat.s-violet b { color: var(--violet-ink); }
.stat small { color: var(--muted); font-size: 12px; }

.strip-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.strip-head h3 { font-size: 15px; font-weight: 800; color: var(--blue-800); }
.strip-bar { display: flex; height: 28px; border-radius: 8px; overflow: hidden; background: var(--surface-2); gap: 3px; }
.strip-bar a { display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 12.5px; min-width: 28px; }
.strip-bar a:hover { filter: brightness(1.08); color: #fff; }
.c-received { background: #94a3b8; }
.c-diagnosing { background: var(--blue-500); }
.c-waiting_approval { background: var(--warn); }
.c-waiting_parts { background: var(--orange); }
.c-repairing { background: var(--violet); }
.c-ready { background: var(--ok); }
.c-unrepairable, .c-rejected { background: var(--bad); }
.c-delivered { background: var(--teal); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 13px; color: var(--text-2); }
.legend a { display: inline-flex; align-items: center; gap: 7px; color: inherit; }
.legend a:hover { color: var(--blue-600); }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.money-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.money-row > * { display: flex; flex-direction: column; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); color: inherit; min-width: 0; }
.money-row a:hover { border-color: var(--blue-300); background: var(--blue-50); color: inherit; }
.money-row span { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.money-row b { font-size: 20px; font-weight: 800; color: var(--blue-800); white-space: nowrap; }
.money-row small { color: var(--muted); font-size: 12px; }

.two-col { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; align-items: start; }
.side-col { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* قوائم المتابعة */
.follow { display: flex; flex-direction: column; gap: 8px; }
.follow-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: #fff; border-right-width: 4px; color: inherit; transition: border-color .15s, box-shadow .15s; }
a.follow-item:hover { box-shadow: 0 4px 14px rgba(11, 37, 87, .08); color: inherit; }
.follow-item.e-bad { border-right-color: var(--bad); background: linear-gradient(270deg, #fff6f5, #fff 40%); }
.follow-item.e-warn { border-right-color: var(--warn); background: linear-gradient(270deg, #fffbee, #fff 40%); }
.follow-item.e-ok { border-right-color: var(--ok); background: linear-gradient(270deg, #f3fbf6, #fff 40%); }
.follow-item.e-blue { border-right-color: var(--blue-500); }
.follow-item.e-violet { border-right-color: var(--violet); }
.follow-item.e-muted { border-right-color: var(--border-2); }
.av { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--blue-50); color: var(--blue-600); font-weight: 800; flex-shrink: 0; }
.av .ic { width: 20px; height: 20px; }
.fi-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fi-main strong { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fi-main strong .code { color: var(--blue-600); font-weight: 800; direction: ltr; unicode-bidi: isolate; }
.fi-main span { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fi-when { display: flex; flex-direction: column; align-items: flex-end; text-align: left; white-space: nowrap; gap: 2px; }
.fi-when span { font-size: 12px; color: var(--muted); }

.recent { display: flex; flex-direction: column; }
.recent-item { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px dashed var(--border); color: inherit; }
.recent-item:last-child { border-bottom: 0; }
a.recent-item:hover { color: inherit; background: var(--surface-2); }
.recent-item > div { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.recent-item span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-item b { white-space: nowrap; }

.empty { text-align: center; padding: 26px 10px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty > .ic { width: 34px; height: 34px; color: var(--blue-400); }
.empty h3 { color: var(--blue-800); font-size: 16px; }

/* ---------------- الجداول ---------------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.toolbar-start, .toolbar-end { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.search { position: relative; display: flex; align-items: center; }
.search .ic { position: absolute; right: 12px; color: var(--muted); width: 16px; height: 16px; pointer-events: none; }
.search input { height: 40px; width: 300px; max-width: 100%; border: 1px solid var(--border-2); border-radius: 10px; padding: 0 38px 0 12px; background: #fff; outline: none; }
.search input:focus, .select-sm:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100); }
.select-sm { height: 40px; border: 1px solid var(--border-2); border-radius: 10px; padding: 0 10px; background: #fff; outline: none; }

.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.table-wrap.flat { box-shadow: none; border: 0; border-radius: 0; }
.table { width: 100%; border-collapse: collapse; }
.table.wide { min-width: 760px; }
.table td.wrap .cell-sub { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table th { background: var(--surface-2); color: var(--text-2); font-weight: 700; font-size: 12.5px; text-align: right; padding: 11px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table td.wrap { white-space: normal; min-width: 160px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafcff; }
.table tr.e-bad td:first-child { box-shadow: inset -4px 0 0 var(--bad); }
.table tr.e-warn td:first-child { box-shadow: inset -4px 0 0 var(--warn); }
.table tr.e-ok td:first-child { box-shadow: inset -4px 0 0 var(--ok); }
.table tr.e-blue td:first-child { box-shadow: inset -4px 0 0 var(--blue-500); }
.table tr.e-violet td:first-child { box-shadow: inset -4px 0 0 var(--violet); }
.table tr.e-muted td:first-child { box-shadow: inset -4px 0 0 var(--border-2); }
.table tfoot td { background: var(--blue-50); font-weight: 800; border-top: 2px solid var(--blue-100); }
.table .num { text-align: left; white-space: nowrap; }
.table td.actions { white-space: nowrap; text-align: left; }
.cell-main { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--text); white-space: nowrap; }
a.cell-main:hover { color: var(--blue-600); }
.cell-sub { display: block; font-size: 12px; color: var(--muted); }
.code { font-weight: 800; color: var(--blue-600); direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.table-foot { margin: 0; color: var(--muted); font-size: 12.5px; }
.only-mobile { display: none; }

.pager { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }

/* ---------------- النماذج ---------------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl-t { font-size: 13px; font-weight: 700; color: var(--text-2); }
.field input, .field select, .field textarea, .inp { width: 100%; border: 1px solid var(--border-2); border-radius: 10px; padding: 9px 12px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
.field input, .field select, .inp { height: 42px; }
.field textarea { resize: vertical; line-height: 1.7; min-height: 78px; }
.field input:focus, .field select:focus, .field textarea:focus, .inp:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100); }
.field input[type=checkbox] { width: 18px; height: 18px; }
.hint { color: var(--muted); font-size: 12px; font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; color: var(--text-2); }
.check input { width: 18px; height: 18px; accent-color: var(--blue-600); }
.check-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.check-pill { position: relative; }
.check-pill input { position: absolute; opacity: 0; pointer-events: none; }
.check-pill span { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-2); background: #fff; font-weight: 700; font-size: 13px; color: var(--text-2); cursor: pointer; transition: all .15s; }
.check-pill input:checked + span { background: var(--blue-50); border-color: var(--blue-500); color: var(--blue-700); }
.check-pill input:checked + span::before { content: '✓'; margin-left: 6px; }
.check-pill input:focus-visible + span { outline: 3px solid var(--blue-200); }
.input-suffix { display: flex; align-items: stretch; border: 1px solid var(--border-2); border-radius: 10px; overflow: hidden; background: #fff; }
.input-suffix:focus-within { border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100); }
.field .input-suffix input { border: 0; box-shadow: none; border-radius: 0; }
.input-suffix span { display: grid; place-items: center; padding: 0 12px; background: var(--surface-2); color: var(--muted); font-size: 13px; border-right: 1px solid var(--border); white-space: nowrap; }
.form-section { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.form-section .num { width: 30px; height: 30px; border-radius: 50%; background: var(--blue-800); color: var(--blue-300); display: grid; place-items: center; font-weight: 800; font-size: 14px; flex-shrink: 0; }
.form-section h3 { font-size: 16px; font-weight: 800; color: var(--blue-800); }
.form-section p { margin: 0; font-size: 12.5px; color: var(--muted); }
.save-bar { position: sticky; bottom: 14px; z-index: 5; }
.save-bar .btn { box-shadow: var(--shadow-lg); }

/* ---------------- تفاصيل الجهاز ---------------- */
.ticket-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.ticket-head .who .code-big { font-size: 24px; font-weight: 800; color: var(--blue-800); direction: ltr; unicode-bidi: isolate; }
.ticket-head .who { display: flex; flex-direction: column; line-height: 1.4; }
.ticket-head .who strong { font-size: 16px; }
.ticket-head .who span { color: var(--muted); font-size: 13px; }
.ticket-head .btn-row { margin-inline-start: auto; }
.kv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.kv-grid > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--border); min-width: 0; }
.kv-grid > div:nth-child(odd) { border-left: 1px solid var(--border); }
.kv-grid > div.full { grid-column: 1 / -1; border-left: 0; flex-direction: column; gap: 2px; }
.kv-grid span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.kv-grid b { text-align: left; font-weight: 700; overflow-wrap: anywhere; }
.kv-grid > div.full b { text-align: right; }
.note { display: flex; gap: 8px; align-items: flex-start; background: var(--blue-50); border: 1px solid var(--blue-100); border-radius: 10px; padding: 9px 12px; font-size: 13.5px; color: var(--blue-800); }
.note .ic { color: var(--blue-500); margin-top: 3px; width: 16px; height: 16px; }
.note.warn { background: var(--warn-bg); border-color: #f7e2a6; color: var(--warn-ink); }
.note.warn .ic { color: var(--warn); }

/* مسار المراحل */
.progress { display: flex; align-items: flex-start; position: relative; margin: 6px 0 2px; }
.progress::before { content: ''; position: absolute; top: 15px; right: 8%; left: 8%; height: 3px; background: var(--border); border-radius: 3px; }
.progress .st { flex: 1; text-align: center; font-size: 12px; color: var(--muted); position: relative; font-weight: 600; }
.progress .dot { width: 32px; height: 32px; border-radius: 50%; background: #fff; border: 3px solid var(--border); margin: 0 auto 5px; display: grid; place-items: center; position: relative; }
.progress .dot .ic { width: 15px; height: 15px; stroke-width: 3; }
.progress .st.done { color: var(--text); }
.progress .st.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.progress .st.now { color: var(--blue-700); font-weight: 800; }
.progress .st.now .dot { background: var(--blue-500); border-color: var(--blue-500); color: #fff; box-shadow: 0 0 0 5px var(--blue-100); }
.progress .st.stop .dot { background: var(--bad); border-color: var(--bad); color: #fff; }
.progress .st.stop { color: var(--bad-ink); font-weight: 800; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 44px 16px 0; }
.timeline li::before { content: ''; position: absolute; right: 15px; top: 32px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .t-ic { position: absolute; right: 0; top: 0; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.timeline .t-ic .ic { width: 16px; height: 16px; }
.timeline .k-status .t-ic, .timeline .k-received .t-ic { background: var(--blue-50); color: var(--blue-600); border-color: var(--blue-100); }
.timeline .k-payment .t-ic { background: var(--ok-bg); color: var(--ok); border-color: #c4ead2; }
.timeline .k-refund .t-ic { background: var(--bad-bg); color: var(--bad); border-color: #f5c6c1; }
.timeline .k-part .t-ic { background: var(--orange-bg); color: var(--orange); border-color: #fbd7b4; }
.timeline .k-note .t-ic { background: var(--violet-bg); color: var(--violet); border-color: #dcd3fb; }
.timeline .what { font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 32px; }
.timeline .body { color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.thumbs a { display: block; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.thumbs.lg a { width: 110px; height: 110px; }

/* لوحة العمليات */
.ops { display: flex; flex-direction: column; }
details.op { border-top: 1px solid var(--border); }
details.op:first-of-type { border-top: 0; }
details.op > summary { cursor: pointer; padding: 12px 2px; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 10px; color: var(--blue-800); }
details.op > summary::-webkit-details-marker { display: none; }
details.op > summary .op-ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--blue-50); color: var(--blue-600); }
details.op > summary .op-ic .ic { width: 16px; height: 16px; }
details.op > summary .op-ic.ok { background: var(--ok-bg); color: var(--ok); }
details.op > summary .op-ic.bad { background: var(--bad-bg); color: var(--bad); }
details.op > summary .op-ic.orange { background: var(--orange-bg); color: var(--orange); }
details.op > summary .op-ic.violet { background: var(--violet-bg); color: var(--violet); }
details.op > summary .sub { margin-inline-start: auto; font-size: 12.5px; color: var(--muted); font-weight: 600; }
details.op > summary::after { content: ''; width: 8px; height: 8px; border-left: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); margin-inline-start: 6px; transition: transform .15s; }
details.op[open] > summary::after { transform: rotate(135deg); }
details.op > .op-body { padding: 2px 0 16px; display: flex; flex-direction: column; gap: 12px; }

.money-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.money-3 div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; }
.money-3 span { font-size: 12px; color: var(--muted); font-weight: 600; }
.money-3 b { font-size: 18px; font-weight: 800; color: var(--blue-800); white-space: nowrap; }
.money-3 .ok b { color: var(--ok-ink); }
.money-3 .bad b { color: var(--bad-ink); }

/* ---------------- رفع الصور ---------------- */
.photo-input { border: 2px dashed var(--blue-200); border-radius: 12px; padding: 16px; text-align: center; background: var(--blue-50); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 700; color: var(--blue-700); transition: border-color .15s, background .15s; }
.photo-input:hover { border-color: var(--blue-500); }
.photo-input input { display: none; }
.photo-input .ic { width: 28px; height: 28px; color: var(--blue-500); }
.photo-input small { color: var(--muted); font-weight: 500; }
.previews { display: flex; flex-wrap: wrap; gap: 8px; }
.previews:empty { display: none; }
.previews .pv { position: relative; width: 74px; height: 74px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.previews img { width: 100%; height: 100%; object-fit: cover; }
.previews button { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(4, 18, 46, .7); color: #fff; cursor: pointer; line-height: 1; font-size: 14px; }

/* ---------------- المحادثة ---------------- */
.chat { display: flex; flex-direction: column; height: 440px; }
.chat .msgs { flex: 1; overflow-y: auto; padding: 12px; background: linear-gradient(180deg, var(--blue-50), #f7f9fc); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; gap: 6px; }
.chat .msg { max-width: 82%; padding: 7px 11px; border-radius: 14px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 1px 2px rgba(11, 37, 87, .06); }
.chat .msg .t { font-size: 11px; opacity: .75; margin-top: 2px; display: flex; gap: 4px; align-items: center; justify-content: flex-end; direction: ltr; }
.chat .msg.mine { align-self: flex-end; background: var(--blue-500); color: #fff; border-bottom-left-radius: 4px; }
.chat .msg.theirs { align-self: flex-start; background: #fff; border: 1px solid var(--border); border-bottom-right-radius: 4px; }
.chat .msg .by { font-size: 11.5px; font-weight: 800; opacity: .85; }
.chat .ticks { font-weight: 800; letter-spacing: -4px; padding-left: 4px; }
.chat .msg.mine .ticks.seen { color: #a5f3fc; }
.chat form { display: flex; gap: 8px; margin-top: 10px; }
.chat textarea { min-height: 44px; height: 44px; flex: 1; overflow: hidden; border: 1px solid var(--border-2); border-radius: 12px; padding: 10px 12px; resize: none; outline: none; }
.chat textarea:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100); }
.chat form .btn { height: 44px; }
.chat .empty-chat { margin: auto; color: var(--muted); font-size: 13.5px; text-align: center; max-width: 260px; }

/* ---------------- الدخول ---------------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(80% 60% at 50% 0%, rgba(96, 165, 250, .25), transparent 70%), linear-gradient(180deg, var(--blue-800), var(--blue-950)); }
.auth-box { width: 100%; max-width: 420px; }
.auth-brand { text-align: center; color: #fff; margin-bottom: 20px; }
.auth-brand .brand-logo { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 18px; }
.auth-brand .brand-logo .ic { width: 34px; height: 34px; }
.auth-brand h1 { font-size: 24px; font-weight: 800; }
.auth-brand p { color: var(--blue-300); margin: 0; }
.auth .card { padding: 24px; border: 0; box-shadow: var(--shadow-lg); }

/* ---------------- صفحة الزبون ---------------- */
.public-top { background: radial-gradient(80% 90% at 100% 0%, rgba(96, 165, 250, .25), transparent 60%), linear-gradient(180deg, var(--blue-800), var(--blue-950)); color: #fff; padding: 20px 16px 64px; }
.public-top .inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.public-top .brand-logo { width: 46px; height: 46px; }
.public-top h1 { font-size: 19px; font-weight: 800; }
.public-top p { margin: 0; color: var(--blue-300); font-size: 13px; }
.public-main { max-width: 640px; margin: -44px auto 0; padding: 0 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.status-big { font-size: 19px; font-weight: 800; text-align: center; margin: 14px 0 4px; color: var(--blue-800); }

/* نافذة عرض الصور */
.lightbox { position: fixed; inset: 0; background: rgba(4, 18, 46, .9); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.lightbox.open { display: flex; }
.lightbox img { max-height: 88vh; max-width: 100%; border-radius: 10px; }
.lightbox .cap { position: absolute; bottom: 16px; inset-inline: 16px; color: #fff; text-align: center; font-size: 14px; }

/* ---------------- الشاشات الصغيرة ---------------- */
@media (max-width: 1200px) {
  .stats, .money-row { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .side-col { grid-template-columns: minmax(0, 1fr) 340px; }
}
@media (max-width: 980px) {
  .side-col { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; right: 0; top: 0; transform: translateX(105%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(4, 18, 46, .45); z-index: 35; }
  .icon-btn.menu-btn { display: inline-grid; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .topbar-title h1 { font-size: 17px; }
  .topbar-title p, .date-pill { display: none; }
  .main { padding: 14px 14px 90px; gap: 14px; }
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .only-desktop { display: none !important; }
  .only-mobile { display: flex; flex-direction: column; }
  .btn.only-mobile { display: inline-flex; flex-direction: row; }
  .card-head { flex-wrap: wrap; }
}
@media (max-width: 600px) {
  .stats, .money-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; gap: 8px; flex-direction: column; align-items: flex-start; }
  .stat b { font-size: 22px; }
  .stat-ic { width: 38px; height: 38px; border-radius: 11px; }
  .stat-ic .ic { width: 19px; height: 19px; }
  .money-row b { font-size: 17px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .kv-grid { grid-template-columns: 1fr; }
  .kv-grid > div:nth-child(odd) { border-left: 0; }
  .card { padding: 14px; }
  .search input { width: 100%; }
  .search, .toolbar-start, .toolbar-end { width: 100%; }
  .toolbar-end > * { flex: 1; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { width: 42px; padding: 0; }
  .ticket-head .btn-row { margin-inline-start: 0; width: 100%; }
  .ticket-head .btn-row .btn { flex: 1; }
  .money-3 b { font-size: 15px; }
  .chat { height: 400px; }
  .fi-when { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  .card, .stat, .table-wrap { box-shadow: none; }
}

/* ---------------- اختيار المستخدم (وضع التجربة) ---------------- */
.user-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.user-pick form { margin: 0; }
.user-card { width: 100%; display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: 16px; border: 1px solid transparent; background: #fff; cursor: pointer; text-align: right; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s; }
.user-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--blue-300); }
.user-card:focus-visible { outline: 3px solid var(--blue-300); }
.uc-ic { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; flex-shrink: 0; background: var(--blue-50); color: var(--blue-600); }
.uc-ic .ic { width: 22px; height: 22px; }
.r-super_admin .uc-ic { background: var(--blue-800); color: var(--blue-300); }
.r-sales_manager .uc-ic { background: var(--ok-bg); color: var(--ok); }
.r-maintenance_manager .uc-ic { background: var(--violet-bg); color: var(--violet); }
.uc-t { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.uc-t strong { color: var(--blue-800); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-t small { color: var(--muted); font-size: 12.5px; }
.auth-note { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--blue-300); font-size: 13px; margin: 18px 0 10px; text-align: center; }
.auth-note .ic { width: 15px; height: 15px; }
.auth-alt { margin-top: 6px; }
.auth-alt summary { cursor: pointer; color: rgba(255, 255, 255, .7); text-align: center; font-size: 13px; font-weight: 700; margin-bottom: 12px; }
.demo-tag { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: rgba(96, 165, 250, .18); color: var(--blue-300); }
.demo-tag .ic { width: 13px; height: 13px; }
@media (max-width: 760px) { .user-pick { grid-template-columns: 1fr 1fr; } }
@media (max-width: 420px) { .user-pick { grid-template-columns: 1fr; } }

/* ---------------- جهاز الاستقبال ---------------- */
.station-wrap { width: 100%; max-width: 940px; display: grid; grid-template-columns: 1fr 400px; gap: 40px; align-items: center; color: #fff; }
.station-info .brand-logo { width: 60px; height: 60px; border-radius: 17px; margin-bottom: 14px; }
.station-info .brand-logo .ic { width: 32px; height: 32px; }
.station-info h1 { font-size: 30px; font-weight: 800; }
.station-name { display: inline-flex; align-items: center; gap: 8px; margin: 6px 0 22px; padding: 4px 14px; border-radius: 999px; background: rgba(96, 165, 250, .18); color: var(--blue-300); font-weight: 700; }
.station-name .ic { width: 16px; height: 16px; }
.station-steps { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 12px; }
.station-steps li { display: flex; align-items: center; gap: 14px; font-size: 20px; font-weight: 700; }
.station-steps li span { width: 38px; height: 38px; border-radius: 50%; background: var(--blue-500); display: grid; place-items: center; font-size: 17px; flex-shrink: 0; }
.station-hint { color: var(--blue-300); font-size: 14px; max-width: 420px; }
.station-card { text-align: center; padding: 26px; }
.qr-box { width: 300px; height: 300px; margin: 0 auto; display: grid; place-items: center; border-radius: 16px; background: #fff; border: 1px solid var(--border); position: relative; }
.qr-box img { width: 280px; height: 280px; image-rendering: pixelated; }
.qr-loading { color: var(--muted); }
.qr-welcome { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: #fff; border-radius: 16px; color: var(--ok-ink); }
.qr-welcome .ic { width: 64px; height: 64px; color: var(--ok); }
.qr-welcome strong { font-size: 22px; color: var(--blue-800); }
.qr-timer { height: 6px; border-radius: 6px; background: var(--surface-2); margin: 16px auto 8px; width: 300px; overflow: hidden; }
.qr-timer i { display: block; height: 100%; width: 100%; background: var(--blue-500); transform-origin: right; }
.qr-status { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.station-bar { display: inline-flex; align-items: center; gap: 8px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--warn-bg); border: 1px solid #f7e2a6; color: var(--warn-ink); font-weight: 700; font-size: 13px; white-space: nowrap; }
.station-bar .ic { width: 15px; height: 15px; }
.station-bar form { margin: 0; }
.station-bar .btn { height: 30px; }
@media (max-width: 860px) {
  .station-wrap { grid-template-columns: 1fr; gap: 20px; text-align: center; }
  .station-steps li { justify-content: center; }
  .station-hint { margin: 0 auto; }
}
