:root {
  --bg-deep: #4163d0;
  --bg-gradient: linear-gradient(135deg, #4163d0 0%, #2a3f85 100%);
  --card-bg: rgba(255, 255, 255, 0.12);
  --card-border: rgba(255, 255, 255, 0.18);
  --fg: #e0ddef;
  --fg-muted: rgba(224, 221, 239, 0.7);
  --accent: #e6a5b8;
  --accent-hover: #f0b8c8;
  --danger: #e57373;
  --success: #81c784;
  --radius: 1rem;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-gradient);
  color: var(--fg);
}

body {
  min-height: 100dvh;
}

.hidden {
  display: none !important;
}

/* Login */
.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-card h1 {
  font-family: 'Pathway Extreme', system-ui, sans-serif;
  font-weight: 900;
  font-size: 2.25rem;
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--fg-muted);
  margin: 0 0 1.5rem;
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

/* Dashboard */
.dashboard {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--card-border);
}

.brand h1 {
  font-family: 'Pathway Extreme', system-ui, sans-serif;
  font-weight: 900;
  font-size: 1.5rem;
  margin: 0;
}

.controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 0.9rem;
}

.container {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  text-align: center;
}

.stat-card .value {
  font-family: 'Pathway Extreme', system-ui, sans-serif;
  font-size: 2.5rem;
  font-weight: 900;
  line-height: 1;
  margin: 0.5rem 0;
}

.stat-card .label {
  color: var(--fg-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Panels */
.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.panel h2 {
  font-family: 'Pathway Extreme', system-ui, sans-serif;
  font-size: 1.25rem;
  margin: 0 0 1rem;
}

.panel h2 small {
  color: var(--fg-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
  margin-bottom: 1rem;
}

.field span {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

input[type="password"],
input[type="text"] {
  padding: 0.65rem 0.85rem;
  border-radius: 0.6rem;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.15);
  color: var(--fg);
  font-size: 1rem;
  outline: none;
}

input[type="password"]:focus,
input[type="text"]:focus {
  border-color: var(--accent);
}

button {
  cursor: pointer;
  border: none;
  border-radius: 0.6rem;
  padding: 0.65rem 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform 0.05s, opacity 0.15s;
}

button:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #2b1a20;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.15);
  color: var(--fg);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Messages */
.message {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  min-height: 1.25rem;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--success);
}

/* RUM */
.rum-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.rum-metric {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 0.6rem;
  padding: 0.75rem;
  text-align: center;
}

.rum-metric .num {
  font-size: 1.5rem;
  font-weight: 800;
}

.rum-metric .name {
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.vital-bar {
  margin-bottom: 0.75rem;
}

.vital-bar label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.vital-bar .track {
  height: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.vital-bar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Config table */
.config-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.config-table th,
.config-table td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid var(--card-border);
}

.config-table th {
  color: var(--fg-muted);
  font-weight: 600;
}

.config-table td:first-child {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
}

.config-table .value-cell {
  width: 100%;
}

.config-table input {
  width: 100%;
}

.actions {
  display: flex;
  gap: 0.5rem;
}

.actions button {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.empty {
  color: var(--fg-muted);
  font-style: italic;
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .controls {
    width: 100%;
    justify-content: space-between;
  }
}
