:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --ink: #111827;
  --muted: #667085;
  --line: #d0d5dd;
  --line-soft: #e4e7ec;
  --accent: #2563eb;
  --accent-ink: #1d4ed8;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --alert: #b42318;
  --alert-bg: #fef3f2;
  --info: #175cd3;
  --info-bg: #eff8ff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Avenir Next", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  overflow-x: hidden;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; }

.login-view {
  display: grid;
  min-height: 100svh;
  place-items: center;
  padding: 22px;
}
.login-panel {
  width: min(430px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(16, 24, 40, 0.12);
}
.login-panel h1 { margin: 0 0 8px; font-size: 1.7rem; letter-spacing: 0; }
.login-copy { margin: 0 0 18px; color: var(--muted); line-height: 1.5; }
.form-stack { display: grid; gap: 12px; }
.form-stack label { display: grid; gap: 6px; color: var(--muted); font-size: 0.82rem; font-weight: 800; }
.form-stack input, select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}
.form-stack input:focus, select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.18);
  border-color: var(--accent);
}
.form-error { min-height: 18px; margin: 0; color: var(--alert); font-size: 0.86rem; }

.app-shell {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: #101828;
  color: #f9fafb;
}
.brand-lockup {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 4px 6px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.14);
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #2563eb;
  object-fit: cover;
}
.brand-kicker, .label, .eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sidebar .brand-kicker, .sidebar .label { color: #98a2b3; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; font-size: 1rem; line-height: 1.2; letter-spacing: 0; }
h2 { margin: 0; font-size: 1.35rem; line-height: 1.25; letter-spacing: 0; }
h3 { margin: 0; font-size: 0.98rem; line-height: 1.35; letter-spacing: 0; }
.side-nav { display: grid; gap: 3px; }
.side-nav a {
  display: block;
  padding: 9px 10px;
  border-radius: 6px;
  color: #d0d5dd;
  font-weight: 650;
}
.side-nav a:hover, .side-nav a.is-active { color: #fff; background: rgba(255,255,255,0.12); text-decoration: none; }
.sidebar-footer {
  display: grid;
  gap: 6px;
  margin-top: auto;
  padding: 12px 8px 4px;
  border-top: 1px solid rgba(255,255,255,0.14);
}
.sidebar-footer a { color: #d1e9ff; font-size: 0.86rem; }
.workspace { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(230px, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 72px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.96);
  box-shadow: var(--shadow);
}
.topbar-group {
  display: grid;
  gap: 5px;
}
.topbar-group label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.topbar-status { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.user-chip, .button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-subtle);
  color: var(--ink);
  font-weight: 750;
}
.button { cursor: pointer; }
.form-stack .button,
.sso-button { width: 100%; }
.sso-button { margin-top: 10px; }
.button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.icon-button { cursor: pointer; }
main {
  display: grid;
  gap: 22px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px;
}
.page-section { scroll-margin-top: 92px; }
.section-heading, .panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 12px;
}
.section-note, .muted { color: var(--muted); }
.panel, .metric-card, .card, .list-item {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel { padding: 16px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-card { padding: 14px; min-height: 92px; }
.metric-card strong { display: block; margin-top: 8px; font-size: 1.75rem; letter-spacing: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.cards.compact { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card { padding: 14px; }
.card-title { margin: 8px 0 6px; }
.meta { margin: 0; color: var(--muted); line-height: 1.5; }
.split-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.stack-list { display: grid; gap: 10px; }
.list-item { padding: 12px; }
.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--info);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.status.configured, .status.operational, .status.ready, .status.active { background: var(--ok-bg); color: var(--ok); }
.status.warning, .status.planned { background: var(--warn-bg); color: var(--warn); }
.status.alert, .status.error, .status.failed { background: var(--alert-bg); color: var(--alert); }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
  }
  .side-nav, .sidebar-footer { display: flex; overflow-x: auto; }
  .side-nav, .sidebar-footer, .brand-lockup { max-width: 100%; min-width: 0; }
  .brand-lockup { border-bottom: 0; padding-bottom: 4px; }
  .workspace, .topbar, main {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
  }
  .topbar { grid-template-columns: 1fr; align-items: stretch; }
  .topbar-status { justify-content: flex-start; flex-wrap: wrap; }
  .metric-grid, .split-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  body { font-size: 13px; }
  main { padding: 14px; gap: 14px; }
  .panel { padding: 12px; }
  .section-heading, .panel-heading { display: grid; gap: 6px; }
  .cards.compact, .cards { grid-template-columns: 1fr; }
}
