:root {
  --bg: #0f1720;
  --surface: #16212d;
  --surface-2: #1c2938;
  --border: #26374a;
  --text: #e6edf3;
  --muted: #8fa3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --radius: 12px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "IBM Plex Sans Arabic", system-ui, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
}

.app { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  display: grid; place-items: center;
  font-weight: 700; color: #06121c; font-size: 19px;
}
.brand strong { display: block; font-size: 15px; }
.brand small { color: var(--muted); font-size: 12px; }

nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  all: unset;
  cursor: pointer;
  padding: 10px 14px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
  display: flex; align-items: center; justify-content: space-between;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active { background: var(--accent); color: #06121c; font-weight: 600; }

.badge {
  background: var(--red); color: #2a0a0a;
  border-radius: 999px; padding: 0 8px;
  font-size: 12px; font-weight: 700;
}
.nav-item.is-active .badge { background: #06121c; color: var(--accent); }

.role-switch { margin-top: auto; border-top: 1px solid var(--border); padding-top: 18px; }
.role-switch label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 6px; }
.role-hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

select, input, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 14px;
}
select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent-strong); outline-offset: 1px; }

/* Content */
.content { padding: 26px 30px 50px; min-width: 0; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
h1 { font-size: 22px; margin: 0; }
.muted { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

.btn {
  all: unset; cursor: pointer;
  padding: 8px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 500; text-align: center;
}
.btn-primary { background: var(--accent); color: #06121c; font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { border: 1px solid var(--border); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-danger { background: var(--red); color: #2a0a0a; font-weight: 600; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* Cards + grid */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 26px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card .kpi { font-size: 28px; font-weight: 700; }
.card .kpi-label { color: var(--muted); font-size: 13px; }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 22px;
}
.panel-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.panel-head h2 { font-size: 15px; margin: 0; }
.panel-body { padding: 18px; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 11px 18px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.pill-green { background: rgba(52,211,153,.15); color: var(--green); }
.pill-amber { background: rgba(251,191,36,.15); color: var(--amber); }
.pill-red { background: rgba(248,113,113,.15); color: var(--red); }
.pill-blue { background: rgba(56,189,248,.15); color: var(--accent); }
.pill-gray { background: rgba(143,163,184,.15); color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 44px 20px; }

/* Workflow steps */
.steps { display: flex; gap: 0; margin: 6px 0 0; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.step + .step::before { content: "←"; margin: 0 10px; color: var(--border); }
.step.done { color: var(--green); }
.step.current { color: var(--accent); font-weight: 600; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Modal */
.modal-backdrop[hidden] { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,10,16,.72);
  display: grid; place-items: center; padding: 20px; z-index: 50;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; width: min(520px, 100%);
}
.modal h2 { font-size: 17px; margin: 0 0 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 20px; }

/* Toast */
.toast {
  position: fixed; inset-block-end: 24px; inset-inline-start: 24px;
  background: var(--green); color: #05231a;
  padding: 11px 18px; border-radius: 9px; font-weight: 600; font-size: 14px;
  z-index: 60;
}

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.timeline li:last-child { border-bottom: none; }
.timeline time { color: var(--muted); font-size: 12px; margin-inline-start: 8px; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: column; }
  .row { grid-template-columns: 1fr; }
  .content { padding: 20px 16px 40px; }
}
