:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #eef3f1;
  --text: #18211f;
  --muted: #65736f;
  --line: #d8dfdc;
  --accent: #0d8068;
  --accent-strong: #075f51;
  --cyan: #1d7185;
  --amber: #a86807;
  --danger: #b83b31;
  --shadow: 0 14px 40px rgba(24, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.35rem, 2vw, 1.9rem);
  line-height: 1.1;
}

main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px clamp(18px, 4vw, 48px) 48px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timestamp {
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-strong);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

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

.text-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-strong);
  font-size: 0.88rem;
  font-weight: 750;
  text-decoration: none;
}

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

.icon-button:active {
  transform: translateY(1px);
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button.is-loading svg {
  animation: spin 800ms linear infinite;
}

.source-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.source-pill {
  display: flex;
  min-height: 66px;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(24, 33, 31, 0.05);
}

.source-pill strong,
.source-pill span {
  display: block;
}

.source-pill strong {
  font-size: 0.9rem;
}

.source-pill span:not(.status-dot) {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: capitalize;
}

.status-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.status-ok .status-dot {
  background: var(--accent);
}

.status-stale .status-dot {
  background: var(--amber);
}

.status-error .status-dot {
  background: var(--danger);
}

.status-disabled .status-dot {
  background: var(--muted);
}

.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 16px;
  align-items: stretch;
}

.widget {
  min-height: 238px;
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.widget.status-stale {
  border-top-color: var(--amber);
}

.widget.status-error {
  border-top-color: var(--danger);
}

.widget.status-disabled {
  border-top-color: var(--muted);
}

.widget-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  margin-bottom: 18px;
}

.widget-header p {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.widget-header h2 {
  margin-top: 4px;
  font-size: 1rem;
  line-height: 1.25;
}

.badge {
  align-self: start;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.stat-value {
  min-height: 68px;
  display: flex;
  align-items: center;
  color: var(--text);
  font-size: clamp(1.8rem, 5vw, 2.65rem);
  font-weight: 800;
  line-height: 1;
  overflow-wrap: anywhere;
}

.caption,
.warning,
.success {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.warning {
  margin-bottom: 14px;
  color: var(--danger);
}

.success {
  color: var(--accent-strong);
}

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

.metric {
  min-height: 86px;
  padding: 12px 12px 12px 0;
  border-left: 3px solid var(--line);
  background: transparent;
}

.metric span,
.metric strong {
  display: block;
}

.metric span {
  color: var(--muted);
  font-size: 0.8rem;
}

.metric strong {
  margin-top: 10px;
  color: var(--cyan);
  font-size: 1.55rem;
  line-height: 1;
  overflow-wrap: anywhere;
}

.item-list {
  display: grid;
  gap: 10px;
}

.item-row {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.item-row:first-child {
  border-top: 0;
}

.item-row strong,
.item-row span {
  display: block;
}

.item-row strong {
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.item-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.item-row b {
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-size: 0.88rem;
  white-space: nowrap;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  padding: 10px 8px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-shell {
  width: min(100%, 430px);
  padding: 24px;
}

.auth-panel {
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  margin-bottom: 8px;
}

.auth-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.auth-panel input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.settings-shell {
  width: min(760px, 100%);
}

.settings-panel {
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.settings-panel input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.settings-panel input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(13, 128, 104, 0.16);
}

.settings-panel .check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-panel .check-row input {
  width: 18px;
  min-height: 18px;
}

.auth-panel input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(13, 128, 104, 0.16);
}

.primary-button {
  display: inline-grid;
  min-height: 42px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--accent-strong);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.primary-button:hover {
  background: var(--accent);
}

.button-link {
  padding: 0 14px;
}

.installer-form {
  display: grid;
  gap: 16px;
}

.debug-panel {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.84rem;
}

.debug-panel strong {
  color: var(--text);
}

@media (max-width: 680px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    width: 100%;
    justify-content: space-between;
  }

  .timestamp {
    white-space: normal;
  }
}
