:root {
  --bg: #0b1220;
  --bg-elevated: #111827;
  --bg-soft: #161f2e;
  --border: #243044;
  --text: #e5eefb;
  --muted: #93a4bd;
  --primary: #22c55e;
  --primary-2: #16a34a;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #38bdf8;
  --sidebar-w: 260px;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --font: "Segoe UI", "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(34,197,94,.12), transparent 50%),
    radial-gradient(900px 500px at 100% 0%, rgba(56,189,248,.08), transparent 45%),
    var(--bg);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }
.btn { border-radius: 10px; font-weight: 600; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #052e16; }
.btn-primary:hover { background: var(--primary-2); border-color: var(--primary-2); color: #052e16; }
.btn-outline-light { border-color: var(--border); color: var(--text); }
.btn-outline-light:hover { background: var(--bg-soft); color: var(--text); border-color: #334155; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0d1524 0%, #0a101b 100%);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem .75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(135deg, #22c55e, #0ea5e9);
  display: grid; place-items: center; font-weight: 800; color: #041016;
}
.brand-text { font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: .75rem; color: var(--muted); }

.nav-link-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem .85rem; border-radius: 10px;
  color: var(--muted); margin-bottom: .25rem; transition: .15s ease;
}
.nav-link-item:hover, .nav-link-item.active {
  background: rgba(34,197,94,.12); color: var(--text);
}
.nav-section {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  color: #64748b; margin: 1rem .85rem .4rem;
}
.nav-sub { padding-left: 1.1rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
  background: rgba(11,18,32,.75); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.page-content { padding: 1.5rem; }

.card-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-panel .card-body { padding: 1.25rem; }
.stat-card { padding: 1.1rem 1.2rem; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; margin-top: .2rem; }

.table { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-border-color: var(--border); color: var(--text); }
.table > :not(caption) > * > * { background: transparent; border-bottom-color: var(--border); }
.table thead th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }

.form-control, .form-select, .form-control:focus, .form-select:focus {
  background: var(--bg-soft); border-color: var(--border); color: var(--text);
  box-shadow: none;
}
.form-control::placeholder { color: #64748b; }
.form-label { color: var(--muted); font-size: .85rem; }

.badge-status {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .35rem .65rem; border-radius: 999px; font-size: .75rem; font-weight: 600;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-ok, .status-online .dot, .status-connected .dot { background: #22c55e; box-shadow: 0 0 8px rgba(34,197,94,.6); }
.dot-warn { background: #f59e0b; }
.dot-err, .status-offline .dot, .status-error .dot { background: #ef4444; }
.dot-muted, .status-not_configured .dot { background: #94a3b8; }
.badge-ok { background: rgba(34,197,94,.15); color: #86efac; }
.badge-warn { background: rgba(245,158,11,.15); color: #fcd34d; }
.badge-err { background: rgba(239,68,68,.15); color: #fca5a5; }
.badge-muted { background: rgba(148,163,184,.15); color: #cbd5e1; }

.webhook-box {
  background: #0a1322; border: 1px dashed #334155; border-radius: 12px; padding: 1rem 1.1rem;
  display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.webhook-url { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; color: #7dd3fc; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.modal-content { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); }
.modal-header, .modal-footer { border-color: var(--border); }
.pre-json {
  background: #070d18; border: 1px solid var(--border); border-radius: 10px;
  padding: 1rem; max-height: 420px; overflow: auto; font-size: .82rem; color: #cbd5e1;
}

.toast-container { z-index: 1080; }
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
}
.auth-card { width: 100%; max-width: 420px; }

@media (max-width: 992px) {
  .sidebar { position: fixed; left: -100%; z-index: 40; transition: .2s ease; }
  .sidebar.open { left: 0; }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; }
  .sidebar-backdrop.show { display: block; }
}
