@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700;900&family=Amiri:wght@400;700&display=swap');

:root {
  --bg: #f0f5fb;
  --surface: #ffffff;
  --surface2: #e8f0fa;
  --surface3: #dce8f5;
  --border: #ccdaed;
  --a1: #1565c0;
  --a2: #00897b;
  --a3: #f9a825;
  --a4: #e53935;
  --a5: #7b1fa2;
  --gold: #c69214;
  --text: #18324a;
  --muted: #607d8b;
  --r: 12px;
  --sh: 0 2px 10px rgba(21,101,192,.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--surface2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── TOPBAR ─────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 2px solid var(--a1);
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(21,101,192,.1);
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-ico {
  width: 34px; height: 34px;
  background: var(--a1);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; flex-shrink: 0;
}

.brand-title {
  font-family: 'Amiri', serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--a1);
  line-height: 1.2;
}

.brand-sub { font-size: 10px; color: var(--muted); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  cursor: pointer;
  font-family: 'Cairo', sans-serif;
  font-size: 12px;
  color: var(--text);
  position: relative;
}

.user-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--a1);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 200;
}

.user-dropdown.open { display: block; }

.dd-item {
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: .15s;
}

.dd-item:hover { background: var(--surface2); }
.dd-item.danger { color: var(--a4); }
.dd-item.danger:hover { background: rgba(229,57,53,.08); }

/* ── YEAR BAR ────────────────────────────── */
.yearbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 7px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  position: sticky;
  top: 54px;
  z-index: 99;
}

.ylbl { font-size: 11px; color: var(--muted); white-space: nowrap; }

.ybtn {
  padding: 4px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: 'Cairo', sans-serif;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: .15s;
  flex-shrink: 0;
}

.ybtn.on {
  background: var(--a1);
  border-color: var(--a1);
  color: #fff;
  font-weight: 700;
}

/* ── LAYOUT ──────────────────────────────── */
.layout {
  display: flex;
  min-height: calc(100vh - 88px);
}

/* ── SIDEBAR ─────────────────────────────── */
.sidebar {
  width: 210px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 88px;
  height: calc(100vh - 88px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-sec {
  padding: 12px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  cursor: pointer;
  border-right: 3px solid transparent;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: .15s;
  user-select: none;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }

.nav-item.active {
  background: var(--surface2);
  color: var(--a1);
  border-right-color: var(--a1);
  font-weight: 700;
}

.nav-ico { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-right: auto;
  background: var(--surface3);
  color: var(--muted);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
}
.nav-item.active .nav-badge { background: rgba(21,101,192,.12); color: var(--a1); }

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}

/* ── CONTENT ─────────────────────────────── */
.content {
  flex: 1;
  padding: 18px;
  overflow: hidden;
}

/* ── PAGE HEADER ─────────────────────────── */
.page-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-hdr h1 {
  font-family: 'Amiri', serif;
  font-size: 20px;
  color: var(--a1);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

.breadcrumb a { color: var(--a1); cursor: pointer; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ── KPI ROW ─────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  border-right: 4px solid transparent;
  box-shadow: var(--sh);
}

.kpi.c1 { border-right-color: var(--a1); }
.kpi.c2 { border-right-color: var(--a2); }
.kpi.c3 { border-right-color: var(--a3); }
.kpi.c4 { border-right-color: var(--a4); }
.kpi.c5 { border-right-color: var(--a5); }
.kpi.cg { border-right-color: var(--gold); }

.kpi-ico { font-size: 18px; margin-bottom: 5px; }
.kpi-lbl { font-size: 10px; color: var(--muted); margin-bottom: 3px; line-height: 1.3; }
.kpi-val { font-size: clamp(16px, 3vw, 22px); font-weight: 900; color: var(--text); line-height: 1; }
.kpi-sub { font-size: 10px; color: var(--muted); margin-top: 3px; }

.kpi-tag {
  display: inline-block;
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 4px;
  margin-top: 5px;
  font-weight: 700;
}

.tag-g { background: rgba(0,137,123,.1); color: var(--a2); }
.tag-r { background: rgba(229,57,53,.1); color: var(--a4); }
.tag-b { background: rgba(21,101,192,.1); color: var(--a1); }
.tag-y { background: rgba(249,168,37,.1); color: var(--a3); }

/* ── GRID ────────────────────────────────── */
.g2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-bottom: 14px; }
.g3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.g4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }

/* ── CARD ────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  box-shadow: var(--sh);
  margin-bottom: 14px;
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.ct-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* ── CHART ───────────────────────────────── */
.ch { position: relative; }
.ch-sm { height: 160px; }
.ch-md { height: 210px; }
.ch-lg { height: 260px; }
.ch canvas { position: absolute; inset: 0; width: 100%!important; height: 100%!important; }

/* ── SECTION HEADER ──────────────────────── */
.sec-hdr {
  font-size: 13px;
  font-weight: 700;
  color: var(--a1);
  padding: 8px 0;
  border-bottom: 2px solid var(--surface3);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ── PHASE CARDS ─────────────────────────── */
.phase-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.pcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px;
  text-align: center;
  box-shadow: var(--sh);
}

.pcard-ico { font-size: 20px; margin-bottom: 4px; }
.pcard-val { font-size: 20px; font-weight: 900; }
.pcard-lbl { font-size: 10px; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.pcard-tag {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 4px;
  font-weight: 700;
}

/* ── MAL CARDS ───────────────────────────── */
.mal-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.mal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  box-shadow: var(--sh);
}

.mal-lbl { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.mal-val { font-size: 20px; font-weight: 900; }
.mal-pct { font-size: 10px; margin-top: 3px; }

/* ── MAHKAMA CARDS ───────────────────────── */
.mah-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.mah-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--a1);
  border-radius: var(--r);
  padding: 14px;
  text-align: center;
  box-shadow: var(--sh);
  cursor: pointer;
  transition: .2s;
}

.mah-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(21,101,192,.15); }
.mah-name { font-size: 13px; font-weight: 700; color: var(--a1); margin-bottom: 7px; }
.mah-num { font-size: 24px; font-weight: 900; }
.mah-sub { font-size: 10px; color: var(--muted); }
.mah-amt { font-size: 12px; color: var(--a2); font-weight: 700; margin-top: 4px; }

/* ── STAT BARS ───────────────────────────── */
.slist { display: flex; flex-direction: column; gap: 8px; }

.srow { display: flex; align-items: center; gap: 8px; }
.sname { min-width: 120px; font-size: 11px; color: var(--text); text-align: right; flex-shrink: 0; line-height: 1.3; }
.sbar-w { flex: 1; background: var(--surface3); border-radius: 3px; height: 5px; overflow: hidden; }
.sbar { height: 100%; border-radius: 3px; transition: width .8s ease; }
.scnt { min-width: 36px; text-align: left; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.spct { min-width: 32px; text-align: left; font-size: 10px; color: var(--muted); flex-shrink: 0; }

/* ── BADGE ───────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.bg { background: rgba(0,137,123,.12); color: var(--a2); }
.br { background: rgba(229,57,53,.12); color: var(--a4); }
.bb { background: rgba(21,101,192,.12); color: var(--a1); }
.by { background: rgba(249,168,37,.12); color: var(--a3); }
.bp { background: rgba(123,31,162,.12); color: var(--a5); }

/* ── TABLE ───────────────────────────────── */
.tbl-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.tbl-search {
  flex: 1;
  min-width: 180px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.tbl-search:focus { border-color: var(--a1); }
.tbl-info { font-size: 11px; color: var(--muted); white-space: nowrap; }

.tbl-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--border); }

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 600px;
}

.tbl thead { background: var(--surface2); }

.tbl th {
  padding: 9px 12px;
  text-align: right;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.tbl td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--surface2); }

/* ── PAGINATION ──────────────────────────── */
.pages {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  margin-top: 10px;
  flex-wrap: wrap;
}

.pg {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-family: 'Cairo', sans-serif;
  font-size: 11px;
  transition: .15s;
}

.pg:hover { border-color: var(--a1); color: var(--a1); }
.pg.on { background: var(--a1); border-color: var(--a1); color: #fff; font-weight: 700; }
.pg:disabled { opacity: .4; cursor: not-allowed; }

/* ── MODAL ───────────────────────────────── */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  align-items: center;
  justify-content: center;
}

.modal-bg.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px;
  width: min(92vw, 440px);
  max-height: 88vh;
  overflow-y: auto;
}

.modal h3 { font-size: 16px; margin-bottom: 16px; color: var(--text); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: .15s;
}

.input:focus { border-color: var(--a1); }

.alert {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 12px;
  display: none;
}

.alert.show { display: block; }
.alert-err { background: rgba(229,57,53,.1); color: var(--a4); border: 1px solid rgba(229,57,53,.2); }
.alert-ok  { background: rgba(0,137,123,.1); color: var(--a2); border: 1px solid rgba(0,137,123,.2); }

/* ── BUTTONS ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  font-weight: 700;
  transition: .15s;
  white-space: nowrap;
}

.btn-primary { background: var(--a1); color: #fff; }
.btn-primary:hover { background: #1250a0; }
.btn-success { background: var(--a2); color: #fff; }
.btn-success:hover { background: #007065; }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--a1); color: var(--a1); }
.btn-danger { background: var(--a4); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── LOADING ─────────────────────────────── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  gap: 12px;
}

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--a1);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-txt { font-size: 13px; color: var(--muted); }

/* ── UPLOAD ZONE ─────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: .2s;
  margin-bottom: 14px;
}

.drop-zone:hover, .drop-zone.drag { border-color: var(--a1); background: rgba(21,101,192,.03); }
.drop-ico { font-size: 28px; margin-bottom: 6px; }
.drop-txt { font-size: 13px; color: var(--muted); }
.drop-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ── PROGRESS ────────────────────────────── */
.prog-wrap { height: 4px; background: var(--surface3); border-radius: 2px; overflow: hidden; margin-top: 8px; display: none; }
.prog-bar { height: 100%; background: var(--a1); border-radius: 2px; transition: width .3s; }

/* ── TOAST ───────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--a2);
  color: #fff;
  padding: 10px 22px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  z-index: 500;
  transition: transform .3s;
  white-space: nowrap;
  pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--a4); }

/* ── ANIMATIONS ──────────────────────────── */
@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.fadein { animation: fadein .25s ease; }

/* ── RESPONSIVE ──────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    inset: 88px 0 0 0;
    width: 220px;
    transform: translateX(100%);
    transition: transform .25s;
    z-index: 90;
    height: auto;
  }

  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 89;
  }
  .sidebar-overlay.open { display: block; }

  .sidebar-toggle { display: flex; }
  .content { padding: 12px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
  .sname { min-width: 85px; font-size: 10px; }
  .tbl { min-width: 500px; }
}

@media (max-width: 400px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .phase-row { grid-template-columns: repeat(2, 1fr); }
  .mal-row { grid-template-columns: repeat(2, 1fr); }
}

/* ── STATUS DOT ──────────────────────────── */
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--a2);
  box-shadow: 0 0 5px var(--a2);
  animation: pulse 2s infinite;
}

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.status-dot.warn { background: var(--a3); box-shadow: 0 0 5px var(--a3); }
.status-txt { font-size: 11px; color: var(--muted); }
