:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #172026;
  --muted: #607080;
  --line: #d8e0e7;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-2: #b45309;
  --bad: #b42318;
  --good: #047857;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 720;
}

h2 {
  font-size: 15px;
  margin-bottom: 12px;
}

#subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 28px 40px;
}

button, select, input {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  font: inherit;
}

button {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: pointer;
  min-width: 92px;
}

.secondary-button, .icon-button {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.icon-button {
  min-width: 36px;
  width: 36px;
  padding: 0;
  font-size: 22px;
}

dialog {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 18px 50px rgb(23 32 38 / 18%);
}

dialog::backdrop {
  background: rgb(23 32 38 / 38%);
}

#dbSyncForm {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.dialog-title {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 20px;
}

.dialog-title h2 {
  margin-bottom: 5px;
}

.dialog-title p {
  color: var(--muted);
  font-size: 12px;
}

#dbSyncForm input {
  width: 100%;
}

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

.form-error {
  color: var(--bad);
  font-size: 12px;
  padding: 10px;
  border: 1px solid #f3b8b2;
  background: #fff4f2;
  border-radius: 6px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
}

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

.notice {
  padding: 12px 14px;
  border: 1px solid #f0c36d;
  background: #fff8e6;
  color: #7a4b00;
  border-radius: 6px;
  margin-bottom: 14px;
  font-weight: 650;
}

.notice.info {
  border-color: #a8c7e8;
  background: #f2f7fc;
  color: #244e75;
}

.hidden {
  display: none;
}

.status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.pill {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}

.pill.failed {
  color: var(--bad);
  border-color: #f3b8b2;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

.card .value {
  font-size: 25px;
  line-height: 1.25;
  margin-top: 10px;
  font-weight: 760;
}

.card .compare {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.up {
  color: var(--good);
}

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

.charts {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr);
  gap: 12px;
  margin-bottom: 12px;
}

.panel {
  padding: 14px;
  overflow: hidden;
}

.chart {
  width: 100%;
  min-height: 280px;
}

svg {
  width: 100%;
  height: 280px;
  display: block;
}

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

.wide-panel {
  grid-column: 1 / -1;
}

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

th, td {
  padding: 8px 6px;
  border-bottom: 1px solid #edf1f4;
  text-align: right;
  white-space: nowrap;
}

th:first-child, td:first-child {
  text-align: left;
  white-space: normal;
}

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

@media (max-width: 980px) {
  .cards, .charts, .tables {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  main {
    padding: 16px;
  }

  .cards, .charts, .tables {
    grid-template-columns: 1fr;
  }
}
