:root {
  color-scheme: dark;
  --bg: #090d14;
  --panel: #101722;
  --panel-2: #151d2a;
  --panel-3: #0c121b;
  --ink: #edf2f8;
  --muted: #9aa8ba;
  --line: #223044;
  --blue: #5b8cff;
  --green: #42d392;
  --amber: #f0b84a;
  --red: #ff6b6b;
  --shadow: 0 16px 34px rgba(0, 0, 0, 0.22);
  --sidebar-width: 236px;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "SFMono-Regular", "Roboto Mono", "Cascadia Code", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(91, 140, 255, 0.08), transparent 34rem),
    linear-gradient(180deg, #0b1018 0%, var(--bg) 45%);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--blue);
  color: #06101f;
  font-size: 14px;
  font-weight: 750;
  line-height: 1;
  cursor: pointer;
  transition: filter 0.16s ease, transform 0.16s ease;
}

button.secondary {
  background: #202b3b;
  color: var(--ink);
}

button:hover:not(:disabled) {
  filter: brightness(1.08);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 16px;
  border-right: 1px solid var(--line);
  background: rgba(9, 13, 20, 0.94);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-block strong {
  display: block;
  font-size: 15px;
  font-weight: 780;
  line-height: 1.15;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(91, 140, 255, 0.42);
  border-radius: 9px;
  background: rgba(91, 140, 255, 0.16);
  color: #dce8ff;
  font-size: 13px;
  font-weight: 820;
}

.nav-list {
  display: grid;
  gap: 4px;
  margin-top: 28px;
}

.nav-list a {
  min-height: 38px;
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 690;
}

.nav-list a:hover,
.nav-list a.active {
  background: #182334;
  color: var(--ink);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: var(--panel-3);
  color: #c8d2df;
  font-size: 13px;
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(66, 211, 146, 0.12);
}

.content-shell {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 24, 35, 0.92);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
  line-height: 1.25;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  font-weight: 760;
  line-height: 1.1;
}

h2 {
  font-size: 17px;
  font-weight: 730;
  line-height: 1.25;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

main {
  max-width: 1220px;
  margin: 0 auto;
  padding: 24px 24px 32px;
}

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

.metric,
.index-panel,
.checks-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.metric:hover,
.index-panel:hover,
.check:hover {
  border-color: #34445c;
}

.metric {
  min-height: 104px;
  padding: 15px;
}

.metric span,
.field label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  line-height: 1.25;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 9px;
  font-size: 23px;
  font-weight: 760;
  line-height: 1.1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.metric small,
.section-header p,
.index-meta,
.check-message {
  color: var(--muted);
  line-height: 1.45;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 28px 0 12px;
}

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

.index-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.index-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.index-title {
  font-size: 19px;
  font-weight: 760;
  line-height: 1.2;
}

.index-meta {
  margin-top: 4px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 760;
  line-height: 1;
  white-space: nowrap;
}

.ok {
  color: var(--green);
  background: rgba(66, 211, 146, 0.13);
}

.warn {
  color: var(--amber);
  background: rgba(240, 184, 74, 0.14);
}

.bad {
  color: var(--red);
  background: rgba(255, 107, 107, 0.13);
}

.bad-text {
  color: var(--red);
}

.muted {
  color: #a9b6c8;
  background: #202b3b;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  border: 1px solid rgba(38, 51, 70, 0.72);
  border-radius: 9px;
  padding: 10px 11px;
  background: rgba(21, 29, 42, 0.62);
}

.toggle-row strong,
.check-name {
  font-size: 14px;
  font-weight: 730;
  line-height: 1.35;
}

.switch {
  position: relative;
  width: 48px;
  height: 28px;
}

.switch input {
  opacity: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: #334156;
  border-radius: 999px;
  cursor: pointer;
}

.slider::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #edf2f8;
  transition: transform 0.16s ease;
}

.switch input:checked + .slider {
  background: var(--green);
}

.switch input:checked + .slider::after {
  transform: translateX(20px);
}

.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.risk-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 2px 0 12px;
}

.risk-summary > div {
  border: 1px solid var(--border);
  padding: 9px;
}

.risk-summary span,
.risk-summary small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.risk-summary strong {
  display: block;
  margin: 3px 0;
}

.field input {
  width: 100%;
  margin-top: 5px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--panel-2);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 14px;
}

.advanced {
  margin: 4px 0 10px;
  border-top: 1px solid rgba(38, 51, 70, 0.72);
}

.advanced summary {
  min-height: 34px;
  padding-top: 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 720;
  list-style-position: inside;
}

.compact-fields {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 2px;
}

.field input:focus {
  border-color: var(--blue);
  outline: 2px solid rgba(91, 140, 255, 0.18);
}

.status-line {
  display: grid;
  gap: 7px;
  min-height: 44px;
  padding-top: 3px;
  color: #c8d2df;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.checks-section {
  margin-top: 26px;
  padding: 16px;
}

.checks-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.checks-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.check {
  border: 1px solid var(--line);
  background: rgba(21, 29, 42, 0.62);
  border-radius: 8px;
  padding: 10px;
}

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

.check-message {
  margin-top: 6px;
  font-size: 12px;
}

dialog {
  background: var(--panel);
  color: var(--ink);
  width: min(420px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.dialog-body {
  padding: 18px;
}

.dialog-body input {
  width: 100%;
  min-height: 42px;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: var(--panel-2);
  color: var(--ink);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(440px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 12px 14px;
  background: #edf2f8;
  color: #090d14;
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.45;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 8, 13, 0.82);
  backdrop-filter: blur(12px);
}

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

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel h2 {
  margin-top: 2px;
}

.login-copy {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.login-panel input {
  width: 100%;
  min-height: 44px;
  margin: 16px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel-2);
  color: var(--ink);
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 7;
    height: auto;
    padding: 14px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    display: flex;
    gap: 6px;
    margin-top: 14px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-list a {
    flex: 0 0 auto;
  }

  .sidebar-footer {
    display: none;
  }

  .topbar {
    position: relative;
    top: auto;
  }

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

}

@media (max-width: 680px) {
  body {
    font-size: 14px;
  }

  .brand-block {
    min-height: 40px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 12px;
  }

  .brand-block strong {
    font-size: 14px;
  }

  .nav-list {
    margin-left: -2px;
    margin-right: -2px;
  }

  .nav-list a {
    min-height: 34px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .topbar {
    gap: 12px;
    padding: 14px 16px;
  }

  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .top-actions button,
  .top-actions .status-pill {
    min-height: 38px;
  }

  main {
    padding: 14px;
  }

  h1 {
    font-size: 24px;
  }

  .metric strong {
    font-size: 22px;
  }

  .metrics-grid {
    display: flex;
    gap: 10px;
    margin: 0 -14px;
    padding: 0 14px 4px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .metrics-grid::-webkit-scrollbar {
    display: none;
  }

  .metric {
    flex: 0 0 min(78vw, 300px);
    min-height: 104px;
    padding: 14px;
    scroll-snap-align: start;
  }

  .indices,
  .checks,
  .fields {
    grid-template-columns: 1fr;
  }

  .section-header {
    margin-top: 20px;
  }

  .index-panel,
  .checks-section {
    padding: 13px;
  }

  .index-head {
    align-items: flex-start;
    gap: 10px;
  }

  .index-title {
    font-size: 18px;
  }

  .toggle-row {
    align-items: center;
  }

  .field input {
    min-height: 42px;
    font-size: 15px;
  }

  .index-panel button {
    width: 100%;
    min-height: 44px;
  }

  .check-name {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .checks-head {
    align-items: stretch;
    flex-direction: column;
  }

  .checks-head button {
    width: 100%;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    max-width: calc(100vw - 24px);
  }
}

@media (max-width: 390px) {
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions button,
  .top-actions .status-pill {
    width: 100%;
  }

  .index-head {
    flex-direction: column;
  }
}
