:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-strong: #eef3f5;
  --text: #162026;
  --muted: #60707a;
  --border: #dbe4e8;
  --accent: #087f8c;
  --accent-strong: #06646f;
  --danger: #c2413b;
  --warning: #a16207;
  --success: #15803d;
  --secondary-bg: #e3f4f5;
  --sidebar-bg: #ffffff;
  --brand-mark-bg: #162026;
  --brand-mark-text: #ffffff;
  --code-text: #213138;
  --status-up-bg: #dcfce7;
  --status-down-bg: #fee2e2;
  --status-unknown-bg: #fef3c7;
  --status-disabled-text: #52616a;
  --status-disabled-bg: #d9e2e7;
  --disabled-text: #5f6f78;
  --disabled-bg: #eef3f5;
  --disabled-strong: #e4ebef;
  --disabled-border: #cad7dd;
  --incident-bg: transparent;
  --incident-border: #dbe4e8;
  --note-bg: #e3f4f5;
  --shadow: 0 18px 48px rgba(22, 32, 38, 0.08);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101316;
  --surface: #171d21;
  --surface-strong: #20282e;
  --text: #edf3f5;
  --muted: #9cadb7;
  --border: #314047;
  --accent: #2fb6c4;
  --accent-strong: #8ce4ec;
  --danger: #f0746e;
  --warning: #e5b154;
  --success: #4ade80;
  --secondary-bg: #143942;
  --sidebar-bg: #15191d;
  --brand-mark-bg: #2fb6c4;
  --brand-mark-text: #071113;
  --code-text: #d9edf1;
  --status-up-bg: #103c25;
  --status-down-bg: #471f22;
  --status-unknown-bg: #46360e;
  --status-disabled-text: #becbd1;
  --status-disabled-bg: #2b363c;
  --disabled-text: #aebdc4;
  --disabled-bg: #1d2429;
  --disabled-strong: #242d33;
  --disabled-border: #3a464d;
  --incident-bg: transparent;
  --incident-border: #314047;
  --note-bg: #143942;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body.modal-open {
  overflow: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.hidden {
  display: none !important;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(8, 127, 140, 0.12), rgba(21, 128, 61, 0.06)),
    var(--bg);
}

.login-shell {
  width: min(100%, 420px);
}

.login-panel {
  display: grid;
  gap: 28px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 42px);
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

h3 {
  margin-bottom: 6px;
  font-size: 17px;
}

.form-stack {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.compact-form {
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.field-warning {
  color: var(--warning);
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: var(--accent);
}

.checkbox-label {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 42px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 127, 140, 0.14);
}

textarea {
  min-height: 104px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  max-width: 100%;
  min-height: 40px;
  padding: 0 14px;
  overflow: hidden;
  border-radius: 8px;
  text-overflow: ellipsis;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  color: #ffffff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  color: var(--accent-strong);
  background: var(--secondary-bg);
}

.ghost-button {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
}

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

.small-button {
  min-height: 34px;
  padding: 0 11px;
  font-size: 13px;
}

.copy-id-button {
  min-height: 22px;
  padding: 0 7px;
  color: var(--accent-strong);
  background: var(--secondary-bg);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.full-width {
  width: 100%;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 20px;
  height: 100vh;
  padding: 22px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--brand-mark-text);
  background: var(--brand-mark-bg);
  border-radius: 8px;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
}

.group-nav {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.nav-item {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border-radius: 8px;
  text-align: left;
  font-weight: 800;
}

.nav-item.active,
.nav-item:hover {
  color: var(--text);
  background: var(--surface-strong);
}

.main-view {
  display: grid;
  align-content: start;
  gap: 22px;
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.topbar > * {
  min-width: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.range-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  min-width: 0;
}

.summary-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  min-height: 96px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.summary-card span {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.summary-card strong {
  overflow-wrap: anywhere;
  font-size: 25px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.range-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.range-form label {
  min-width: 170px;
}

.range-form .search-label {
  flex: 1 1 280px;
}

.range-card {
  min-height: 82px;
  padding: 14px;
}

.monitor-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.group-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.group-title-row h2 {
  overflow-wrap: anywhere;
}

.section-head,
.monitor-head,
.monitor-foot,
.monitor-actions,
.user-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.monitor-list {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.monitor-card,
.panel-block,
.empty-state {
  min-width: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(22, 32, 38, 0.03);
}

.monitor-disabled {
  color: var(--disabled-text);
  background: var(--disabled-bg);
  border-color: var(--disabled-border);
}

.monitor-disabled .metric-pair {
  background: var(--disabled-strong);
}

.monitor-title {
  min-width: 0;
}

.monitor-url {
  max-width: 760px;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.monitor-context {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.monitor-context span,
.monitor-context button {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  overflow-wrap: anywhere;
}

.monitor-context span + span::before,
.monitor-context button::before {
  width: 4px;
  height: 4px;
  margin-right: 12px;
  background: currentColor;
  border-radius: 999px;
  content: "";
  opacity: 0.42;
}

.status-pill {
  display: inline-grid;
  place-items: center;
  min-width: 78px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
}

.status-up {
  color: var(--success);
  background: var(--status-up-bg);
}

.status-down {
  color: var(--danger);
  background: var(--status-down-bg);
}

.status-unknown {
  color: var(--warning);
  background: var(--status-unknown-bg);
}

.status-disabled {
  color: var(--status-disabled-text);
  background: var(--status-disabled-bg);
}

.monitor-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.metric-pair {
  display: grid;
  gap: 5px;
  min-height: 70px;
  padding: 11px;
  background: var(--surface-strong);
  border-radius: 8px;
}

.metric-pair span,
.monitor-foot span,
.user-row small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-pair strong {
  align-self: end;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.monitor-foot {
  align-items: flex-start;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.monitor-actions {
  justify-content: flex-start;
  margin-top: 14px;
  flex-wrap: wrap;
}

.check-now-button {
  margin-left: auto;
}

.incident-block {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 10px 0 0;
  background: var(--incident-bg);
  border-top: 1px solid var(--incident-border);
}

.incident-text {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  align-items: center;
  min-width: 0;
}

.incident-text strong {
  font-size: 13px;
}

.incident-text span,
.incident-text small,
.incident-summary-text {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.incident-summary-text {
  display: grid;
  gap: 6px;
}

.incident-detail-line {
  overflow-wrap: anywhere;
  color: var(--muted) !important;
}

.planned-label {
  color: var(--success) !important;
}

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

.incident-history {
  margin-top: 8px;
  border-top: 1px solid var(--border);
}

.incident-history-toggle {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  list-style: none;
}

.incident-history-toggle::-webkit-details-marker {
  display: none;
}

.incident-history-toggle::after {
  color: var(--accent);
  content: "Show";
}

.incident-history[open] .incident-history-toggle::after {
  content: "Hide";
}

.incident-history-toggle small {
  margin-right: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.incident-history-panel {
  display: grid;
  gap: 8px;
  padding-top: 10px;
}

.incident-history-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  min-width: 0;
  padding: 10px;
  background: var(--surface-strong);
  border-radius: 8px;
}

.incident-history-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.incident-history-main strong {
  font-size: 13px;
}

.incident-history-main small,
.incident-history-empty {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.danger-link {
  color: var(--danger);
  background: transparent;
  border-color: transparent;
}

.action-menu {
  position: relative;
}

.action-menu summary {
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  list-style: none;
}

.action-menu summary::-webkit-details-marker {
  display: none;
}

.action-menu-panel {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 5;
  display: grid;
  gap: 6px;
  min-width: 130px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.action-menu:not([open]) .action-menu-panel {
  display: none;
}

.action-menu-panel button {
  width: 100%;
  text-align: left;
}

.panel-block {
  display: grid;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
}

.api-block code,
.user-row code {
  display: block;
  max-width: 100%;
  padding: 9px 10px;
  overflow: auto;
  overflow-wrap: anywhere;
  color: var(--code-text);
  background: var(--surface-strong);
  border-radius: 8px;
  font-size: 12px;
}

.api-block {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.user-list {
  display: grid;
  gap: 10px;
}

.user-row {
  align-items: flex-start;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.user-row strong,
.user-row small {
  display: block;
  margin-bottom: 6px;
}

.empty-state {
  display: grid;
  gap: 6px;
  min-height: 180px;
  place-items: center;
  text-align: center;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  padding: 13px 16px;
  color: #ffffff;
  background: var(--text);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(22, 32, 38, 0.34);
  backdrop-filter: blur(2px);
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 50;
  display: grid;
  gap: 18px;
  width: min(520px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  padding: 22px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}

.modal-wide {
  width: min(760px, calc(100vw - 36px));
}

.modal-docs {
  width: min(980px, calc(100vw - 36px));
}

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

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

.modal-head h2 {
  margin-bottom: 0;
}

.api-docs {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.doc-section {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding-top: 2px;
  border-top: 1px solid var(--border);
}

.doc-section:first-child {
  border-top: 0;
}

.doc-section h3 {
  margin-bottom: 0;
}

.doc-section p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.endpoint-list {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.endpoint-row {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 8px 10px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.endpoint-row > code {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 800;
}

.endpoint-row p {
  grid-column: 2;
}

.method {
  align-self: start;
  padding: 4px 7px;
  color: #ffffff;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}

.method.get {
  background: #087f8c;
}

.method.post {
  background: #15803d;
}

.method.patch {
  background: #a16207;
}

.method.delete {
  background: #c2413b;
}

.api-docs pre {
  max-width: 100%;
  margin: 0;
  padding: 12px;
  overflow: auto;
  color: var(--code-text);
  background: var(--surface-strong);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
}

.api-docs code {
  overflow-wrap: anywhere;
}

.doc-table-wrap {
  max-width: 100%;
  overflow: auto;
}

.doc-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 13px;
}

.doc-table th,
.doc-table td {
  padding: 10px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.doc-table th {
  color: var(--muted);
  background: var(--surface-strong);
}

.doc-maintainer-note {
  padding: 10px 12px;
  color: var(--accent-strong) !important;
  background: var(--note-bg);
  border-radius: 8px;
  font-weight: 800;
}

@media (max-width: 1280px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

}

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

  .sidebar {
    position: static;
    height: auto;
    grid-template-rows: none;
  }

  .group-nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
  }

  .topbar,
  .section-head,
  .monitor-head,
  .monitor-foot,
  .incident-block,
  .incident-history-row {
    align-items: stretch;
    flex-direction: column;
  }

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

  .endpoint-row {
    grid-template-columns: 1fr;
  }

  .endpoint-row p {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .main-view,
  .sidebar {
    padding: 18px;
  }

  .summary-grid,
  .range-summary-grid,
  .monitor-meta,
  .form-row {
    grid-template-columns: 1fr;
  }

  .top-actions {
    display: grid;
  }

  .range-form {
    display: grid;
  }

  .range-form label {
    min-width: 0;
  }

  .modal {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    padding: 18px;
  }

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