:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d9dee7;
  --panel: #ffffff;
  --accent: #166534;
  --accent-text: #ffffff;
  --warn: #b45309;
  --danger: #b91c1c;
  --soft: #eef2f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  white-space: nowrap;
}

nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

nav a {
  color: var(--text);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 6px;
}

nav a:hover {
  background: var(--soft);
}

main {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto 48px;
}

h1 {
  font-size: 24px;
  margin: 0 0 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric,
.panel,
.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 16px;
}

.metric div,
.metric span,
.hint {
  color: var(--muted);
}

.status-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.token-warning {
  margin-top: 12px;
}

.token-warning ul {
  margin: 0;
  padding-left: 20px;
  color: var(--warn);
  font-weight: 600;
}

.intro-panel {
  padding: 18px;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.guide-card {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 2px 10px;
  min-height: 88px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  background: #fff;
}

.guide-card:hover {
  background: var(--soft);
}

.guide-card span {
  grid-row: span 2;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.guide-card strong {
  font-size: 14px;
}

.guide-card small,
.muted-text {
  color: var(--muted);
  font-size: 12px;
}

.secret-form {
  margin-top: 14px;
}

.compact-form {
  margin-bottom: 14px;
}

.advanced-settings {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.advanced-settings summary {
  cursor: pointer;
  font-weight: 700;
}

.advanced-settings[open] summary {
  margin-bottom: 12px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.metric strong {
  display: block;
  font-size: 28px;
  margin: 2px 0;
}

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

.panel-title {
  font-weight: 700;
  margin-bottom: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

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

code {
  background: var(--soft);
  border-radius: 5px;
  padding: 2px 5px;
}

form {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-check {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  white-space: nowrap;
}

.inline-check input {
  width: auto;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

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

textarea {
  min-height: 120px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.plain-textarea {
  min-height: 72px;
  font-family: inherit;
  font-size: 14px;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  filter: brightness(0.95);
}

.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  text-decoration: none;
}

.secondary-link {
  background: var(--soft);
  color: var(--text);
}

.small-link {
  min-height: 34px;
  padding: 7px 10px;
}

.danger-button {
  background: var(--danger);
}

.plan-limit {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.plan-limit legend {
  padding: 0 4px;
  color: var(--text);
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  background: #dcfce7;
  color: #166534;
}

.badge.warn {
  background: #fef3c7;
  color: var(--warn);
}

.badge.muted {
  background: #e5e7eb;
  color: #4b5563;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(420px, calc(100vw - 32px));
  padding: 22px;
}

.error {
  color: var(--danger);
  font-weight: 700;
}

@media (max-width: 820px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 12px;
  }

  nav {
    flex-wrap: wrap;
  }

  .metric-grid,
  .guide-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
