:root {
  --bg: #060a11;
  --bg-2: #0a1220;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eaf0f8;
  --muted: #8b9bb4;
  --dim: #64748b;
  --emerald: #2ee6a8;
  --emerald-deep: #0e9f73;
  --blue: #5b8cff;
  --gold: #f7c948;
  --red: #ff5f6d;
  --violet: #a87bff;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.9);
  --font: "Segoe UI", "Noto Kufi Arabic", "Tajawal", Tahoma, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(46, 230, 168, 0.10), transparent 60%),
    radial-gradient(800px 520px at 5% 0%, rgba(91, 140, 255, 0.10), transparent 55%),
    radial-gradient(1000px 700px at 50% 120%, rgba(168, 123, 255, 0.07), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.mono { font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace; }

a { color: inherit; text-decoration: none; }

/* ---------------- login ---------------- */

.login-shell {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-glow {
  position: fixed;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(46, 230, 168, 0.18), transparent 65%);
  filter: blur(40px);
  animation: float 9s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translate3d(0, -12px, 0) scale(1); }
  50% { transform: translate3d(0, 18px, 0) scale(1.06); }
}

.login-card {
  position: relative;
  width: min(420px, 100%);
  padding: 34px 30px 26px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-card h1 { font-size: 22px; margin: 18px 0 6px; }
.login-card p { margin: 0 0 22px; font-size: 13px; }

.brand-mark {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 1px;
  font-size: 19px;
  color: #04211a;
  background: linear-gradient(135deg, #58ffc9, #17c98d 45%, #0b8f68);
  box-shadow: 0 12px 30px -12px rgba(46, 230, 168, 0.7);
}

.brand-mark.small { width: 40px; height: 40px; border-radius: 12px; font-size: 13px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.field input:focus {
  border-color: rgba(46, 230, 168, 0.55);
  box-shadow: 0 0 0 3px rgba(46, 230, 168, 0.12);
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.12s, background 0.16s, border-color 0.16s, opacity 0.16s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.09); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, #2ee6a8, #12a97a);
  border-color: transparent;
  color: #04211a;
  box-shadow: 0 14px 30px -16px rgba(46, 230, 168, 0.8);
}
.btn.primary:hover { background: linear-gradient(135deg, #4bf0b8, #17bd8a); }
.btn.danger { background: rgba(255, 95, 109, 0.14); border-color: rgba(255, 95, 109, 0.35); color: #ffb3b9; }
.btn.danger:hover { background: rgba(255, 95, 109, 0.22); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 9px; }

.form-error { color: #ff8a92; font-size: 13px; min-height: 18px; margin: 10px 0 0 !important; }

/* ---------------- shell ---------------- */

.app-shell {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 262px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  border-inline-end: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(10, 18, 32, 0.85), rgba(6, 10, 17, 0.9));
  backdrop-filter: blur(14px);
}

.sidebar-head { display: flex; align-items: center; gap: 12px; padding: 4px 6px 22px; }
.brand-title { font-weight: 700; font-size: 15px; letter-spacing: 0.2px; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav a .ico { width: 18px; text-align: center; opacity: 0.85; font-size: 14px; }
.nav a:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.nav a.active {
  background: linear-gradient(90deg, rgba(46, 230, 168, 0.16), rgba(46, 230, 168, 0.03));
  color: #b7ffe4;
  border-color: rgba(46, 230, 168, 0.22);
}

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 14px; display: grid; gap: 12px; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  width: fit-content;
}
.live-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.live-pill.on .dot { background: var(--emerald); box-shadow: 0 0 0 4px rgba(46, 230, 168, 0.14); }
.live-pill.off .dot { background: var(--red); box-shadow: 0 0 0 4px rgba(255, 95, 109, 0.14); }

.user-row { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.35), rgba(46, 230, 168, 0.28));
  border: 1px solid var(--border-strong);
  font-weight: 700; font-size: 13px;
}
.user-meta { flex: 1; min-width: 0; }
.user-meta > div:first-child { font-size: 13px; font-weight: 600; }
.icon-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); width: 32px; height: 32px; border-radius: 10px;
  cursor: pointer; font-size: 14px;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

.menu-btn { display: none !important; }
.scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 10, 17, 0.72);
  backdrop-filter: blur(16px);
}
.topbar h1 { font-size: 19px; margin: 0; }
.topbar-title p { margin: 3px 0 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.chip {
  font-size: 11.5px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  white-space: nowrap;
}
.chip.ok { color: #9dffd9; border-color: rgba(46, 230, 168, 0.3); background: rgba(46, 230, 168, 0.08); }
.chip.warn { color: #ffd98a; border-color: rgba(247, 201, 72, 0.3); background: rgba(247, 201, 72, 0.08); }
.chip.bad { color: #ff9ba2; border-color: rgba(255, 95, 109, 0.3); background: rgba(255, 95, 109, 0.08); }

.view { padding: 24px 28px 60px; display: grid; gap: 18px; }

/* ---------------- cards ---------------- */

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
  box-shadow: 0 20px 50px -34px rgba(0, 0, 0, 0.9);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h2 { font-size: 14.5px; margin: 0; font-weight: 650; letter-spacing: 0.2px; }
.card-head .hint { font-size: 11.5px; color: var(--muted); }

.grid { display: grid; gap: 16px; align-items: start; }
.grid.kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

@media (max-width: 1100px) {
  .grid.kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .grid.kpi { grid-template-columns: 1fr; }
}

.kpi-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.012));
}
.kpi-card::after {
  content: "";
  position: absolute; inset-inline-start: -30px; top: -40px;
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent, rgba(46, 230, 168, 0.22)), transparent 70%);
  opacity: 0.55;
}
.kpi-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.kpi-value { font-size: 27px; font-weight: 750; margin-top: 8px; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.kpi-foot { font-size: 11.5px; color: var(--dim); margin-top: 6px; }

.stat-row { display: flex; align-items: baseline; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.06); font-size: 13px; }
.stat-row:last-child { border-bottom: none; }
.stat-row .k { color: var(--muted); }
.stat-row .v { font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------------- table ---------------- */

.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: start;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--muted);
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th:hover { color: var(--text); }
tbody td { padding: 11px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.045); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: rgba(46, 230, 168, 0.055); }
.num { font-variant-numeric: tabular-nums; text-align: end; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
}
.tag.green { color: #9dffd9; border-color: rgba(46, 230, 168, 0.3); background: rgba(46, 230, 168, 0.08); }
.tag.red { color: #ff9ba2; border-color: rgba(255, 95, 109, 0.3); background: rgba(255, 95, 109, 0.08); }
.tag.gold { color: #ffdf9b; border-color: rgba(247, 201, 72, 0.3); background: rgba(247, 201, 72, 0.08); }
.tag.blue { color: #b6caff; border-color: rgba(91, 140, 255, 0.3); background: rgba(91, 140, 255, 0.08); }
.tag.violet { color: #d9c8ff; border-color: rgba(168, 123, 255, 0.3); background: rgba(168, 123, 255, 0.08); }

/* ---------------- toolbar / inputs ---------------- */

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.input {
  padding: 9px 13px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  min-width: 180px;
}
.input:focus { border-color: rgba(46, 230, 168, 0.5); }
select.input { cursor: pointer; }

/* ---------------- charts ---------------- */

.chart { width: 100%; height: 150px; display: block; }
.chart .bar { fill: url(#barGrad); rx: 4; }
.chart .bar:hover { fill: #6bffd0; }
.chart-axis { font-size: 9.5px; fill: var(--dim); }

.spark { width: 100%; height: 38px; display: block; }

/* ---------------- drawer / modal ---------------- */

.drawer, .modal { position: fixed; inset: 0; z-index: 40; }
.drawer-backdrop, .modal-backdrop { position: absolute; inset: 0; background: rgba(2, 5, 10, 0.72); backdrop-filter: blur(3px); }

.drawer-panel {
  position: absolute; inset-block: 0; inset-inline-start: 0;
  width: min(460px, 100%);
  background: linear-gradient(180deg, #0b1422, #070c14);
  border-inline-end: 1px solid var(--border);
  box-shadow: 30px 0 80px -40px #000;
  overflow-y: auto;
  animation: slideIn 0.22s ease;
  padding: 22px;
}
@keyframes slideIn { from { transform: translateX(-18px); opacity: 0.4; } to { transform: none; opacity: 1; } }

.modal-card {
  position: absolute; top: 50%; inset-inline-start: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 32px));
  max-height: 84vh; overflow-y: auto;
  background: linear-gradient(180deg, #0c1524, #070c14);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  animation: pop 0.16s ease;
}
@keyframes pop { from { transform: translate(-50%, -50%) scale(0.97); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

.drawer h2, .modal h2 { font-size: 17px; margin: 0 0 4px; }
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--dim); margin: 22px 0 10px; }
.profile-top { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.profile-avatar {
  width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center;
  font-size: 20px; font-weight: 800;
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.32), rgba(46, 230, 168, 0.25));
  border: 1px solid var(--border-strong);
}

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.action-grid .btn { justify-content: center; }
.action-grid .full { grid-column: span 2; }

/* ---------------- versions ---------------- */

.dropzone {
  border: 1.5px dashed rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  padding: 28px 20px;
  text-align: center;
  transition: border-color 0.16s, background 0.16s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag { border-color: rgba(46, 230, 168, 0.5); background: rgba(46, 230, 168, 0.05); }
.dropzone .big { font-size: 24px; margin-bottom: 8px; opacity: 0.7; }

.version-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.02);
  margin-bottom: 8px;
}
.version-row.current { border-color: rgba(46, 230, 168, 0.35); background: rgba(46, 230, 168, 0.06); }
.version-main { flex: 1; min-width: 0; }
.version-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.version-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.version-actions { display: flex; gap: 6px; }

.deploy-log {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px;
  max-height: 260px;
  overflow: auto;
  color: #a9bad2;
  direction: ltr;
  text-align: left;
}

.progress {
  height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden;
}
.progress > i {
  display: block; height: 100%; width: 30%; border-radius: 999px;
  background: linear-gradient(90deg, #2ee6a8, #5b8cff);
  animation: slide 1.4s ease-in-out infinite;
}
@keyframes slide { 0% { margin-inline-start: -30%; } 100% { margin-inline-start: 100%; } }

/* ---------------- feed ---------------- */

.feed { display: grid; gap: 2px; }
.feed-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 11px;
  font-size: 12.5px;
}
.feed-item:nth-child(odd) { background: rgba(255, 255, 255, 0.022); }
.feed-item .time { color: var(--dim); font-size: 11px; font-variant-numeric: tabular-nums; min-width: 62px; }
.feed-item .name { font-weight: 600; }
.feed-item .type { font-size: 10.5px; color: var(--muted); }

/* ---------------- toasts ---------------- */

.toasts { position: fixed; inset-block-end: 22px; inset-inline-end: 22px; z-index: 90; display: grid; gap: 10px; }
.toast {
  min-width: 260px; max-width: 380px;
  padding: 13px 16px; border-radius: 13px;
  background: rgba(12, 20, 34, 0.96);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toastIn 0.18s ease;
}
.toast.ok { border-color: rgba(46, 230, 168, 0.45); }
.toast.err { border-color: rgba(255, 95, 109, 0.5); }
.toast .t-title { font-weight: 650; margin-bottom: 3px; }
.toast .t-body { color: var(--muted); font-size: 12px; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- misc ---------------- */

.empty {
  text-align: center; padding: 26px 20px; color: var(--dim); font-size: 13px;
}
.empty .big { font-size: 30px; opacity: 0.4; margin-bottom: 10px; }

.loader { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.2); border-top-color: var(--emerald); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.spinning { animation: spin 0.8s linear infinite; display: inline-block; }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }

.copy-line {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px;
  font-family: "JetBrains Mono", Consolas, monospace; font-size: 11.5px;
  direction: ltr; text-align: left;
  overflow-x: auto;
}

.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.meta-ltr { direction: ltr; text-align: right; unicode-bidi: isolate; }

.banner {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: 14px; font-size: 13px;
  border: 1px solid rgba(247, 201, 72, 0.3);
  background: rgba(247, 201, 72, 0.07);
  color: #ffe6ad;
}
.banner.ok { border-color: rgba(46, 230, 168, 0.3); background: rgba(46, 230, 168, 0.06); color: #b6ffe3; }
.banner.bad { border-color: rgba(255, 95, 109, 0.3); background: rgba(255, 95, 109, 0.07); color: #ffc3c8; }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; font-size: 13px; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; word-break: break-word; }

/* ---------------- responsive ---------------- */

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40;
    width: 262px; transform: translateX(102%); transition: transform 0.22s ease;
    background: #0a1119;
    box-shadow: -30px 0 60px -20px rgba(0, 0, 0, 0.9);
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex !important; }
  .scrim.open {
    display: block;
    position: fixed; inset: 0; z-index: 35;
    background: rgba(2, 6, 12, 0.66);
    backdrop-filter: blur(3px);
  }
  .view { padding: 16px 14px 80px; }
  .topbar { padding: 12px 14px; gap: 10px; }
  .topbar h1 { font-size: 16px; }
  .topbar-title { flex: 1; min-width: 0; }
  .topbar h1, .topbar-title p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .grid.kpi { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .kpi-value { font-size: 22px; }
}

@media (max-width: 560px) {
  .topbar-title p { display: none; }
  .chip { font-size: 10.5px; padding: 6px 9px; }
  .action-grid { grid-template-columns: 1fr; }
  .action-grid .full { grid-column: span 1; }
}
