.afi-wrap {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #222;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Shortcodes de pedidos: separación bajo cabecera fija del tema (solo vista no móvil) */
@media (min-width: 768px) {
  #afi-reservations.afi-wrap,
  #afi-res-date.afi-wrap,
  #afi-hired.afi-wrap,
  #afi-res-date-afi.afi-wrap,
  #afi-hired-afi.afi-wrap {
    margin-top: 70px;
  }
}

.afi-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 16px;
  margin: 0 0 16px;
}

.afi-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 12px;
}

.afi-grid input,
.afi-grid textarea,
.afi-inline input,
.afi-inline select,
.afi-card select {
  width: 100%;
  border: 1px solid #cfcfcf;
  border-radius: 8px;
  padding: 8px;
}

.afi-inline {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
}

.afi-btn {
  border: 0;
  border-radius: 10px;
  background: #7bc47f;
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
}

.afi-machine-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 8px;
  margin: 8px 0;
}

.afi-machine-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.afi-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: #dbeafe;
  color: #1e40af;
  cursor: pointer;
}

.afi-edit:hover {
  background: #bfdbfe;
}

.afi-icon-edit {
  display: block;
}

.afi-delete {
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  background: #f4d1d8;
  cursor: pointer;
}

.afi-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
}

.afi-modal-overlay[hidden] {
  display: none;
}

.afi-modal {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.afi-modal.afi-modal-wide {
  max-width: 960px;
}

.afi-modal h3 {
  margin: 0 0 16px;
  font-size: 1.25rem;
}

.afi-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.afi-btn-secondary {
  border: 1px solid #ccc;
  border-radius: 10px;
  background: #fff;
  color: #333;
  padding: 10px 14px;
  cursor: pointer;
}

.afi-btn-secondary:hover {
  background: #f5f5f5;
}

.afi-reg-toolbar {
  justify-content: space-between;
  flex-wrap: wrap;
}

.afi-reg-toolbar input {
  flex: 1;
}

.afi-reg-table-wrap {
  overflow: auto;
  margin-top: 8px;
}

.afi-reg-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  background: #fff;
}

.afi-reg-table th,
.afi-reg-table td {
  border: 1px solid #e7e7e7;
  padding: 8px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

.afi-col-center {
  text-align: center !important;
  width: 44px;
}

.afi-aff-check {
  width: 16px;
  height: 16px;
}

.afi-reg-table th {
  background: #f7f7f7;
  position: sticky;
  top: 0;
}

.afi-link-btn {
  background: transparent;
  border: 0;
  color: #1e40af;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.afi-aff-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 14px;
}

.afi-aff-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.afi-aff-form-grid input,
.afi-aff-form-grid textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #cfcfcf;
  border-radius: 8px;
  padding: 8px;
}

.afi-aff-code { grid-column: span 1; }
.afi-aff-name { grid-column: span 2; }
.afi-aff-email { grid-column: span 1; }
.afi-aff-phone { grid-column: span 1; }
.afi-aff-address { grid-column: span 1; }
.afi-aff-family { grid-column: span 2; }
.afi-aff-family-phone { grid-column: span 1; }

.afi-csv-dropzone {
  border: 2px dashed #9ca3af;
  border-radius: 12px;
  padding: 22px;
  text-align: center;
  background: #f9fafb;
}

.afi-csv-dropzone.is-dragover {
  background: #e0f2fe;
  border-color: #0284c7;
}

@media (max-width: 900px) {
  .afi-aff-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .afi-aff-name,
  .afi-aff-family {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .afi-aff-form-grid {
    grid-template-columns: 1fr;
  }
  .afi-aff-code,
  .afi-aff-name,
  .afi-aff-email,
  .afi-aff-phone,
  .afi-aff-address,
  .afi-aff-family,
  .afi-aff-family-phone {
    grid-column: span 1;
  }
}

.afi-weekly-select-row select {
  flex: 1;
  min-width: 160px;
}

.afi-week-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 8px;
  margin: 8px 0;
  align-items: start;
}

.afi-week-row textarea {
  width: 100%;
  min-height: 3.25rem;
  resize: vertical;
  box-sizing: border-box;
  font-family: inherit;
  font-size: inherit;
  line-height: 1.4;
  border: 1px solid #cfcfcf;
  border-radius: 8px;
  padding: 8px;
}

.afi-weekly-save-row,
.afi-replicate-year-row {
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
}

.afi-replicate-year-row input[type="number"] {
  width: 96px;
  max-width: 100%;
}

.afi-festivos-intro {
  font-size: 0.9rem;
  color: #444;
  margin: 0 0 12px;
  max-width: 720px;
}

.afi-festivos-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.afi-festivos-btn-hoy {
  font-weight: 700;
  min-width: 4.5rem;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 10px;
  background: #fffde7;
  color: #333;
  border: none;
  box-shadow:
    0 0 0 2px #ffc107,
    0 0 0 4px #fff,
    0 0 0 6px #ffc107,
    0 0 0 8px #fff,
    0 0 0 10px #ffc107;
}

.afi-festivos-btn-hoy:hover {
  background: #fff9c4;
}

.afi-festivos-nav-label {
  font-weight: 600;
  min-width: 200px;
  text-align: center;
  margin: 4px 0 12px;
}

.afi-festivos-calendars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.afi-festivos-cal-host {
  min-width: 0;
}

.afi-festivos-cal-caption {
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
}

.afi-festivos-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  font-size: 13px;
}

.afi-festivos-dow {
  text-align: center;
  font-weight: 600;
  color: #666;
  padding: 4px 0;
}

.afi-festivos-cell--empty {
  min-height: 32px;
}

.afi-festivos-day {
  border: 1px solid #ddd;
  border-radius: 6px;
  min-height: 36px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 4px 2px;
}

.afi-festivos-day--today {
  border-color: #ffc107 !important;
  box-shadow:
    0 0 0 1px #ffc107,
    0 0 0 3px #fff,
    0 0 0 5px #ffc107,
    0 0 0 7px #fff,
    0 0 0 9px #ffc107;
  position: relative;
  z-index: 1;
}

.afi-festivos-day--red {
  color: #c62828;
}

.afi-festivos-day--black {
  color: #111;
}

.afi-festivos-day--service {
  background: #d8f5dc;
}

.afi-festivos-day--noservice {
  background: #ececec;
}

.afi-festivos-day--selected {
  outline: 2px solid #2e7d32;
  outline-offset: 1px;
}

.afi-festivos-detail {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: #fafafa;
}

.afi-festivos-detail-date {
  font-weight: 600;
  margin: 0 0 8px;
}

.afi-festivos-holiday-blurb {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.afi-festivos-holiday-why {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.afi-festivos-holiday-celebration {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.4;
}

.afi-festivos-holiday-celebration strong {
  font-weight: 700;
}

.afi-festivos-no-slots {
  margin: 0;
}

.afi-festivos-machine-block {
  margin-bottom: 10px;
}

.afi-festivos-slot-list {
  margin: 4px 0 0 18px;
  padding: 0;
}

.afi-msg-error {
  background: #fff3e0;
  border: 1px solid #ffb74d;
  color: #5d4037;
}

.afi-msg {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 10px;
}

/* Vista reservas / res_date: usa todo el ancho del contenedor (tema + móvil), sin tope fijo 480px */
.afi-mobile {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
  --afi-week-nav-bg: #ffc107;
  --afi-week-nav-text: #111111;
  --afi-hoy-bg: #ffc107;
  --afi-hoy-text: #111111;
  --afi-day-active-bg: #b7e4c7;
  --afi-day-active-text: #111111;
  --afi-available-bg: #b7e4c7;
  --afi-available-text: #111111;
  background: #f7f7f7;
  min-height: 100vh;
  padding: 16px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
}

@media (max-width: 767px) {
  .afi-mobile {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .afi-mobile button,
  .afi-mobile [role="button"],
  .afi-mobile .afi-day-pill {
    touch-action: manipulation;
  }
}

.afi-user {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.afi-user--with-action {
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
  gap: 10px;
}

.afi-user-text {
  flex: 1;
  min-width: 0;
}

.afi-avatar-wrap {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: #d5d5d5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.afi-avatar-wrap--session {
  background: #fd9643;
}

.afi-avatar-silhouette {
  width: 34px;
  height: 34px;
  display: block;
}

.afi-user-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
  font-weight: 700;
  color: #153a5c;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.afi-user-month {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  color: #8a8a8a;
  font-weight: 400;
}

.afi-days {
  padding-bottom: 12px;
  margin-bottom: 8px;
}

.afi-days-nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

.afi-week-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-radius: 12px;
  background: var(--afi-week-nav-bg);
  color: var(--afi-week-nav-text);
  padding: 6px 10px;
}

.afi-week-month {
  flex: 1;
  text-align: center;
  color: var(--afi-week-nav-text);
  font-weight: 700;
  text-transform: lowercase;
  font-size: 18px;
}

.afi-week-nav-btn {
  flex-shrink: 0;
  width: 72px;
  min-height: 72px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--afi-week-nav-text);
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

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

.afi-week-actions--with-title {
  justify-content: space-between;
  width: 100%;
}

.afi-week-view-title {
  flex: 1;
  min-width: 0;
  text-align: left;
  color: var(--afi-week-nav-text);
  font-weight: 700;
  font-size: 18px;
  line-height: 1.2;
  text-transform: none;
}

.afi-hoy-btn {
  border: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--afi-hoy-bg);
  color: var(--afi-hoy-text);
  padding: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.afi-hoy-btn.is-current {
  border: 3px double var(--afi-hoy-bg);
}

.afi-week-nav-btn:active {
  filter: brightness(0.96);
}

.afi-days-strip {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: space-between;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.afi-day-pill {
  border: 0;
  border-radius: 12px;
  background: #ebebeb;
  min-width: 44px;
  flex: 1 1 0;
  max-width: 72px;
  min-height: 96px;
  padding: 8px 4px;
  color: #666;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  line-height: 1.1;
}

.afi-day-pill-day {
  font-size: 16px;
  font-weight: 700;
}

.afi-day-pill-num {
  font-size: 24px;
  font-weight: 800;
}

.afi-day-pill.active {
  background: var(--afi-day-active-bg);
  color: var(--afi-day-active-text);
}

.afi-day-pill.active .afi-day-pill-day,
.afi-day-pill.active .afi-day-pill-num {
  color: var(--afi-day-active-text);
}

.afi-day-pill.today-highlight {
  border: 8px double var(--afi-hoy-bg);
}

.afi-machine-card {
  background: #f2f2f2;
  border-radius: 14px;
  padding: 12px;
  margin: 12px 0;
  border-left: 8px solid var(--afi-machine-color, #ff6f00);
}

.afi-machine-card h3 {
  margin: 0 0 10px;
  font-size: 22px;
}

.afi-slot-wrap {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.afi-slot {
  border: 0;
  border-radius: 20px;
  width: 78px;
  height: 78px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  color: #333;
}

.afi-slot.available {
  background: var(--afi-available-bg);
  color: var(--afi-available-text);
}

.afi-slot.reserved {
  background: #e9c9d5;
}

.afi-slot.disabled {
  background: #d1d1d4;
}

.afi-slot.mine {
  background: #fd9643;
}

.afi-slot:disabled {
  cursor: not-allowed;
  opacity: 0.85;
}

.afi-empty {
  color: #777;
}

.afi-time-card {
  background: #f2f2f2;
  border-radius: 14px;
  padding: 12px;
  margin: 12px 0;
  border-left: 8px solid #ff6f00;
}

.afi-time-card h3 {
  margin: 0 0 10px;
  font-size: 22px;
}

.afi-time-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.afi-band-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.afi-band-status-soon-pending {
  background: #cfe8ff;
  color: #0b3a66;
}

.afi-band-status-available {
  background: var(--afi-available-bg);
  color: var(--afi-available-text);
}

.afi-band-status-ended {
  background: #d1d1d4;
  color: #444;
}

.afi-band-status-active {
  background: #b7e4c7;
  color: #1e4f2a;
}

.afi-equip-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.afi-equip-pill {
  border: 0;
  border-radius: 18px;
  min-width: 80px;
  height: 80px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 20px;
  color: #333;
  background: #d1d1d4;
  white-space: normal;
  word-break: break-word;
  line-height: 1.1;
  text-align: center;
}

.afi-equip-pill.available {
  background: var(--afi-available-bg);
  color: var(--afi-available-text);
}

.afi-equip-pill.reserved {
  background: #e9c9d5;
}

.afi-equip-pill.mine {
  background: #fd9643;
}

.afi-equip-pill.disabled {
  background: #d1d1d4;
}

.afi-equip-pill:disabled {
  cursor: not-allowed;
  opacity: 0.9;
}

@media (max-width: 540px) {
  .afi-user-title {
    font-size: 18px;
  }

  .afi-user-title.afi-aff-session-name {
    font-size: 18px;
  }

  .afi-day-pill {
    min-width: 38px;
    max-width: none;
    padding: 6px 2px;
  }
}

/* Diálogos táctiles: reservar / cancelar en móvil */
.afi-touch-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 200000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.5);
  -webkit-tap-highlight-color: transparent;
}

.afi-touch-dialog {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 16px;
  padding: 22px 20px 18px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
  box-sizing: border-box;
}

.afi-touch-dialog-msg {
  margin: 0 0 20px;
  font-size: 1.1rem;
  line-height: 1.45;
  color: #222;
  text-align: center;
  white-space: pre-line;
}

.afi-touch-dialog-actions {
  display: flex;
  flex-direction: row;
  gap: 12px;
  justify-content: stretch;
}

.afi-touch-dialog-actions-single {
  justify-content: center;
}

.afi-touch-dialog-btn {
  flex: 1;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  touch-action: manipulation;
}

.afi-touch-dialog-btn-primary {
  background: #7bc47f;
  color: #fff;
}

.afi-touch-dialog-btn-primary:active {
  filter: brightness(0.95);
}

.afi-touch-dialog-btn-secondary {
  background: #eee;
  color: #333;
}

.afi-touch-dialog-actions-single .afi-touch-dialog-btn {
  flex: 0 1 auto;
  min-width: 160px;
}

.afi-aff-session-name {
  line-height: 1.1;
  font-size: 22px;
}

.afi-user-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.afi-aff-logout-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: #f4d1d8;
  color: #7a1027;
  font-weight: 700;
  cursor: pointer;
}

.afi-codepad-modal {
  max-width: 420px;
}

.afi-codepad-display {
  margin: 6px 0 10px;
  text-align: center;
  font-size: 46px;
  font-weight: 700;
  letter-spacing: 3px;
  background: #ececec;
  border-radius: 12px;
  padding: 10px 6px;
}

.afi-codepad-name {
  text-align: center;
  min-height: 22px;
  font-weight: 600;
  margin: 0 0 10px;
}

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

.afi-codepad-key {
  min-height: 62px;
  border: 0;
  border-radius: 10px;
  font-size: 34px;
  background: #efefef;
  color: #666;
  cursor: pointer;
}

.afi-codepad-clear {
  background: #fd9643;
  color: #fff;
  font-weight: 700;
}

.afi-codepad-back {
  background: #f36a77;
  color: #fff;
}
