:root {
  color-scheme: light dark;
  --bg: #f6f1e8;
  --panel: #fffaf0;
  --panel-2: #eee4d5;
  --ink: #18171b;
  --muted: #6e6871;
  --line: #202536;
  --shadow: #202536;
  --green: #1b9b5d;
  --yellow: #a86f00;
  --red: #c43d2c;
  --blue: #2458d8;
  --button: #101827;
  --button-ink: #fffaf0;
  font-family: "Courier New", Courier, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101014;
    --panel: #1b1a20;
    --panel-2: #252230;
    --ink: #f4f1df;
    --muted: #b8b3a2;
    --line: #4b4655;
    --shadow: #050507;
    --green: #75e36f;
    --yellow: #ffd55f;
    --red: #ff6b57;
    --blue: #6fc3ff;
    --button: #f4f1df;
    --button-ink: #111016;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--ink) 6%, transparent) 1px, transparent 1px),
    linear-gradient(color-mix(in srgb, var(--ink) 6%, transparent) 1px, transparent 1px),
    var(--bg);
  background-size: 24px 24px;
  line-height: 1.55;
}

a {
  color: inherit;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  background: var(--yellow);
  color: var(--bg);
  padding: 8px 12px;
  z-index: 10;
}

.skip-link:focus {
  top: 16px;
}

.topbar,
.dashboard-head,
.panel-section,
.admin-section {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding-inline: clamp(16px, 4vw, 32px);
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 900;
}

.brand-icon {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  border: 3px solid var(--line);
  box-shadow: 4px 4px 0 var(--shadow);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 14px;
  border: 3px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--shadow);
  font: inherit;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

.button.primary {
  background: var(--button);
  color: var(--button-ink);
}

.button.danger {
  border-color: var(--red);
}

.button:hover {
  transform: translate(1px, 1px);
}

.dashboard-head {
  display: grid;
  gap: 20px;
  padding-block: 28px 24px;
}

.section-heading {
  display: grid;
  gap: 10px;
}

.compact-heading {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.compact-heading p {
  grid-column: 1 / -1;
}

h1,
h2,
h3,
p {
  margin: 0;
  overflow-wrap: anywhere;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.5rem);
  line-height: 1;
  text-shadow: 4px 4px 0 color-mix(in srgb, var(--shadow) 35%, transparent);
}

h2 {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
}

.hero-text,
.section-heading p,
.console-session,
.admin-message {
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.summary-card,
.monitor-row,
.admin-form,
.auth-panel {
  border: 4px solid var(--line);
  background: var(--panel);
  box-shadow: 6px 6px 0 var(--shadow);
}

.summary-card {
  min-height: 110px;
  padding: 16px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-weight: 900;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  color: var(--green);
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1;
}

.panel-section,
.admin-section {
  padding-block: 20px 56px;
}

.monitor-table {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.monitor-row {
  display: grid;
  grid-template-columns: 78px 150px minmax(200px, 1fr) 86px 80px 154px 156px minmax(112px, auto);
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 12px;
}

.monitor-row-head {
  min-height: 42px;
  background: var(--panel-2);
  color: var(--blue);
  font-weight: 900;
}

.monitor-row a,
.monitor-row time {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.status-badge {
  display: inline-flex;
  justify-content: center;
  padding: 4px 8px;
  background: var(--yellow);
  color: var(--bg);
  font-weight: 900;
  box-shadow: 3px 3px 0 var(--shadow);
}

.status-ok {
  background: var(--green);
}

.status-down {
  background: var(--red);
}

.sparkline {
  display: grid;
  grid-template-columns: repeat(24, 5px);
  gap: 2px;
  align-items: end;
}

.spark {
  display: block;
  width: 5px;
  height: 26px;
  background: var(--line);
}

.spark.ok {
  background: var(--green);
}

.spark.watch {
  background: var(--yellow);
}

.spark.down {
  background: var(--red);
}

.empty-state {
  margin: 0;
  padding: 22px;
  border: 4px dashed var(--line);
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 75%, transparent);
}

.row-actions,
.form-actions,
.console-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.row-actions .button {
  min-height: 34px;
  padding: 5px 9px;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.admin-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 900;
}

.admin-form input,
.admin-form select {
  width: 100%;
  min-height: 44px;
  border: 3px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  padding: 8px 10px;
}

.form-actions,
.admin-message {
  grid-column: 1 / -1;
}

.admin-form label:nth-of-type(1),
.admin-form label:nth-of-type(2) {
  grid-column: span 2;
}

.admin-form label:nth-of-type(3),
.admin-form label:nth-of-type(4) {
  grid-column: span 2;
}

.auth-page {
  min-height: 100vh;
}

.auth-shell {
  display: grid;
  align-content: center;
  gap: 24px;
  width: min(680px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.auth-panel {
  display: grid;
  gap: 16px;
  padding: 20px;
}

@media (max-width: 920px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .monitor-table {
    overflow-x: auto;
    padding-bottom: 10px;
  }

  .monitor-row {
    min-width: 1040px;
  }
}

@media (max-width: 1080px) {
  .admin-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .topbar,
  .console-nav,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-heading {
    grid-template-columns: 1fr;
  }

  .summary-grid,
  .admin-form {
    grid-template-columns: 1fr;
  }
}
