:root {
  --bg: #f4f6f9;
  --card: #fff;
  --text: #1f2933;
  --muted: #6b7785;
  --border: #e2e7ee;
  --primary: #1d5fd1;
  --primary-dark: #154ba8;
  --danger: #d13a3a;
  --success: #1f9d55;
  --warning: #d98b0b;
  --gold: #b8860b;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
.hidden { display: none !important; }
a { color: var(--primary); text-decoration: none; }

/* شريط علوي */
.topbar {
  display: flex; align-items: center; gap: 16px;
  background: #1b2a41; color: #fff; padding: 10px 20px;
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 18px; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: #cdd6e3; padding: 7px 12px; border-radius: 8px; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; }

main { max-width: 1200px; margin: 0 auto; padding: 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 17px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat .value.pos { color: var(--success); }
.stat .value.neg { color: var(--danger); }

/* أزرار */
.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit;
}
.btn:hover { background: #f0f3f7; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); border-color: #f1c4c4; }
.btn.danger:hover { background: #fdf0f0; }
.btn.ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.3); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.icon-btn { border: 0; background: transparent; font-size: 18px; cursor: pointer; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* نماذج */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 9px 10px;
  border: 1px solid var(--border); border-radius: 8px; font: inherit; color: var(--text); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b9d0f7; border-color: var(--primary); }
textarea { min-height: 70px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.filters label { margin: 0; min-width: 150px; }
.error { color: var(--danger); min-height: 1em; margin: 4px 0; }

/* جداول */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
th { background: #f7f9fc; font-size: 13px; color: var(--muted); font-weight: 600; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f7faff; }
tfoot td { font-weight: 700; background: #f7f9fc; }
td.wrap { white-space: normal; min-width: 160px; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 24px; }

/* شارات */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.r-excellent { background: #fff5d6; color: var(--gold); }
.r-good { background: #e3f6ea; color: var(--success); }
.r-normal { background: #eef1f5; color: var(--muted); }
.r-caution { background: #fde7e7; color: var(--danger); }
.s-pending { background: #eef1f5; color: var(--muted); }
.s-in_progress { background: #e6effd; color: var(--primary); }
.s-ready { background: #fff2dc; color: var(--warning); }
.s-delivered { background: #e3f6ea; color: var(--success); }
.late { color: var(--danger); font-weight: 600; }

.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: zoom-in; }
.img-preview { max-width: 100%; max-height: 240px; border-radius: 8px; margin-top: 8px; display: block; }

/* تبويبات */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 16px; }
.info-grid div span { display: block; font-size: 12px; color: var(--muted); }

/* رسم بياني */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 220px; padding: 10px 4px 0; border-bottom: 1px solid var(--border); }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart .bars { display: flex; gap: 2px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.chart .bar { width: 42%; max-width: 22px; border-radius: 4px 4px 0 0; min-height: 1px; }
.chart .bar.sales { background: var(--primary); }
.chart .bar.profit { background: var(--success); }
.chart .bar.loss { background: var(--danger); }
.chart-labels { display: flex; gap: 6px; padding: 4px; }
.chart-labels span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 4px; }

.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* نافذة منبثقة */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 35, .5); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 40px 12px; overflow-y: auto; }
.modal-box { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; padding: 18px; }
.modal-box.wide { max-width: 900px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 18px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1b2a41; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 100; }
.toast.err { background: var(--danger); }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { margin-top: 0; font-size: 22px; }
.login-card .btn { width: 100%; }

.print-head { display: none; }

/* معرض الأعمال (إدارة) */
.gal-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.gal-item { border: 1px solid var(--border); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.gal-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; }
.gal-item input { margin: 0; padding: 6px; font-size: 13px; }

/* التكلفة والربح بالطلبية */
.cost-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 4px 16px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); font-size: 14px; }
.cost-box:empty { display: none; }
.cost-total { font-size: 15px; }
.cost-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 12px; }

/* البحث عن الزبون */
.cust-picker { position: relative; }
.cust-list { position: absolute; top: calc(100% - 8px); right: 0; left: 0; z-index: 20; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 280px; overflow-y: auto; }
.cust-item { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #f1f3f6; }
.cust-item:last-child { border-bottom: 0; }
.cust-item.active, .cust-item:hover { background: #eef3fb; }
.cust-new { color: var(--primary); display: block; }

/* ألوان الألمنيوم */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #eef3fb; border: 1px solid #d3e0f5; border-radius: 20px; padding: 5px 8px 5px 12px; font-weight: 600; }
.chip button { border: 0; background: transparent; color: var(--danger); cursor: pointer; font-size: 13px; padding: 0 2px; }

/* الدفات */
.items-editor { border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 10px; background: #fafbfd; }
.item-row { display: grid; grid-template-columns: 1fr .9fr .9fr .6fr 1fr 1.1fr 1.1fr auto; gap: 6px; align-items: end; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.item-row:last-of-type { border-bottom: 0; }
.item-row label { margin: 0; font-size: 12px; }
.item-row input, .item-row select { padding: 7px 6px; }
.item-calc { grid-column: 1 / -1; font-size: 12px; color: var(--primary); }
/* كل الطلبيات نفس اللون، وبين كل طلبية والثانية خط أسود عريض */
.sheet-order { --oc: #1d5fd1; --ob: #fff; border: 2px solid #c9d1dc; background: var(--ob); border-radius: 12px; padding: 0 12px 12px; margin-bottom: 0; page-break-inside: avoid; overflow: hidden; }
.sheet-order + .sheet-order { margin-top: 0; }
.sheet-order:not(:last-child) { margin-bottom: 26px; position: relative; overflow: visible; }
.sheet-order:not(:last-child)::before { content: ""; position: absolute; left: -4px; right: -4px; bottom: -20px; height: 14px; background: #000; border-radius: 3px; }
.sheet-order h3 { margin: 0 -12px 10px; padding: 10px 12px; background: var(--oc); color: #fff; font-size: 17px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-radius: 10px 10px 0 0; }
.sheet-order h3 .status-select { background: #fff; color: var(--text); border: 0; }
/* طلبيات اليوم والمتأخرة: ضو أحمر بيضوي */
.due-light { display: inline-block; width: 16px; height: 16px; border-radius: 50%; background: #ff2d2d; box-shadow: 0 0 0 3px #fff; animation: dueBlink 1s infinite; flex-shrink: 0; }
@keyframes dueBlink { 0%, 100% { opacity: 1; box-shadow: 0 0 0 3px #fff, 0 0 14px 4px rgba(255,45,45,.9); } 50% { opacity: .25; box-shadow: 0 0 0 3px #fff; } }
.due-tag { background: #ff2d2d; color: #fff; font-size: 13px; font-weight: 800; padding: 1px 9px; border-radius: 99px; border: 2px solid #fff; }
.sheet-order.due-now { border-color: #ff2d2d; box-shadow: 0 0 0 2px rgba(255,45,45,.25); }
/* حالة القزاز بورقة القص */
.glass-box { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; font-size: 15px; }
.glass-box .btn { margin: 0; }
.g-box-not_sent { background: #fde7e7; color: #a11; border: 2px solid #f3b4b4; }
.g-box-sent { background: #e8f4ff; color: #0b4a8a; border: 1px solid #b9d6f5; }
.g-box-received { background: #e3f6ea; color: #14532d; border: 1px solid #b6e3c6; }
.glass-all { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; background: #fff7e6; border: 2px solid #f0c34a; border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; font-size: 15px; }
.it-note { font-size: 13px; font-weight: 600; color: #7a4b00; background: #fff6e0; border-radius: 6px; padding: 2px 6px; margin-top: 4px; white-space: normal; }
.item-note { grid-column: 1 / -1; font-size: 12px; color: #7a4b00; }
.nav-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 12px; text-align: center; }
/* طلبات الزباين */
.req-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 0; background: #fff; }
.req-card:not(:last-child) { margin-bottom: 22px; box-shadow: 0 12px 0 -2px #000; }
.req-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.req-door { display: flex; gap: 10px; border-top: 1px dashed var(--border); padding: 8px 0; }
.req-pics { display: flex; gap: 4px; flex: 0 0 auto; }
.req-svg { width: 74px; height: auto; max-height: 120px; }
.req-info { flex: 1; min-width: 0; font-size: 14px; }
.req-hinges span { display: inline-block; background: #f1f4f9; border-radius: 6px; padding: 0 6px; margin: 2px 0; }
.req-approve { background: #f7f9fc; border-radius: 10px; padding: 10px; margin-top: 8px; }
.req-approve .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.badge.req-submitted { background: #fff2dc; color: var(--warning); }
.badge.req-open { background: #eef2f7; color: var(--muted); }
.badge.req-approved { background: #e3f6ea; color: var(--success); }
.badge.req-rejected { background: #fde7e7; color: var(--danger); }
/* جدول الطلبيات (الكمبيوتر): خط أسود عريض بين كل طلبية والثانية */
.orders-table tbody tr { border-bottom: 6px solid #000; }
.orders-table table { border-collapse: collapse; }
.near-box { border: 3px solid #25d366; background: #effcf3; border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.near-box h3 { margin: 0 0 6px; }
.sheet-order .sheet-meta { color: #4a5563; }
.sheet-order .table-wrap { background: #fff; border-radius: 8px; border: 1px solid var(--border); }
.sheet-order th { background: #fff; }
.sheet-meta { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.big { font-size: 17px; font-weight: 700; }
.dims { border-collapse: collapse; width: auto; margin: 0; white-space: nowrap; }
.sheet-order .dims th, .sheet-order .dims td { border: 1px solid #c9d1dc; padding: 3px 12px; text-align: center; }
.sheet-order .dims th { background: #eef2f7; color: var(--muted); font-size: 12px; font-weight: 600; }
.sheet-order .dims td { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; background: #fff; }
.dims-head { margin-bottom: 4px; }
.glass-pick { width: auto !important; display: inline-block !important; margin: 0 !important; transform: scale(1.3); }
.g-not_sent { background: #fde7e7; color: var(--danger); }
.g-sent { background: #fff2dc; color: var(--warning); }
.g-received { background: #e3f6ea; color: var(--success); }

@media (max-width: 720px) {
  .item-row { grid-template-columns: 1fr 1fr; }
}

@media print {
  body.print-modal #app, body.print-modal .modal-head, body.print-modal .no-print { display: none !important; }
  body.print-modal .modal { position: static; background: none; padding: 0; display: block; }
  body.print-modal .modal-box { max-width: none; padding: 0; }
  .sheet-order { border-color: #000; background: #fff; box-shadow: none; }
  .sheet-order h3 { background: none; color: #000; border-bottom: 2px solid #000; }
  .sheet-order:not(:last-child)::before { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sheet-order th, .sheet-order td { font-size: 14px; padding: 7px 6px; color: #000; }
  .sheet-order h3 { font-size: 18px; }
  .sheet-order .big { font-size: 18px; }
  .sheet-order .dims th { color: #333; font-size: 12px; padding: 2px 10px; }
  .sheet-order .dims td { font-size: 19px; padding: 3px 10px; border-color: #777; }
  .sheet-meta { font-size: 14px; color: #333; }
  .table-wrap { overflow: visible; }
}

.menu-btn, .current-page { display: none; }

/* التوصيل */
.live-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #16a34a; animation: livePulse 1.6s infinite; vertical-align: middle; }
@keyframes livePulse { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.55); } 100% { box-shadow: 0 0 0 10px rgba(22,163,74,0); } }
.d-active { border: 2px solid #16a34a; background: #f3fbf6; }
.d-state { font-weight: 700; padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; }
.d-state.ok { background: #dcf5e5; color: #14532d; }
.d-state.wait { background: #fff4dc; color: #8a5a00; }
.d-state.err { background: #fde7e7; color: var(--danger); }
.d-hint { font-size: 13px; color: #3d4756; margin-bottom: 10px; }
.d-trip { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-top: 10px; }
.d-trip-head { font-size: 16px; margin-bottom: 4px; }
.d-addr { color: var(--muted); font-size: 13px; margin-top: 3px; }
.d-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.d-btns .btn { flex: 1; text-align: center; padding: 10px 8px; white-space: nowrap; }
.btn.d-wa { background: #25d366; border-color: #25d366; color: #fff; flex-basis: 100%; font-weight: 700; }
.btn.d-chat { background: #e8f9ee; border-color: #25d366; color: #0f7a3b; font-weight: 700; flex: 2; }
.btn.d-call { background: #eef3fb; border-color: #b9cdf0; color: var(--primary); font-weight: 700; }
.d-nophone { font-size: 13px; color: var(--muted); background: #f5f6f8; border-radius: 8px; padding: 8px 10px; width: 100%; }
.btn.d-done { background: #16a34a; border-color: #16a34a; color: #fff; font-weight: 700; flex: 2; }
.d-order { display: flex; flex-direction: column; gap: 8px; }
.d-start { padding: 11px; font-size: 15px; }
.d-onroad { font-size: 13px; color: #14532d; font-weight: 600; }
.track-pill { position: fixed; bottom: 16px; left: 16px; z-index: 40; background: #14532d; color: #fff; padding: 9px 14px; border-radius: 999px; font-weight: 700; font-size: 14px; box-shadow: 0 6px 18px rgba(0,0,0,.25); display: flex; align-items: center; gap: 8px; }
.track-pill:hover { color: #fff; }
.order-cards { display: none; }

/* بطاقة الطلبية (للجوال) */
/* كل البطاقات نفس اللون، وبين كل وحدة والثانية خط أسود عريض */
.o-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 0; position: relative; }
.o-card:not(:last-child) { margin-bottom: 28px; }
.o-card:not(:last-child)::after { content: ""; position: absolute; left: -2px; right: -2px; bottom: -21px; height: 14px; background: #000; border-radius: 3px; }
.o-top { display: flex; gap: 10px; align-items: flex-start; }
.o-img { width: 58px; height: 58px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); flex-shrink: 0; cursor: zoom-in; }
.o-title { flex: 1; min-width: 0; }
.o-id { display: inline-block; background: #eef2f7; color: var(--muted); font-weight: 700; font-size: 13px; padding: 1px 8px; border-radius: 6px; margin-left: 6px; }
.o-cust { font-weight: 700; font-size: 16px; }
.o-sub { color: var(--text); font-size: 14px; margin-top: 3px; }
.o-details { color: var(--muted); font-size: 12px; margin-top: 2px; }
.o-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0; }
.o-grid div { background: #f7f9fc; border-radius: 8px; padding: 6px 10px; }
.o-grid span { display: block; font-size: 11px; color: var(--muted); }
.o-grid b { font-size: 15px; font-variant-numeric: tabular-nums; }
select.o-status { margin: 0 0 8px; padding: 8px 10px; }
.o-actions { display: flex; gap: 6px; }
.o-actions .btn { flex: 1; padding: 9px 4px; white-space: nowrap; }

/* ================= الجوال ================= */
@media screen and (max-width: 720px) {
  body { font-size: 15px; }
  main { padding: 10px; }
  .grid2, .cols2 { grid-template-columns: 1fr; }
  .stat .value { font-size: 18px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 10px 12px; }
  .card { padding: 12px; border-radius: 12px; }
  .info-grid { grid-template-columns: 1fr 1fr; gap: 10px 12px; }

  /* الشريط العلوي: زر ☰ والقائمة بتنفتح لتحت */
  .topbar { padding: 8px 10px; gap: 10px; flex-wrap: nowrap; }
  .menu-btn { display: block; background: rgba(255,255,255,.1); border: 0; color: #fff; font-size: 22px; width: 42px; height: 40px; border-radius: 8px; cursor: pointer; flex-shrink: 0; }
  .brand { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .current-page { display: block; flex: 1; color: #9fb0c8; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .current-page::before { content: "· "; }
  .topbar nav { display: none; position: absolute; top: 100%; right: 0; left: 0; background: #1b2a41; flex-direction: column; padding: 6px 10px 12px; box-shadow: 0 12px 24px rgba(0,0,0,.25); gap: 2px; }
  .topbar.open nav { display: flex; }
  .topbar nav a { padding: 12px 14px; font-size: 16px; }

  /* العناوين والأزرار */
  .page-head { margin-bottom: 10px; }
  .page-head h1 { font-size: 19px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn, .page-head > .btn { flex: 1; padding: 11px 12px; text-align: center; }
  .page-head > .btn { flex: 0 0 auto; }
  .btn { padding: 9px 14px; }
  .btn.small { padding: 7px 11px; font-size: 13px; }

  /* الفلاتر: البحث بعرض كامل والباقي جنب بعض */
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .filters label { min-width: 0; }
  .filters label:first-child, .filters label:nth-child(2) { grid-column: 1 / -1; }

  /* الزبائن: بطاقة صغيرة (الاسم، التصنيف، الرقم، الرصيد) */
  table.rt.cust-table > tbody > tr { display: grid; grid-template-columns: 1fr auto; column-gap: 10px; padding: 8px 12px; margin-bottom: 8px; }
  table.rt.cust-table > tbody > tr > td { border: 0; padding: 2px 0; }
  table.rt.cust-table > tbody > tr > td::before { display: none; }
  table.rt.cust-table > tbody > tr > td:nth-child(1) { text-align: right; }
  table.rt.cust-table > tbody > tr > td:nth-child(2) { grid-row: 2; text-align: right !important; color: var(--muted); font-size: 14px; }
  table.rt.cust-table > tbody > tr > td:nth-child(4) { grid-row: 1; grid-column: 2; }
  table.rt.cust-table > tbody > tr > td:nth-child(8) { grid-row: 2; grid-column: 2; font-weight: 700; }
  table.rt.cust-table > tbody > tr > td:nth-child(3),
  table.rt.cust-table > tbody > tr > td:nth-child(5),
  table.rt.cust-table > tbody > tr > td:nth-child(6),
  table.rt.cust-table > tbody > tr > td:nth-child(7) { display: none; }

  /* الطلبيات: بطاقات مرتبة بدل الجدول */
  .orders-table { display: none; }
  .order-cards { display: block; }

  /* 16px بيمنع الآيفون يكبّر الشاشة لما تكتب */
  input, select, textarea { font-size: 16px; padding: 10px; }

  /* التبويبات بتنسحب بالعرض */
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tabs button { white-space: nowrap; padding: 10px 12px; }

  /* الجداول بتصير بطاقات */
  .table-wrap { overflow: visible; }
  table.rt, table.rt > tbody, table.rt > tfoot, table.rt > tbody > tr, table.rt > tfoot > tr { display: block; width: 100%; }
  table.rt > thead { display: none; }
  table.rt > tbody > tr, table.rt > tfoot > tr { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 4px 12px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(20,30,50,.05); }
  table.rt > tfoot > tr { background: #f3f6fb; }
  table.rt > tbody > tr > td, table.rt > tfoot > tr > td { display: block; overflow: hidden; border-bottom: 1px dashed #e8ecf2; padding: 8px 0; white-space: normal; text-align: left; min-width: 0; background: none; }
  table.rt > tbody > tr > td:last-child, table.rt > tfoot > tr > td:last-child { border-bottom: 0; }
  table.rt > tbody > tr > td::before, table.rt > tfoot > tr > td::before { content: attr(data-label); float: right; margin-left: 12px; color: var(--muted); font-size: 13px; font-weight: 600; text-align: right; }
  table.rt td[data-label=""]::before { display: none; }
  table.rt td[data-label=""] { text-align: right; }
  table.rt > tbody > tr > td:first-child { font-weight: 700; font-size: 16px; }
  table.rt td .actions { justify-content: flex-start; }
  table.rt td[data-label=""] .actions .btn { flex: 1; text-align: center; }
  table.rt td .dims { display: inline-table; }
  table.rt td .status-select { display: inline-block; }
  tr.clickable:hover td { background: none; }
  td.wrap { min-width: 0; }

  /* النوافذ بتاخد الشاشة كلها */
  .modal { padding: 0; }
  .modal-box, .modal-box.wide { max-width: none; min-height: 100%; border-radius: 0; padding: 14px 12px 30px; }
  .modal-head { position: sticky; top: 0; background: #fff; z-index: 5; padding: 6px 0; margin: -6px 0 10px; border-bottom: 1px solid var(--border); }
  .modal-head h2 { font-size: 17px; }
  .icon-btn { font-size: 24px; padding: 4px 8px; }

  .modal .grid2 { grid-template-columns: 1fr 1fr; gap: 0 8px; }
  .modal .grid2 label { min-width: 0; }

  /* محرر الدفات */
  .items-editor { padding: 8px; }
  .item-row { grid-template-columns: 1fr 1fr 1fr; gap: 8px; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 8px; }
  .item-row label:first-child { grid-column: 1 / -1; }
  .item-row > .btn { grid-column: 1 / -1; justify-self: end; padding: 6px 14px; }
  .modal form > .actions .btn { flex: 1; padding: 12px; font-size: 16px; }
  .sheet-order { padding: 0 8px 8px; margin-bottom: 28px; }
  .sheet-order h3 { margin: 0 -8px 8px; padding: 10px; font-size: 16px; }
  .sheet-order::after { margin: 10px -8px -8px; }
  .sheet-order .table-wrap { background: none; border: 0; }
  .sheet-order table.rt > tbody > tr { border: 1px solid var(--oc); border-right-width: 5px; }

  .toast { width: calc(100% - 24px); text-align: center; bottom: 14px; }
}

@media print {
  .no-print, .topbar, .tabs, .actions, .btn { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
  .print-head { display: block; margin-bottom: 12px; }
  th, td { padding: 6px; font-size: 12px; }
}
