:root {
  color-scheme: light;
  --ink: #101514;
  --muted: #63706c;
  --line: #dce3e0;
  --surface: #ffffff;
  --canvas: #f4f7f5;
  --teal: #087f6b;
  --teal-dark: #075e52;
  --coral: #ef6a52;
  --gold: #d9a526;
  --danger: #b83333;
  --success: #14805f;
  --shadow: 0 12px 28px rgba(16, 21, 20, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--surface);
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.brand-lockup {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 11px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--coral);
  color: #fff;
  font-size: 21px;
  font-weight: 800;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.1);
}

.brand-lockup h1,
.brand-lockup p,
.section-heading h2,
.section-heading h3,
.section-heading p,
.admin-header h2,
.admin-header p,
.welcome-band h2,
.welcome-band p,
.state-view h2,
.state-view p { margin: 0; }

.brand-lockup h1 {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
  line-height: 1.2;
}

.eyebrow {
  color: var(--teal);
  font-size: 10px;
  line-height: 1.25;
  font-weight: 800;
  text-transform: uppercase;
}

.eyebrow.light { color: #a9e9dc; }

.language-control select {
  min-width: 92px;
  height: 40px;
  padding: 0 30px 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
}

.welcome-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 180px;
  padding: 28px 20px;
  color: #fff;
  background: #101d1a;
  border-bottom: 4px solid var(--gold);
}

.welcome-band h2 {
  margin-top: 6px;
  font-size: 26px;
  line-height: 1.15;
}

.welcome-band p:last-child {
  margin-top: 8px;
  color: #c9d6d2;
  max-width: 360px;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 750;
  line-height: 1.2;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.button:active { transform: translateY(1px); }
.button:disabled { cursor: wait; opacity: 0.55; }
.button.primary { background: var(--teal); color: #fff; }
.button.primary:hover { background: var(--teal-dark); }
.button.accent { background: var(--coral); color: #fff; box-shadow: 0 8px 20px rgba(239, 106, 82, 0.2); }
.button.secondary { border-color: var(--line); background: #fff; color: var(--ink); }
.button.danger { background: var(--danger); color: #fff; }
.button.full { width: 100%; }

.tabbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 52px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.active { color: var(--teal); border-bottom-color: var(--teal); }
.tab-panel { display: none; padding: 24px 18px; }
.tab-panel.active { display: block; }

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

.section-heading h2,
.section-heading h3 {
  margin-top: 4px;
  font-size: 20px;
  line-height: 1.2;
}

.compact-top { margin-top: 32px; }
.section-intro { margin: -6px 0 18px; color: var(--muted); }

.count-badge {
  min-width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #e4f2ee;
  color: var(--teal-dark);
  font-weight: 800;
}

.stack-list { display: grid; gap: 10px; }
.plans-grid { display: grid; gap: 14px; }

.membership-row,
.payment-row,
.empty-state {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  background: var(--surface);
}

.membership-row-header,
.payment-row-header,
.plan-header,
.method-row,
.form-footer,
.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.membership-row strong,
.payment-row strong { overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: 13px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #e4f2ee;
  color: var(--success);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.plan-card {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 15px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.plan-card.featured { border-top: 4px solid var(--coral); }
.plan-card h3 { margin: 0; font-size: 19px; line-height: 1.2; overflow-wrap: anywhere; }
.plan-card p { margin: 0; color: var(--muted); }

.price-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px; }
.price-value { font-size: 28px; font-weight: 850; line-height: 1; }
.price-currency { color: var(--muted); font-weight: 750; }

.plan-facts,
.method-tags { display: flex; flex-wrap: wrap; gap: 7px; }

.fact,
.method-tag {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 6px;
  background: #f0f4f2;
  color: #394641;
  font-size: 12px;
  font-weight: 650;
}

.stars-note {
  padding: 10px 11px;
  border-left: 3px solid var(--gold);
  background: #fff8df;
  color: #5c4711;
  font-size: 13px;
}

.support-form,
.settings-list { display: grid; gap: 16px; }
.support-form label,
.setting-row label,
.modal label { font-size: 13px; font-weight: 800; }

textarea,
input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #bdc9c5;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea { resize: vertical; min-height: 110px; }
textarea:focus, input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8, 127, 107, 0.12); }
.form-footer { align-items: flex-end; }
.form-footer span { color: var(--muted); font-size: 12px; }

.state-view {
  min-height: 66vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 32px;
  text-align: center;
}

.state-view p { color: var(--muted); max-width: 360px; }
.status-symbol {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 2px solid var(--coral);
  border-radius: 50%;
  color: var(--coral);
  font-size: 24px;
  font-weight: 850;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(calc(100% - 32px), 460px);
  transform: translateX(-50%);
  padding: 12px 15px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  text-align: center;
  font-weight: 650;
}

/* Admin */
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  background: #101514;
  color: #fff;
}

.admin-brand { padding: 0 6px 22px; border-bottom: 1px solid #2b3532; }
.admin-brand h1 { max-width: 154px; }
.admin-nav { display: grid; gap: 5px; padding-top: 18px; }

.nav-item {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #b7c4bf;
  text-align: left;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active { background: #24302d; color: #fff; }
.nav-item span { min-width: 25px; padding: 2px 6px; border-radius: 999px; background: var(--coral); color: #fff; text-align: center; font-size: 11px; }

.admin-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 14px 6px 0;
  border-top: 1px solid #2b3532;
  min-width: 0;
}

.avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold);
  color: #292005;
  font-weight: 850;
}

.admin-identity div { min-width: 0; }
.admin-identity strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-identity small { color: #92a19b; }

.admin-main { min-width: 0; padding: 28px clamp(18px, 4vw, 54px) 48px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.admin-header h2 { margin-top: 4px; font-size: 26px; }

.icon-button {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
}

.admin-view { display: none; }
.admin-view.active { display: block; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  min-height: 116px;
  display: grid;
  align-content: space-between;
  padding: 15px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--teal);
  border-radius: 8px;
  background: var(--surface);
}

.stat-card:nth-child(2) { border-top-color: var(--coral); }
.stat-card:nth-child(3) { border-top-color: var(--gold); }
.stat-card:nth-child(4) { border-top-color: #517bb8; }
.stat-card span { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-card strong { font-size: 25px; line-height: 1; overflow-wrap: anywhere; }

.content-band { padding-top: 22px; border-top: 1px solid var(--line); }
.text-button { border: 0; background: transparent; color: var(--teal); font-weight: 800; }

.payment-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-left-color: var(--coral); }
.payment-main { display: grid; gap: 6px; min-width: 0; }
.payment-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.payment-actions .button { min-height: 38px; padding: 7px 11px; font-size: 13px; }

.admin-plans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.plan-card.inactive { opacity: 0.7; box-shadow: none; }
.method-list { display: grid; gap: 7px; padding-top: 4px; }
.method-row { min-height: 40px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; }
.method-row span { min-width: 0; overflow-wrap: anywhere; font-size: 13px; font-weight: 650; }

.toggle {
  width: 42px;
  height: 24px;
  flex: 0 0 42px;
  position: relative;
  border: 0;
  border-radius: 999px;
  background: #aeb9b5;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 140ms ease;
}

.toggle.on { background: var(--teal); }
.toggle.on::after { transform: translateX(18px); }

.setting-row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.setting-row input { min-width: 0; }
.setting-row .button { min-height: 40px; padding: 8px 13px; }

.modal {
  width: min(calc(100% - 28px), 520px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(16, 21, 20, 0.28);
}

.modal::backdrop { background: rgba(8, 14, 12, 0.65); }
.modal form { display: grid; gap: 15px; padding: 20px; }
.modal h3 { margin: 4px 0 0; font-size: 20px; }
.modal-actions { justify-content: flex-end; }

.proof-modal { width: min(calc(100% - 24px), 820px); padding: 18px; }
.proof-content { min-height: 220px; display: grid; place-items: center; margin-top: 14px; background: #eef2f0; }
.proof-content img,
.proof-content iframe { display: block; width: 100%; max-height: 72vh; border: 0; object-fit: contain; background: #fff; }
.proof-content iframe { height: 68vh; }

@media (min-width: 640px) {
  .client-app { padding: 24px 0; }
  .app-shell { min-height: calc(100vh - 48px); border: 1px solid var(--line); box-shadow: var(--shadow); }
  .plans-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #featured-plan .plan-card { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  #featured-plan .plan-card .button { min-width: 170px; }
}

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar {
    position: sticky;
    z-index: 10;
    height: auto;
    padding: 10px 12px;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
  }
  .admin-brand { display: none; }
  .admin-nav { display: flex; padding: 0; gap: 4px; }
  .nav-item { min-width: max-content; min-height: 40px; }
  .admin-identity { order: -1; margin: 0; padding: 0 12px 0 0; border: 0; border-right: 1px solid #2b3532; }
  .admin-identity div { display: none; }
  .admin-main { padding-top: 20px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 580px) {
  .welcome-band { grid-template-columns: 1fr; align-items: end; }
  .welcome-band .button { width: 100%; }
  .payment-row { grid-template-columns: 1fr; }
  .payment-actions { justify-content: stretch; }
  .payment-actions .button { flex: 1; }
  .admin-plans { grid-template-columns: 1fr; }
  .setting-row { grid-template-columns: 1fr; gap: 7px; }
  .setting-row .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
