:root {
  --brand-orange: #ff6a00;
  --brand-orange-soft: #ff9d47;
  --brand-blue: #1c2f4b;
  --ok: #2ad47f;
  --danger: #ef4444;
}

body[data-theme="dark"] {
  --bg-a: #07090f;
  --bg-b: #062322;
  --surface: rgba(15, 20, 30, 0.82);
  --surface-soft: rgba(28, 47, 75, 0.35);
  --text: #f4f7ff;
  --muted: #a8b1c0;
  --border: rgba(132, 148, 177, 0.25);
  --btn-bg: #1a2234;
  --card-glow: rgba(255, 106, 0, 0.14);
}

body[data-theme="light"] {
  --bg-a: #f6f9ff;
  --bg-b: #e9fff8;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-soft: rgba(28, 47, 75, 0.08);
  --text: #152035;
  --muted: #5a6b87;
  --border: rgba(103, 121, 158, 0.28);
  --btn-bg: #eef3ff;
  --card-glow: rgba(28, 47, 75, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Segoe UI", "SF Pro Text", "Noto Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 12% 92%, rgba(255, 106, 0, 0.17), transparent 60%),
    radial-gradient(1000px 640px at 88% 90%, rgba(45, 212, 191, 0.14), transparent 62%),
    linear-gradient(145deg, var(--bg-a), var(--bg-b));
  animation: bgShift 12s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0% {
    background-position: 0 0, 0 0, 0 0;
  }
  100% {
    background-position: -20px 15px, 24px -10px, 0 0;
  }
}

.app-shell {
  max-width: 680px;
  margin: 0 auto;
  padding: 10px 10px 16px;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  backdrop-filter: blur(10px);
  box-shadow: 0 15px 40px rgba(6, 8, 14, 0.28);
  overflow: hidden;
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(110deg, transparent 25%, var(--card-glow) 50%, transparent 75%);
  transform: translateX(-120%);
  transition: transform 0.6s ease;
}

.card:hover::after {
  transform: translateX(120%);
}

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

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

.brand-fire {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand-orange), var(--brand-orange-soft));
  font-size: 20px;
}

.brand-title {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.2px;
}

.brand-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  border-radius: 12px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  font-size: 18px;
}

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

.subscription,
.connect,
.renewal,
.email,
.actions,
.devices,
.legal {
  padding: 10px;
}

.sub-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sub-head h2 {
  margin: 0;
  font-size: 24px;
}

.status-chip {
  border-radius: 999px;
  padding: 7px 11px;
  font-weight: 700;
  font-size: 12px;
  border: 1px solid transparent;
}

.status-chip.is-active {
  background: rgba(42, 212, 127, 0.15);
  border-color: rgba(42, 212, 127, 0.5);
  color: var(--ok);
}

.status-chip.is-inactive {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.45);
  color: var(--danger);
}

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

.field {
  padding: 8px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.field-wide {
  grid-column: 1 / -1;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.field strong {
  font-size: 17px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.section-head h3 {
  margin: 0;
  font-size: 19px;
}

.slider-block {
  padding: 8px;
  border-radius: 12px;
  background: var(--surface-soft);
  margin-bottom: 8px;
}

.slider-title {
  font-size: 16px;
  margin-bottom: 8px;
}

.device-slider {
  width: 100%;
  accent-color: var(--brand-orange);
}

.slider-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

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

.tariff-card {
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  border-radius: 12px;
  padding: 9px;
  text-align: left;
  display: grid;
  gap: 3px;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.tariff-card:hover {
  transform: translateY(-1px);
}

.tariff-card.is-selected {
  border-color: rgba(255, 157, 71, 0.75);
  box-shadow: 0 0 0 2px rgba(255, 157, 71, 0.2);
}

.tariff-card.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tariff-name {
  font-size: 12px;
  color: var(--muted);
}

.tariff-main {
  font-size: 22px;
  font-weight: 700;
}

.tariff-meta {
  font-size: 11px;
}

.tariff-meta.subtle {
  color: var(--muted);
}

.pay-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.connect-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.connect-block {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 10px;
}

.connect-block h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.connect-block p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.store-groups {
  display: grid;
  gap: 8px;
}

.store-accordion {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.store-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  font-size: 14px;
  font-weight: 700;
  user-select: none;
}

.store-summary::-webkit-details-marker {
  display: none;
}

.store-summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.store-accordion[open] .store-summary::after {
  transform: rotate(180deg);
}

.store-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.store-dot-happ {
  background: linear-gradient(135deg, #ff7b35, #ffb176);
}

.store-dot-incy {
  background: linear-gradient(135deg, #3d7dff, #6fa5ff);
}

.store-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 0 8px 8px;
}

.store-link {
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  text-decoration: none;
  border-radius: 10px;
  padding: 8px;
  font-size: 12px;
  text-align: center;
}

.store-link:hover {
  border-color: rgba(255, 145, 82, 0.6);
}

.autoconnect-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.sub-link-hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.email-status {
  color: var(--muted);
  margin-bottom: 8px;
  font-size: 13px;
}

.email-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.email-grid input {
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  border-radius: 11px;
  padding: 10px;
  min-width: 0;
}

.actions h3,
.devices h3,
.legal h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

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

.action-btn {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--btn-bg);
  color: var(--text);
  padding: 8px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.action-btn:active,
.btn-primary:active,
.btn-secondary:active {
  transform: translateY(1px);
}

.btn-secondary,
.btn-primary {
  border-radius: 11px;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 8px 12px;
  font-weight: 600;
}

.btn-secondary {
  background: var(--btn-bg);
  color: var(--text);
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-orange), var(--brand-orange-soft));
  color: #ffffff;
  border-color: rgba(255, 145, 82, 0.6);
}

.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-danger {
  border-radius: 11px;
  border: 1px solid rgba(239, 68, 68, 0.38);
  background: rgba(239, 68, 68, 0.13);
  color: #ff8a8a;
  cursor: pointer;
  padding: 8px 12px;
  font-weight: 600;
}

.device-list {
  display: grid;
  gap: 8px;
}

.device-item {
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.device-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.device-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.device-actions {
  display: flex;
  gap: 8px;
  margin-top: 9px;
}

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

.legal-links {
  display: grid;
  gap: 6px;
}

.legal-links a {
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  border-radius: 10px;
  padding: 10px;
}

.legal-links a:hover {
  border-color: rgba(255, 145, 82, 0.6);
}

.empty {
  border-radius: 12px;
  border: 1px dashed var(--border);
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(6, 8, 14, 0.9);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hidden {
  display: none !important;
}

.faq-screen {
  padding: 10px;
}

.faq-list {
  display: grid;
  gap: 10px;
}

.faq-item {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 10px;
}

.faq-item h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.faq-item p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 5, 12, 0.74);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(520px, 100%);
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.35);
  padding: 14px;
}

.modal-card h3 {
  margin: 0 0 8px;
  font-size: 22px;
}

.modal-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.modal-actions {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 640px) {
  .actions-grid,
  .pay-row,
  .tariff-grid {
    grid-template-columns: 1fr 1fr;
  }

  .connect-grid,
  .store-links {
    grid-template-columns: 1fr;
  }

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

  .field strong {
    font-size: 16px;
  }

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

@media (max-width: 420px) {
  .actions-grid,
  .pay-row,
  .tariff-grid,
  .email-grid {
    grid-template-columns: 1fr;
  }

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