:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #182026;
  --muted: #62717c;
  --line: #dbe2e7;
  --accent: #216b63;
  --accent-strong: #164c47;
  --ok: #1f7a4d;
  --warn: #a8631a;
  --bad: #b23b32;
  --shadow: 0 16px 40px rgba(24, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(33, 107, 99, 0.08), transparent 280px),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button.secondary {
  color: var(--ink);
  background: #eef2f4;
}

button.secondary:hover {
  background: #e1e8ec;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -3px;
  animation: spin 0.8s linear infinite;
}

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

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

label {
  display: block;
  margin: 14px 0 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 36px;
  align-items: start;
  min-height: 430px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 24px;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-size: 1.3rem;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.provider h3,
.provider p {
  margin: 0;
}

.brand h1 {
  font-size: clamp(2.2rem, 6vw, 4.8rem);
  line-height: 1;
}

.brand p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 1.05rem;
}

.session-panel,
.provider,
.dashboard,
.data-card,
.trend-card,
.activity {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.session-panel {
  padding: 18px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.tab {
  color: var(--ink);
  background: #eef2f4;
}

.tab.active,
.tab:hover {
  color: #fff;
  background: var(--accent);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.auth-form button {
  width: 100%;
  margin-top: 18px;
}

.workspace {
  display: grid;
  gap: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.topbar h2 {
  margin-top: 4px;
  font-size: 2rem;
  line-height: 1.1;
}

#userMeta {
  margin-top: 8px;
  color: var(--muted);
}

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

.provider {
  display: grid;
  gap: 18px;
  min-height: 260px;
  padding: 22px;
}

.provider h3 {
  margin-top: 6px;
  font-size: 1.45rem;
}

.provider-copy {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.5;
}

.provider-status {
  align-self: end;
  border: 1px solid var(--line);
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
  padding: 8px 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.provider-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.dashboard {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h3,
.data-card h4,
.trend-card h4,
.empty-state {
  margin: 0;
}

.section-heading h3 {
  margin-top: 4px;
  font-size: 1.45rem;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #f7f9fa;
}

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

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.data-card,
.trend-card {
  box-shadow: none;
}

.data-card {
  min-height: 148px;
  padding: 16px;
}

.data-card h4 {
  margin-top: 8px;
  min-height: 40px;
  font-size: 1rem;
  line-height: 1.2;
}

.data-value {
  margin-top: 12px;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.data-card p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

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

.trend-card {
  display: grid;
  gap: 9px;
  min-height: 180px;
  padding: 16px;
}

.trend-heading,
.trend-row {
  display: grid;
  align-items: center;
  gap: 10px;
}

.trend-heading {
  grid-template-columns: minmax(0, 1fr) auto;
}

.trend-heading span {
  color: var(--muted);
  font-size: 0.84rem;
}

.trend-row {
  grid-template-columns: 56px minmax(72px, 1fr) 54px;
  min-height: 18px;
  color: var(--muted);
  font-size: 0.82rem;
}

.trend-row strong {
  color: var(--ink);
  font-weight: 700;
  text-align: right;
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef1;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.activity {
  margin-top: 22px;
  padding: 16px;
}

.backend-state {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warn);
}

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

.dot.bad {
  background: var(--bad);
}

#messageLog {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.message {
  border-left: 3px solid var(--accent);
  padding: 8px 10px;
  color: var(--muted);
  background: #f7f9fa;
  overflow-wrap: anywhere;
}

.message.error {
  border-left-color: var(--bad);
  color: var(--bad);
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 24px, 1080px);
    padding: 24px 0;
  }

  .hero,
  .providers,
  .card-grid,
  .metric-grid,
  .trend-grid {
    grid-template-columns: 1fr;
  }

  .brand {
    padding-top: 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar .secondary {
    width: 100%;
  }

  .provider-actions {
    grid-template-columns: 1fr;
  }
}
