/* Riftoria panel — dark theme, no framework, no JS dependency for rendering. */

:root {
  --bg: #0b0f17;
  --bg-soft: #0f1521;
  --surface: #111827;
  --surface-2: #16202f;
  --border: rgba(148, 163, 184, 0.14);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #7c5cff;
  --accent-2: #2dd4bf;
  --warn: #f97316;
  --danger: #ef4444;
  --ok: #22c55e;
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
pre { overflow-x: auto; }

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

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; }
.brand .cube {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(160deg, var(--accent), #5b3ee0);
  font-size: 18px;
}
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: -0.01em; }

.user-chip {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.user-name { font-weight: 600; }
.user-role { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-link {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--muted); font-size: 13px;
}
.nav-link:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav-link.active { background: rgba(124, 92, 255, 0.16); color: #c4b5fd; font-weight: 600; }
.nav-icon { width: 16px; text-align: center; opacity: 0.9; }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.logout-form { margin: 0; }
.btn-link { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; font: inherit; }
.btn-link:hover { color: var(--danger); }

.content { flex: 1; min-width: 0; padding: 20px 24px 40px; }
.content-head { margin-bottom: 16px; }
.content-head h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.content-foot { margin-top: 28px; color: var(--muted); font-size: 11px; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
}
.card-head {
  padding: 10px 14px;
  font-weight: 700;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.card-body { padding: 14px; }

/* --------------------------------------------------------------- stats grid */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.stat-spark { margin-top: 4px; opacity: 0.9; height: 36px; }

.delta { font-size: 11px; font-weight: 700; }
.delta-up { color: var(--ok); }
.delta-down { color: var(--danger); }

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

.rift-chart { display: block; max-width: 100%; height: auto; }
.rift-empty { color: var(--muted); padding: 20px 0; text-align: center; }

/* ----------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 8px 10px;
  color: var(--muted); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(124, 92, 255, 0.05); }
.table-empty { text-align: center; color: var(--muted); padding: 24px; }

/* ----------------------------------------------------------------- badges */

.badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600; border: 1px solid transparent;
}
.badge-ok { background: rgba(34, 197, 94, 0.14); color: #86efac; border-color: rgba(34, 197, 94, 0.3); }
.badge-warn { background: rgba(249, 115, 22, 0.14); color: #fdba74; border-color: rgba(249, 115, 22, 0.3); }
.badge-danger { background: rgba(239, 68, 68, 0.14); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }
.badge-info { background: rgba(59, 130, 246, 0.14); color: #93c5fd; border-color: rgba(59, 130, 246, 0.3); }
.badge-muted { background: rgba(148, 163, 184, 0.12); color: var(--muted); border-color: var(--border); }

/* ----------------------------------------------------------------- forms */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field-label { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.input, select.input, textarea.input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font: inherit;
  width: 100%;
}
.input:focus { outline: 2px solid rgba(124, 92, 255, 0.5); border-color: var(--accent); }

.btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 3px 9px; font-size: 12px; }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.row-actions .inline { display: inline; margin: 0; }

.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.quick-actions form { margin: 0; display: flex; gap: 6px; align-items: center; }

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

.health-list { margin: 0; padding-left: 18px; }
.health-list li { margin: 3px 0; }

.flash { padding: 9px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; border: 1px solid; }
.flash-ok { background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.35); }
.flash-warn { background: rgba(249, 115, 22, 0.12); border-color: rgba(249, 115, 22, 0.35); }
.flash-danger { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.35); }
.flash-info { background: rgba(59, 130, 246, 0.12); border-color: rgba(59, 130, 246, 0.35); }

.muted { color: var(--muted); }
.link { color: var(--accent-2); }
.code-display {
  font-family: ui-monospace, monospace; font-size: 22px; font-weight: 700;
  letter-spacing: 0.14em; padding: 14px; text-align: center;
  background: var(--surface-2); border: 1px dashed var(--accent); border-radius: 10px;
}

.toast {
  position: fixed; right: 18px; bottom: 18px;
  background: var(--surface-2); border: 1px solid var(--accent);
  padding: 10px 14px; border-radius: 8px; opacity: 0;
  transition: opacity 0.2s ease; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; }

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

.login-page {
  display: grid; place-items: center; min-height: 100vh;
  background: radial-gradient(900px 500px at 50% -10%, rgba(124, 92, 255, 0.22), transparent 60%), var(--bg);
}
.login-card {
  width: min(380px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand h1 { font-size: 20px; margin: 0; }
.login-sub { color: var(--muted); font-size: 12px; margin: 2px 0 16px; }
.login-form { display: flex; flex-direction: column; }
.login-form .btn { margin-top: 6px; }
.login-foot { color: var(--muted); font-size: 11px; margin-top: 14px; }

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

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex: 0 0 auto; height: auto; position: static;
    flex-direction: row; align-items: center; overflow-x: auto; padding: 10px;
  }
  .brand { padding: 0 8px; }
  .user-chip, .sidebar-foot { display: none; }
  .nav { flex-direction: row; }
  .content { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}