:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #667085;
  --line: #e4e7ec;
  --brand: #1d4ed8;
  --brand-soft: #e8eefc;
  --side: #0f172a;
  --side-ink: #cbd5e1;
  --ok: #059669;  --ok-soft: #e7f6f0;
  --due: #d97706; --due-soft: #fdf3e2;
  --bad: #dc2626; --bad-soft: #fdecec;
  --wait: #7c3aed; --wait-soft: #f1ebfd;
  --off: #94a3b8; --off-soft: #f1f5f9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "IBM Plex Sans Arabic", "Tajawal", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14.5px; line-height: 1.6;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* ----- layout ----- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-ink); padding: 22px 14px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
}
.brand { color: #fff; font-weight: 700; font-size: 17px; padding: 4px 10px 18px; display: flex; gap: 10px; align-items: center; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg,#3b82f6,#0d9488); display: grid; place-items: center; font-size: 17px; }
.side a.nav {
  color: var(--side-ink); padding: 9px 12px; border-radius: 10px; display: flex; align-items: center; gap: 10px;
  font-weight: 500;
}
.side a.nav:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.side a.nav.active { background: rgba(59,130,246,.18); color: #fff; }
.side .sep { font-size: 11.5px; color: #64748b; padding: 14px 12px 4px; letter-spacing: .02em; }
.side .badge { margin-inline-start: auto; background: var(--wait); color: #fff; border-radius: 999px; font-size: 11.5px; padding: 0 8px; }
.side .foot { margin-top: auto; font-size: 12px; color: #64748b; padding: 10px 12px; }
.main { padding: 26px 30px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h1 { font-size: 22px; margin: 0; }
.topbar .sub { color: var(--muted); font-size: 13px; }

/* ----- components ----- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h3 { margin: 0 0 12px; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.card h3 small { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g21 { grid-template-columns: 2fr 1fr; }
.mt { margin-top: 16px; }

.kpi { position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 700; margin: 4px 0 2px; }
.kpi .hint { font-size: 12.5px; color: var(--muted); }
.kpi::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--brand)); }
.kpi.bad { --accent: var(--bad); } .kpi.due { --accent: var(--due); } .kpi.wait { --accent: var(--wait); } .kpi.ok { --accent: var(--ok); }

.catcard { display: flex; gap: 14px; align-items: center; }
.catcard .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: color-mix(in srgb, var(--c) 12%, white); }
.catcard .t { font-weight: 600; }
.catcard .m { color: var(--muted); font-size: 12.5px; }
.catcard .alerts { margin-inline-start: auto; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-ok { color: var(--ok); background: var(--ok-soft); }
.st-due { color: var(--due); background: var(--due-soft); }
.st-overdue { color: var(--bad); background: var(--bad-soft); }
.st-reported { color: var(--wait); background: var(--wait-soft); }
.st-inactive { color: var(--off); background: var(--off-soft); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; background: var(--off-soft); color: #475569; }
.cat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 6px; }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: start; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 10px 10px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
table.t td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr:hover td { background: #fafbff; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.name-cell .n { font-weight: 600; }
.name-cell .d { color: var(--muted); font-size: 12.5px; }
.days { font-weight: 700; white-space: nowrap; }
.days.bad { color: var(--bad); } .days.due { color: var(--due); } .days.ok { color: var(--ok); }
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 4px; min-width: 70px; }
.bar > i { display: block; height: 100%; background: var(--ok); }
.bar.due > i { background: var(--due); } .bar.bad > i { background: var(--bad); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; }
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: #1e40af; }
.btn.green { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.red { background: #fff; color: var(--bad); border-color: #f5c2c2; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

form .fields { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px 16px; }
form .full { grid-column: 1 / -1; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: #344054; }
label.f small { font-weight: 400; color: var(--muted); }
input, select, textarea {
  font: inherit; padding: 9px 11px; border: 1px solid #d0d5dd; border-radius: 10px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfd3fb; border-color: var(--brand); }
textarea { min-height: 80px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: 13px; }
.check input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; background: #fff; }
legend { padding: 0 8px; font-weight: 700; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 150px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-weight: 600; font-size: 13px; }
.tabs a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs a:hover { text-decoration: none; }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; }
.flash.ok { background: var(--ok-soft); color: #065f46; }
.flash.error { background: var(--bad-soft); color: #991b1b; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.bars-h .row { display: grid; grid-template-columns: 110px 1fr 90px; gap: 10px; align-items: center; margin: 7px 0; font-size: 13px; }
.bars-h .track { height: 10px; background: var(--off-soft); border-radius: 99px; overflow: hidden; }
.bars-h .track i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.bars-h .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.t td.num { white-space: nowrap; }
.vbars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; height: 220px; align-items: end; padding-top: 6px; }
.vb { display: flex; flex-direction: column; align-items: center; height: 100%; gap: 4px; min-width: 0; }
.vb .val { font-size: 11.5px; color: var(--muted); min-height: 16px; }
.vb .col { flex: 1; width: 100%; max-width: 38px; display: flex; align-items: flex-end; background: var(--off-soft); border-radius: 8px; overflow: hidden; }
.vb .col i { display: block; width: 100%; background: var(--brand); border-radius: 8px 8px 0 0; min-height: 2px; }
.vb .lb { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.stack { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: var(--off-soft); }
.stack i { display: block; height: 100%; }
.legend { display: grid; gap: 6px; margin-top: 12px; font-size: 13px; }
.legend div { display: flex; align-items: center; }
.legend b { margin-inline-start: auto; padding-inline-start: 12px; }
.chart-box { position: relative; height: 230px; }
.logline { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.logline:last-child { border: 0; }
.logline .tm { color: var(--muted); white-space: nowrap; }

/* ----- public confirm page ----- */
.public { max-width: 520px; margin: 40px auto; padding: 0 16px; }
.public .card { padding: 24px; }
.public .head { text-align: center; margin-bottom: 18px; }
.public .head .big { font-size: 42px; }
.login-box { max-width: 380px; margin: 12vh auto; padding: 0 16px; }

.mobile-nav { display: none; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g21 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { display: none; }
  .mobile-nav { display: flex; gap: 6px; overflow-x: auto; background: var(--side); padding: 10px 12px; position: sticky; top: 0; z-index: 5; }
  .mobile-nav a { color: var(--side-ink); white-space: nowrap; padding: 6px 12px; border-radius: 8px; font-size: 13px; }
  .mobile-nav a.active { background: rgba(59,130,246,.25); color: #fff; }
  .main { padding: 16px; }
  .g3, .g2 { grid-template-columns: 1fr; }
  form .fields { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 110px 1fr; }
}
@media (max-width: 520px) { .g4 { grid-template-columns: 1fr; } }
