
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700;800&display=swap');

/* ══════════════════════════════════════
   DESIGN TOKENS
══════════════════════════════════════ */
:root {
  --font-ar: 'IBM Plex Sans Arabic', sans-serif;
  --font-en: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-sans: var(--font-en);
  --bg-app: #f1f5f9; --bg-surface: #ffffff; --bg-subtle: #f8fafc; --bg-disabled: #f1f5f9;
  --border-light: rgba(15, 23, 42, 0.06); --border-base: rgba(15, 23, 42, 0.12); --border-focus: #4f46e5;
  --text-main: #0f172a; --text-muted: #475569; --text-light: #94a3b8;
  --brand-primary: #4f46e5; --brand-hover: #4338ca;
  --status-success: #10b981; --status-error: #ef4444; --status-warning: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --glow-brand: 0 8px 16px rgba(79, 70, 229, 0.2);
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px;
  --transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

html[lang="ar"] { --font-sans: var(--font-ar); }
html[lang="en"] { --font-sans: var(--font-en); }

[data-theme="dark"] {
  --bg-app: #09090b; --bg-surface: #121217; --bg-subtle: #18181f; --bg-disabled: #09090b;
  --border-light: rgba(255, 255, 255, 0.06); --border-base: rgba(255, 255, 255, 0.12); --border-focus: #6366f1;
  --text-main: #f8fafc; --text-muted: #94a3b8; --text-light: #64748b;
  --brand-primary: #6366f1; --brand-hover: #4f46e5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
  font-family: var(--font-sans); background-color: var(--bg-app); color: var(--text-main); line-height: 1.5; -webkit-font-smoothing: antialiased; 
  background-image: radial-gradient(circle at 100% 0%, rgba(79, 70, 229, 0.05) 0%, transparent 40%), radial-gradient(circle at 0% 100%, rgba(16, 185, 129, 0.03) 0%, transparent 40%);
  background-attachment: fixed;
}
[data-theme="dark"] body {
  background-image: radial-gradient(circle at 100% 0%, rgba(99, 102, 241, 0.1) 0%, transparent 40%), radial-gradient(circle at 0% 100%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
}
.app-container { display: flex; width: 100%; min-height: 100vh; }
.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ══════════════════════════════════════
   SIDEBAR
══════════════════════════════════════ */
.sidebar {
  width: 280px; flex-shrink: 0; background-color: var(--bg-surface);
  border-left: 1px solid var(--border-light); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40; transition: transform var(--transition);
}
[dir="ltr"] .sidebar { border-left: none; border-right: 1px solid var(--border-light); }
.sidebar::-webkit-scrollbar { width: 4px; } .sidebar::-webkit-scrollbar-thumb { background: var(--border-base); border-radius: 4px; }

.sidebar-header { padding: 24px 20px; border-bottom: 1px solid var(--border-light); }
.sidebar-logo { display: flex; align-items: center; gap: 8px; font-size: 22px; font-weight: 800; color: var(--text-main); }
.sidebar-sub { font-size: 11px; color: var(--text-muted); font-weight: 600; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px;}

.sidebar-nav { padding: 16px; display: flex; flex-direction: column; gap: 4px; border-bottom: 1px solid var(--border-light); }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius-md); font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer; transition: all var(--transition); }
.nav-icon { font-size: 20px; }
.nav-item:hover { background: var(--bg-subtle); color: var(--text-main); }
.nav-item.active { background: var(--brand-primary); color: #ffffff; box-shadow: var(--glow-brand); }

.sidebar-content { padding: 20px; flex: 1; }
.sidebar-section-title { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-light); margin: 0 0 16px 0; }
.sidebar-section-title i { font-size: 16px; }
.sidebar-footer { padding: 20px; border-top: 1px solid var(--border-light); display: flex; flex-direction: column; gap: 10px; }

/* ══════════════════════════════════════
   FORM INPUTS
══════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-main); margin-bottom: 6px; }
.input-wrapper { position: relative; display: flex; align-items: center; }
.input-adornment { position: absolute; font-size: 13px; color: var(--text-light); font-weight: 700; pointer-events: none; }
.form-input {
  width: 100%; padding: 10px 12px; font-family: var(--font-sans); font-size: 14px; 
  font-weight: 500; color: var(--text-main); background-color: var(--bg-surface);
  border: 1px solid rgba(15, 23, 42, 0.1); border-radius: var(--radius-sm);
  transition: all var(--transition); outline: none; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.02);
}
.form-input:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15); }
.form-input.readonly { background-color: var(--bg-disabled); color: var(--text-muted); cursor: not-allowed; box-shadow: none; border-color: var(--border-light); }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

[dir="rtl"] .adorn-prefix { right: 12px; } [dir="rtl"] .has-prefix .form-input { padding-right: 28px; text-align: left; }
[dir="ltr"] .adorn-prefix { left: 12px; } [dir="ltr"] .has-prefix .form-input { padding-left: 28px; text-align: left; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; font-size: 13px; font-weight: 700; font-family: var(--font-sans); border-radius: var(--radius-md); cursor: pointer; transition: all var(--transition); border: 1px solid var(--border-base); background: var(--bg-surface); color: var(--text-main); width: 100%; box-shadow: var(--shadow-sm); border: 1px solid var(--border-base); }
.btn i { font-size: 16px; }
.btn:hover { background: var(--bg-subtle); }
.btn-primary { background: var(--brand-primary); color: #ffffff; border: none; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-hover); color: #ffffff; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-group { display: flex; gap: 8px; margin-bottom: 16px; } .btn-group .btn { flex: 1; padding: 8px; } .btn-group .btn.active { background: var(--text-main); color: var(--bg-surface); border-color: var(--text-main); }

/* Global Top Nav */
.global-top-nav { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; background: var(--bg-surface); border-bottom: 1px solid rgba(15, 23, 42, 0.05); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.02); z-index: 40; position: sticky; top: 0; }
.gtn-left { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 15px; color: var(--text-main); }
.gtn-center { flex: 1; max-width: 480px; margin: 0 24px; position: relative; }
.gtn-center input { width: 100%; padding: 10px 16px 10px 40px; border-radius: 8px; border: 1px solid var(--border-base); background: var(--bg-subtle); outline: none; font-family: var(--font-sans); font-size: 13px; color: var(--text-main); transition: all 0.2s; }
[dir="rtl"] .gtn-center input { padding: 10px 40px 10px 16px; }
.gtn-center input:focus { background: var(--bg-surface); border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1); }
.gtn-center .ph-magnifying-glass { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-light); font-size: 16px; pointer-events: none; }
[dir="rtl"] .gtn-center .ph-magnifying-glass { left: auto; right: 14px; }
.gtn-center .cmd-k { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 10px; color: var(--text-light); border: 1px solid var(--border-base); padding: 2px 6px; border-radius: 4px; font-weight: 700; pointer-events: none; background: var(--bg-surface); }
[dir="rtl"] .gtn-center .cmd-k { right: auto; left: 14px; }
.gtn-right { display: flex; align-items: center; gap: 16px; }
.user-profile { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--brand-primary), #8b5cf6); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; box-shadow: var(--shadow-sm); }
.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 13px; font-weight: 700; color: var(--text-main); line-height: 1.2; }
.user-company { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.badge-super { background: rgba(245, 158, 11, 0.1); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.2); padding: 2px 6px; border-radius: 4px; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; }

/* Numbered Sections & Merged Inputs */
.section-num-title { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.num-circle { width: 26px; height: 26px; border-radius: 50%; background: var(--bg-subtle); border: 1px solid var(--border-base); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: var(--text-muted); flex-shrink: 0; box-shadow: inset 0 2px 4px rgba(0,0,0,0.02); }
.nt-title { font-size: 14px; font-weight: 800; color: var(--text-main); line-height: 1.2; margin-bottom: 4px; }
.nt-desc { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.input-group-merged { display: flex; align-items: stretch; width: 100%; box-shadow: inset 0 2px 4px rgba(0,0,0,0.02); border-radius: var(--radius-sm); }
.input-group-merged .form-input { box-shadow: none; }

/* Inventory & Warehouses Specific Styles */
.btn-blue { background: #3b82f6; color: #fff; border: none; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25); }
.btn-blue:hover { background: #2563eb; color: #fff; transform: translateY(-2px); }
.btn-outline { background: var(--bg-surface); border: 1px solid var(--border-base); color: var(--text-main); }
.btn-outline:hover { background: var(--bg-subtle); border-color: var(--text-muted); }
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 700; letter-spacing: 0.3px; }
.badge.success { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.badge.warning { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.badge.brand { background: rgba(99, 102, 241, 0.1); color: #6366f1; }
.badge.purple { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.action-icon { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 6px; color: var(--text-muted); background: var(--bg-subtle); transition: all 0.2s; cursor: pointer; border: 1px solid var(--border-light); margin-inline-end: 4px; }
.action-icon:hover { background: var(--bg-surface); color: var(--brand-primary); border-color: var(--brand-primary); box-shadow: var(--shadow-sm); }
.action-icon.delete:hover { color: var(--status-error); border-color: var(--status-error); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--bg-surface); padding: 16px; border-radius: var(--radius-md); border: 1px solid var(--border-light); box-shadow: var(--shadow-sm); transition: transform 0.2s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-base); }
.stat-title { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; margin-bottom: 6px; }
.stat-val { font-size: 22px; font-weight: 800; line-height: 1; }
.stat-val.green { color: #10b981; } .stat-val.orange { color: #f59e0b; } .stat-val.purple { color: #8b5cf6; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; align-items: center; justify-content: space-between; }
.toolbar-left, .toolbar-right { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filter-pill { padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 600; cursor: pointer; border: 1px solid var(--border-base); background: var(--bg-surface); color: var(--text-muted); transition: all 0.2s; }
.filter-pill:hover, .filter-pill.active { background: var(--text-main); color: var(--bg-surface); border-color: var(--text-main); }
.search-input { padding: 8px 14px 8px 36px; border-radius: 20px; border: 1px solid var(--border-base); font-size: 12px; font-family: var(--font-sans); background: var(--bg-subtle) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="%2394a3b8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>') no-repeat 12px center; outline: none; transition: border-color 0.2s; }
.search-input:focus { background-color: var(--bg-surface); border-color: var(--brand-primary); }

/* Modern Toggle Switch */
.toggle-switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--border-base); transition: .3s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: var(--brand-primary); }
input:checked + .slider:before { transform: translateX(16px); }
[dir="rtl"] input:checked + .slider:before { transform: translateX(-16px); }
.checkbox-label { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--text-main); cursor: pointer; margin-bottom: 16px;}

/* Warehouse Stepper & Layout */
.layout-with-sidebar { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
@media (max-width: 1024px) { .layout-with-sidebar { grid-template-columns: 1fr; } }
.stepper-nav { display: flex; align-items: center; gap: 32px; margin-bottom: 24px; border-bottom: 1px solid var(--border-light); padding-bottom: 16px; overflow-x: auto; }
.step-item { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--text-light); white-space: nowrap; transition: color 0.3s; }
.step-item.active { color: var(--text-main); }
.step-item.completed { color: var(--status-success); }
.step-circle { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; background: var(--bg-subtle); border: 1px solid var(--border-base); transition: all 0.3s; }
.step-item.active .step-circle { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); box-shadow: var(--glow-brand); }
.step-item.completed .step-circle { background: var(--status-success); color: #fff; border-color: var(--status-success); }
.quick-notes { background: rgba(59, 130, 246, 0.04); border: 1px solid rgba(59, 130, 246, 0.15); border-radius: var(--radius-lg); padding: 20px; }
[data-theme="dark"] .quick-notes { background: rgba(99, 102, 241, 0.05); border-color: rgba(99, 102, 241, 0.2); }
.quick-notes h4 { font-size: 13px; font-weight: 700; color: #3b82f6; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
[data-theme="dark"] .quick-notes h4 { color: #818cf8; }
.quick-notes p, .quick-notes ul { font-size: 12px; color: var(--text-muted); line-height: 1.6; margin-bottom: 12px; }
.quick-notes ul { margin-inline-start: 20px; }
.quick-notes li { margin-bottom: 6px; }
.spin { animation: spin 1s linear infinite; }

/* Upload Zone & Custom Cards */
.upload-zone { border: 2px dashed var(--border-base); border-radius: var(--radius-md); padding: 40px 20px; text-align: center; color: var(--text-muted); cursor: pointer; transition: all 0.2s; background: var(--bg-subtle); }
.upload-zone:hover { border-color: var(--brand-primary); background: rgba(79, 70, 229, 0.02); }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* ══════════════════════════════════════
   MAIN LAYOUT & LIVE KPI BAR
══════════════════════════════════════ */
.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.live-kpi-bar {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  background: rgba(255, 255, 255, 0.65); padding: 20px 32px; border-bottom: 1px solid rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  position: sticky; top: 0; z-index: 30; box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .live-kpi-bar { background: rgba(18, 18, 23, 0.65); border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.live-kpi-item { display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--border-light); padding-right: 16px;}
[dir="ltr"] .live-kpi-item { border-right: none; border-left: 1px solid var(--border-light); padding-right: 0; padding-left: 16px;}
.live-kpi-item:first-child { border: none !important; padding: 0 !important; }
.live-kpi-label { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.live-kpi-label i { font-size: 16px; color: var(--text-light); }
.live-kpi-val { font-size: 26px; font-weight: 800; color: var(--text-main); line-height: 1; letter-spacing: -0.02em; display:flex; align-items:center; gap:8px;}
.live-kpi-val.text-success { background: linear-gradient(135deg, #10b981, #059669); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.live-kpi-val.text-error { background: linear-gradient(135deg, #ef4444, #be123c); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.live-kpi-val.text-brand { background: linear-gradient(135deg, var(--brand-primary), #8b5cf6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.page-container { padding: 32px; flex: 1; display: none; }
.page-container.active { display: block; animation: fadeIn 0.3s ease; }
.page-header { margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 800; color: var(--text-main); margin-bottom: 6px; }
.page-desc { font-size: 13px; color: var(--text-muted); font-weight: 500; }

.card { background: var(--bg-surface); border: 1px solid rgba(15, 23, 42, 0.08); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-sm); margin-bottom: 24px; transition: transform var(--transition), box-shadow var(--transition); position: relative; overflow: hidden; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border-light); }
.card-title { font-size: 16px; font-weight: 800; color: var(--text-main); display: flex; align-items: center; gap: 8px;}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }

/* Modal Styles */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); z-index: 100; backdrop-filter: blur(4px); }
.modal-box { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 101; width: 100%; max-width: 480px; background: var(--bg-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 24px; border: 1px solid var(--border-light); }

/* Market Performance Cards */
.market-card { border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: 24px; background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-subtle) 100%); box-shadow: var(--shadow-md); transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition); position: relative; overflow: hidden; }
.market-card::after { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: radial-gradient(circle at top right, rgba(255,255,255,0.1), transparent); pointer-events: none; }
.market-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); border-color: var(--brand-primary); }
.mc-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.mc-flag { font-size: 38px; line-height: 1; filter: drop-shadow(0 8px 12px rgba(0,0,0,0.15)); transition: transform var(--transition); }
.market-card:hover .mc-flag { transform: scale(1.1) rotate(-5deg); }
.mc-name { font-size: 14px; font-weight: 800; margin-top: 6px;}
.mc-net { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 4px; display:flex; align-items:center; gap:8px;}
.mc-net.text-success { background: linear-gradient(135deg, #10b981, #059669); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.mc-net.text-error { background: linear-gradient(135deg, #ef4444, #be123c); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.mc-margin { font-size: 12px; font-weight: 600; color: var(--text-muted);}

.mc-list { border-top: 1px solid var(--border-light); padding-top: 16px; margin-top: 16px; }
.mc-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 12px; }
.mc-row span:first-child { color: var(--text-muted); font-weight: 600; }
.mc-row span:last-child { color: var(--text-main); font-weight: 800; }

.text-success { color: var(--status-success) !important; -webkit-text-fill-color: var(--status-success); } .text-error { color: var(--status-error) !important; -webkit-text-fill-color: var(--status-error); } .text-brand { color: var(--brand-primary) !important; -webkit-text-fill-color: var(--brand-primary); }

/* Tables */
.table-container { width: 100%; overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border-light); }
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; min-width: 950px; background: var(--bg-surface); }
[dir="rtl"] .data-table { text-align: right; }
.data-table th { background: rgba(15, 23, 42, 0.02); padding: 14px 16px; font-weight: 700; color: var(--text-muted); border-bottom: 1px solid var(--border-light); font-size: 11px; text-transform: uppercase; }
[data-theme="dark"] .data-table th { background: rgba(255, 255, 255, 0.02); }
.data-table td { padding: 14px 16px; border-bottom: 1px solid var(--border-light); color: var(--text-main); font-weight: 600; }
.data-table tbody tr:hover { background-color: var(--bg-subtle); }
.data-table tfoot td { background: rgba(15, 23, 42, 0.03); font-weight: 800; border-top: 2px solid var(--border-base); font-size: 14px; }
[data-theme="dark"] .data-table tfoot td { background: rgba(255, 255, 255, 0.03); }

/* Collapsible Nav Group */
.nav-group { margin-top: 8px; margin-bottom: 8px; }
.nav-group-header {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 12px 16px; border-radius: var(--radius-md); font-size: 14px; font-weight: 600;
  color: var(--text-muted); cursor: pointer; transition: all var(--transition);
  background: transparent; border: none; font-family: inherit;
}
.nav-group-header:hover { background: var(--bg-subtle); color: var(--text-main); }
.nav-group-header .left-side { display: flex; align-items: center; gap: 12px; }
.nav-group-header .ph-caret-down { transition: transform 0.3s ease; font-size: 16px; color: var(--text-light); }
.nav-group.open .nav-group-header .ph-caret-down { transform: rotate(180deg); }
.nav-group.open .nav-group-header { background: var(--brand-primary); color: #ffffff; box-shadow: var(--shadow-sm); }
.nav-group.open .nav-group-header .ph-caret-down, .nav-group.open .nav-group-header .left-side i { color: #ffffff; }

.nav-group-items {
  display: none; flex-direction: column; gap: 6px;
  margin-top: 8px; margin-bottom: 8px; position: relative;
  list-style: none; padding: 0;
}
.nav-group.open .nav-group-items { display: flex; animation: fadeIn 0.3s ease; }
[dir="rtl"] .nav-group-items { padding-right: 42px; }
[dir="ltr"] .nav-group-items { padding-left: 42px; }
.nav-group-items::before { content: ''; position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border-base); }
[dir="rtl"] .nav-group-items::before { right: 23px; }
[dir="ltr"] .nav-group-items::before { left: 23px; }

.nav-sub-item { display: flex; align-items: center; padding: 10px 14px; font-size: 13px; font-weight: 500; color: var(--text-muted); cursor: pointer; border-radius: var(--radius-sm); transition: all var(--transition); position: relative; background: var(--bg-surface); }
.nav-sub-item:hover { color: var(--text-main); background: var(--bg-subtle); font-weight: 600; }
.nav-sub-item.active { background: var(--bg-disabled); color: var(--text-main); font-weight: 700; }
.nav-sub-item::before { content: ''; position: absolute; top: 50%; width: 12px; height: 1px; background: var(--border-base); }
[dir="rtl"] .nav-sub-item::before { right: -19px; } [dir="ltr"] .nav-sub-item::before { left: -19px; }

/* ══════════════════════════════════════
   FINANCE MODULE
══════════════════════════════════════ */
.finance-grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; margin-bottom: 24px; }
.finance-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.finance-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 24px; }

.fc-card {
  background: var(--bg-surface); padding: 20px; border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border-light);
  display: flex; flex-direction: column; gap: 8px; transition: all var(--transition);
}
.fc-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.fc-blue { border-inline-start: 4px solid #3b82f6; }
.fc-orange { border-inline-start: 4px solid #f97316; }
.fc-green { border-inline-start: 4px solid #10b981; }
.fc-light-green { border-inline-start: 4px solid #34d399; }
.fc-red { border-inline-start: 4px solid #ef4444; }
.fc-yellow { border-inline-start: 4px solid #eab308; }
.fc-purple { border-inline-start: 4px solid #8b5cf6; }

.pl-table tr:hover { background-color: var(--bg-subtle) !important; }
.pl-row-rev td { background-color: rgba(59, 130, 246, 0.05); color: #2563eb; } [data-theme="dark"] .pl-row-rev td { color: #60a5fa; }
.pl-row-cogs td { background-color: rgba(249, 115, 22, 0.05); color: #ea580c; } [data-theme="dark"] .pl-row-cogs td { color: #fb923c; }
.pl-row-gp td { background-color: rgba(16, 185, 129, 0.1); color: #059669; font-weight: 800; font-size: 14px; } [data-theme="dark"] .pl-row-gp td { color: #34d399; }
.pl-row-exp td { background-color: rgba(239, 68, 68, 0.05); color: #dc2626; } [data-theme="dark"] .pl-row-exp td { color: #f87171; }
.pl-row-np td { background-color: rgba(16, 185, 129, 0.2); color: #047857; font-weight: 800; font-size: 16px; border-top: 2px solid #10b981; } [data-theme="dark"] .pl-row-np td { color: #10b981; border-top-color: #059669; }

/* ══════════════════════════════════════
   ACCOUNTING MODULE
══════════════════════════════════════ */
.accounting-grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 24px; }
.acc-empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 64px 20px; text-align: center; }
.acc-empty-state .empty-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--bg-subtle); border: 1px solid var(--border-base); display: flex; align-items: center; justify-content: center; font-size: 32px; color: var(--text-light); margin-bottom: 16px; }
.acc-empty-state .empty-title { font-size: 16px; font-weight: 800; color: var(--text-main); margin-bottom: 8px; }
.acc-empty-state .empty-desc { font-size: 13px; color: var(--text-muted); max-width: 400px; line-height: 1.5; }


/* ══════════════════════════════════════
   LOGIN UI
══════════════════════════════════════ */
.login-wrapper { position: fixed; inset: 0; background: var(--bg-app); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 20px; }
.login-card { background: var(--bg-surface); padding: 40px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); width: 100%; max-width: 400px; border: 1px solid var(--border-light); }
.login-logo { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 28px; font-weight: 800; color: var(--text-main); margin-bottom: 8px; }
.login-desc { text-align: center; font-size: 14px; color: var(--text-muted); margin-bottom: 32px; }
.toggle-password { position: absolute; right: 12px; cursor: pointer; color: var(--text-light); font-size: 18px; }
[dir="rtl"] .toggle-password { right: auto; left: 12px; }
.login-error { background: rgba(239, 68, 68, 0.1); color: var(--status-error); font-size: 13px; font-weight: 600; padding: 10px; border-radius: var(--radius-sm); text-align: center; margin-top: 16px; border: 1px solid rgba(239, 68, 68, 0.2); }

/* ══════════════════════════════════════
   MOBILE RESPONSIVENESS & PRINT
══════════════════════════════════════ */
.mobile-header { display: none; }
.sidebar-overlay { display: none; }

@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .marketing-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .finance-grid-6 { grid-template-columns: repeat(3, 1fr); }
  .accounting-grid-5 { grid-template-columns: repeat(3, 1fr); }
  .lp-builder-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .mobile-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; background: var(--bg-surface); border-bottom: 1px solid var(--border-light); position: sticky; top: 0; z-index: 50; }
  .menu-btn { background: none; border: none; font-size: 24px; color: var(--text-main); cursor: pointer; }
  .live-kpi-bar { grid-template-columns: repeat(2, 1fr); padding: 16px; position: static; }
  .live-kpi-item { border: none !important; padding: 0 !important; margin-bottom: 8px;}
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); z-index: 90; opacity: 0; pointer-events: none; transition: opacity var(--transition); }
  .sidebar-overlay.active { opacity: 1; pointer-events: auto; display: block; }
  .sidebar { position: fixed; top: 0; bottom: 0; width: 280px; z-index: 100; transition: transform 0.3s ease; }
  [dir="rtl"] .sidebar { right: 0; transform: translateX(100%); border-left: none; } [dir="rtl"] .sidebar.active { transform: translateX(0); }
  [dir="ltr"] .sidebar { left: 0; transform: translateX(-100%); border-right: none; } [dir="ltr"] .sidebar.active { transform: translateX(0); }
  .page-container { padding: 20px 16px; } .card { padding: 20px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }
  .marketing-grid-4 { grid-template-columns: 1fr; }
  .mpc-stats { flex-direction: column; gap: 12px; }
  .finance-grid-6, .finance-grid-3, .finance-grid-2 { grid-template-columns: 1fr; }
  .accounting-grid-5 { grid-template-columns: 1fr; }
  #page-create-order > div[style*="grid-template-columns:300px"] { grid-template-columns: 1fr !important; }
  #page-add-store > div[style*="grid-template-columns:1fr 320px"] { grid-template-columns: 1fr !important; }
}

@media print {
  .sidebar, .mobile-header, .no-print { display: none !important; }
  .main-content { padding: 0; }
  .card { border: 1px solid #000; box-shadow: none; break-inside: avoid; }
  body { background: #fff; color: #000; }
  .live-kpi-bar { position: static; border: 1px solid #000; margin-bottom: 20px; }
}

/* UI Utilities (Loading & Errors) */
.ui-spinner {
  border: 3px solid var(--border-light);
  border-top: 3px solid var(--brand-primary);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}
.ui-error-msg {
  background: rgba(239, 68, 68, 0.1); color: var(--status-error);
  padding: 12px; border-radius: var(--radius-sm); border: 1px solid rgba(239, 68, 68, 0.2);
  font-size: 13px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
  animation: fadeIn 0.3s ease;
  width: 100%;
}
.ui-error-msg.ui-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--status-success);
  border-color: rgba(16, 185, 129, 0.2);
}

/* ── Call Center / shared page utilities ── */
.page-description { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-bottom: 0; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn-sm { padding: 4px 10px !important; font-size: 12px !important; height: auto !important; }
.page-header:has(.header-actions) { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 16px; }

