/* =============================================
   RTF - Radiate the Future | Design System
   ============================================= */

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

:root {
  /* Brand Colors - from RTF logo */
  --rtf-orange:        #C8622A;
  --rtf-orange-light:  #E07A45;
  --rtf-orange-muted:  #F0A878;
  --rtf-orange-pale:   #FBF0E9;
  --rtf-orange-glow:   rgba(200, 98, 42, 0.12);

  /* Neutrals */
  --white:             #FFFFFF;
  --off-white:         #FAFAF8;
  --bg-subtle:         #F5F3F0;
  --border-light:      #EDE8E2;
  --border:            #D9D1C7;
  --text-muted:        #9E9189;
  --text-secondary:    #6B6059;
  --text-primary:      #2A211C;

  /* Status Colors */
  --success:           #2D8A5E;
  --success-bg:        #EBF7F2;
  --danger:            #C0392B;
  --danger-bg:         #FDF0EE;
  --warning:           #D4820A;
  --warning-bg:        #FEF6E7;

  /* Spacing */
  --radius-sm:         6px;
  --radius-md:         12px;
  --radius-lg:         18px;
  --radius-xl:         24px;
  --radius-full:       9999px;

  /* Shadows */
  --shadow-xs:         0 1px 3px rgba(42,33,28,0.06);
  --shadow-sm:         0 2px 8px rgba(42,33,28,0.08);
  --shadow-md:         0 4px 20px rgba(42,33,28,0.10);
  --shadow-lg:         0 8px 40px rgba(42,33,28,0.12);
  --shadow-orange:     0 4px 24px rgba(200,98,42,0.20);

  /* Typography */
  --font-arabic:       'IBM Plex Sans Arabic', sans-serif;
  --font-latin:        'Plus Jakarta Sans', sans-serif;

  /* Transitions */
  --transition:        all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-arabic);
  background: var(--off-white);
  color: var(--text-primary);
  direction: rtl;
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-subtle); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--rtf-orange-muted); }

/* =============================================
   TOPBAR / HEADER
   ============================================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
  height: 68px;
  display: flex;
  align-items: center;
  padding: 0 32px;
}

.topbar-inner {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.topbar-logo img {
  height: 38px;
  width: auto;
}

.topbar-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.topbar-logo-ar {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.topbar-logo-en {
  font-family: var(--font-latin);
  font-size: 11px;
  font-weight: 500;
  color: var(--rtf-orange);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
}

.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; }

.nav-link:hover {
  background: var(--rtf-orange-pale);
  color: var(--rtf-orange);
}

.nav-link.active {
  background: var(--rtf-orange-pale);
  color: var(--rtf-orange);
  font-weight: 600;
}

.nav-link.active svg { stroke: var(--rtf-orange); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--rtf-orange-pale);
  border: 2px solid var(--rtf-orange-muted);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--rtf-orange);
}

.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* =============================================
   PAGE LAYOUT
   ============================================= */
.page-wrapper {
  max-width: 1320px;
  margin: 0 auto;
  padding: 36px 32px 60px;
}

/* ---- Page Header ---- */
.page-header {
  margin-bottom: 32px;
}

.page-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 6px;
}

.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.page-breadcrumb span { color: var(--rtf-orange); }
.page-breadcrumb svg { width: 12px; height: 12px; }

.page-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-subtitle {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-muted);
}

/* =============================================
   STAT CARDS
   ============================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  box-shadow: var(--shadow-xs);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}

.stat-card.highlight {
  background: var(--rtf-orange);
  border-color: var(--rtf-orange);
}

.stat-card.highlight .stat-label,
.stat-card.highlight .stat-change { color: rgba(255,255,255,0.7); }
.stat-card.highlight .stat-value { color: var(--white); }
.stat-card.highlight .stat-icon { background: rgba(255,255,255,0.15); color: var(--white); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--rtf-orange);
  opacity: 0;
  transition: var(--transition);
}

.stat-card:hover::before { opacity: 1; }
.stat-card.highlight::before { opacity: 0; }

.stat-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  background: var(--rtf-orange-pale);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--rtf-orange);
  flex-shrink: 0;
}

.stat-icon svg { width: 22px; height: 22px; }

.stat-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.stat-badge.up { background: var(--success-bg); color: var(--success); }
.stat-badge.down { background: var(--danger-bg); color: var(--danger); }
.stat-badge.neutral { background: var(--bg-subtle); color: var(--text-muted); }

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-family: var(--font-latin);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-value .currency {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-right: 4px;
}

.stat-change {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* =============================================
   CONTENT PANELS / CARDS
   ============================================= */
.panel {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title svg { width: 18px; height: 18px; color: var(--rtf-orange); }

.panel-body { padding: 24px; }
.panel-body.no-pad { padding: 0; }

/* =============================================
   TABLE
   ============================================= */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 12px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--rtf-orange-glow); }

tbody td {
  padding: 15px 20px;
  font-size: 14px;
  color: var(--text-secondary);
  vertical-align: middle;
}

.td-main { font-weight: 600; color: var(--text-primary); }
.td-amount { font-family: var(--font-latin); font-weight: 700; color: var(--text-primary); }
.td-amount.expense { color: var(--danger); }
.td-amount.income { color: var(--success); }

/* ---- Status Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.badge-dot { width: 6px; height: 6px; border-radius: 50%; }

.badge.approved { background: var(--success-bg); color: var(--success); }
.badge.approved .badge-dot { background: var(--success); }
.badge.pending { background: var(--warning-bg); color: var(--warning); }
.badge.pending .badge-dot { background: var(--warning); }
.badge.rejected { background: var(--danger-bg); color: var(--danger); }
.badge.rejected .badge-dot { background: var(--danger); }
.badge.draft { background: var(--bg-subtle); color: var(--text-muted); }
.badge.draft .badge-dot { background: var(--text-muted); }

/* ---- Table Actions ---- */
.tbl-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }

.btn-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-icon svg { width: 15px; height: 15px; }
.btn-icon:hover { background: var(--rtf-orange-pale); color: var(--rtf-orange); border-color: var(--rtf-orange-muted); }
.btn-icon.danger:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

/* =============================================
   BUTTONS
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: var(--radius-md);
  font-family: var(--font-arabic);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  border: none;
  white-space: nowrap;
}

.btn svg { width: 17px; height: 17px; flex-shrink: 0; }

.btn-primary {
  background: var(--rtf-orange);
  color: var(--white);
  box-shadow: var(--shadow-orange);
}

.btn-primary:hover {
  background: var(--rtf-orange-light);
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(200,98,42,0.30);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--white);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--rtf-orange-muted);
  color: var(--rtf-orange);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 10px 14px;
}

.btn-ghost:hover { background: var(--rtf-orange-pale); color: var(--rtf-orange); }

.btn-sm { padding: 7px 16px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

/* =============================================
   FORMS
   ============================================= */
.form-group { margin-bottom: 20px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

.form-label .required { color: var(--rtf-orange); margin-right: 3px; }

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-arabic);
  font-size: 14px;
  color: var(--text-primary);
  transition: var(--transition);
  outline: none;
  direction: rtl;
}

.form-control::placeholder { color: var(--text-muted); }

.form-control:focus {
  border-color: var(--rtf-orange-muted);
  box-shadow: 0 0 0 3px var(--rtf-orange-glow);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239E9189' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 36px;
}

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 5px; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* Input with icon */
.input-wrap { position: relative; }
.input-icon {
  position: absolute;
  right: 12px;
  top: 50%; transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.input-icon svg { width: 17px; height: 17px; }
.input-wrap .form-control { padding-right: 42px; }

/* =============================================
   FILTERS / TOOLBAR
   ============================================= */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar-start, .toolbar-end {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input {
  position: relative;
}

.search-input input {
  width: 260px;
  padding: 9px 14px 9px 40px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-arabic);
  font-size: 14px;
  color: var(--text-primary);
  transition: var(--transition);
  outline: none;
  direction: rtl;
}

.search-input input:focus { border-color: var(--rtf-orange-muted); box-shadow: 0 0 0 3px var(--rtf-orange-glow); }
.search-input input::placeholder { color: var(--text-muted); }

.search-input .search-icon {
  position: absolute;
  left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted);
}
.search-input .search-icon svg { width: 16px; height: 16px; }

/* Filter chips */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-family: var(--font-arabic);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.filter-chip:hover, .filter-chip.active {
  background: var(--rtf-orange-pale);
  border-color: var(--rtf-orange-muted);
  color: var(--rtf-orange);
}

.filter-chip svg { width: 14px; height: 14px; }

/* =============================================
   MODAL / DIALOG
   ============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(42,33,28,0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px) scale(0.98);
  transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
}

.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky; top: 0;
  background: var(--white);
  z-index: 1;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title svg { color: var(--rtf-orange); }

.modal-close {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-subtle);
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.modal-close svg { width: 18px; height: 18px; }

.modal-body { padding: 24px 28px; }

.modal-footer {
  padding: 16px 28px 24px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* =============================================
   FLASH / TOAST MESSAGES
   ============================================= */
.flash-container {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 320px;
}

.flash {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 14px;
  font-weight: 500;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { transform: translateY(-16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.flash-success { background: var(--success-bg); color: var(--success); border: 1px solid #B8E5D2; }
.flash-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #F2C2BE; }
.flash-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #F5DCAA; }

.flash svg { width: 18px; height: 18px; flex-shrink: 0; }

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
  text-align: center;
  padding: 64px 32px;
}

.empty-icon {
  width: 72px; height: 72px;
  background: var(--rtf-orange-pale);
  border-radius: var(--radius-xl);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  color: var(--rtf-orange-muted);
}

.empty-icon svg { width: 36px; height: 36px; }
.empty-title { font-size: 17px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.empty-desc { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }

/* =============================================
   PAGINATION
   ============================================= */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
}

.page-info { font-size: 13px; color: var(--text-muted); }

.page-btns { display: flex; gap: 6px; }

.page-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.page-btn:hover, .page-btn.active {
  background: var(--rtf-orange);
  border-color: var(--rtf-orange);
  color: var(--white);
}

/* =============================================
   CHART SECTION
   ============================================= */
.chart-wrap {
  position: relative;
  height: 260px;
  padding: 8px 0;
}

/* =============================================
   PROGRESS / BUDGET BARS
   ============================================= */
.budget-item {
  margin-bottom: 20px;
}

.budget-item:last-child { margin-bottom: 0; }

.budget-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.budget-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.budget-amounts { font-family: var(--font-latin); font-size: 13px; color: var(--text-muted); }

.budget-bar {
  height: 8px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.budget-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--rtf-orange);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.budget-fill.warning { background: var(--warning); }
.budget-fill.danger  { background: var(--danger); }
.budget-fill.safe    { background: var(--success); }

/* =============================================
   DETAIL / VIEW PAGE
   ============================================= */
.detail-section {
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border-light);
}

.detail-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.detail-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--rtf-orange);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.detail-item { }
.detail-item-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.detail-item-value { font-size: 14px; font-weight: 600; color: var(--text-primary); }

/* =============================================
   SIDEBAR (for reports / filters)
   ============================================= */
.layout-with-sidebar {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}

/* =============================================
   TABS
   ============================================= */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-arabic);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { background: var(--white); color: var(--rtf-orange); font-weight: 700; box-shadow: var(--shadow-xs); }

/* =============================================
   DIVIDER
   ============================================= */
.divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 24px 0;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .layout-with-sidebar { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .topbar { padding: 0 20px; }
  .page-wrapper { padding: 24px 20px 48px; }
  .topbar-nav { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal { margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 80vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }
}

/* =============================================
   RESPONSIVE — MOBILE MENU & IMPROVEMENTS
   ============================================= */

/* Mobile hamburger button */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: var(--transition);
}
.mobile-menu-btn:hover { background: var(--rtf-orange-pale); color: var(--rtf-orange); }
.mobile-menu-btn i { font-size: 22px; }

/* Mobile nav drawer */
.mobile-nav-drawer {
  display: none;
  position: fixed;
  top: 68px; left: 0; right: 0; bottom: 0;
  background: var(--white);
  z-index: 99;
  padding: 16px;
  overflow-y: auto;
  border-top: 1px solid var(--border-light);
  animation: slideInDown 0.2s ease;
}

@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mobile-nav-drawer.open { display: block; }

.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 4px;
}
.mobile-nav-link:hover,
.mobile-nav-link.active {
  background: var(--rtf-orange-pale);
  color: var(--rtf-orange);
}
.mobile-nav-link i { font-size: 18px; width: 24px; text-align: center; }

/* Search bar responsive */
.topbar-search-wrap {
  flex: 1;
  max-width: 320px;
  margin: 0 16px;
}

/* ── Responsive breakpoints ── */

@media (max-width: 1200px) {
  .topbar-search-wrap { max-width: 220px; }
  .nav-link { padding: 8px 10px; font-size: 13px; }
}

@media (max-width: 1024px) {
  .topbar-nav { display: none; }
  .topbar-search-wrap { display: none; }
  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .layout-with-sidebar { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .topbar { padding: 0 16px; height: 60px; }
  .page-wrapper { padding: 20px 16px 48px; }
  .topbar-logo-text { display: none; }
  .user-info { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .page-title { font-size: 22px; }
  .panel-header { padding: 16px 18px; }
  .panel-body { padding: 16px 18px; }
  thead th { padding: 10px 14px; font-size: 11px; }
  tbody td { padding: 12px 14px; font-size: 13px; }
  .page-header-top { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-header-top > div:last-child { width: 100%; }
  .page-header-top .btn { width: 100%; justify-content: center; }
  .mobile-nav-drawer { top: 60px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; gap: 10px; }
  .stat-value { font-size: 24px; }
  .modal { margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 85vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .flash-container { left: 16px; right: 16px; transform: none; min-width: auto; }
  .table-wrap { font-size: 12px; }
  thead th { padding: 8px 10px; }
  tbody td { padding: 10px 10px; }
  .tbl-actions { gap: 4px; }
  .btn-icon { width: 28px; height: 28px; }
}

/* ── Touch improvements ── */
@media (hover: none) {
  .stat-card:hover { transform: none; box-shadow: var(--shadow-xs); }
  .btn-primary:hover { transform: none; }
}

/* ── Print styles ── */
@media print {
  .topbar, .flash-container, .tbl-actions, .pagination, .toolbar { display: none !important; }
  .page-wrapper { padding: 0; }
  .panel { box-shadow: none; border: 1px solid #ddd; }
}

/* =============================================
   ERP SIDEBAR LAYOUT
   ============================================= */

  /* ══ SIDEBAR LAYOUT ══ */
  body { margin:0; display:flex; flex-direction:column; min-height:100vh; background:var(--bg-page); }

  .app-shell { display:flex; min-height:100vh; }

  /* Sidebar */
  .sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--white);
    border-left: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 200;
    transition: transform 0.25s ease;
  }
  .sidebar::-webkit-scrollbar { width:4px; }
  .sidebar::-webkit-scrollbar-thumb { background:var(--border-light); border-radius:4px; }

  .sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px 16px;
    text-decoration: none;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
  }
  .sidebar-logo-text { display:flex; flex-direction:column; line-height:1.2; }
  .sidebar-logo-ar   { font-size:13px; font-weight:700; color:var(--text-primary); }
  .sidebar-logo-en   { font-family:var(--font-latin); font-size:10px; font-weight:500;
                       color:var(--rtf-orange); letter-spacing:.06em; text-transform:uppercase; }

  .sidebar-nav { flex:1; padding:10px 0; overflow-y:auto; }

  .sidebar-section { padding:14px 16px 4px; font-size:10px; font-weight:700;
                     color:var(--text-muted); text-transform:uppercase; letter-spacing:.08em; }

  .sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    border-radius: 0;
    position: relative;
  }
  .sidebar-link i { font-size:16px; width:20px; text-align:center; flex-shrink:0; }
  .sidebar-link:hover { background:var(--rtf-orange-pale); color:var(--rtf-orange); }
  .sidebar-link.active {
    background: var(--rtf-orange-pale);
    color: var(--rtf-orange);
    font-weight: 600;
    border-right: 3px solid var(--rtf-orange);
  }
  .sidebar-link .badge-count {
    margin-right: auto;
    background: var(--danger);
    color: #fff;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    min-width: 18px;
    text-align: center;
  }

  .sidebar-footer {
    border-top: 1px solid var(--border-light);
    padding: 12px 0;
    flex-shrink: 0;
  }

  /* Main content */
  .main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: hidden;
  }

  /* Topbar — slim, no nav links */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--white);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-xs);
    height: 58px;
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
  }
  .topbar-search { flex:1; max-width:340px; }
  .topbar-search input {
    width:100%; padding:7px 34px 7px 12px;
    border:1px solid var(--border-light); border-radius:var(--radius-md);
    font-size:13px; background:var(--bg-subtle); font-family:var(--font-arabic);
    color:var(--text-primary); outline:none;
  }
  .topbar-search input:focus { border-color:var(--rtf-orange); }

  /* Mobile overlay */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 199;
  }

  .page-wrapper { padding: 28px 32px 60px; }

  /* ── Responsive ── */
  @media (max-width: 900px) {
    .sidebar {
      position: fixed;
      top: 0; right: 0; height: 100vh;
      transform: translateX(100%);
      box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .page-wrapper { padding: 20px 16px 48px; }
    .topbar { padding: 0 16px; }
  }
  @media (max-width: 600px) {
    .topbar-search { display:none; }
  }
  

/* ── ERP additions ── */
.sidebar-badge {
  margin-right: auto;
  background: var(--danger);
  color: #fff;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
}

.page-wrapper {
  padding: 28px 32px 60px;
  max-width: 1400px;
  width: 100%;
  box-sizing: border-box;
}

/* ── ERP Status badges ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}
.status-dot { width:6px; height:6px; border-radius:50%; }
.status-open    { background:var(--warning-bg); color:var(--warning); }
.status-open    .status-dot { background:var(--warning); }
.status-paid    { background:var(--success-bg); color:var(--success); }
.status-paid    .status-dot { background:var(--success); }
.status-draft   { background:var(--bg-subtle); color:var(--text-muted); }
.status-draft   .status-dot { background:var(--text-muted); }
.status-partial { background:#FEF0E7; color:#D4820A; }
.status-partial .status-dot { background:#D4820A; }
.status-cancelled { background:var(--danger-bg); color:var(--danger); }
.status-cancelled .status-dot { background:var(--danger); }
.status-returned  { background:#F3E8FF; color:#7C3AED; }
.status-returned  .status-dot { background:#7C3AED; }

/* ── Summary cards (ERP KPI row) ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-card.primary { background:var(--rtf-orange); border-color:var(--rtf-orange); }
.kpi-card.primary .kpi-label,
.kpi-card.primary .kpi-sub { color:rgba(255,255,255,0.75); }
.kpi-card.primary .kpi-value { color:#fff; }
.kpi-label  { font-size:12px; color:var(--text-muted); font-weight:500; }
.kpi-value  { font-size:26px; font-weight:700; font-family:var(--font-latin);
              color:var(--text-primary); letter-spacing:-0.02em; line-height:1; }
.kpi-value .currency { font-size:13px; font-weight:500; color:var(--text-muted); margin-left:3px; }
.kpi-sub    { font-size:12px; color:var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .page-wrapper { padding: 20px 16px 48px; }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .topbar, .flash-container { display:none !important; }
  .main-area { width:100%; }
  .page-wrapper { padding:0; }
}
