/* ==========================================================================
   بلاد الزيتون — Olive Country · Design System v1.0
   Mobile-first · Native-feel · RTL
   ========================================================================== */

/* ---------- Fonts (self-hosted) ---------- */
@font-face{font-family:'PlexArabic';font-style:normal;font-weight:400;font-display:swap;src:url('/fonts/plex-arabic-400.woff2') format('woff2');unicode-range:U+0600-06FF,U+0750-077F,U+0870-088E,U+0890-0891,U+0898-08E1,U+08E3-08FF,U+200C-200E,U+2010-2011,U+204F,U+2E41,U+FB50-FDFF,U+FE70-FE74,U+FE76-FEFC,U+102E0-102FB,U+10E60-10E7E,U+10EC2-10EC4,U+10EFC-10EFF,U+1EE00-1EE03,U+1EE05-1EE1F,U+1EE21-1EE22,U+1EE24,U+1EE27,U+1EE29-1EE32,U+1EE34-1EE37,U+1EE39,U+1EE3B,U+1EE42,U+1EE47,U+1EE49,U+1EE4B,U+1EE4D-1EE4F,U+1EE51-1EE52,U+1EE54,U+1EE57,U+1EE59,U+1EE5B,U+1EE5D,U+1EE5F,U+1EE61-1EE62,U+1EE64,U+1EE67-1EE6A,U+1EE6C-1EE72,U+1EE74-1EE77,U+1EE79-1EE7C,U+1EE7E,U+1EE80-1EE89,U+1EE8B-1EE9B,U+1EEA1-1EEA3,U+1EEA5-1EEA9,U+1EEAB-1EEBB,U+1EEF0-1EEF1}
@font-face{font-family:'PlexArabic';font-style:normal;font-weight:500;font-display:swap;src:url('/fonts/plex-arabic-500.woff2') format('woff2');unicode-range:U+0600-06FF,U+0750-077F,U+0870-088E,U+0890-0891,U+0898-08E1,U+08E3-08FF,U+200C-200E,U+2010-2011,U+204F,U+2E41,U+FB50-FDFF,U+FE70-FE74,U+FE76-FEFC,U+102E0-102FB,U+10E60-10E7E,U+10EC2-10EC4,U+10EFC-10EFF,U+1EE00-1EE03,U+1EE05-1EE1F,U+1EE21-1EE22,U+1EE24,U+1EE27,U+1EE29-1EE32,U+1EE34-1EE37,U+1EE39,U+1EE3B,U+1EE42,U+1EE47,U+1EE49,U+1EE4B,U+1EE4D-1EE4F,U+1EE51-1EE52,U+1EE54,U+1EE57,U+1EE59,U+1EE5B,U+1EE5D,U+1EE5F,U+1EE61-1EE62,U+1EE64,U+1EE67-1EE6A,U+1EE6C-1EE72,U+1EE74-1EE77,U+1EE79-1EE7C,U+1EE7E,U+1EE80-1EE89,U+1EE8B-1EE9B,U+1EEA1-1EEA3,U+1EEA5-1EEA9,U+1EEAB-1EEBB,U+1EEF0-1EEF1}
@font-face{font-family:'PlexArabic';font-style:normal;font-weight:600;font-display:swap;src:url('/fonts/plex-arabic-600.woff2') format('woff2');unicode-range:U+0600-06FF,U+0750-077F,U+0870-088E,U+0890-0891,U+0898-08E1,U+08E3-08FF,U+200C-200E,U+2010-2011,U+204F,U+2E41,U+FB50-FDFF,U+FE70-FE74,U+FE76-FEFC,U+102E0-102FB,U+10E60-10E7E,U+10EC2-10EC4,U+10EFC-10EFF,U+1EE00-1EE03,U+1EE05-1EE1F,U+1EE21-1EE22,U+1EE24,U+1EE27,U+1EE29-1EE32,U+1EE34-1EE37,U+1EE39,U+1EE3B,U+1EE42,U+1EE47,U+1EE49,U+1EE4B,U+1EE4D-1EE4F,U+1EE51-1EE52,U+1EE54,U+1EE57,U+1EE59,U+1EE5B,U+1EE5D,U+1EE5F,U+1EE61-1EE62,U+1EE64,U+1EE67-1EE6A,U+1EE6C-1EE72,U+1EE74-1EE77,U+1EE79-1EE7C,U+1EE7E,U+1EE80-1EE89,U+1EE8B-1EE9B,U+1EEA1-1EEA3,U+1EEA5-1EEA9,U+1EEAB-1EEBB,U+1EEF0-1EEF1}
@font-face{font-family:'PlexArabic';font-style:normal;font-weight:700;font-display:swap;src:url('/fonts/plex-arabic-700.woff2') format('woff2');unicode-range:U+0600-06FF,U+0750-077F,U+0870-088E,U+0890-0891,U+0898-08E1,U+08E3-08FF,U+200C-200E,U+2010-2011,U+204F,U+2E41,U+FB50-FDFF,U+FE70-FE74,U+FE76-FEFC,U+102E0-102FB,U+10E60-10E7E,U+10EC2-10EC4,U+10EFC-10EFF,U+1EE00-1EE03,U+1EE05-1EE1F,U+1EE21-1EE22,U+1EE24,U+1EE27,U+1EE29-1EE32,U+1EE34-1EE37,U+1EE39,U+1EE3B,U+1EE42,U+1EE47,U+1EE49,U+1EE4B,U+1EE4D-1EE4F,U+1EE51-1EE52,U+1EE54,U+1EE57,U+1EE59,U+1EE5B,U+1EE5D,U+1EE5F,U+1EE61-1EE62,U+1EE64,U+1EE67-1EE6A,U+1EE6C-1EE72,U+1EE74-1EE77,U+1EE79-1EE7C,U+1EE7E,U+1EE80-1EE89,U+1EE8B-1EE9B,U+1EEA1-1EEA3,U+1EEA5-1EEA9,U+1EEAB-1EEBB,U+1EEF0-1EEF1}
@font-face{font-family:'PlexArabic';font-style:normal;font-weight:400;font-display:swap;src:url('/fonts/plex-latin-400.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:'PlexArabic';font-style:normal;font-weight:500;font-display:swap;src:url('/fonts/plex-latin-500.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:'PlexArabic';font-style:normal;font-weight:600;font-display:swap;src:url('/fonts/plex-latin-600.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:'PlexArabic';font-style:normal;font-weight:700;font-display:swap;src:url('/fonts/plex-latin-700.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}

/* ---------- Tokens ---------- */
:root{
  /* brand */
  --brand-900:#22301C; --brand-800:#2B4422; --brand-700:#35522A; --brand-600:#3F6132;
  --olive-600:#6C7D23; --olive-500:#788B27; --olive-400:#8FA03F; --olive-100:#EFF3E3;
  /* neutrals */
  --cream-50:#FBFBF6; --cream-100:#F7F7F1; --cream-200:#F1F2E8;
  --ink-900:#1C2A18; --ink-700:#33412C; --ink-500:#5E6E55; --ink-400:#7C8C73; --ink-300:#9DAA95;
  --line:#E4E7D8; --line-soft:#EFF1E7; --white:#fff;
  /* semantic */
  --ok:#2E7D32; --ok-bg:#EAF4E9;
  --warn:#A2601A; --warn-bg:#FDF0E4;
  --danger:#A32A20; --danger-bg:#FBEAE8;
  --info:#2A5A7D; --info-bg:#E7F0F6;
  /* radii */
  --r-xs:8px; --r-sm:12px; --r-md:16px; --r-lg:20px; --r-xl:28px; --r-full:999px;
  /* spacing (4pt) */
  --s-1:4px; --s-2:8px; --s-3:12px; --s-4:16px; --s-5:20px; --s-6:24px; --s-7:32px; --s-8:40px; --s-9:56px;
  /* elevation — green-tinted */
  --e-1:0 1px 2px rgba(34,48,28,.06), 0 1px 3px rgba(34,48,28,.04);
  --e-2:0 4px 14px rgba(34,48,28,.07), 0 1px 3px rgba(34,48,28,.05);
  --e-3:0 12px 34px rgba(34,48,28,.12), 0 2px 6px rgba(34,48,28,.06);
  /* motion */
  --ease:cubic-bezier(.22,1,.36,1); --t-fast:150ms; --t-mid:220ms; --t-slow:320ms;
  /* layout */
  --header-h:56px; --tabbar-h:64px; --sidebar-w:248px;
  --safe-b:env(safe-area-inset-bottom,0px); --safe-t:env(safe-area-inset-top,0px);
}

/* ---------- Reset ---------- */
*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
body{
  margin:0;background:var(--cream-100);color:var(--ink-900);
  font-family:'PlexArabic',system-ui,-apple-system,'Segoe UI',Tahoma,sans-serif;
  font-size:15px;line-height:1.65;font-weight:400;
  -webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;
  overscroll-behavior-y:contain;
}
a{color:inherit;text-decoration:none;-webkit-tap-highlight-color:transparent}
button,input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}
button{-webkit-tap-highlight-color:transparent;touch-action:manipulation}
h1,h2,h3,h4,p{margin:0}
img,svg{display:block;max-width:100%}
::selection{background:var(--olive-100)}

/* ---------- Typography scale ---------- */
.t-display{font-size:clamp(26px,6vw,34px);font-weight:700;line-height:1.25;letter-spacing:-.02em;color:var(--brand-800)}
.t-h1{font-size:clamp(21px,4.6vw,26px);font-weight:700;line-height:1.3;letter-spacing:-.01em;color:var(--brand-800)}
.t-h2{font-size:18px;font-weight:600;line-height:1.35;color:var(--brand-800)}
.t-h3{font-size:15.5px;font-weight:600;line-height:1.4;color:var(--ink-900)}
.t-body{font-size:14.5px;font-weight:400;color:var(--ink-700)}
.t-sm{font-size:13px;color:var(--ink-500)}
.t-xs{font-size:11.5px;color:var(--ink-400)}
.t-num{font-variant-numeric:tabular-nums;font-feature-settings:"tnum" 1;letter-spacing:-.01em}
.t-ltr{direction:ltr;unicode-bidi:isolate}

/* ---------- App shell ---------- */
.app{min-height:100dvh;display:flex;flex-direction:column;background:var(--cream-100)}
.main{flex:1;min-width:0;display:flex;flex-direction:column}

.topbar{
  position:sticky;top:0;z-index:40;height:calc(var(--header-h) + var(--safe-t));
  padding:var(--safe-t) var(--s-4) 0;display:flex;align-items:center;gap:var(--s-3);
  background:rgba(251,251,246,.86);backdrop-filter:saturate(180%) blur(14px);
  -webkit-backdrop-filter:saturate(180%) blur(14px);
  border-bottom:1px solid var(--line-soft);
}
.topbar .brand{display:flex;align-items:center;gap:10px;min-width:0}
.topbar .brand svg{width:30px;height:30px;flex:none}
.topbar .brand b{font-size:15px;font-weight:600;color:var(--brand-800);display:block;line-height:1.1}
.topbar .brand small{font-size:7.5px;letter-spacing:.28em;color:var(--olive-500)}
.topbar .spacer{flex:1}
.icon-btn{
  width:40px;height:40px;border-radius:var(--r-full);border:1px solid var(--line);
  background:var(--white);display:grid;place-items:center;cursor:pointer;color:var(--brand-700);
  transition:transform var(--t-fast) var(--ease),background var(--t-fast);
}
.icon-btn:active{transform:scale(.94);background:var(--cream-200)}

.page{flex:1;padding:var(--s-4) var(--s-4) calc(var(--tabbar-h) + var(--safe-b) + var(--s-6));max-width:880px;width:100%;margin:0 auto}

/* bottom tab bar (mobile) */
.tabbar{
  position:fixed;inset-inline:0;bottom:0;z-index:50;
  height:calc(var(--tabbar-h) + var(--safe-b));padding-bottom:var(--safe-b);
  display:grid;grid-template-columns:repeat(4,1fr);
  background:rgba(255,255,255,.92);backdrop-filter:saturate(180%) blur(18px);
  -webkit-backdrop-filter:saturate(180%) blur(18px);
  border-top:1px solid var(--line-soft);
}
.tabbar a{
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;
  font-size:10.5px;color:var(--ink-400);position:relative;
  transition:color var(--t-fast);
}
.tabbar a svg{width:22px;height:22px;stroke-width:1.8}
.tabbar a.on{color:var(--brand-700);font-weight:600}
.tabbar a.on::before{content:"";position:absolute;top:0;width:26px;height:3px;border-radius:0 0 3px 3px;background:var(--olive-500)}
.tabbar a:active{transform:scale(.95)}

/* desktop sidebar */
.sidebar{display:none}
@media (min-width:960px){
  .app{flex-direction:row}
  .sidebar{
    display:flex;flex-direction:column;gap:2px;width:var(--sidebar-w);flex:none;
    background:var(--white);border-inline-start:1px solid var(--line);
    padding:var(--s-5) var(--s-4);position:sticky;top:0;height:100dvh;
  }
  .sidebar .brand{display:flex;align-items:center;gap:11px;padding:0 6px var(--s-5);border-bottom:1px solid var(--line-soft);margin-bottom:var(--s-3)}
  .sidebar .brand svg{width:38px;height:38px}
  .sidebar .brand b{font-size:17px;color:var(--brand-800);display:block;line-height:1.1}
  .sidebar .brand small{font-size:8px;letter-spacing:.3em;color:var(--olive-500)}
  .sidebar nav{display:flex;flex-direction:column;gap:2px}
  .sidebar nav a{display:flex;align-items:center;gap:11px;padding:10px 12px;border-radius:var(--r-sm);color:var(--ink-500);font-size:13.5px;transition:background var(--t-fast),color var(--t-fast)}
  .sidebar nav a svg{width:19px;height:19px;stroke-width:1.8;flex:none}
  .sidebar nav a:hover{background:var(--cream-200);color:var(--brand-700)}
  .sidebar nav a.on{background:var(--olive-100);color:var(--brand-700);font-weight:600}
  .sidebar .side-foot{margin-top:auto;padding-top:var(--s-4);border-top:1px solid var(--line-soft)}
  .topbar{display:none}
  .tabbar{display:none}
  .page{padding:var(--s-7) var(--s-8) var(--s-8);max-width:1000px}
}

/* ---------- Cards & KPI ---------- */
.card{background:var(--white);border:1px solid var(--line);border-radius:var(--r-md);padding:var(--s-4);box-shadow:var(--e-1)}
.card.pad-0{padding:0;overflow:hidden}

.kpi-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:var(--s-3);margin-bottom:var(--s-5)}
@media (min-width:600px){.kpi-grid{grid-template-columns:repeat(3,1fr)}}
@media (min-width:960px){.kpi-grid{grid-template-columns:repeat(4,1fr)}}
.kpi{background:var(--white);border:1px solid var(--line);border-radius:var(--r-md);padding:var(--s-3) var(--s-4);box-shadow:var(--e-1);position:relative;overflow:hidden}
.kpi .k{font-size:11.5px;color:var(--ink-400);margin-bottom:2px}
.kpi .v{font-size:26px;font-weight:700;color:var(--brand-800);line-height:1.15;font-variant-numeric:tabular-nums}
.kpi .n{font-size:10.5px;color:var(--ink-300);margin-top:2px}
.kpi.accent{background:linear-gradient(150deg,var(--brand-700),var(--brand-600));border-color:transparent;color:#fff}
.kpi.accent .k,.kpi.accent .n{color:rgba(255,255,255,.72)}
.kpi.accent .v{color:#fff}

/* ---------- List rows ---------- */
.list{background:var(--white);border:1px solid var(--line);border-radius:var(--r-md);overflow:hidden;box-shadow:var(--e-1)}
.row{display:flex;align-items:center;gap:var(--s-3);padding:13px var(--s-4);border-bottom:1px solid var(--line-soft);transition:background var(--t-fast)}
.row:last-child{border-bottom:0}
.row:active{background:var(--cream-100)}
.row .lead{width:38px;height:38px;border-radius:var(--r-sm);background:var(--olive-100);color:var(--brand-700);display:grid;place-items:center;font-weight:600;font-size:12px;flex:none}
.row .body{flex:1;min-width:0}
.row .title{font-size:14px;font-weight:600;color:var(--ink-900);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.row .meta{font-size:11.5px;color:var(--ink-400);margin-top:1px}
.row .tail{font-size:13px;font-weight:600;color:var(--brand-700);font-variant-numeric:tabular-nums}
.row .chev{color:var(--ink-300);flex:none}

/* ---------- Pills / badges ---------- */
.pill{display:inline-flex;align-items:center;gap:5px;padding:3px 10px;border-radius:var(--r-full);font-size:11px;font-weight:500;background:var(--olive-100);color:var(--brand-700)}
.pill.ok{background:var(--ok-bg);color:var(--ok)}
.pill.warn{background:var(--warn-bg);color:var(--warn)}
.pill.danger{background:var(--danger-bg);color:var(--danger)}
.pill.info{background:var(--info-bg);color:var(--info)}
.pill.ghost{background:transparent;border:1px solid var(--line);color:var(--ink-500)}

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  min-height:44px;padding:0 var(--s-5);border-radius:var(--r-sm);
  border:1px solid var(--line);background:var(--white);color:var(--ink-700);
  font-size:14px;font-weight:500;cursor:pointer;
  transition:transform var(--t-fast) var(--ease),background var(--t-fast),border-color var(--t-fast);
}
.btn:active{transform:scale(.975)}
.btn-primary{background:var(--brand-700);border-color:var(--brand-700);color:#fff;font-weight:600}
.btn-primary:active{background:var(--brand-800)}
.btn-ghost{background:transparent;border-color:transparent;color:var(--brand-700)}
.btn-block{width:100%}
.btn-sm{min-height:36px;padding:0 var(--s-4);font-size:12.5px;border-radius:var(--r-xs)}

/* ---------- Forms ---------- */
.field{display:block;margin-bottom:var(--s-4)}
.field > span{display:block;font-size:12px;color:var(--ink-500);margin-bottom:6px;font-weight:500}
.input,.select{
  width:100%;min-height:46px;padding:11px 14px;font-size:16px; /* 16px prevents iOS zoom */
  border:1px solid var(--line);border-radius:var(--r-sm);background:var(--cream-50);
  transition:border-color var(--t-fast),background var(--t-fast),box-shadow var(--t-fast);
}
.input:focus,.select:focus{outline:none;border-color:var(--olive-500);background:var(--white);box-shadow:0 0 0 3px rgba(120,139,39,.12)}
.searchbar{position:relative;margin-bottom:var(--s-4)}
.searchbar svg{position:absolute;inset-inline-start:14px;top:50%;transform:translateY(-50%);width:18px;height:18px;color:var(--ink-300)}
.searchbar .input{padding-inline-start:42px}

/* ---------- Segmented control ---------- */
.segmented{display:flex;gap:4px;padding:4px;background:var(--cream-200);border-radius:var(--r-sm);margin-bottom:var(--s-4);overflow-x:auto;scrollbar-width:none}
.segmented::-webkit-scrollbar{display:none}
.segmented button{flex:1;white-space:nowrap;border:0;background:transparent;padding:8px 14px;border-radius:9px;font-size:12.5px;color:var(--ink-500);cursor:pointer;transition:background var(--t-fast),color var(--t-fast)}
.segmented button.on{background:var(--white);color:var(--brand-700);font-weight:600;box-shadow:var(--e-1)}

/* ---------- Table (scrollable) ---------- */
.table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;border:1px solid var(--line);border-radius:var(--r-md);background:var(--white);box-shadow:var(--e-1)}
table{width:100%;border-collapse:collapse;min-width:560px}
th{text-align:right;font-size:11px;color:var(--ink-400);font-weight:500;padding:11px 14px;background:var(--cream-50);border-bottom:1px solid var(--line);white-space:nowrap}
td{padding:12px 14px;border-bottom:1px solid var(--line-soft);font-size:13px;white-space:nowrap}
tr:last-child td{border-bottom:0}

/* ---------- Empty / skeleton ---------- */
.empty{background:var(--white);border:1px dashed #D8DEC8;border-radius:var(--r-md);padding:var(--s-7) var(--s-5);text-align:center;color:var(--ink-400);font-size:13px}
.empty svg{width:34px;height:34px;margin:0 auto var(--s-3);color:var(--olive-400);stroke-width:1.5}
.skeleton{background:linear-gradient(90deg,var(--cream-200) 25%,#F7F8F0 50%,var(--cream-200) 75%);background-size:200% 100%;animation:sh 1.4s infinite;border-radius:var(--r-xs)}
@keyframes sh{0%{background-position:200% 0}100%{background-position:-200% 0}}

/* ---------- Section header ---------- */
.section-head{display:flex;align-items:baseline;justify-content:space-between;gap:var(--s-3);margin:var(--s-5) 0 var(--s-3)}
.section-head:first-child{margin-top:0}
.section-head .link{font-size:12.5px;color:var(--olive-600);font-weight:500}

/* ---------- Page header ---------- */
.page-head{margin-bottom:var(--s-5)}
.page-head .sub{font-size:12.5px;color:var(--ink-400);margin-top:2px}

/* ---------- Charts (CSS bars) ---------- */
.bars{display:flex;flex-direction:column;gap:10px}
.bar{display:grid;grid-template-columns:76px 1fr 44px;align-items:center;gap:10px;font-size:12px}
.bar .track{height:8px;border-radius:var(--r-full);background:var(--cream-200);overflow:hidden}
.bar .fill{height:100%;border-radius:var(--r-full);background:linear-gradient(90deg,var(--olive-500),var(--brand-700))}
.bar .val{text-align:left;font-weight:600;color:var(--brand-700);font-variant-numeric:tabular-nums}

/* ---------- Misc ---------- */
.stack{display:flex;flex-direction:column;gap:var(--s-3)}
.row-flex{display:flex;align-items:center;gap:var(--s-3)}
.muted{color:var(--ink-400)}
.nowrap{white-space:nowrap}
.fab{position:fixed;inset-inline-end:var(--s-4);bottom:calc(var(--tabbar-h) + var(--safe-b) + var(--s-4));width:54px;height:54px;border-radius:var(--r-full);background:var(--brand-700);color:#fff;display:grid;place-items:center;box-shadow:var(--e-3);border:0;cursor:pointer;transition:transform var(--t-fast) var(--ease);z-index:45}
.fab:active{transform:scale(.93)}
@media (min-width:960px){.fab{bottom:var(--s-6)}}
.notice{display:flex;gap:10px;align-items:flex-start;padding:12px 14px;border-radius:var(--r-sm);font-size:12.5px;line-height:1.6}
.notice.info{background:var(--info-bg);color:var(--info)}
.notice.warn{background:var(--warn-bg);color:var(--warn)}
.notice.danger{background:var(--danger-bg);color:var(--danger)}

@media (prefers-reduced-motion:reduce){*{animation-duration:.01ms!important;transition-duration:.01ms!important}}
