:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --text: #171a1f;
  --muted: #667085;
  --line: #d9dee7;
  --line-soft: #e8ebf0;
  --accent: #1769aa;
  --accent-dark: #0f4f83;
  --ok: #157347;
  --warn: #a15c07;
  --down: #b42318;
  --unknown: #5f6470;
  --shadow: 0 16px 44px rgba(18, 32, 53, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 650;
  padding: 9px 12px;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

button.secondary:hover {
  background: var(--panel-soft);
}

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

a:hover {
  text-decoration: underline;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #101828;
  color: #f9fafb;
  padding: 20px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  padding: 0 8px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  color: #101828;
  font-weight: 800;
}

.brand-title {
  font-size: 15px;
  font-weight: 750;
}

.brand-subtitle {
  color: #cbd5e1;
  font-size: 12px;
}

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

.nav button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  border-radius: 7px;
  background: transparent;
  color: #d0d5dd;
  justify-content: flex-start;
  padding: 10px 11px;
  text-align: left;
}

.nav button:hover,
.nav button.active {
  background: #1d2939;
  color: #fff;
}

.nav-icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: #9fb2c8;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 249, 0.94);
  padding: 18px 28px;
  backdrop-filter: blur(10px);
}

h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 780;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 730;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 730;
}

p {
  margin: 0;
}

#page-description {
  margin-top: 4px;
  color: var(--muted);
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.session-user {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.token-form {
  display: grid;
  grid-template-columns: auto minmax(180px, 260px) auto;
  align-items: end;
  gap: 8px;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

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

textarea {
  min-height: 120px;
  resize: vertical;
}

.notice {
  margin: 20px 28px 0;
  border: 1px solid #c8d7ea;
  border-radius: var(--radius);
  background: #eef6ff;
  color: #123b63;
  padding: 12px 14px;
}

.notice.error {
  border-color: #f4c7c3;
  background: #fff1f0;
  color: #8a1f16;
}

.content {
  padding: 24px 28px 42px;
}

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

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

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

.panel {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
  padding: 16px 18px;
}

.panel-body {
  padding: 16px 18px;
}

.metric {
  display: grid;
  gap: 8px;
  min-height: 112px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-value {
  font-size: 30px;
  font-weight: 780;
}

.metric-foot {
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.field {
  display: grid;
  min-width: 160px;
  gap: 5px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

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

th {
  background: var(--panel-soft);
  color: #344054;
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

td {
  color: #202631;
}

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

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  padding: 4px 8px;
  text-transform: lowercase;
}

.status.ok,
.status.active,
.status.published,
.status.approved,
.status.completed {
  background: #e8f5ee;
  color: var(--ok);
}

.status.degraded,
.status.draft,
.status.pending,
.status.running {
  background: #fff4df;
  color: var(--warn);
}

.status.down,
.status.failed,
.status.archived,
.status.error {
  background: #fff1f0;
  color: var(--down);
}

.status.unknown {
  background: #eef0f3;
  color: var(--unknown);
}

.split {
  display: grid;
  grid-template-columns: minmax(260px, 380px) minmax(0, 1fr);
  gap: 16px;
}

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

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

.empty {
  color: var(--muted);
  padding: 18px;
}

.tree {
  display: grid;
  gap: 10px;
}

.tree-node {
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #fff;
  padding: 12px;
}

.tree-node-title {
  font-weight: 750;
}

.tree-node-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.article-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.article-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-radius: 6px;
  background: var(--panel-soft);
  padding: 8px 10px;
}

.raw {
  overflow: auto;
  max-height: 320px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #0b1220;
  color: #d6e2ff;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  padding: 12px;
  white-space: pre-wrap;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(16, 24, 40, 0.72);
  padding: 20px;
}

.login-overlay[hidden] {
  display: none;
}

.login-card {
  display: grid;
  width: min(420px, 100%);
  gap: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
  padding: 26px;
}

.login-brand {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #101828;
  color: #fff;
  font-weight: 800;
}

.login-card h2 {
  margin: 0;
}

.login-card p {
  color: var(--muted);
}

.login-error {
  border: 1px solid #f4c7c3;
  border-radius: 7px;
  background: #fff1f0;
  color: #8a1f16;
  padding: 10px 12px;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .topbar,
  .token-form,
  .split,
  .grid.cols-2,
  .grid.cols-3 {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    display: grid;
  }
}

@media (max-width: 560px) {
  .content,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .notice {
    margin-left: 16px;
    margin-right: 16px;
  }

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