:root {
  --primary: #0b6b4b;
  --primary-dark: #074d38;
  --primary-50: #eef8f4;
  --primary-100: #cae7dd;
  --secondary: #0c8db3;
  --secondary-50: #edf8fb;
  --accent: #c5a44d;
  --accent-50: #fbf7ea;
  --app-bg: #f5f7f6;
  --surface: #ffffff;
  --text: #122a24;
  --muted: #687871;
  --border: #dfe7e3;
  --border-soft: #edf1ef;
  --rag-green: #16845b;
  --rag-amber: #d79a24;
  --rag-red: #c84a4a;
  --rag-gray: #98a39f;
  --sidebar-width: 278px;
  --topbar-height: 72px;
  --radius-sm: 9px;
  --radius-md: 13px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 3px rgba(16, 42, 34, .04), 0 8px 22px rgba(16, 42, 34, .035);
  --shadow-md: 0 16px 40px rgba(16, 42, 34, .08);
  --shadow-lg: 0 22px 58px rgba(16, 42, 34, .16);
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);
  --dir-factor: -1;
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  color: var(--text);
  background: var(--app-bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

html[dir="ltr"] { --dir-factor: 1; font-family: Manrope, "IBM Plex Sans Arabic", sans-serif; }
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--app-bg); scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--app-bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; }
::selection { background: var(--primary-100); color: var(--primary-dark); }
:focus-visible { outline: 3px solid rgba(12, 141, 179, .25); outline-offset: 2px; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 26px; }
.page-header h1 { margin: 0; font-size: clamp(24px, 2.1vw, 34px); line-height: 1.28; letter-spacing: -.025em; color: var(--primary-dark); }
.page-header p { margin: 7px 0 0; max-width: 760px; color: var(--muted); font-size: 13.5px; line-height: 1.85; }
.page-eyebrow { color: var(--secondary); font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.page-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.surface-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.section-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow-sm); }
.section-card + .section-card { margin-top: 18px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-heading h2, .section-heading h3 { margin: 0; color: var(--text); font-size: 16px; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11.5px; }
.section-link { display: inline-flex; align-items: center; gap: 6px; color: var(--primary); font-size: 11.5px; font-weight: 700; }
.section-link svg { width: 15px; }

.btn { border: 0; min-height: 40px; border-radius: 10px; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 700; font-size: 12px; transition: transform .14s var(--ease-out), box-shadow .18s var(--ease-out), background .18s var(--ease-out), border-color .18s var(--ease-out); }
.btn:active { transform: scale(.97); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { color: #fff; background: linear-gradient(145deg, var(--primary), var(--primary-dark)); box-shadow: 0 8px 18px rgba(11, 107, 75, .18); }
.btn-primary:hover { box-shadow: 0 12px 24px rgba(11, 107, 75, .24); }
.btn-secondary { color: var(--primary-dark); background: var(--primary-50); border: 1px solid var(--primary-100); }
.btn-outline { color: #465850; background: #fff; border: 1px solid var(--border); }
.btn-ghost { color: var(--muted); background: transparent; }
.btn-danger { color: var(--rag-red); background: #fdf0f0; border: 1px solid #f5d0d0; }
.btn:disabled { opacity: .5; pointer-events: none; }

.status-chip { width: max-content; display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 9px; border-radius: 999px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-green { color: var(--rag-green); background: #eaf7f1; }
.status-amber { color: #9a6811; background: #fff6df; }
.status-red { color: var(--rag-red); background: #fdeeee; }
.status-gray { color: #74807c; background: #f0f3f2; }

.progress-ring { --progress: 0; position: relative; flex: none; border-radius: 50%; background: conic-gradient(var(--ring-color) calc(var(--progress) * 1%), #edf1ef 0); display: grid; place-items: center; }
.progress-ring::after { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 1px rgba(16, 42, 34, .02); }
.progress-ring-inner { position: relative; z-index: 1; display: flex; align-items: baseline; justify-content: center; color: var(--text); direction: ltr; }
.progress-ring-inner strong { font: 700 clamp(20px, 2vw, 27px) Manrope, sans-serif; letter-spacing: -.06em; }
.progress-ring-inner small { font: 700 10px Manrope, sans-serif; margin-left: 2px; color: var(--muted); }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.metric-card { min-height: 126px; padding: 17px 18px; border-radius: 15px; background: #fff; border: 1px solid var(--border-soft); box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.metric-card::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px; background: var(--metric-color, var(--primary)); }
.metric-label { color: var(--muted); font-size: 11.5px; display: flex; align-items: center; gap: 8px; }
.metric-label svg { width: 16px; color: var(--metric-color, var(--primary)); }
.metric-value { margin-top: 13px; display: flex; align-items: baseline; gap: 7px; direction: ltr; justify-content: flex-end; }
[dir="ltr"] .metric-value { justify-content: flex-start; }
.metric-value strong { font: 700 30px Manrope, sans-serif; letter-spacing: -.045em; color: var(--text); }
.metric-value span { color: var(--muted); font-size: 10px; direction: rtl; }
.metric-footnote { margin-top: 4px; color: var(--muted); font-size: 9.5px; line-height: 1.6; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 17px; }
.toolbar-search { min-width: 270px; flex: 1; max-width: 480px; position: relative; }
.toolbar-search svg { position: absolute; inset-inline-start: 12px; inset-block-start: 50%; transform: translateY(-50%); width: 17px; color: var(--muted); }
.input, .select, .textarea { width: 100%; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: #fff; outline: 0; transition: border-color .18s, box-shadow .18s; }
.input, .select { height: 41px; padding: 0 12px; font-size: 12px; }
.toolbar-search .input { padding-inline-start: 39px; }
.textarea { min-height: 104px; padding: 11px 12px; resize: vertical; line-height: 1.7; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(12, 141, 179, .1); }
.control-label { display: grid; gap: 6px; color: #50615b; font-size: 11px; font-weight: 600; }

.data-table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: 13px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 760px; background: #fff; }
.data-table th { padding: 12px 15px; text-align: start; background: #f8faf9; color: #697872; font-size: 10.5px; font-weight: 700; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 14px 15px; text-align: start; font-size: 11.5px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .16s var(--ease-out); }
.data-table tbody tr:hover { background: #fbfcfc; }
.data-table .code { font: 700 10.5px Manrope, sans-serif; color: var(--secondary); direction: ltr; white-space: nowrap; }

.inline-progress { min-width: 110px; display: flex; align-items: center; gap: 8px; direction: ltr; }
.inline-progress-track { flex: 1; height: 5px; border-radius: 99px; background: #edf1ef; overflow: hidden; }
.inline-progress-fill { height: 100%; border-radius: inherit; background: var(--primary); }
.inline-progress strong { width: 32px; font: 700 10px Manrope, sans-serif; text-align: right; }

.empty-state { min-height: 240px; display: grid; place-items: center; text-align: center; padding: 34px; }
.empty-state svg { width: 44px; height: 44px; color: var(--rag-gray); margin-bottom: 12px; }
.empty-state h3 { margin: 0; font-size: 15px; }.empty-state p { margin: 6px auto 0; color: var(--muted); font-size: 11.5px; max-width: 420px; line-height: 1.8; }
.loading-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.skeleton { min-height: 138px; border-radius: 15px; background: linear-gradient(90deg, #eef2f0 25%, #f8faf9 38%, #eef2f0 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -100% 0; } }

.modal-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(9, 29, 23, .38); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .18s var(--ease-out); }
.drawer { position: fixed; inset-block: 0; inset-inline-end: 0; z-index: 95; width: min(520px, 94vw); background: #fff; box-shadow: var(--shadow-lg); transform: translateX(calc(var(--dir-factor) * 102%)); transition: transform .25s var(--ease-out); display: flex; flex-direction: column; }
.drawer:not(.drawer-open) { visibility: hidden !important; pointer-events: none !important; }
.drawer.drawer-open { visibility: visible; pointer-events: auto; }
.modal-open .modal-backdrop { opacity: 1; pointer-events: auto; }.modal-open .drawer { transform: translateX(0); }
.drawer-header { padding: 21px 23px; display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--border-soft); }
.drawer-header h2 { margin: 0; font-size: 18px; }.drawer-header p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.drawer-body { padding: 22px 23px; overflow: auto; display: grid; gap: 15px; }
.drawer-footer { margin-top: auto; padding: 15px 23px; border-top: 1px solid var(--border-soft); display: flex; justify-content: flex-end; gap: 8px; }

.breadcrumb { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10.5px; margin-bottom: 14px; }
.breadcrumb a { color: var(--primary); }.breadcrumb svg { width: 13px; }
.eyebrow-code { width: max-content; padding: 4px 8px; border-radius: 6px; background: var(--secondary-50); color: var(--secondary); font: 700 10px Manrope, sans-serif; direction: ltr; }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.info-chip { padding: 5px 9px; border-radius: 7px; background: #f3f6f5; color: #53645e; font-size: 10px; }

@media (max-width: 1320px) { .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 860px) { .page-header { flex-direction: column; }.page-actions { width: 100%; }.metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }.loading-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .metric-grid, .loading-grid { grid-template-columns: 1fr; }.section-card { padding: 17px; }.btn { flex: 1; } }

@media print {
  :root { --app-bg: #fff; }
  .sidebar, .topbar, .page-actions, .toolbar, .no-print { display: none !important; }
  .workspace { margin: 0 !important; }.main-content { padding: 0 !important; max-width: none !important; }
  .surface-card, .section-card, .metric-card { box-shadow: none !important; break-inside: avoid; }
}

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