:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --text: #17202a;
  --muted: #5f6f7f;
  --line: #d9e0e7;
  --panel: #ffffff;
  --up: #168a4a;
  --down: #c73232;
  --never: #7b8794;
  --accent: #265f9f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
}

button:hover,
.button:hover {
  border-color: var(--accent);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.panel,
.alertSettings,
.detail,
.metric,
.tableWrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
}

.authPanel {
  display: grid;
  gap: 14px;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 14px;
  margin-top: 18px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 36px;
  padding: 7px 10px;
  color: var(--text);
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--down);
}

.dashboard {
  padding: 20px;
  display: grid;
  gap: 16px;
}

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

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

.toolbar span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  min-height: 40px;
  padding: 8px 4px;
}

.tabs button.active {
  border-bottom-color: var(--accent);
  color: var(--text);
  font-weight: 650;
}

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

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

.alertSettings {
  padding: 14px;
}

.settingsHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.statusBadge {
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  padding: 6px 9px;
}

.statusBadge.enabled {
  background: var(--up);
}

.statusBadge.disabled {
  background: var(--never);
}

.settingsGrid {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(260px, 1.6fr) repeat(2, minmax(120px, 0.6fr)) minmax(240px, 1.2fr);
  gap: 10px;
  margin-top: 12px;
}

.globalSettingsGrid {
  grid-template-columns: minmax(120px, 0.6fr) repeat(2, minmax(120px, 0.7fr)) minmax(260px, 1.8fr);
}

.webhookState {
  align-self: end;
  color: var(--muted);
  font-size: 12px;
  min-height: 36px;
  display: flex;
  align-items: center;
}

.statusLine {
  min-height: 18px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.errorText {
  color: var(--down);
}

.webhookManager {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.webhookCreate,
.webhookCard {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.webhookCreateGrid {
  display: grid;
  grid-template-columns: minmax(160px, 0.8fr) minmax(280px, 1.4fr);
  gap: 10px;
  margin-top: 10px;
}

.webhookList {
  display: grid;
  gap: 12px;
}

.webhookCardHeader {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.webhookCardHeader span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.eventTypeGrid {
  border: 0;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 8px;
}

.eventTypeGrid legend {
  color: var(--muted);
  font-size: 12px;
  padding: 0 0 7px;
}

.emptyState {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 0;
}

.metric {
  min-height: 70px;
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 4px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  font-size: 28px;
  line-height: 1;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px;
}

.tile {
  min-height: 54px;
  color: #fff;
  border: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile.up {
  background: var(--up);
}

.tile.down {
  background: var(--down);
}

.tile.never {
  background: var(--never);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.tableWrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #edf4fb;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 7px;
}

.dot.up {
  background: var(--up);
}

.dot.down {
  background: var(--down);
}

.dot.never {
  background: var(--never);
}

.detail {
  padding: 16px;
  min-height: 360px;
}

.formGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check input {
  width: auto;
}

.schedulePreview {
  align-self: end;
  color: var(--muted);
  font-size: 12px;
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 0 2px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.timeline {
  margin: 8px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.timeline time {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stateTimeline {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  min-width: 0;
}

.stateAxis {
  display: grid;
  grid-template-columns: 88px 1fr 1fr 1fr;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.stateAxis span:nth-child(1) {
  grid-column: 2;
}

.stateAxis span:nth-child(2) {
  text-align: center;
}

.stateAxis span:nth-child(3) {
  text-align: right;
}

.stateRow {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.stateLabel {
  color: var(--muted);
  font-size: 12px;
}

.stateTrack {
  position: relative;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef2f6;
  overflow: hidden;
}

.stateSegment {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 0 7px;
  color: #fff;
  font-size: 11px;
  line-height: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.stateSegment.up {
  background: var(--up);
}

.stateSegment.down {
  background: var(--down);
}

.stateSegment.unknown {
  background: var(--never);
}

@media (max-width: 1100px) {
  .settingsGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 900px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 560px) {
  .dashboard {
    padding: 12px;
  }

  .toolbar,
  .formGrid,
  .settingsGrid,
  .webhookCreateGrid {
    grid-template-columns: 1fr;
    display: grid;
  }

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

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

  .stateAxis,
  .stateRow {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .stateAxis {
    grid-template-columns: 72px repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
}
