:root {
  --bg: #f4f7f8;
  --panel: #ffffff;
  --ink: #10222b;
  --muted: #5a6a70;
  --line: #d5dde0;
  --accent: #0f766e;
  --accent-soft: #d9f2ef;
  --danger: #b91c1c;
  --warn: #c2410c;
  --caution: #a16207;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 15%, #e8f7f4 0%, rgba(232, 247, 244, 0) 35%),
    radial-gradient(circle at 90% 0%, #ffe9dd 0%, rgba(255, 233, 221, 0) 25%),
    var(--bg);
}

.top-shell {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(120deg, #082028, #113542 55%, #275564);
  color: #eff8fb;
  padding: 14px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.brand-wrap h1 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: 0.02em;
}

.brand-kicker {
  font-family: "Space Mono", monospace;
  opacity: 0.8;
  font-size: 0.8rem;
}

.meta-row {
  display: flex;
  gap: 16px;
  font-size: 0.82rem;
  margin-top: 6px;
  opacity: 0.9;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.top-nav a {
  color: #deedf4;
  text-decoration: none;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 0.9rem;
}

.top-nav a.active,
.top-nav a:hover {
  background: rgba(255, 255, 255, 0.15);
}

.refresh-strip {
  position: sticky;
  top: 112px;
  z-index: 9;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(248, 251, 252, 0.97);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(4px);
}

.refresh-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.refresh-controls label {
  font-size: 0.8rem;
  color: var(--muted);
}

.refresh-controls select,
.refresh-controls button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  background: #fff;
  color: var(--ink);
}

.refresh-controls button {
  background: #123646;
  color: #fff;
  border-color: #123646;
  cursor: pointer;
  font-weight: 600;
}

.refresh-disabled-note {
  font-size: 0.82rem;
  color: var(--muted);
}

.refresh-status-grid {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.status-chip-group {
  display: flex;
  gap: 8px;
}

.status-chip,
.widget-status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.status-chip.live,
.widget-status-pill.fresh {
  background: #d8f3ee;
  color: #0f766e;
}

.status-chip.refreshing,
.widget-status-pill.refreshing {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-chip.neutral,
.widget-status-pill.unchanged {
  background: #e2e8f0;
  color: #475569;
}

.status-chip.warn,
.widget-status-pill.stale {
  background: #fef3c7;
  color: #a16207;
}

.status-chip.error,
.widget-status-pill.error {
  background: #fee2e2;
  color: #b91c1c;
}

.refresh-timeline {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--muted);
}

.filter-bar {
  position: sticky;
  top: 170px;
  z-index: 8;
  background: rgba(244, 247, 248, 0.96);
  backdrop-filter: blur(4px);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  align-items: end;
}

.filters-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.76rem;
  color: var(--muted);
}

.filters-grid input,
.filters-grid select,
.filters-grid button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.86rem;
  background: #fff;
  color: var(--ink);
}

.filters-grid button {
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

.check-wrap {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  margin-bottom: 5px;
}

main {
  padding: 14px 16px 28px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 4px 14px rgba(12, 25, 34, 0.04);
}

.kpi-card h3 {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  margin-top: 4px;
  font-size: 1.8rem;
  font-weight: 700;
}

.kpi-sub {
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--muted);
}

.widget-grid {
  display: grid;
  gap: 12px;
}

.widget-grid.two-col {
  grid-template-columns: 1fr;
}

@media (min-width: 1100px) {
  .widget-grid.two-col {
    grid-template-columns: 1fr 1fr;
  }
}

.widget-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 4px 14px rgba(12, 25, 34, 0.04);
}

.widget-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.widget-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

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

.widget-meta {
  color: var(--muted);
  font-size: 0.75rem;
}

.widget-body {
  min-height: 42px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eaf1f4;
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
  text-align: left;
  padding: 7px 8px;
}

tbody td {
  border-bottom: 1px solid #edf2f4;
  padding: 6px 8px;
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: var(--accent-soft);
}

.empty-cell {
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

.pill {
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  display: inline-block;
}

.p0 { background: var(--danger); }
.p1 { background: var(--warn); }
.p2 { background: var(--caution); }
.p3 { background: #64748b; }

.bar {
  --pct: 10;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) calc(var(--pct) * 1%), #deebef calc(var(--pct) * 1%), #deebef 100%);
}

.detail-panel {
  position: fixed;
  right: -460px;
  top: 0;
  width: 460px;
  max-width: 92vw;
  height: 100vh;
  background: #0f1f28;
  color: #e8f3f7;
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  transition: right 180ms ease;
  z-index: 20;
  display: flex;
  flex-direction: column;
}

.detail-panel.open {
  right: 0;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.detail-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.detail-head button {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  color: #e8f3f7;
  border-radius: 6px;
  padding: 5px 8px;
  cursor: pointer;
}

#detail-content {
  margin: 0;
  padding: 12px;
  overflow: auto;
  font-size: 0.75rem;
  line-height: 1.3;
  font-family: "Space Mono", monospace;
}

@media (max-width: 780px) {
  .refresh-strip {
    top: 146px;
    flex-direction: column;
    align-items: flex-start;
  }

  .refresh-status-grid {
    justify-content: flex-start;
  }

  .filter-bar {
    top: 250px;
  }
}

.auth-body,
.error-body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
}

.auth-shell,
.error-shell {
  width: min(760px, 94vw);
}

.auth-card,
.error-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 20px 45px rgba(9, 25, 35, 0.12);
}

.auth-card h1,
.error-card h1 {
  margin: 0;
}

.auth-sub {
  margin-top: 4px;
  color: var(--muted);
}

.auth-note {
  margin: 14px 0;
  padding: 12px;
  border-radius: 10px;
  background: #edf5f8;
  border: 1px solid #d5e1e8;
}

.auth-button {
  display: inline-block;
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: 9px;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.auth-error {
  color: var(--danger);
  font-weight: 600;
  margin-top: 10px;
}

.error-card h2 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.error-card pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #0f1f28;
  color: #d8edf5;
  border-radius: 8px;
  padding: 12px;
  border: 1px solid #203744;
  max-height: 46vh;
  overflow: auto;
  font-size: 0.76rem;
}

.error-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.error-actions a {
  display: inline-block;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--ink);
}
