:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f7fb;
  color: #172033;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #dbe3ef;
  --text-muted: #64748b;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --positive: #15803d;
  --positive-bg: #ecfdf3;
  --warning: #b45309;
  --warning-bg: #fff7ed;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: #f4f7fb;
  color: #172033;
}

button, input { font: inherit; }
button { cursor: pointer; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px clamp(18px, 4vw, 52px);
  color: #fff;
  background: linear-gradient(135deg, #0f172a, #134e4a);
}

.app-header h1,
.panel h2 { margin: 0; }

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
  color: #14b8a6;
}

.page-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 24px auto 56px;
}

.panel,
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.panel { padding: 22px; margin-bottom: 22px; }
.setup-panel { max-width: 680px; margin-inline: auto; }
.setup-panel p,
.danger-zone p { color: var(--text-muted); line-height: 1.7; }

.connection-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

label { display: grid; gap: 8px; font-weight: 700; }
input {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 0;
  font-weight: 800;
}

.primary-button { color: #fff; background: var(--primary); }
.primary-button:hover { background: var(--primary-dark); }
.secondary-button { color: #0f172a; background: #fff; }
.danger-button { color: var(--danger); background: var(--danger-bg); }

.status-panel {
  min-height: 0;
  margin-bottom: 18px;
}
.status-panel:not(:empty) {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.status-panel.error { color: var(--danger); border-color: #fecaca; background: var(--danger-bg); }
.status-panel.success { color: var(--positive); border-color: #bbf7d0; background: var(--positive-bg); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.summary-card { padding: 20px; }
.summary-card span { display: block; color: var(--text-muted); font-size: 14px; }
.summary-card strong { display: block; margin-top: 10px; font-size: 34px; }
.summary-card.positive { background: var(--positive-bg); }
.summary-card.warning { background: var(--warning-bg); }

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.muted { color: var(--text-muted); font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th, td { padding: 12px 10px; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: top; }
th { color: #475569; font-size: 13px; background: var(--surface-soft); }
td { font-size: 14px; }

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e2e8f0;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.status-badge.candidate { color: var(--positive); background: var(--positive-bg); }
.status-badge.warning { color: var(--warning); background: var(--warning-bg); }
.status-badge.excluded { color: #475569; background: #e2e8f0; }

.rate-up { color: var(--positive); font-weight: 800; }
.rate-down { color: var(--danger); font-weight: 800; }

.two-column-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.card-list { display: grid; gap: 12px; }
.list-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}
.list-card h3 { margin: 0 0 8px; font-size: 15px; }
.list-card p { margin: 6px 0 0; color: var(--text-muted); line-height: 1.55; font-size: 13px; }
.list-card a { color: var(--primary); font-weight: 800; text-decoration: none; }
.list-meta { display: flex; flex-wrap: wrap; gap: 8px 12px; color: var(--text-muted); font-size: 12px; }

.empty-message { color: var(--text-muted); }
.danger-zone { border-color: #fecaca; }

@media (max-width: 820px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .app-header { padding: 18px; }
  .app-header h1 { font-size: 22px; }
  .page-shell { width: min(100% - 20px, 1180px); margin-top: 14px; }
  .panel { padding: 16px; border-radius: 15px; }
  .connection-form { grid-template-columns: 1fr; }
  .summary-grid { gap: 10px; }
  .summary-card { padding: 16px; border-radius: 15px; }
  .summary-card strong { font-size: 28px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
}
