:root {
  --primary: #4F46E5;
  --primary-dark: #3730A3;
  --primary-darker: #1E1B4B;
  --accent: #22D3EE;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --text: #1E293B;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --error: #DC2626;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

/* Topbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar__actions .btn--secondary {
  flex: none;
  padding: 8px 14px;
  font-size: 0.85rem;
  border-radius: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary-darker);
}

.brand__mark {
  width: 28px;
  height: 28px;
  color: var(--primary);
  flex-shrink: 0;
}

.brand__name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Dashboard Pro */
.dashboard-pro {
  background: #EEF2FF;
  border-bottom: 1px solid var(--border);
}

.dashboard-pro__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px;
}

.dashboard-pro__title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary-darker);
  margin: 0 0 14px;
}

.account-pro-badge {
  color: #16A34A;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  margin: 0 0 4px;
}

/* Layout */
.layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 18px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  min-height: 44px;
  padding: 9px 8px;
  border-radius: 6px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab.is-active {
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.tab:focus-visible,
.btn:focus-visible,
.field:focus-visible,
.color-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Input panels */
.input-panel { display: none; }
.input-panel.is-active { display: block; }

.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 14px 0 6px;
}

.field-label:first-child { margin-top: 0; }

.field {
  width: 100%;
  padding: 11px 12px;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.field:focus {
  border-color: var(--primary);
}

textarea.field { resize: vertical; min-height: 90px; }

.field-with-action {
  display: flex;
  gap: 8px;
}

.field-with-action .field { flex: 1; }

.field-action {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 6px 0 0;
}

.field-error {
  color: var(--error);
  font-size: 0.85rem;
  font-weight: 600;
  margin: 12px 0 0;
}

/* Customize */
.customize {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.customize__title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.customize__row {
  display: flex;
  gap: 16px;
}

.customize__row .field-group { flex: 1; }

.color-input {
  width: 100%;
  height: 42px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  overflow: hidden;
}
.color-input::-webkit-color-swatch-wrapper { padding: 4px; }
.color-input::-webkit-color-swatch { border: none; border-radius: 6px; }
.color-input::-moz-color-swatch { border: none; border-radius: 6px; }

.logo-upload {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.logo-upload__input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
label.logo-upload__btn {
  flex: none;
  min-height: 44px;
  padding: 10px 16px;
  background: #16A34A;
  border: none;
  color: #fff;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.35);
}
.logo-upload__btn::before {
  content: "\2191";
  margin-right: 6px;
  font-weight: 800;
}
label.logo-upload__btn:hover {
  background: #15803D;
}
.logo-upload__filename {
  font-size: 0.85rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.logo-upload__preview[hidden] { display: none; }
.logo-upload__preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  width: 100%;
}

.logo-upload__preview img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  background: var(--bg);
}

.logo-upload__remove {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

/* Preview */
.panel--preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.preview-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.preview-card__canvas {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.preview-card__canvas canvas,
.preview-card__canvas svg {
  max-width: 100%;
  max-height: 100%;
}

.preview-empty {
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
  padding: 0 20px;
  margin: 0;
}

.preview-watermark {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

.download-actions {
  width: 100%;
  display: flex;
  gap: 10px;
}

/* Buttons */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s ease, transform 0.05s ease;
}

.btn:active { transform: scale(0.98); }

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

.btn--primary {
  flex: 1;
  background: var(--primary);
  color: #fff;
}

.btn--primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn--secondary {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn--pro-cta {
  background: #F97316;
  color: #fff;
  padding: 8px 14px;
  font-size: 0.85rem;
  box-shadow: 0 2px 6px rgba(249, 115, 22, 0.4);
  border-radius: 20px;
  white-space: nowrap;
}
.btn--pro-cta:hover { background: #EA580C; }

/* Ad slot */
.ad-slot {
  width: 100%;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.ad-slot p { margin: 0 0 4px; }
.ad-slot p:last-child { margin: 0; }
.ad-slot__cta strong { color: #F97316; }

/* Footer */
.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 24px 16px 40px;
}
.footer__extension-link {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
}
.footer__extension-link:hover { text-decoration: underline; }

/* Modal */
.modal[hidden] { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.modal__card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  max-width: 360px;
  width: 100%;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow);
}

.modal__card h3 {
  margin: 0 0 14px;
  font-size: 1.2rem;
}

.modal__list {
  margin: 0 0 14px;
  padding-left: 20px;
  font-size: 0.92rem;
}

.modal__list li { margin-bottom: 6px; }

.modal__note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 18px;
}

.modal__close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

.modal .btn--primary,
.modal a.btn--primary {
  width: 100%;
  display: block;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
  margin-bottom: 16px;
}

.modal__divider {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-align: center;
  margin: 4px 0 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.license-success {
  color: #16A34A;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 12px 0 0;
}

/* Locked (pro) select options rendered normally; lock feedback handled via JS alert-style error text */

/* Dynamic QR toggle */
.dynamic-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
}

.dynamic-toggle input { flex-shrink: 0; width: 18px; height: 18px; }

/* Account tabs/forms inside the Pro modal */
.account-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 14px;
}

.account-tab {
  flex: 1;
  border: none;
  background: transparent;
  min-height: 36px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.account-tab.is-active {
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.account-form { display: none; }
.account-form.is-active { display: block; }

.account-submit { margin-top: 14px; }

.account-email {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 14px;
  text-align: center;
}

/* Mis QRs panel */
.myqrs__count {
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.myqrs__empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0;
}

.qr-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.qr-item__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.qr-item__dest {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

.qr-item__scans {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.qr-item__link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.qr-item__link input {
  flex: 1;
  font-size: 0.78rem;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
}

.qr-item__chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 36px;
  margin-top: 10px;
}

.qr-item__bar {
  flex: 1;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
}

/* Desktop */
@media (min-width: 900px) {
  .layout {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: start;
  }

  .panel--preview {
    position: sticky;
    top: 84px;
  }
}
