/* AI Gateway portal — dark glass, gold accent (Al-Maqdisi brand family). */

:root {
  --bg-0: #0b0f14;
  --bg-1: #101722;
  --glass: rgba(255, 255, 255, 0.045);
  --glass-border: rgba(255, 255, 255, 0.09);
  --text: #e8e6e1;
  --muted: #9aa3ad;
  --gold: #c9a25c;
  --gold-strong: #e0b96f;
  --green: #4cc38a;
  --red: #e5646e;
  --amber: #e3b341;
  --radius: 14px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(201, 162, 92, 0.10), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(76, 121, 195, 0.08), transparent 55%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.muted { color: var(--muted); }
.error { color: var(--red); font-size: 0.85rem; }
[hidden] { display: none !important; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-view {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.login-card { width: 100%; max-width: 400px; padding: 36px; }
.brand { text-align: center; margin-bottom: 26px; }
.brand h1 { margin: 10px 0 4px; font-size: 1.5rem; letter-spacing: 0.02em; }
.brand p { margin: 0; font-size: 0.85rem; }
.brand-mark { color: var(--gold); font-size: 1.5rem; }
.login-card label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.login-card input {
  width: 100%; padding: 12px 14px; margin-bottom: 14px;
  border-radius: 10px; border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.35); color: var(--text); font-size: 0.95rem;
}
.login-card input:focus { outline: 2px solid var(--gold); border-color: transparent; }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 12px; z-index: 10;
  margin: 12px 20px 0; padding: 12px 18px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand-row { display: flex; align-items: center; gap: 10px; }
.host { font-size: 0.78rem; }
main { max-width: 1080px; margin: 0 auto; padding: 20px; }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 26px 4px 14px;
}
.section-head h2 { margin: 0; font-size: 1.15rem; font-weight: 600; }
.inline-title { display: inline; margin: 0 10px; }

/* ── Buttons / chips / switches ───────────────────────────────────────── */
.btn {
  font-family: var(--font); font-size: 0.85rem; font-weight: 500;
  padding: 9px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; transition: all 0.15s ease;
}
.btn-gold { background: var(--gold); color: #14100a; }
.btn-gold:hover { background: var(--gold-strong); }
.btn-outline { background: transparent; color: var(--gold); border-color: rgba(201, 162, 92, 0.5); }
.btn-outline:hover { border-color: var(--gold); background: rgba(201, 162, 92, 0.08); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: transparent; color: var(--red); border-color: rgba(229, 100, 110, 0.4); }
.btn-danger:hover { background: rgba(229, 100, 110, 0.1); }
.btn-sm { padding: 5px 10px; font-size: 0.75rem; border-radius: 8px; }

.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.03em;
}
.chip.on { background: rgba(76, 195, 138, 0.14); color: var(--green); }
.chip.off { background: rgba(229, 100, 110, 0.14); color: var(--red); }
.chip.warn { background: rgba(227, 179, 65, 0.14); color: var(--amber); }

.switch-label { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--muted); }
.switch { appearance: none; width: 40px; height: 22px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.14); position: relative; cursor: pointer; transition: background 0.15s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(18px); }

.mode-select {
  padding: 8px 12px; border-radius: 9px; font-size: 0.85rem;
  border: 1px solid var(--glass-border); background: rgba(0, 0, 0, 0.35);
  color: var(--text); font-family: var(--font); cursor: pointer;
}
.mode-select:focus { outline: 2px solid var(--gold); border-color: transparent; }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.app-card { padding: 20px; cursor: pointer; transition: border-color 0.15s, transform 0.15s; }
.app-card:hover { border-color: rgba(201, 162, 92, 0.45); transform: translateY(-1px); }
.app-card .card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.app-card h3 { margin: 0; font-size: 1.02rem; }
.app-card .metrics { display: flex; gap: 22px; margin: 10px 0 4px; }
.metric .val { font-size: 1.25rem; font-weight: 650; }
.metric .lbl { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.key-hint { font-size: 0.78rem; color: var(--muted); margin-top: 8px; }
.key-hint code { color: var(--gold); }

/* ── Panels / tables / tabs ───────────────────────────────────────────── */
.panel { padding: 18px 20px; margin-bottom: 16px; }
.panel h3 { margin: 2px 0 12px; font-size: 0.95rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.note { font-size: 0.78rem; margin: 10px 2px 0; }

table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.05em; padding: 8px 10px;
  border-bottom: 1px solid var(--glass-border); }
td { padding: 9px 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.045); }
tr:last-child td { border-bottom: none; }
td code { font-size: 0.8rem; color: var(--gold); }

.tabs { display: flex; gap: 4px; margin: 18px 0 14px; border-bottom: 1px solid var(--glass-border); }
.tab { background: none; border: none; color: var(--muted); font-family: var(--font);
  font-size: 0.88rem; padding: 10px 16px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); font-weight: 600; }

.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { flex: 1; min-width: 130px; padding: 14px 16px; }
.stat .val { font-size: 1.35rem; font-weight: 650; }
.stat .lbl { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ── Charts (inline SVG bars) ─────────────────────────────────────────── */
.chart { width: 100%; min-height: 170px; }
.chart svg { width: 100%; height: 190px; display: block; }
.chart .bar-ok { fill: var(--gold); opacity: 0.85; }
.chart .bar-err { fill: var(--red); opacity: 0.8; }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart .empty { color: var(--muted); font-size: 0.85rem; padding: 40px 0; text-align: center; }

/* ── Dialogs / toast ──────────────────────────────────────────────────── */
dialog { border: 1px solid var(--glass-border); color: var(--text);
  padding: 26px; width: min(440px, 92vw);
  background: rgba(16, 23, 34, 0.97); }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(3px); }
dialog h3 { margin: 0 0 6px; }
dialog label { display: block; font-size: 0.78rem; color: var(--muted); margin: 12px 0 5px; }
dialog input, dialog select {
  width: 100%; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--glass-border); background: rgba(0, 0, 0, 0.35);
  color: var(--text); font-size: 0.9rem;
}
dialog input:focus { outline: 2px solid var(--gold); border-color: transparent; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.secret-box { display: block; padding: 14px; margin: 14px 0 4px; border-radius: 9px;
  background: rgba(0, 0, 0, 0.45); border: 1px dashed rgba(201, 162, 92, 0.5);
  color: var(--gold); font-size: 0.82rem; word-break: break-all; user-select: all; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(16, 23, 34, 0.97); border: 1px solid var(--glass-border);
  border-radius: 10px; padding: 11px 20px; font-size: 0.85rem; z-index: 100; }
.toast.ok { border-color: rgba(76, 195, 138, 0.5); }
.toast.err { border-color: rgba(229, 100, 110, 0.5); }

@media (max-width: 640px) {
  .topbar { margin: 8px; }
  main { padding: 12px; }
  .stat-row { gap: 8px; }
}
