:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #687586;
  --line: #dde3ea;
  --primary: #146c94;
  --primary-dark: #0f5575;
  --danger: #b42318;
  --warning: #9a6700;
  --success: #107c41;
  --shadow: 0 1px 2px rgba(20, 31, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
}

.sidebar {
  background: #1f2933;
  color: #eef2f6;
  padding: 22px 18px;
}

.brand {
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 24px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a,
.logout-button {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #d8e0e8;
  padding: 10px 12px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.nav a:hover,
.logout-button:hover {
  background: #344250;
  text-decoration: none;
}

.content {
  min-width: 0;
  padding: 26px 30px 42px;
}

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

.title h1 {
  margin: 0 0 6px;
  font-size: 26px;
  line-height: 1.2;
}

.title p {
  margin: 0;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.panel,
.stat,
.auth-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.panel h3 {
  margin: 8px 0 0;
  font-size: 15px;
}

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

.panel-heading h2,
.panel-heading p {
  margin: 0;
}

.panel-heading p {
  margin-top: 4px;
}

.status-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.status-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.up,
.status-segment.up {
  background: #2da44e;
}

.legend-dot.down,
.status-segment.down {
  background: #cf222e;
}

.legend-dot.degraded,
.status-segment.degraded {
  background: #d29922;
}

.legend-dot.unknown,
.status-segment.unknown {
  background: #d8dee6;
}

.legend-dot.disabled,
.status-segment.disabled {
  background: #9aa6b2;
}

.status-board {
  display: grid;
  gap: 12px;
}

.status-lane {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(220px, 1fr) 92px;
  gap: 14px;
  align-items: center;
}

.status-lane-info {
  min-width: 0;
}

.status-lane-info a {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.status-track {
  display: grid;
  grid-template-columns: repeat(144, minmax(2px, 1fr));
  gap: 2px;
  min-height: 34px;
  align-items: stretch;
}

.status-segment {
  display: block;
  min-width: 2px;
  border-radius: 2px;
}

.status-metric {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.status-metric strong {
  font-size: 15px;
}

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

.token-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.token-list code {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f4f7fa;
  padding: 4px 7px;
  color: #273746;
}

.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mini-actions {
  display: inline-flex;
  gap: 6px;
}

.small-button {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.stat {
  padding: 16px;
}

.stat .label {
  color: var(--muted);
  font-size: 13px;
}

.stat .value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 6px;
}

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

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #edf2f7;
  color: #344250;
  font-size: 12px;
  white-space: nowrap;
}

.badge.success {
  background: #e7f6ec;
  color: var(--success);
}

.badge.error {
  background: #fdecec;
  color: var(--danger);
}

.badge.warning {
  background: #fff5d6;
  color: var(--warning);
}

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

.small {
  font-size: 12px;
}

.flash {
  margin-bottom: 16px;
  padding: 11px 13px;
  border-radius: 7px;
  border: 1px solid #b8dcc5;
  background: #ecf8f0;
  color: #0b5d2a;
}

.flash.error {
  border-color: #f0b8b8;
  background: #fff0f0;
  color: var(--danger);
}

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

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cdd6df;
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

textarea {
  min-height: 112px;
  resize: vertical;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: auto;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.button:hover,
button:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

.button.secondary,
button.secondary {
  background: #fff;
  color: var(--primary);
}

.button.secondary:hover,
button.secondary:hover {
  background: #eef7fb;
}

.button.danger,
button.danger {
  border-color: var(--danger);
  background: #fff;
  color: var(--danger);
}

.button.danger:hover,
button.danger:hover {
  background: #fff0f0;
}

.inline-form {
  display: inline;
}

.sync-link-actions {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.sync-link-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.sync-link-action-row.danger-row {
  padding-top: 2px;
}

button.solid-danger {
  background: var(--danger);
  color: #fff;
}

button.solid-danger:hover {
  background: #8f1d14;
}

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

.auth-box {
  width: min(420px, 100%);
  padding: 24px;
}

.auth-box h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.auth-box form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.code {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  background: #f1f4f7;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .stats,
  .grid.two,
  .grid.three,
  .variable-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .panel-heading,
  .status-lane {
    grid-template-columns: 1fr;
  }

  .status-legend {
    justify-content: flex-start;
  }

  .status-track {
    grid-template-columns: repeat(144, 5px);
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .status-metric {
    justify-items: start;
  }
}
