:root {
  color-scheme: light dark;
  --bg: #f5f2ee;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: #fffaf4;
  --text: #171614;
  --muted: #77716a;
  --line: rgba(23, 22, 20, 0.1);
  --accent: #ff8a2a;
  --accent-soft: rgba(255, 138, 42, 0.14);
  --good: #147a50;
  --bad: #b42318;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111;
    --surface: rgba(31, 31, 34, 0.82);
    --surface-strong: #202024;
    --text: #f7f4ee;
    --muted: #a9a39b;
    --line: rgba(255, 255, 255, 0.1);
    --accent-soft: rgba(255, 138, 42, 0.18);
  }
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  min-height: 100vh;
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: white;
  font-weight: 900;
}

.brand span, .muted, small {
  color: var(--muted);
}

nav {
  display: grid;
  gap: 8px;
}

nav a, .ghost {
  color: var(--text);
  text-decoration: none;
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  background: transparent;
  font: inherit;
  text-align: left;
}

nav a.active, nav a:hover, .ghost:hover {
  background: var(--accent-soft);
}

.ghost {
  position: absolute;
  bottom: 24px;
  left: 22px;
  right: 22px;
}

.content {
  padding: 34px clamp(24px, 4vw, 64px) 64px;
}

.topbar, .section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

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

h1, h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.1rem, 4vw, 4.2rem);
  line-height: 0.96;
}

h2 {
  font-size: 1.35rem;
}

.panel-section {
  margin-top: 34px;
}

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

.metric-card, .table-shell, .funnel-step, .login-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.06);
}

.metric-card {
  padding: 20px;
  display: grid;
  gap: 8px;
}

.metric-card span {
  color: var(--muted);
}

.metric-card strong {
  font-size: 2.15rem;
  line-height: 1;
}

.table-shell {
  margin-top: 14px;
  overflow: hidden;
}

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

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

td small {
  display: block;
  margin-top: 4px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(120, 120, 120, 0.14);
  color: var(--muted);
  font-weight: 700;
}

.pill.good {
  background: rgba(20, 122, 80, 0.14);
  color: var(--good);
}

.pill.bad {
  background: rgba(180, 35, 24, 0.14);
  color: var(--bad);
}

.funnel {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.funnel-step {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.funnel-step div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(120, 120, 120, 0.16);
  overflow: hidden;
}

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

.login-page {
  display: grid;
  place-items: center;
  grid-template-columns: 1fr;
  padding: 24px;
}

.login-shell {
  width: min(440px, 100%);
  padding: 34px;
}

.login-shell h1 {
  margin-top: 12px;
  font-size: 2.25rem;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

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

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 15px;
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
}

button[type="submit"] {
  border: 0;
  border-radius: 14px;
  padding: 15px 18px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 800;
}

.form-error {
  color: var(--bad);
  margin: 0;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 520px;
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--bad);
  color: white;
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .ghost {
    position: static;
    margin-top: 18px;
    width: 100%;
  }

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

  .topbar, .section-title, .funnel-step div:first-child {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-shell {
    overflow-x: auto;
  }
}
