:root {
  color-scheme: light;
  --brand: #1769aa;
  --brand-dark: #0d4f86;
  --brand-soft: #e9f3fb;
  --accent: #16a36a;
  --bg: #f2f6fa;
  --surface: #fff;
  --text: #17263b;
  --muted: #6d7e91;
  --border: #dbe5ef;
  --danger: #b42318;
  --shadow: 0 12px 35px rgba(23, 46, 75, .07);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: linear-gradient(180deg, #e9f1f8 0, var(--bg) 280px); direction: rtl; }
button, input, select, textarea { font: inherit; }
.shell { width: min(1440px, 100%); margin: auto; padding: 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; color: #fff; background: linear-gradient(135deg, var(--brand), #2995dd); font-size: 29px; box-shadow: 0 10px 24px rgba(23,105,170,.24); }
.brand h1 { margin: 0; font-size: clamp(22px, 2.4vw, 29px); letter-spacing: -.4px; }
.brand p { margin: 4px 0 0; color: var(--muted); }
.top-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { position: relative; overflow: hidden; min-height: 105px; padding: 19px; border: 1px solid rgba(219,229,239,.9); border-radius: 18px; background: rgba(255,255,255,.92); box-shadow: var(--shadow); }
.stat::after { content: ""; position: absolute; inset-inline-end: -26px; bottom: -36px; width: 95px; height: 95px; border-radius: 50%; background: var(--brand-soft); }
.stat span { display: block; color: var(--muted); font-size: 14px; }
.stat strong { display: block; margin-top: 7px; font-size: 31px; line-height: 1; color: var(--brand-dark); }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; }
.card { grid-column: span 12; background: var(--surface); border: 1px solid var(--border); border-radius: 19px; padding: 21px; box-shadow: var(--shadow); }
.half { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-4 { grid-column: span 4; }
.upload-card { border-top: 4px solid var(--brand); }
.card h2 { margin: 0 0 16px; font-size: 19px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.step { min-width: 42px; text-align: center; padding: 7px 10px; border-radius: 11px; color: var(--brand-dark); background: var(--brand-soft); font-weight: 800; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: #087443; font-size: 13px; font-weight: 700; }
.live-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #19a86b; box-shadow: 0 0 0 5px #dcfce7; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.single { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
label { font-weight: 700; font-size: 14px; }
input, select, textarea { width: 100%; border: 1px solid var(--border); border-radius: 11px; padding: 11px 13px; color: var(--text); background: #fff; outline: none; transition: border-color .18s, box-shadow .18s; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(23, 105, 170, .11); }
textarea { min-height: 105px; resize: vertical; }
.checkbox { flex-direction: row; align-items: center; }
.checkbox input, .select-all input, .customer-option input { width: 17px; height: 17px; accent-color: var(--brand); }
.actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 7px; }
.btn { border: 0; border-radius: 11px; padding: 10px 16px; cursor: pointer; font-weight: 750; transition: transform .15s, opacity .15s, background .15s; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: .58; cursor: wait; }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--brand), #2387cb); box-shadow: 0 8px 20px rgba(23,105,170,.2); }
.btn-primary:hover { background: linear-gradient(135deg, var(--brand-dark), var(--brand)); }
.btn-secondary { color: #fff; background: #244c70; }
.btn-muted { color: var(--text); background: #e8eff6; }
.btn-outline { color: var(--brand-dark); border: 1px solid #b7cada; background: rgba(255,255,255,.65); }
.btn-small { padding: 7px 11px; font-size: 13px; }

.picker-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.picker-heading strong { color: var(--brand); font-size: 13px; }
.picker-tools { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
.select-all { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 11px; white-space: nowrap; background: #f8fafc; }
.customer-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-height: 265px; overflow: auto; padding: 9px; border: 1px solid var(--border); border-radius: 13px; background: #f8fafc; }
.customer-option { display: flex; align-items: flex-start; gap: 9px; min-width: 0; padding: 11px; border: 1px solid transparent; border-radius: 11px; background: #fff; cursor: pointer; }
.customer-option:has(input:checked) { border-color: #8ac0e5; background: var(--brand-soft); }
.customer-option span { min-width: 0; }
.customer-option strong, .customer-option small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customer-option small { margin-top: 4px; color: var(--muted); font-weight: 500; }
.picker-empty { grid-column: 1 / -1; padding: 22px; text-align: center; color: var(--muted); }
.tip { margin-top: 24px; padding: 16px; border-radius: 14px; background: linear-gradient(135deg, #eef7ff, #f5fbff); border: 1px solid #d7eaf8; }
.tip strong { color: var(--brand-dark); }
.tip p { margin: 7px 0 0; color: var(--muted); line-height: 1.7; }

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 13px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 12px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbfd; }
th { color: var(--muted); background: #f7f9fc; font-size: 13px; white-space: nowrap; }
.table-subtitle { display: block; margin-top: 5px; color: var(--muted); font-weight: 500; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 750; white-space: nowrap; }
.badge.on { color: #087443; background: #dcfce7; }
.badge.off { color: #9f2d24; background: #fee4e2; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.notice { display: none; position: fixed; inset-inline-start: 24px; bottom: 24px; max-width: min(540px, calc(100vw - 48px)); z-index: 2000; padding: 14px 18px; border-radius: 13px; color: #fff; background: #173b5f; box-shadow: 0 14px 40px rgba(0,0,0,.22); }
.notice.show { display: block; animation: notice-in .2s ease-out; }
.notice.error { background: var(--danger); }
@keyframes notice-in { from { transform: translateY(8px); opacity: 0; } }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); background: var(--surface); padding: 30px; border: 1px solid var(--border); border-radius: 19px; box-shadow: 0 22px 65px rgba(23,46,75,.15); }
.login-card h1 { margin-top: 0; }
.form-error { min-height: 1.4em; color: var(--danger); }

@media (max-width: 1050px) {
  .span-8, .span-4, .half { grid-column: span 12; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .shell { padding: 14px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; }
  .top-actions .btn { flex: 1; }
  .stats { gap: 10px; }
  .stat { min-height: 90px; padding: 15px; }
  .stat strong { font-size: 27px; }
  .card { padding: 16px; border-radius: 15px; }
  .form-grid, .customer-picker { grid-template-columns: 1fr; }
  .picker-tools { grid-template-columns: 1fr; }
  .select-all { white-space: normal; }
  .section-heading { align-items: flex-start; }
  .live-dot { display: none; }
}
