:root {
  --bg: #eef2f8;
  --panel: rgba(255, 255, 255, 0.97);
  --text: #17233a;
  --muted: #647184;
  --line: rgba(23, 35, 58, 0.12);
  --accent: #1f56b0;
  --accent-strong: #163f82;
  --accent-soft: #e3ecfb;
  --navy: #16294a;
  --navy-soft: #1d3a63;
  --red: #e2372a;
  --red-strong: #b82a1f;
  --red-soft: #fbe4e2;
  --shadow: 0 16px 38px rgba(15, 24, 41, 0.12);
  --shadow-sm: 0 6px 18px rgba(15, 24, 41, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

.topbar {
  min-height: 96px;
  padding: 22px 32px;
  background: linear-gradient(135deg, var(--navy), var(--navy-soft));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

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

.brand-logo {
  height: 52px;
  width: auto;
  display: block;
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

h1, h2, p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  font-weight: 750;
}

h2 {
  margin-bottom: 6px;
  font-size: 19px;
}

p {
  color: var(--muted);
}

main {
  flex: 1;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.status {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 10px 12px;
  color: #dbe6f7;
  min-width: 150px;
  text-align: center;
}

.band {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
}

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

.section-head.compact {
  align-items: center;
  margin-bottom: 12px;
}

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

.workspace {
  grid-template-columns: 1.4fr 1fr;
  align-items: start;
  margin-bottom: 22px;
}

.admin-workspace {
  grid-template-columns: minmax(320px, .85fr) minmax(0, 1.15fr);
}

.card,
.form-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.settings-intro {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.email-settings { margin: 16px 0 24px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.email-settings > summary { cursor: pointer; font-weight: 700; margin-bottom: 16px; }
.email-settings textarea { width: 100%; min-height: 88px; box-sizing: border-box; font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 6px; resize: vertical; }
.email-settings input[type="color"] { width: 64px; height: 40px; padding: 4px; }
.email-settings input[type="file"] { max-width: 100%; box-sizing: border-box; }
#emailLanguageOptions { margin: 12px 0; gap: 20px; }
#emailLanguageOptions label { display: flex; align-items: center; gap: 8px; }
#emailTranslations > details { padding: 8px 0; }
#emailTranslations summary { cursor: pointer; }
.email-logo-preview { display: block; width: 180px; height: 80px; object-fit: contain; margin: 8px 0; }

@media (max-width: 900px) {
  .settings-intro {
    grid-template-columns: 1fr;
  }
}

.module-card {
  position: relative;
}

.module-card.locked {
  filter: grayscale(0.75);
  opacity: 0.62;
  cursor: pointer;
}

.module-card.locked::after {
  content: "Modulo no incluido en el plan";
  position: absolute;
  inset: auto 14px 14px 14px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}

.module-card.locked input,
.module-card.locked label {
  pointer-events: none;
}

.module-picker {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #eef2f8;
}

.module-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.mini-pill {
  display: inline-flex;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 750;
}

.muted-pill {
  background: #e8ecf2;
  color: #8b96a8;
  text-decoration: line-through;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #cfd8e6;
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus {
  outline: 2px solid rgba(31, 86, 176, 0.22);
  border-color: var(--accent);
}

input[type="checkbox"] {
  width: 20px;
  min-height: 20px;
  accent-color: var(--accent);
}

.switch-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
  font-size: 15px;
}

.switch-line.small {
  font-size: 13px;
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.subsection {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.subsection h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.inline-form {
  display: grid;
  gap: 8px;
}

.compact-list .row {
  padding: 10px;
}

.campaign-panel {
  display: grid;
  gap: 14px;
}

.campaign-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  padding-top: 2px;
}

.campaign-head h3 {
  margin: 0 0 3px;
  font-size: 16px;
}

.campaign-head p {
  margin: 0;
  font-size: 13px;
}

.campaign-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #eef2f8;
}

.campaign-form label {
  margin-bottom: 0;
}

.advanced-fields {
  border: 1px dashed rgba(23, 35, 58, 0.22);
  border-radius: 10px;
  padding: 9px 10px;
  background: #eef2f8;
}

.advanced-fields summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.advanced-fields .pair {
  margin-top: 10px;
}

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

.compact-pair {
  gap: 8px;
}

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

.amount-buttons button {
  min-height: 34px;
  padding: 6px;
  font-size: 13px;
}

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

.campaign-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.campaign-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.campaign-item:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.campaign-item strong {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.campaign-rule {
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  margin-bottom: 3px;
}

button {
  min-height: 38px;
  border: 1px solid #cdd6e4;
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

button:hover {
  border-color: var(--accent);
}

button:active {
  transform: translateY(1px);
}

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  border-color: var(--accent-strong);
  box-shadow: 0 10px 20px rgba(22, 63, 130, 0.22);
}

button.primary:hover {
  background: var(--accent-strong);
}

button.ghost {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

.hidden {
  display: none !important;
}

.login-panel {
  min-height: calc(100vh - 220px);
  display: grid;
  place-items: center;
}

.login-shell {
  width: min(100%, 900px);
  min-height: 430px;
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(320px, 1.1fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  box-shadow: 0 30px 70px rgba(20, 20, 16, 0.24);
  background: #fff;
}

.login-card {
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 38px;
  background: #fff;
}

.login-card h2,
.login-card p {
  margin-bottom: 0;
}

.login-logo {
  width: 142px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.login-welcome {
  position: relative;
  display: flex;
  align-items: end;
  padding: 38px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(22, 41, 74, 0.2), rgba(10, 16, 28, 0.8)),
    url("/static/login-bg.png") center / cover;
}

.login-welcome h2 {
  max-width: 480px;
  margin: 12px 0 0;
  font-size: 34px;
  line-height: 1.05;
}

.glass-label {
  display: inline-flex;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 750;
  color: #fff;
}

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

.row,
.event {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.row:hover {
  box-shadow: var(--shadow-sm);
  border-color: rgba(31, 86, 176, 0.3);
  transform: translateY(-1px);
}

.row strong {
  display: block;
  margin-bottom: 3px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-flex;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red-strong);
  font-size: 12px;
  font-weight: 750;
  padding: 5px 8px;
}

.events {
  display: grid;
  gap: 8px;
}

.events-panel {
  padding-bottom: 18px;
}

.events-collapsible {
  width: 100%;
}

.events-collapsible > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.events-collapsible > summary::-webkit-details-marker {
  display: none;
}

.events-summary h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
}

.events-summary h2::before {
  content: "▸";
  display: inline-block;
  color: var(--muted);
  font-size: 14px;
  transition: transform 0.2s ease;
}

.events-collapsible[open] .events-summary h2::before {
  transform: rotate(90deg);
}

.events-hint {
  margin: 4px 0 0 22px;
  font-size: 13px;
}

.events-scroll {
  margin-top: 12px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 4px;
}

.events-scroll .event:nth-child(n+11) {
  display: none;
}

.event {
  display: grid;
  gap: 4px;
}

#companyResult {
  gap: 8px;
  margin-bottom: 12px;
}

code {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  background: #eef2f8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 6px;
}

.site-footer {
  margin-top: auto;
  padding: 18px 32px;
  text-align: center;
  background: linear-gradient(135deg, var(--navy), var(--navy-soft));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.site-footer p {
  margin: 0;
  color: #b7c4da;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.site-footer strong {
  color: #fff;
  font-weight: 650;
}

.join-page {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(22, 41, 74, 0.45), rgba(10, 16, 28, 0.82)),
    url("/static/login-bg.png") center / cover fixed;
}

.join-main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.join-shell {
  width: min(100%, 460px);
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 30px 70px rgba(14, 18, 14, 0.36);
}

.join-brand {
  margin-bottom: 22px;
}

.join-brand h1 {
  margin: 10px 0 4px;
  font-size: 28px;
}

.join-brand p:last-child {
  margin-bottom: 0;
}

.join-form {
  display: grid;
  gap: 12px;
}

.phone-field {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(150px, 1fr);
  gap: 10px;
}

.gift-code {
  font-family: monospace;
  letter-spacing: 1px;
}

.gift-balance {
  font-size: 24px;
  font-weight: 600;
}

.phone-field label {
  margin-bottom: 0;
}

.consent-line {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: start;
  gap: 10px;
  margin: 4px 0;
  line-height: 1.4;
}

.join-message {
  padding: 14px;
  border: 1px solid rgba(31, 86, 176, 0.28);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}

.join-message.error {
  border-color: rgba(160, 55, 45, 0.24);
  background: #fff0ed;
  color: #8e3029;
}

@media (max-width: 900px) {
  .settings-grid,
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-welcome {
    min-height: 220px;
    order: -1;
  }

  .login-welcome h2 {
    font-size: 28px;
  }

  .join-main {
    padding: 14px;
  }

  .join-shell {
    padding: 22px;
  }

  .phone-field {
    grid-template-columns: 1fr;
  }

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

  .campaign-item {
    grid-template-columns: 1fr;
  }
}
.mfa-qr {
  display: block;
  width: 208px;
  height: 208px;
  max-width: 100%;
  object-fit: contain;
  margin: 12px auto;
  background: white;
}

#mfaRecoveryCodes {
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.auth-dialog {
  width: min(440px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  box-sizing: border-box;
  padding: 24px;
  border: 1px solid #dce2e7;
  border-radius: 8px;
  background: #fff;
  color: #172827;
  box-shadow: 0 20px 64px #0003;
  overflow-y: auto;
}

.auth-dialog::backdrop { background: #111b26a6; }
.auth-dialog-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.auth-dialog h2 { font-size: 20px; line-height: 1.35; margin: 0; flex: 1; }
.auth-close { flex: 0 0 32px; width: 32px; height: 32px; padding: 0; font-size: 24px; }
.auth-dialog p { font-size: 14px; line-height: 1.5; }
.auth-dialog input { width: 100%; min-width: 0; box-sizing: border-box; }
.auth-dialog label { display: block; margin: 12px 0 8px; }
.auth-dialog .primary { width: 100%; margin-top: 8px; }
.auth-manual { margin: 12px 0 20px; }
.auth-manual summary { cursor: pointer; font-size: 13px; }
.auth-manual input { font-family: monospace; font-size: 12px; }
.auth-error { color: #a32432; min-height: 21px; margin: 8px 0; }
#mfaRecoveryCodes { padding: 16px; background: #f0f4f6; border-radius: 4px; line-height: 1.8; }

.language-picker { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.language-picker select { width: auto; min-width: 108px; margin: 0; padding: 8px 10px; }
.auth-dialog .language-picker { display: flex; justify-content: flex-end; margin: 0 0 14px; }
.join-page .language-picker { justify-content: flex-end; margin-bottom: 20px; }
.topbar-actions { flex-wrap: wrap; }
.panel-nav { display: flex; flex-wrap: wrap; gap: 20px; padding: 12px 0 20px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.panel-nav a { color: var(--text); font-size: 14px; text-decoration: none; }
.panel-nav a:hover { text-decoration: underline; }
.company-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.company-actions button { flex-shrink: 0; }
#companies .row { grid-template-columns: minmax(0, 1fr) auto; }
#companies .row > div { min-width: 0; overflow-wrap: anywhere; }
.auth-dialog code, .auth-dialog strong { overflow-wrap: anywhere; }
.action-link { display: inline-flex; padding: 10px 14px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); background: white; font-size: 14px; text-decoration: none; }
.danger { background: #b52434; color: white; }
.registration-layout { display: grid; grid-template-columns: 208px minmax(0, 1fr); align-items: center; gap: 28px; }
.registration-qr { width: 208px; height: 208px; object-fit: contain; background: white; }
.registration-details { min-width: 0; }
.registration-details input { width: 100%; margin: 8px 0 16px; }
.archived-companies { margin-top: 20px; }
.archived-companies summary { cursor: pointer; margin-bottom: 12px; }
.registration-print-page { background: white; }
.print-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 24px; padding: 20px; }
.registration-poster { width: min(680px, 100%); margin: 30px auto; text-align: center; padding: 24px; }
.registration-poster h1 { font-size: 30px; overflow-wrap: anywhere; }
.registration-poster h2 { font-size: 22px; overflow-wrap: anywhere; }
.registration-poster img { display: block; width: min(360px, 100%); aspect-ratio: 1; margin: 24px auto; object-fit: contain; }
.registration-poster img.hidden { display: none; }
.poster-url { font-size: 13px; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .topbar-brand { flex-direction: column; align-items: flex-start; gap: 12px; }
  .topbar h1 { font-size: 24px; overflow-wrap: anywhere; }
  #companies .row { grid-template-columns: minmax(0, 1fr); }
  .registration-layout { grid-template-columns: minmax(0, 1fr); }
  .registration-qr { margin: 0 auto; }
}
@media print {
  .registration-print-page .print-controls { display: none; }
  .registration-print-page .registration-poster { margin: 0 auto; padding: 12mm; width: 100%; }
  .registration-print-page .registration-poster img { width: 85mm; max-width: 100%; }
  .registration-print-page .registration-poster { break-inside: avoid; }
}
.notice-dialog { width: min(400px, calc(100% - 32px)); border-top: 4px solid #2460ae; }
.notice-dialog[data-kind="error"] { border-top-color: #b52c3c; }
.notice-dialog[data-kind="success"] { border-top-color: #18766a; }
.notice-dialog h2 { font-size: 18px; }
#noticeMessage { margin: 0 0 24px; overflow-wrap: anywhere; white-space: pre-line; }
.notice-actions { display: flex; justify-content: flex-end; }
.notice-dialog .primary { width: auto; min-width: 96px; margin: 0; }
.gift-card-list summary { cursor: pointer; font-weight: 700; padding: 12px 0; }
.gift-card-list .list { margin-top: 12px; }
.gift-qr { width: 220px; max-width: 100%; height: auto; justify-self: center; }
.gift-barcode { width: 100%; max-width: 440px; height: auto; justify-self: center; }
.gift-code { letter-spacing: 0; overflow-wrap: anywhere; min-width: 0; }
