:root {
  color-scheme: light dark;
  --bg: #f4f7f6;
  --panel: #ffffff;
  --text: #17211f;
  --muted: #64706d;
  --line: #dce4e1;
  --primary: #106b5b;
  --primary-strong: #0a4d42;
  --accent: #d9892b;
  --danger: #b42318;
  --ok: #197a45;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  --bg: #111816;
  --panel: #192320;
  --text: #eef7f4;
  --muted: #9fb0ab;
  --line: #2d3a36;
  --primary: #42c6a5;
  --primary-strong: #83dec7;
  --accent: #f2b45d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.portal-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.portal-hero {
  min-height: 38vh;
  display: flex;
  align-items: flex-end;
  padding: 28px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(12, 29, 25, .35), rgba(12, 29, 25, .86)),
    url("https://images.unsplash.com/photo-1556740758-90de374c12ad?auto=format&fit=crop&w=1400&q=80") center/cover;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #fff;
  color: #106b5b;
  font-weight: 900;
}

.brand-logo {
  width: 150px;
  max-height: 64px;
  object-fit: contain;
  display: block;
}

.portal-copy .brand {
  align-items: center;
}

.portal-copy h1 {
  margin: 18px 0 8px;
  font-size: clamp(2rem, 8vw, 4.5rem);
  line-height: .96;
  letter-spacing: 0;
  max-width: 720px;
}

.portal-copy p {
  max-width: 560px;
  margin: 0;
  color: rgba(255, 255, 255, .86);
  font-size: 1.05rem;
}

.portal-card {
  width: min(560px, calc(100% - 32px));
  margin: -36px auto 32px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(17, 24, 22, .18);
}

.portal-offers {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto 34px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.offer-card,
.survey-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.offer-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
}

.table-thumb {
  width: 72px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  display: block;
}

.offer-card strong,
.survey-card strong {
  display: block;
  margin-bottom: 8px;
}

.survey-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.survey-options button,
.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: color-mix(in srgb, var(--panel), var(--text) 5%);
  color: var(--text);
}

.grid {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.check span {
  color: var(--muted);
  font-size: .92rem;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel), var(--bg) 24%);
  color: var(--text);
  border-radius: 8px;
  padding: 13px 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary), transparent 76%);
}

.check {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
}

.check input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

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

.icon-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel), var(--text) 5%);
  color: var(--text);
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
}

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

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

.button {
  border: 0;
  border-radius: 8px;
  padding: 13px 16px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.button.secondary {
  background: color-mix(in srgb, var(--panel), var(--text) 8%);
  color: var(--text);
}

.button:disabled {
  opacity: .55;
  cursor: wait;
}

.message {
  min-height: 22px;
  font-weight: 700;
}

.message.error {
  color: var(--danger);
}

.message.ok {
  color: var(--ok);
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  padding: 22px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.nav button {
  text-align: left;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.nav button.active {
  background: color-mix(in srgb, var(--primary), transparent 84%);
  color: var(--primary-strong);
  font-weight: 800;
}

.content {
  padding: 24px;
  overflow: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.6rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}

.license-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.license-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.license-card h2 {
  margin: 0;
  font-size: 1.2rem;
}

.license-card p,
.license-card small {
  margin: 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.toolbar input {
  max-width: 320px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metric {
  font-size: 2rem;
  font-weight: 900;
}

.metric.small {
  font-size: 1.45rem;
}

.license-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.license-title h2 {
  margin: 0;
}

.license-title p {
  margin: 6px 0 0;
  color: var(--muted);
}

.promo,
.upgrade {
  margin-bottom: 14px;
}

.promo h2,
.upgrade h2 {
  margin: 10px 0 8px;
}

.empty {
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

.empty h2 {
  margin: 8px 0;
  color: var(--text);
}

.chart-bars {
  height: 220px;
  display: flex;
  align-items: end;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.chart-bars span {
  flex: 1;
  min-width: 28px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, var(--primary), var(--accent));
}

.section {
  margin-top: 18px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
}

.section h2,
.card h2 {
  margin: 0 0 12px;
  font-size: 1.08rem;
}

.funnel {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.funnel:last-child {
  border-bottom: 0;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.sync-panels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.mini-sync {
  display: grid;
  gap: 10px;
}

.portal-config {
  margin-bottom: 18px;
}

.portal-config p {
  color: var(--muted);
  margin: 8px 0 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: .92rem;
}

th {
  color: var(--muted);
  font-weight: 800;
}

.signin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 1fr;
  background: #202d3b;
}

.signin-panel {
  width: min(420px, calc(100% - 32px));
  align-self: center;
  justify-self: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .22);
}

.signin-art {
  min-height: 100vh;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 210, 178, .95), transparent 22%),
    radial-gradient(circle at 70% 8%, rgba(181, 53, 222, .9), transparent 34%),
    linear-gradient(145deg, #18c8d1 0%, #15bdd7 32%, #7731d7 62%, #d22dd4 100%);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 12% 100%);
}

.wide {
  width: 100%;
}

.hidden {
  display: none !important;
}

@media (max-width: 840px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .split,
  .portal-offers,
  .signin-shell {
    grid-template-columns: 1fr;
  }

  .signin-art {
    display: none;
  }
}

@media (max-width: 520px) {
  .portal-hero {
    min-height: 32vh;
    padding: 20px 16px 52px;
  }

  .portal-card {
    margin-top: -42px;
  }

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

  th:nth-child(4),
  td:nth-child(4) {
    display: none;
  }
}
