/* Sajjel Ministry Console V2 — "The Minister's Command Center" */

:root {
  --ink: #23201A;
  --ink-muted: #6E675B;
  --paper: #FBF9F3;
  --raised: #FFFFFF;
  --line: #E4DFD2;
  --primary: #1A5632;
  --primary-deep: #0F3D23;
  --tint: #E9F1EA;
  --accent: #B08B2E;
  --danger: #96342B;
  --warning: #8A5A0B;
  --info: #2C5A78;
  --chart-green: #1E7B45;
  --chart-gray: #a5a196;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --font: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.7;
  font-size: 15px;
}
.mono { font-family: "IBM Plex Sans", system-ui, sans-serif; font-variant-numeric: tabular-nums; }
h1 { font-size: 26px; font-weight: 700; margin: 0; line-height: 1.4; }
h2 { font-size: 15px; font-weight: 600; margin: 0; }

/* ---------- ribbon + header ---------- */
.demo-ribbon {
  background: var(--ink);
  color: var(--paper);
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.02em;
  padding: 4px 12px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 32px;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 16px; }
.wordmark { font-size: 30px; font-weight: 700; position: relative; line-height: 1; }
.shadda-dot { display: none; }
.wordmark { color: var(--ink); }
/* color the shadda region: simplest robust approach — small seal ring next to the word */
.brand::before {
  content: "";
  width: 14px; height: 14px;
  border: 2.5px solid var(--primary);
  border-radius: 50%;
  display: inline-block;
  flex: none;
}
.brand-rule { width: 1px; height: 36px; background: var(--line); }
.ministry-name { font-weight: 600; font-size: 14px; }
.console-name { font-size: 12.5px; color: var(--ink-muted); }
.topbar-side { display: flex; align-items: center; gap: 16px; }
.clock { font-size: 12.5px; color: var(--ink-muted); }
.lang-toggle {
  font-family: var(--font);
  font-size: 13px; font-weight: 600;
  padding: 5px 14px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.lang-toggle:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- breadcrumbs ---------- */
.crumbs {
  padding: 10px 32px;
  font-size: 13px;
  color: var(--ink-muted);
  display: flex;
  gap: 8px;
  align-items: center;
}
.crumbs a { color: var(--primary); text-decoration: none; cursor: pointer; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { color: var(--line); }

/* ---------- layout ---------- */
#app { max-width: 1280px; margin: 0 auto; padding: 8px 32px 48px; }
.page-head { margin: 12px 0 20px; }
.page-sub { margin: 4px 0 0; color: var(--ink-muted); font-size: 13.5px; }
.tag-illustrative {
  display: inline-block;
  margin-inline-start: 10px;
  font-size: 11.5px;
  padding: 1px 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--ink-muted);
  background: var(--raised);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; margin-bottom: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 980px) {
  .grid-2, .grid-2-1, .grid-3 { grid-template-columns: 1fr; }
  #app { padding: 8px 16px 40px; }
  .topbar, .crumbs { padding-left: 16px; padding-right: 16px; }
}

.card {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-note { font-size: 12px; color: var(--ink-muted); }
.card-sep { border-top: 1px solid var(--line); margin: 16px -20px; }
.fineprint { font-size: 12px; color: var(--ink-muted); margin: 10px 0 0; }

/* ---------- KPI row ---------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
@media (max-width: 1100px) { .kpi-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px)  { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  cursor: default;
}
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: var(--primary); }
.kpi-label { font-size: 12px; color: var(--ink-muted); margin-bottom: 2px; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 11.5px; color: var(--ink-muted); }
.kpi-sub .up { color: var(--primary); font-weight: 600; }
.kpi-anchor { color: var(--accent); font-weight: 600; }

/* ---------- charts ---------- */
.chart-box svg { display: block; width: 100%; height: auto; }
.gauge-box { display: flex; justify-content: center; }
.gauge-box svg { width: 78%; height: auto; }

.split-meter { margin-top: 8px; }
.split-labels { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.split-labels b { color: var(--primary); }
.split-bar { height: 10px; background: var(--chart-gray); border-radius: 6px; overflow: hidden; }
.split-fill { height: 100%; background: var(--chart-green); border-radius: 6px 0 0 6px; transition: width .6s ease; }
[dir="rtl"] .split-fill { border-radius: 0 6px 6px 0; }

/* gov bars are clickable */
.gov-bar-row { cursor: pointer; }
.gov-bar-row:hover rect.bar { fill: var(--primary-deep); }

/* ---------- targets table ---------- */
.targets-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.targets-table td { padding: 8px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.targets-table tr:last-child td { border-bottom: none; }
.t-meter { position: relative; height: 8px; background: var(--paper); border: 1px solid var(--line); border-radius: 5px; min-width: 110px; }
.t-fill { position: absolute; inset-block: 0; inset-inline-start: 0; background: var(--chart-green); border-radius: 5px; }
.t-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--accent); }
.t-nums { font-size: 12px; color: var(--ink-muted); white-space: nowrap; padding-inline-start: 10px; }
.t-nums b { color: var(--ink); }

/* ---------- funnel ---------- */
.funnel-step { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.funnel-bar { height: 26px; background: var(--tint); border: 1px solid var(--line); border-radius: var(--radius-sm); display: flex; align-items: center; padding: 0 10px; font-weight: 600; font-size: 13px; color: var(--primary-deep); min-width: 56px; justify-content: flex-end; }
.funnel-step:nth-child(3) .funnel-bar { background: #F4E9D8; color: var(--warning); }
.funnel-step:nth-child(4) .funnel-bar, .funnel-step:last-child .funnel-bar { background: #F3E3E0; color: var(--danger); }
.funnel-label { font-size: 12.5px; color: var(--ink-muted); }

/* ---------- KYB ---------- */
.kyb-top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.kyb-big { font-size: 30px; font-weight: 700; color: var(--ink); }
.kyb-sub { font-size: 12.5px; color: var(--ink-muted); }

/* ---------- routing ---------- */
.routing-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.routing-row:last-child { border-bottom: none; }
.routing-name { flex: 1; font-size: 13.5px; }
.routing-avg { font-size: 12px; color: var(--ink-muted); white-space: nowrap; }
.routing-pct { font-weight: 700; color: var(--primary); font-size: 14px; min-width: 46px; text-align: end; font-variant-numeric: tabular-nums; }
.routing-track { flex: 0 0 90px; height: 7px; background: var(--paper); border: 1px solid var(--line); border-radius: 5px; position: relative; }
.routing-fill { position: absolute; inset-block: 0; inset-inline-start: 0; background: var(--chart-green); border-radius: 5px; }

/* ---------- auto-approve toggle ---------- */
.card-toggle { display: flex; flex-direction: column; }
.toggle-row { display: flex; gap: 16px; align-items: center; margin: 6px 0 14px; }
.switch {
  flex: none;
  width: 58px; height: 30px;
  border-radius: 30px;
  background: var(--chart-gray);
  border: none;
  position: relative;
  cursor: pointer;
  transition: background .25s;
}
.switch[aria-checked="true"] { background: var(--primary); }
.switch .knob {
  position: absolute;
  top: 3px; inset-inline-start: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform .25s;
}
.switch[aria-checked="true"] .knob { transform: translateX(-28px); }
[dir="ltr"] .switch[aria-checked="true"] .knob { transform: translateX(28px); }
.toggle-state { font-weight: 700; font-size: 15px; }
.toggle-detail { font-size: 12.5px; color: var(--ink-muted); }
.queue-preview {
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 13.5px;
}
.queue-preview b.shrink { color: var(--primary); font-size: 20px; }
.queue-preview .was { color: var(--ink-muted); text-decoration: line-through; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font);
  font-size: 14px; font-weight: 600;
  border-radius: var(--radius-md);
  padding: 9px 20px;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-deep); }
.btn-ghost { background: var(--raised); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink-muted); }
.btn-danger { background: var(--raised); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #F3E3E0; }

/* ---------- queue ---------- */
.queue-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.gov-mini { display: flex; gap: 8px; flex-wrap: wrap; }
.gov-chip {
  font-family: var(--font);
  font-size: 12.5px;
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--raised);
  cursor: pointer;
  color: var(--ink);
}
.gov-chip.active { background: var(--tint); border-color: var(--primary); color: var(--primary-deep); font-weight: 600; }
.inline-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.inline-toggle input { accent-color: var(--primary); width: 16px; height: 16px; }

.table-card { padding: 0; overflow-x: auto; }
.queue-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.queue-table th {
  text-align: start;
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  white-space: nowrap;
}
.queue-table td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.queue-table tbody tr { cursor: pointer; }
.queue-table tbody tr:hover { background: var(--tint); }
.queue-table tbody tr:last-child td { border-bottom: none; }
.case-id { font-family: "IBM Plex Sans", monospace, sans-serif; font-size: 12.5px; color: var(--ink-muted); white-space: nowrap; }

.tag {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 4px;
  white-space: nowrap;
}
.tag-auto      { background: var(--tint);    color: var(--primary-deep); }
.tag-exam      { background: #E3ECF2; color: var(--info); }
.tag-awaiting  { background: #F4E9D8; color: var(--warning); }
.tag-referred  { background: #EFEBE0; color: var(--ink-muted); border: 1px solid var(--line); }
.sla-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sla-low { color: var(--danger); font-weight: 700; }

/* ---------- case view ---------- */
.identity-bar {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 18px;
  padding: 16px 22px;
}
.id-field .lbl { font-size: 11px; color: var(--ink-muted); }
.id-field .val { font-weight: 600; font-size: 14px; }
.id-flag {
  flex-basis: 100%;
  font-size: 13px;
  color: var(--warning);
  background: #F9F2E4;
  border: 1px solid #EAD9B8;
  border-radius: var(--radius-md);
  padding: 8px 14px;
}
.id-flag.ok { color: var(--primary-deep); background: var(--tint); border-color: #CBDECF; }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.checklist li:last-child { border-bottom: none; }
.chk { flex: none; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; margin-top: 2px; }
.chk-ok { background: var(--tint); color: var(--primary-deep); }
.chk-no { background: #F3E3E0; color: var(--danger); }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding-inline-start: 26px; padding-bottom: 14px; font-size: 13px; }
.timeline li::before {
  content: ""; position: absolute; inset-inline-start: 6px; top: 7px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--chart-green);
}
.timeline li.pending::before { background: var(--chart-gray); }
.timeline li::after {
  content: ""; position: absolute; inset-inline-start: 9.5px; top: 18px; bottom: -2px;
  width: 1px; background: var(--line);
}
.timeline li:last-child::after { display: none; }
.timeline .tl-date { color: var(--ink-muted); font-size: 11.5px; }

.decision { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- toast ---------- */
#toastRoot { position: fixed; bottom: 22px; inset-inline-start: 22px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  box-shadow: 0 6px 18px rgba(35,32,26,.25);
  display: flex; gap: 10px; align-items: center;
  animation: toast-in .35s ease;
  max-width: 340px;
}
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--chart-green); flex: none; }
.toast.ok .dot { background: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .split-fill, .switch, .switch .knob { transition: none; }
}

/* ---------- footer ---------- */
.foot {
  border-top: 1px solid var(--line);
  padding: 18px 32px 26px;
  font-size: 12px;
  color: var(--ink-muted);
  text-align: center;
}

/* views */
.view[hidden] { display: none; }
