/* ===================== Export Pro — styles ===================== */
:root {
  --primary: #4F46E5;            /* modern indigo */
  --primary-dark: #4338CA;
  --primary-soft: rgba(79, 70, 229, .10);
  --primary-grad: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
  --primary-grad-hover: linear-gradient(135deg, #5B5BF0 0%, #4338CA 100%);
  --success: #16A34A;
  --warning: #D97706;
  --danger: #DC2626;
  --info: #0EA5E9;
  --accent-violet: #7C3AED;
  --accent-cyan: #0891B2;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 2px 8px rgba(16,24,40,.05);
  --shadow-md: 0 4px 10px rgba(16,24,40,.07), 0 8px 22px rgba(16,24,40,.08);
  --shadow-lg: 0 16px 40px rgba(16,24,40,.18);
  --shadow-hover: 0 10px 26px rgba(79,70,229,.16);
  --ring: 0 0 0 3px var(--primary-soft);
  --sidebar-w: 260px;
  --tr: .18s ease;
  --ease: cubic-bezier(.16,1,.3,1);
}

/* Light theme (default) */
:root, [data-theme="light"] {
  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-glass: rgba(255,255,255,.85);
  --sidebar-bg: #F8FAFC;
  --text: #0F172A;
  --text-soft: #475569;
  --muted: #94A3B8;
  --border: #E2E8F0;
  --input-bg: #FFFFFF;
  --row-hover: rgba(79,70,229,.05);
  --primary-text: #4F46E5;
  --success-soft: rgba(22,163,74,.12);  --success-text: #16A34A;
  --warning-soft: rgba(217,119,6,.12);  --warning-text: #D97706;
  --danger-soft:  rgba(220,38,38,.12);  --danger-text:  #DC2626;
  --info-soft:    rgba(14,165,233,.12); --info-text:    #0284C7;
  --purple-soft:  rgba(124,58,237,.12); --purple-text:  #7C3AED;
  --orange-soft:  rgba(234,88,12,.13);  --orange-text:  #EA580C;
  --cyan-soft:    rgba(6,182,212,.14);  --cyan-text:    #0891B2;
}

/* Dark theme */
[data-theme="dark"] {
  --bg: #0F172A;
  --surface: #1E293B;
  --surface-2: #182235;
  --surface-glass: rgba(30,41,59,.85);
  --sidebar-bg: #1E293B;
  --text: #F1F5F9;
  --text-soft: #CBD5E1;
  --muted: #7C8CA5;
  --border: #334155;
  --input-bg: #0F172A;
  --row-hover: rgba(99,102,241,.08);
  --primary-text: #A5B4FC;
  --success-soft: rgba(74,222,128,.12);  --success-text: #4ADE80;
  --warning-soft: rgba(251,191,36,.12);  --warning-text: #FBBF24;
  --danger-soft:  rgba(248,113,113,.13); --danger-text:  #F87171;
  --info-soft:    rgba(56,189,248,.13);  --info-text:    #38BDF8;
  --purple-soft:  rgba(196,181,253,.13); --purple-text:  #C4B5FD;
  --orange-soft:  rgba(251,146,60,.14);  --orange-text:  #FB923C;
  --cyan-soft:    rgba(103,232,249,.14); --cyan-text:    #67E8F9;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 4px 14px rgba(0,0,0,.25);
  --shadow-md: 0 4px 10px rgba(0,0,0,.35), 0 8px 22px rgba(0,0,0,.30);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Tajawal", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--tr), color var(--tr);
}
[lang="ar"] body, [dir="rtl"] body { font-family: "Tajawal", "Inter", system-ui, sans-serif; }
a { color: inherit; text-decoration: none; }
h1,h2,h3 { margin: 0 0 .25rem; font-weight: 700; letter-spacing: -.01em; }
::selection { background: rgba(79,70,229,.22); color: inherit; }

/* ---------- Layout ---------- */
.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 14px; gap: 8px; z-index: 40;
  transition: transform var(--tr), background var(--tr);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--primary-grad); color: #fff; font-weight: 700;
  display: grid; place-items: center; font-size: 15px; letter-spacing: .5px;
  box-shadow: 0 6px 16px rgba(79,70,229,.35);
}
.brand-name { font-weight: 700; font-size: 16px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: var(--radius-sm);
  color: var(--text-soft); font-weight: 500; transition: var(--tr);
}
.nav-item:hover { background: var(--primary-soft); color: var(--primary); }
.nav-item.active { background: var(--primary-grad); color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.30); }
.nav-item.active::before {
  content: ""; position: absolute; inset-inline-start: -14px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: var(--primary);
}
[dir="rtl"] .nav-item.active::before { border-radius: 4px 0 0 4px; }
.nav-ico { display: inline-flex; }

.main { margin-inline-start: var(--sidebar-w); min-height: 100vh; transition: margin var(--tr); }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 24px;
  background: var(--surface-glass); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px) saturate(1.2); -webkit-backdrop-filter: blur(10px) saturate(1.2);
}
.page-title { font-size: 20px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding-inline-start: 10px; border-inline-start: 1px solid var(--border); }
.user-meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
[dir="rtl"] .user-meta { align-items: flex-start; }
.user-name { font-weight: 600; font-size: 13px; }

.content { padding: 24px; max-width: 1280px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-soft); cursor: pointer; transition: var(--tr); font-weight: 600;
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }

/* theme icon swap */
.ico-moon { display: none; }
[data-theme="dark"] .ico-sun { display: none; }
[data-theme="dark"] .ico-moon { display: inline; }
#themeToggle svg { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.ico-moon { fill: currentColor !important; stroke: none !important; }

/* hamburger / overlay (mobile) */
.hamburger { display: none; position: fixed; top: 14px; inset-inline-start: 14px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  width: 42px; height: 42px; border-radius: 10px; cursor: pointer; }
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }

/* ---------- Cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title { font-size: 16px; font-weight: 700; }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; display: flex; align-items: center; gap: 14px;
  transition: transform .18s var(--ease), box-shadow var(--tr), border-color var(--tr);
  animation: fadeUp .3s var(--ease) both;
}
.stats .stat:nth-child(2) { animation-delay: .04s; }
.stats .stat:nth-child(3) { animation-delay: .08s; }
.stats .stat:nth-child(4) { animation-delay: .12s; }
.stats .stat:nth-child(5) { animation-delay: .16s; }
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: rgba(79,70,229,.25); }
.stat-ico {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  background: var(--primary-grad); color: #fff; flex: none;
  box-shadow: 0 6px 16px rgba(79,70,229,.28);
  transition: transform .25s var(--ease);
}
.stat:hover .stat-ico { transform: scale(1.06) rotate(-3deg); }
.stat-val { font-size: 24px; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-soft); font-size: 12px; }

/* per-card accent tints (cycled in the dashboard grid) */
.stats .stat:nth-child(2) .stat-ico { background: linear-gradient(135deg,#22C55E,#16A34A); box-shadow: 0 6px 16px rgba(22,163,74,.28); }
.stats .stat:nth-child(3) .stat-ico { background: linear-gradient(135deg,#A78BFA,#7C3AED); box-shadow: 0 6px 16px rgba(124,58,237,.28); }
.stats .stat:nth-child(4) .stat-ico { background: linear-gradient(135deg,#38BDF8,#0891B2); box-shadow: 0 6px 16px rgba(8,145,178,.28); }
.stats .stat:nth-child(5) .stat-ico { background: linear-gradient(135deg,#FBBF24,#D97706); box-shadow: 0 6px 16px rgba(217,119,6,.28); }

.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--primary-grad); color: #fff; font-weight: 600; font-size: 13px;
  cursor: pointer; transition: background var(--tr), color var(--tr), border-color var(--tr), box-shadow var(--tr), transform .18s var(--ease); font-family: inherit;
  box-shadow: 0 4px 12px rgba(79,70,229,.22);
}
.btn:hover { background: var(--primary-grad-hover); transform: translateY(-1px); box-shadow: 0 8px 18px rgba(79,70,229,.28); }
.btn:active { transform: translateY(0); box-shadow: 0 3px 8px rgba(79,70,229,.22); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); box-shadow: none; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-text); background: var(--primary-soft); transform: translateY(-1px); }
.btn-danger { background: var(--danger); box-shadow: 0 4px 12px rgba(220,38,38,.22); }
.btn-danger:hover { background: #B91C1C; }
.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: var(--radius-xs); }
.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; }
.badge-primary { background: var(--primary-soft); color: var(--primary-text); }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-warn    { background: var(--warning-soft); color: var(--warning-text); }
.badge-danger  { background: var(--danger-soft); color: var(--danger-text); }
.badge-info    { background: var(--info-soft); color: var(--info-text); }
.badge-muted   { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
/* leading status dot on status badges */
.badge-primary::before, .badge-success::before, .badge-warn::before,
.badge-danger::before, .badge-info::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; margin-inline-end: 6px; opacity: .75; flex: none;
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data thead th { background: var(--surface-2); color: var(--text-soft); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
table.data thead th:first-child { border-start-start-radius: var(--radius-sm); }
table.data thead th:last-child { border-start-end-radius: var(--radius-sm); }
table.data tbody tr { transition: background var(--tr); }
table.data tbody tr:hover { background: var(--row-hover); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td { font-variant-numeric: tabular-nums; }
/* opt-in vertical scroll + sticky header */
.table-wrap.scroll-y { max-height: 65vh; overflow-y: auto; }
.table-wrap.scroll-y table.data thead th { position: sticky; top: 0; z-index: 1; }
table.data td.actions-cell { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 600; color: var(--text-soft); }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--input-bg); color: var(--text); font-family: inherit; font-size: 14px; transition: var(--tr);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
/* custom select chevron (mirrored explicitly for RTL) */
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-inline-end: 34px;
}
[dir="rtl"] select { background-position: left 12px center; }
textarea { resize: vertical; min-height: 72px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
.checkbox input { width: auto; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---------- Alerts ---------- */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 500; border: 1px solid transparent; }
.alert-success { background: var(--success-soft); color: var(--success-text); border-color: rgba(22,163,74,.3); }
.alert-danger  { background: var(--danger-soft); color: var(--danger-text); border-color: rgba(220,38,38,.3); }
.alert-warn    { background: var(--warning-soft); color: var(--warning-text); border-color: rgba(217,119,6,.3); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: none; z-index: 70; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal.open { display: flex; animation: modalFade .18s ease; }
.modal.open .modal-box { animation: modalIn .22s cubic-bezier(.16,1,.3,1); }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-box { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 720px; border: 1px solid var(--border); }
.modal-box.lg { max-width: 960px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px; }
.modal-close { background: none; border: none; color: var(--text-soft); font-size: 22px; cursor: pointer; line-height: 1; }

/* ---------- Toolbar / search ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 360px; }
.spacer { flex: 1; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { padding: 10px 16px; cursor: pointer; color: var(--text-soft); font-weight: 600; border-bottom: 2px solid transparent; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Capacity bar ---------- */
.capbar { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.capbar > span { display: block; height: 100%; background: var(--primary); transition: width var(--tr); }
.capbar.over > span { background: var(--danger); }

/* dynamic order items table */
.items-table input { padding: 6px 8px; font-size: 13px; }
.items-table td, .items-table th { padding: 6px; }
.muted-text { color: var(--muted); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(1100px 560px at 100% -10%, rgba(99,102,241,.14), transparent 65%),
  radial-gradient(900px 480px at -10% 110%, rgba(124,58,237,.10), transparent 60%),
  var(--bg); }
.login-card { position: relative; overflow: hidden; width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 32px;
  animation: fadeUp .4s var(--ease) both; }
.login-card::before { content: ""; position: absolute; inset-inline: 0; top: 0; height: 3px;
  background: var(--primary-grad); }
.login-logo { width: 54px; height: 54px; border-radius: 14px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 20px; margin: 0 auto 16px;
  animation: logoFloat 4s ease-in-out infinite; }
@keyframes logoFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.login-card h2 { text-align: center; }
.login-card .sub { text-align: center; color: var(--text-soft); margin-bottom: 22px; }
.login-card .field { margin-bottom: 14px; }
.login-card input { padding: 11px 14px; font-size: 15px; }
.login-card .btn { width: 100%; margin-top: 6px; padding: 12px; font-size: 14px; }
.login-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.login-row .login-tools { display: flex; align-items: center; gap: 4px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0 0; }

/* ===================== Phase 2 additions ===================== */
/* backdrop blur on modals */
.modal { backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }

/* toasts (top-right, auto dismiss) */
#toastHost { position: fixed; top: 16px; inset-inline-end: 16px; z-index: 90; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  min-width: 220px; max-width: 360px; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); border-inline-start: 4px solid var(--primary);
  font-weight: 600; font-size: 13.5px; opacity: 0; transform: translateY(-8px);
  transition: opacity var(--tr), transform var(--tr); pointer-events: auto;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-inline-start-color: var(--success); }
.toast-danger  { border-inline-start-color: var(--danger); }
.toast-warning { border-inline-start-color: var(--warning); }

/* empty state */
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--muted);
  border: 1.5px dashed var(--border); border-radius: var(--radius); background: var(--surface-2);
}
.empty-state svg { width: 48px; height: 48px; opacity: .5; margin-bottom: 10px; }
.empty-state p { margin: 0; font-weight: 500; }

/* compact progress bar (reuses capbar look) */
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); min-width: 90px; }
.progress > span { display: block; height: 100%; background: var(--primary); transition: width var(--tr); }
.progress.over > span { background: var(--danger); }
.progress > span.lvl-zero { background: transparent; }
.progress > span.lvl-part { background: var(--warning); }
.progress > span.lvl-ok { background: var(--success); }
.progress-label { font-size: 11px; color: var(--text-soft); margin-top: 3px; }

/* warehouse loading cell (order detail + orders list) */
.load-cell { display: flex; flex-direction: column; gap: 4px; min-width: 110px; }
.load-num { font-weight: 700; font-variant-numeric: tabular-nums; }
.load-conts { display: flex; flex-wrap: wrap; gap: 4px; }
.load-cont {
  font-size: 11px; font-weight: 600; color: var(--primary-text); background: var(--primary-soft);
  padding: 1px 8px; border-radius: 999px; white-space: nowrap;
}
.load-cont:hover { text-decoration: underline; }
.load-summary {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.load-summary-lbl { font-weight: 700; color: var(--text-soft); font-size: 12.5px; }
.load-summary .progress { flex: 1; min-width: 160px; }

/* currency chip */
.badge-cur { background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border); }

/* detail header */
.detail-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.detail-head h2 { font-size: 20px; margin: 0; }
.detail-head .spacer { flex: 1; }

/* tab underline animation */
.tab { position: relative; transition: color var(--tr); }
.tab::after { content: ""; position: absolute; inset-inline: 0; bottom: -1px; height: 2px; background: var(--primary); transform: scaleX(0); transition: transform var(--tr); }
.tab.active::after { transform: scaleX(1); }

/* loading affordance on submit buttons */
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; top: calc(50% - 8px); inset-inline-start: calc(50% - 8px); border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: btnspin .6s linear infinite; }
@keyframes btnspin { to { transform: rotate(360deg); } }

/* mini summary row */
.summary-row { display: flex; gap: 18px; flex-wrap: wrap; padding-top: 12px; margin-top: 8px; border-top: 1px solid var(--border); font-weight: 600; }
.summary-row .muted-text { font-weight: 500; }

/* ===================== Phase 3 (Orders) additions ===================== */
/* extra status badge colors */
.badge-purple { background: var(--purple-soft); color: var(--purple-text); }
.badge-orange { background: var(--orange-soft); color: var(--orange-text); }
.badge-cyan   { background: var(--cyan-soft); color: var(--cyan-text); }
.badge-purple::before, .badge-orange::before, .badge-cyan::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; margin-inline-end: 6px; opacity: .75; flex: none;
}

/* date-range inputs in filter bar */
.toolbar .daterange { display: flex; align-items: center; gap: 6px; }
.toolbar input[type="date"] { max-width: 160px; }

/* auto-calculated (read-only) item fields */
input.calc-out, .calc-cell {
  background: var(--primary-soft); color: var(--primary-text); font-weight: 600;
  border-color: rgba(79,70,229,.25);
}
input.calc-out { cursor: default; }

/* item image thumbnails */
.thumb-50 { width: 50px; height: 50px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); cursor: pointer; }
.thumb-cell { display: flex; align-items: center; gap: 6px; }

/* sticky order summary bar */
.order-summary-bar {
  position: sticky; bottom: 0; z-index: 20; margin-top: 16px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 12px 18px;
}
.order-summary-bar .sum { display: flex; flex-direction: column; line-height: 1.2; }
.order-summary-bar .sum b { font-size: 16px; }
.order-summary-bar .sum span { font-size: 11.5px; color: var(--text-soft); }
.order-summary-bar .grow { flex: 1; }
.btn-success { background: var(--success); }
.btn-success:hover { filter: brightness(.93); }

/* image lightbox (reuses .modal) */
.img-lightbox .modal-box { max-width: 90vw; width: auto; background: transparent; border: none; box-shadow: none; }
.img-lightbox img { max-width: 90vw; max-height: 85vh; border-radius: 10px; }

/* delete-row button */
.rm-row-x { background: var(--danger); color: #fff; border: none; width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-weight: 700; line-height: 1; }

/* print */
@media print {
  .sidebar, .topbar, .hamburger, .overlay, .toolbar, .form-actions,
  .order-summary-bar, .no-print, #toastHost { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; max-width: none !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
  body { background: #fff !important; }
}

/* ===================== Phase 4 (Containers) additions ===================== */
/* capacity-bar fill colour by load level */
.capbar > span.lvl-ok     { background: var(--success); }
.capbar > span.lvl-warn   { background: var(--warning); }
.capbar > span.lvl-danger { background: var(--danger); }

/* sticky live CBM / weight meter bar (container-new) */
.meter-bar {
  position: sticky; top: 0; z-index: 25; margin: 0 0 16px;
  display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 14px 18px;
}
.meter-bar .meter { flex: 1; min-width: 220px; }
.meter-bar .meter-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; color: var(--text-soft); margin-bottom: 6px; }
.meter-bar .meter-top b { color: var(--text); font-size: 13px; }
.meter-bar .meter-warn { flex-basis: 100%; color: var(--danger); font-weight: 700; font-size: 13px; }

/* collapsible supplier groups (container-new step 2) */
.sup-group { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 14px; overflow: hidden; }
.sup-head { background: var(--primary-soft); color: var(--primary); font-weight: 700; padding: 10px 14px; cursor: pointer; user-select: none; }
.sup-head .caret { display: inline-block; transition: transform var(--tr); }
.sup-head.collapsed .caret { transform: rotate(-90deg); }
.sup-body { padding: 10px 14px; }
.ord-sub { font-weight: 600; color: var(--text-soft); font-size: 12.5px; margin: 8px 0 4px; }
tr.picked { background: var(--primary-soft); }

/* ===================== Phase 5 (Final polish) additions ===================== */
/* breadcrumbs */
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
.breadcrumb a { color: var(--text-soft); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--muted); opacity: .7; }
.breadcrumb .current { color: var(--text); font-weight: 600; }

/* skeleton shimmer (async tables) */
.skeleton { display: block; height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.2s ease-in-out infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* reports + settings helpers */
.report-section { margin-bottom: 22px; }
.logo-preview { max-height: 64px; max-width: 200px; border: 1px solid var(--border); border-radius: 8px; padding: 6px; background: var(--surface-2); }
.cur-toggle-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--border); }
.cur-toggle-row:last-child { border-bottom: none; }
.cur-toggle-row .cur-name { font-weight: 600; min-width: 60px; }

/* friendly 404 */
.error-wrap { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 20px; }
.error-code { font-size: 84px; font-weight: 800; color: var(--primary); line-height: 1; }
.error-wrap h2 { margin: 10px 0 6px; }
.error-wrap p { color: var(--text-soft); margin-bottom: 20px; }

/* ===================== Modern polish ===================== */
/* rounder icon buttons */
.icon-btn { border-radius: 10px; }
.icon-btn:hover { transform: translateY(-1px); }
/* cards lift subtly */
.card { transition: box-shadow var(--tr), border-color var(--tr); }
/* gentle fade-in for page content */
.content > .card, .content > .grid, .content > .report-section, .content > .tabs { animation: fadeUp .28s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* login card gets the brand gradient logo */
.login-logo { background: var(--primary-grad); box-shadow: 0 10px 24px rgba(79,70,229,.35); }

/* global search in the top bar */
.global-search { position: relative; flex: 1; max-width: 440px; margin-inline: 18px; display: flex; align-items: center; }
.global-search .gs-ico { position: absolute; inset-inline-start: 12px; color: var(--muted); pointer-events: none; }
.global-search input { padding-inline-start: 38px; border-radius: 999px; background: var(--surface-2); }
.gs-results { position: absolute; top: calc(100% + 8px); inset-inline: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; max-height: 64vh; overflow-y: auto; animation: fadeUp .16s ease both; }
.gs-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); }
.gs-item:hover { background: var(--primary-soft); }
.gs-type { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--primary); background: var(--primary-soft); padding: 2px 8px; border-radius: 999px; flex: none; }
.gs-label { font-weight: 600; }
.gs-sub { color: var(--muted); font-size: 12px; margin-inline-start: auto; }
.gs-empty { padding: 14px; color: var(--muted); text-align: center; }

/* ===================== List pages: summary + cards + controls ===================== */
.list-summary { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.list-summary .ls-item {
  flex: 1; min-width: 130px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px; display: flex; flex-direction: column; gap: 2px;
}
.list-summary .ls-val { font-size: 20px; font-weight: 800; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.list-summary .ls-lbl { font-size: 12px; color: var(--text-soft); }

.list-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.list-controls .sort-label { color: var(--text-soft); }
.list-controls select { max-width: 200px; }

.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.view-toggle button {
  width: auto; padding: 8px 14px; border: none; background: transparent; color: var(--text-soft);
  cursor: pointer; font-size: 15px; line-height: 1; transition: var(--tr);
}
.view-toggle button:hover { color: var(--primary); background: var(--primary-soft); }
.view-toggle button.active { background: var(--primary-grad); color: #fff; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.entity-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; cursor: pointer;
  display: flex; flex-direction: column; gap: 12px;
  transition: transform var(--tr), box-shadow var(--tr), border-color var(--tr);
  animation: fadeUp .25s var(--ease) both;
}
.entity-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: rgba(79,70,229,.25); }
.entity-card-head { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 42px; height: 42px; border-radius: 12px; flex: none; color: #fff; font-weight: 800;
  display: grid; place-items: center; font-size: 17px; box-shadow: 0 4px 12px rgba(16,24,40,.18);
}
.ec-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ec-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ec-sub { font-size: 12px; color: var(--muted); }
.ec-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ec-phone { color: var(--text-soft); font-size: 13px; }
.ec-stats { display: flex; gap: 10px; border-top: 1px solid var(--border); padding-top: 12px; }
.ec-stats > div { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.ec-stat-val { font-weight: 700; font-size: 14px; }
.ec-stat-lbl { font-size: 11px; color: var(--text-soft); }
.ec-cap { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); padding-top: 12px; }
.ec-cap-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-soft); }
.ec-actions { display: flex; gap: 8px; justify-content: flex-end; }

.icon-action {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft);
  cursor: pointer; transition: var(--tr);
}
.icon-action:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); transform: translateY(-1px); }
.icon-action.danger:hover { color: var(--danger); border-color: var(--danger); background: rgba(220,38,38,.10); }

/* respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ===================== Refinement pass ===================== */
/* keep the login-row lang/theme buttons compact (login .btn is full-width) */
.login-row .btn { width: auto; margin-top: 0; }

/* custom scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* visible keyboard focus on interactive elements */
.btn:focus-visible, .icon-btn:focus-visible, .icon-action:focus-visible,
a:focus-visible, .tab:focus-visible, .view-toggle button:focus-visible,
.modal-close:focus-visible, .rm-row-x:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-110%); }
  [dir="rtl"] .sidebar { transform: translateX(110%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-inline-start: 0; }
  .hamburger { display: grid; place-items: center; }
  .topbar { padding-inline-start: 64px; }
  .overlay.open { display: block; }
  .user-name { display: none; }
  .content { padding: 16px; }
  .toolbar .search { max-width: none; }
  .global-search { display: none; }
}

/* small phones */
@media (max-width: 480px) {
  .content { padding: 12px; }
  .card { padding: 16px; }
  .stat { padding: 14px; }
  .login-card { padding: 24px; }
  .modal { padding: 20px 10px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}
