:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #172033;
  --muted: #697386;
  --line: #d8dee8;
  --ok: #177245;
  --down: #b42318;
  --warn: #9a6700;
  --unknown: #596579;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

a {
  color: #175cd3;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 24px;
}

.brand {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.topbar nav {
  align-items: center;
  display: flex;
  gap: 18px;
}

.topbar span {
  color: var(--muted);
}

.logout-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
}

.logout-button:hover {
  background: var(--bg);
  text-decoration: none;
}

.page {
  margin: 0 auto;
  max-width: 1440px;
  padding: 24px;
}

.login-page {
  align-items: center;
  display: flex;
  min-height: 100vh;
}

.login-shell {
  margin: 0 auto;
  max-width: 360px;
  padding: 24px;
  width: 100%;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 14px;
  padding: 22px;
}

.login-panel h1 {
  margin-bottom: 4px;
}

.login-panel label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 6px;
}

.login-panel input {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  padding: 9px 10px;
}

.login-panel button {
  background: #175cd3;
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 10px 12px;
}

.login-error {
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: 6px;
  color: var(--down);
  margin: 0;
  padding: 9px 10px;
}

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

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 8px;
}

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

.metric.ok strong {
  color: var(--ok);
}

.metric.down strong {
  color: var(--down);
}

.metric.unknown strong {
  color: var(--unknown);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 18px;
}

.panel-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 58px;
  padding: 14px 16px;
}

h1,
h2 {
  font-size: 18px;
  margin: 0;
}

h2 {
  font-size: 16px;
}

.panel-header span,
.back {
  color: var(--muted);
  font-size: 12px;
}

.filters {
  align-items: end;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 16px;
}

.filters label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 4px;
  min-width: 140px;
}

.filters-search {
  flex: 1 1 220px;
}

.filters input,
.filters select {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 7px 9px;
}

.filters input:focus,
.filters select:focus {
  border-color: #175cd3;
  outline: none;
}

.filters-clear {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
}

.filters-clear:hover {
  background: var(--bg);
}

.table-empty {
  color: var(--muted);
  margin: 0;
  padding: 18px 16px;
  text-align: center;
}

.table-wrap {
  overflow-x: auto;
}

th.sortable {
  cursor: pointer;
  padding-right: 22px;
  position: relative;
  user-select: none;
}

th.sortable::after {
  color: var(--line);
  content: "↕";
  font-size: 11px;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}

th.sortable:hover {
  color: var(--text);
}

th.sort-asc::after {
  color: var(--text);
  content: "▲";
}

th.sort-desc::after {
  color: var(--text);
  content: "▼";
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td {
  color: #283244;
}

.metric {
  white-space: nowrap;
}

.metric-limit,
.metric-stale {
  color: var(--muted);
  font-size: 0.85em;
}

.target {
  max-width: 360px;
  overflow-wrap: anywhere;
}

.status {
  border: 1px solid currentColor;
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  min-width: 76px;
  padding: 3px 8px;
  text-align: center;
}

.status.ok,
.status.resolved {
  color: var(--ok);
}

.status.down,
.status.error {
  color: var(--down);
}

.status.warning,
.status.measure_error {
  color: var(--warn);
}

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

.details {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  padding: 16px;
}

.details div {
  min-width: 0;
}

.details dt {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

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

.sla-period {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 8px 16px;
}

.sla-period-links {
  display: flex;
  gap: 14px;
}

.sla-table td {
  font-variant-numeric: tabular-nums;
}

.sla-table td:first-child {
  color: var(--text);
  font-weight: 700;
}

.sla-metric {
  font-size: 16px;
  font-weight: 700;
}

.sla-nodata {
  color: var(--muted);
  font-style: italic;
}

.sla-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  margin: 14px 2px 0;
  max-width: 78ch;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
  }

  .page {
    padding: 16px;
  }

  .summary-grid,
  .details {
    grid-template-columns: 1fr;
  }
}
