:root {
  color-scheme: light;
  --page: #f6f7f4;
  --panel: #ffffff;
  --panel-soft: #f1f4ef;
  --text: #1f2521;
  --muted: #647067;
  --line: #dce3da;
  --green: #1f7a4f;
  --green-soft: #e4f4ec;
  --amber: #a66b00;
  --amber-soft: #fff1d6;
  --red: #b42318;
  --red-soft: #fde7e4;
  --blue: #245b94;
  --blue-soft: #e6eef7;
  --shadow: 0 10px 35px rgba(31, 37, 33, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 32px;
  background: #18231c;
  color: #f7fbf5;
  border-bottom: 4px solid #d5a432;
}

.topbar h1,
.auth-panel h2,
.section-heading h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: #8f9b92;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: #c8d5c9;
}

.session {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
}

.session-email {
  max-width: 260px;
  overflow: hidden;
  color: #dbe7da;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 46px;
}

.auth-view {
  display: grid;
  place-items: start center;
  padding-top: 42px;
}

.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--text);
  background: #fff;
  border: 1px solid #cfd8ce;
  border-radius: 6px;
}

input:focus {
  outline: 3px solid rgba(36, 91, 148, 0.18);
  border-color: var(--blue);
}

.primary-button,
.ghost-button,
.tab-button {
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--green);
}

.ghost-button {
  color: #eef7ed;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.ghost-button.danger {
  color: #ffdeda;
}

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

.controls-row,
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.date-control {
  width: 180px;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #e6ece4;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tab-button {
  color: var(--muted);
  background: transparent;
}

.tab-button.active {
  color: var(--text);
  background: #fff;
  border-color: #cfd8ce;
  box-shadow: 0 1px 7px rgba(31, 37, 33, 0.09);
}

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

.kpi-card,
.scraper-card,
.alerts-panel,
.events-meta {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 6px rgba(31, 37, 33, 0.04);
}

.kpi-card {
  min-height: 105px;
  padding: 16px;
}

.kpi-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.kpi-value {
  margin: 0;
  font-size: 28px;
  font-weight: 850;
  line-height: 1.05;
}

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

.alerts-panel {
  display: grid;
  gap: 10px;
  min-height: 52px;
  margin-bottom: 18px;
  padding: 14px;
}

.alert {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 12px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 7px;
  background: var(--amber-soft);
  color: #4a3500;
}

.alert.high {
  background: var(--red-soft);
  color: #4f130d;
}

.alert.none {
  background: var(--green-soft);
  color: #174b33;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.badge.ready,
.badge.succeeded,
.badge.skipped {
  color: #155538;
  background: var(--green-soft);
}

.badge.partial,
.badge.warning,
.badge.stale,
.badge.running,
.badge.started {
  color: #6c4700;
  background: var(--amber-soft);
}

.badge.missing,
.badge.failed,
.badge.access-denied {
  color: var(--red);
  background: var(--red-soft);
}

.badge.unknown {
  color: #254d7a;
  background: var(--blue-soft);
}

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

.scraper-card {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.scraper-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.scraper-title {
  margin: 0;
  font-size: 18px;
}

.scraper-desc {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

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

.scraper-metrics div {
  min-height: 64px;
  padding: 10px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.scraper-metrics dt {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.scraper-metrics dd {
  margin: 0;
  font-size: 19px;
  font-weight: 850;
}

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

.events-meta {
  max-width: 560px;
  padding: 13px 15px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.table-wrap {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #46524a;
  background: #eef3ec;
  font-size: 12px;
  text-transform: uppercase;
}

td {
  color: #303832;
  font-size: 13px;
  line-height: 1.35;
}

.hidden {
  display: none !important;
}

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

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

@media (max-width: 720px) {
  .topbar,
  .controls-row,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .session,
  .tabs {
    flex-wrap: wrap;
  }

  main {
    width: min(100% - 28px, 1440px);
    padding-top: 18px;
  }

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

  .date-control {
    width: 100%;
  }

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