:root {
  color-scheme: dark;
  --bg: #100a18;
  --panel: #171025;
  --panel-strong: #211436;
  --border: #463160;
  --text: #f7f1ff;
  --muted: #b8aacb;
  --green: #b884ff;
  --green-soft: rgba(184, 132, 255, 0.16);
  --red: #ff6f7d;
  --red-soft: rgba(255, 111, 125, 0.14);
  --gold: #f2c96d;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 0%, rgba(184, 132, 255, 0.16), transparent 32rem),
    linear-gradient(135deg, #0f0818 0%, #160d24 42%, #17121d 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.shell {
  min-height: 100vh;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(33, 20, 54, 0.96), rgba(18, 11, 30, 0.96));
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--green), #7c52cf);
  box-shadow: 0 0 28px rgba(184, 132, 255, 0.34);
}

h1,
h2,
p {
  margin-top: 0;
}

.login-panel h1 {
  margin: 18px 0 24px;
  font-size: 2rem;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.login-form input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  color: var(--text);
  background: #100a18;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
}

.login-form input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.login-form button,
.secondary-button {
  min-height: 40px;
  padding: 0 16px;
  color: #14091f;
  font-weight: 700;
  background: linear-gradient(180deg, #d6bcff, var(--green));
  border: 0;
  border-radius: 6px;
}

.secondary-button {
  color: var(--text);
  background: #1b122b;
  border: 1px solid var(--border);
}

.dashboard-view {
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 2.6rem);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  color: var(--muted);
  background: #1b122b;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.toggle input {
  position: absolute;
  opacity: 0;
}

.toggle span {
  position: relative;
  width: 42px;
  height: 22px;
  border-radius: 999px;
  background: var(--red-soft);
  border: 1px solid rgba(255, 111, 125, 0.45);
}

.toggle span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--red);
  transition: transform 140ms ease, background 140ms ease;
}

.toggle input:checked + span {
  background: var(--green-soft);
  border-color: rgba(184, 132, 255, 0.5);
}

.toggle input:checked + span::after {
  transform: translateX(20px);
  background: var(--green);
}

.metrics-grid,
.content-grid,
.table-grid {
  display: grid;
  gap: 14px;
}

.metrics-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.content-grid {
  grid-template-columns: minmax(0, 2fr) minmax(300px, 0.9fr);
  margin-bottom: 14px;
}

.table-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.metric-panel,
.chart-panel,
.status-panel,
.table-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(33, 20, 54, 0.92), rgba(17, 10, 28, 0.92));
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
}

.metric-panel {
  min-height: 104px;
  padding: 18px;
}

.metric-panel span,
.panel-heading span,
.status-list dt,
.empty-note {
  color: var(--muted);
}

.metric-panel strong {
  display: block;
  margin-top: 10px;
  font-size: 1.7rem;
}

.chart-panel,
.status-panel,
.table-panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.pill {
  padding: 4px 8px;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid rgba(184, 132, 255, 0.34);
  border-radius: 999px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  min-height: 260px;
}

.status-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.status-list dd {
  margin: 0;
  text-align: right;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(70, 49, 96, 0.72);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.positive {
  color: var(--green);
}

.negative,
.error-line {
  color: var(--red);
}

.action-status {
  min-height: 22px;
  margin: 16px 0 0;
  color: var(--muted);
}

.empty-note {
  margin-bottom: 0;
}

[hidden] {
  display: none !important;
}

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

  .topbar-actions {
    justify-content: flex-start;
  }

  .metrics-grid,
  .content-grid,
  .table-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .dashboard-view,
  .login-view {
    padding: 14px;
  }

  .login-panel,
  .chart-panel,
  .status-panel,
  .table-panel,
  .metric-panel {
    padding: 14px;
  }
}
