:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #1b1f24;
  --muted: #6b7280;
  --border: #e2e5e9;
  --accent: #2563eb;
  --ok: #16a34a;
  --warning: #d97706;
  --critical: #dc2626;
  --unknown: #6b7280;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1c1f24;
    --text: #e6e8eb;
    --muted: #9aa1ab;
    --border: #2a2e35;
    --accent: #5b8def;
  }
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

header.topbar .brand-group { display: flex; align-items: center; gap: 1.25rem; }
header.topbar .brand { font-weight: 600; color: var(--text); }
header.topbar .brand:hover { text-decoration: none; }
header.topbar .nav-link { color: var(--muted); font-size: 0.9rem; }
header.topbar .who { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); font-size: 0.9rem; }
header.topbar .role-badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

main { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
}

.empty-state { color: var(--muted); text-align: center; padding: 3rem 1rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.02em; }

.dot { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; margin-right: 0.4rem; }
.dot.ok { background: var(--ok); }
.dot.warning { background: var(--warning); }
.dot.critical { background: var(--critical); }
.dot.unknown { background: var(--unknown); }

form.stack { display: flex; flex-direction: column; gap: 0.9rem; max-width: 320px; margin: 3rem auto; }
form.stack label { font-size: 0.85rem; color: var(--muted); }
form.stack input {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
form.stack button {
  padding: 0.6rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  cursor: pointer;
}
form.stack button:hover { opacity: 0.92; }

.error-message {
  background: color-mix(in srgb, var(--critical) 12%, transparent);
  border: 1px solid var(--critical);
  color: var(--critical);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
}

.login-title { text-align: center; font-weight: 600; font-size: 1.3rem; margin-bottom: 0.5rem; }

button.link-button {
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.9rem; padding: 0;
}
button.link-button:hover { color: var(--text); text-decoration: underline; }

.panel-title { margin: 0 0 1rem; font-size: 1rem; font-weight: 600; }

.inline-form { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.inline-form div { display: flex; flex-direction: column; gap: 0.3rem; }
.inline-form label { font-size: 0.85rem; color: var(--muted); }
.inline-form input {
  padding: 0.5rem 0.65rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); font-size: 0.95rem; min-width: 220px;
}
.inline-form button {
  padding: 0.55rem 1.1rem; border: none; border-radius: 6px; background: var(--accent);
  color: white; font-size: 0.95rem; cursor: pointer; height: fit-content;
}

.token-banner { margin-bottom: 1.5rem; border-color: var(--accent); }
.token-value {
  display: block; margin: 0.6rem 0; padding: 0.6rem 0.8rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem;
  word-break: break-all; user-select: all;
}
.token-banner .hint { color: var(--muted); font-size: 0.85rem; margin: 0; }
.token-banner .hint code { background: var(--bg); padding: 0.05rem 0.35rem; border-radius: 4px; }

.meta-grid { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.2rem; margin: 0; }
.meta-grid dt { color: var(--muted); font-size: 0.85rem; }
.meta-grid dd { margin: 0; }

.row-actions { display: flex; gap: 0.9rem; justify-content: flex-end; }

.yaml-view, .diff-view {
  width: 100%; padding: 0.9rem; margin: 0; overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem; line-height: 1.5;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
  white-space: pre;
}

.diff-view .diff-add { color: var(--ok); }
.diff-view .diff-del { color: var(--critical); }

.yaml-editor {
  width: 100%; min-height: 320px; padding: 0.9rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem; line-height: 1.5; tab-size: 2;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); resize: vertical;
}
.instance { color: var(--muted); font-size: 0.85rem; margin-left: 0.3rem; }
.message-cell { color: var(--muted); max-width: 320px; }
