:root {
  color-scheme: dark;
  --bg: #1b1e24;
  --surface: #242832;
  --border: #343a46;
  --text: #e6e8ec;
  --muted: #9aa1ad;
  --accent: #7fbf5f;
  --accent-dim: #4d7a3a;
  --error: #e06c60;
  --warn: #e0b25f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
}

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

.topbar nav .spacer {
  flex: 1;
}

.topbar a {
  color: var(--muted);
  text-decoration: none;
}

.topbar a.active,
.topbar a:hover {
  color: var(--text);
}

.inline {
  display: inline;
}

.linklike {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.linklike:hover {
  color: var(--text);
}

main {
  max-width: 75rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

h1 {
  font-size: 1.4rem;
}

h2 {
  font-size: 1.05rem;
  margin-top: 1.75rem;
}

.status-banner {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: inline-block;
}

.banner-row {
  display: flex;
  align-items: stretch;
  gap: 1rem;
}

.banner-row > *,
.banner-row .status-banner {
  margin: 0;
}

.banner-row .status-banner {
  display: flex;
  align-items: center;
}

.banner-row form.inline {
  display: flex;
}

.banner-row button[type="submit"] {
  padding: 0.5rem 0.75rem;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.tiles-two {
  grid-template-columns: repeat(2, 1fr);
}

/* First-view split: stats left (1/3), event log right (2/3) - stacks on narrow screens */
.dashboard-split {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1.75rem;
  align-items: start;
  margin-top: 1.25rem;
}

.dashboard-split .tiles {
  margin-top: 0;
}

.dashboard-split h2 {
  margin-top: 0;
}

.no-top-margin {
  margin-top: 0;
}

@media (max-width: 50rem) {
  .dashboard-split {
    grid-template-columns: 1fr;
  }

  .cores {
    grid-template-columns: 1fr;
  }
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.tile-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.tile-value {
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bar {
  background: var(--border);
  border-radius: 4px;
  height: 0.85rem;
  overflow: hidden;
  min-width: 8rem;
}

.bar-fill {
  background: var(--accent);
  height: 100%;
}

/* Two cores per visual row (1+2, 3+4, ...) like the Discord card */
.cores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 1.5rem;
}

.core-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr 3.5rem;
  align-items: center;
  gap: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.core-label,
.core-percent {
  color: var(--muted);
  font-size: 0.9rem;
}

.core-percent {
  text-align: right;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 1rem;
}

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

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2rem;
}

.event-log {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.event-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-right: 0.35rem;
}

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

.status-banner.warn {
  border-color: var(--warn);
}

.status-banner.error-banner {
  border-color: var(--error);
}

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

.badge {
  border-radius: 999px;
  font-size: 0.75rem;
  padding: 0.15rem 0.6rem;
  white-space: nowrap;
}

.badge.default {
  background: var(--border);
  color: var(--muted);
}

.badge.env {
  background: #2c4a63;
  color: #a8cbe8;
}

.badge.override {
  background: var(--accent-dim);
  color: #d9f0cc;
}

.badge.excluded {
  background: #5c3535;
  color: #e8b3ac;
}

.settings-table td {
  vertical-align: middle;
}

.setting-key code {
  font-size: 0.85rem;
}

.actions-cell {
  white-space: nowrap;
}

.actions-cell form {
  display: inline-block;
}

.actions-cell form + form {
  margin-left: 0.5rem;
}

.save-row {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 0.75rem 0;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.login-card {
  max-width: 22rem;
  margin: 4rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

input,
select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.5rem 0.65rem;
  font: inherit;
}

button[type="submit"] {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--text);
  padding: 0.55rem 1rem;
  font: inherit;
  cursor: pointer;
}

button[type="submit"]:hover {
  background: var(--accent);
  color: #10130d;
}

/* Danger buttons - defined last so they win the source-order tie against the
   generic green button[type="submit"] rule (equal specificity) */
button.btn-danger {
  background: #6e2a24;
  border: 1px solid var(--error);
  border-radius: 6px;
  color: #ffffff;
  padding: 0.3rem 0.85rem;
  min-width: 4.5rem;
  font: inherit;
  cursor: pointer;
}

button.btn-danger:hover {
  background: var(--error);
  color: #ffffff;
}
