:root {
  --bg: #0b1220;
  --surface: #131e30;
  --elevated: #1b2940;
  --border: #2c405c;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --radius: 16px;
}

html[data-theme="light"] {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --elevated: #f8fafc;
  --border: #dbe3ef;
  --text: #0f172a;
  --muted: #475569;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { display: block; }
.brand-title { font-weight: 700; font-size: 1.05rem; }
.brand-sub { font-size: 0.8rem; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.container { max-width: 1240px; margin: 24px auto; padding: 0 18px 48px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.card h2, .card h3 { margin: 0 0 4px; font-size: 1.08rem; }
.muted { margin: 0; color: var(--muted); font-size: 0.86rem; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; }
.field input, .field select, .search-input, .select-sm {
  background: var(--elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.92rem;
}
.field input:focus, .field select:focus, .search-input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.form-actions { display: flex; align-items: flex-end; }
.mt { margin-top: 14px; }

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 140ms ease, opacity 140ms ease;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-outline { background: transparent; border-color: var(--danger); color: #fca5a5; }
html[data-theme="light"] .btn-danger-outline { color: #dc2626; }
.btn-ghost { background: var(--elevated); border-color: var(--border); color: var(--text); }

.pill {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.pill-muted { background: var(--elevated); color: var(--muted); }
.pill-ok { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.pill-err { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
html[data-theme="light"] .pill-ok { color: #047857; }
html[data-theme="light"] .pill-err { color: #b91c1c; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.kpi-label { font-size: 0.84rem; color: var(--muted); }
.kpi-value { font-size: 1.8rem; font-weight: 700; margin-top: 4px; color: var(--text); }

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 18px;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  white-space: nowrap;
  cursor: pointer;
}
.tab.active { background: var(--primary); color: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: start; vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: var(--elevated); }
.empty { text-align: center; color: var(--muted); padding: 24px; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-ok { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.badge-warn { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.badge-err { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
html[data-theme="light"] .badge-ok { color: #047857; }
html[data-theme="light"] .badge-warn { color: #b45309; }
html[data-theme="light"] .badge-err { color: #b91c1c; }

.alert {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  border: 1px solid var(--border);
}
.alert.hidden { display: none; }
.alert.ok { background: rgba(16, 185, 129, 0.14); border-color: rgba(16, 185, 129, 0.4); }
.alert.err { background: rgba(239, 68, 68, 0.14); border-color: rgba(239, 68, 68, 0.4); }

.command-box, .output-box {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.command-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 0.85rem; color: var(--muted); }
pre { margin: 0; white-space: pre-wrap; word-break: break-all; font-size: 0.82rem; font-family: ui-monospace, Consolas, monospace; }
.inline-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.checklist { margin: 8px 0 0; padding-inline-start: 20px; display: grid; gap: 10px; font-size: 0.9rem; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 0.82rem; }
