*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

:root {
  --bg: #0d0d0d;
  --card-bg: #1a1a1a;
  --border: #333;
  --text: #ffffff;
  --muted: #aaaaaa;
  --accent: #1a73e8;
  --danger: #dc2626;
  --success: #16a34a;
  --font: 'Arial', sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ──────────────────────────
   LOGIN
────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2.5rem 2rem;
}

.login-logo {
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-align: center;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.form-group input {
  width: 100%;
  background: #111;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.75rem;
  font-family: var(--font);
  font-size: 0.9rem;
  border-radius: 3px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: #555;
}

.login-error {
  color: #f87171;
  font-size: 0.82rem;
  margin-top: 0.75rem;
  text-align: center;
  min-height: 1.2rem;
}

/* ──────────────────────────
   BUTTONS
────────────────────────── */
button[type="submit"],
.upload-btn {
  display: block;
  width: 100%;
  padding: 0.75rem;
  background: #222;
  color: var(--text);
  border: 1px solid var(--border);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  border-radius: 3px;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s;
}

button[type="submit"]:hover:not(:disabled),
.upload-btn:hover {
  background: #2a2a2a;
}

button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ──────────────────────────
   ADMIN PANEL
────────────────────────── */
.admin-panel {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-header {
  background: #111;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-header-logo {
  font-weight: 900;
  letter-spacing: 0.06em;
  font-size: 1rem;
  margin-right: auto;
}

.admin-region-selector {
  display: flex;
  gap: 0.25rem;
}

.region-btn {
  padding: 0.35rem 0.9rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
}

.region-btn.active,
.region-btn:hover {
  background: #333;
  color: var(--text);
  border-color: #555;
}

.btn-logout,
.btn-backup,
.btn-restore {
  padding: 0.35rem 0.9rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.82rem;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-restore {
  display: inline-block;
}

.btn-logout:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--text);
}

.btn-backup:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text);
}

.btn-restore:hover {
  background: var(--success);
  border-color: var(--success);
  color: var(--text);
}

.btn-backup:disabled,
.btn-restore.is-disabled {
  cursor: wait;
  opacity: 0.6;
  pointer-events: none;
}

.backup-status {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.78rem;
  min-height: 1rem;
  text-align: right;
}

.backup-status.ok {
  color: #4ade80;
}

.backup-status.error {
  color: #f87171;
}

.admin-main {
  padding: 1.5rem;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.admin-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem;
}

.admin-section-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.admin-section-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.65rem 1rem;
}

.admin-section-tab:hover,
.admin-section-tab.active {
  border-bottom-color: var(--accent);
  color: #60a5fa;
}

.admin-card h2 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* Portada */
.portada-preview-wrap {
  position: relative;
  width: 220px;
  min-height: 160px;
  background: #111;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.portada-img {
  width: 100%;
  display: block;
}

.portada-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Upload status */
.upload-status {
  font-size: 0.83rem;
  margin-top: 0.75rem;
  min-height: 1.2rem;
}

.upload-status.ok { color: #4ade80; }
.upload-status.error { color: #f87171; }
.upload-status.loading { color: var(--muted); }

/* Vacantes grid */
.admin-vacantes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .75rem;
  margin-top: 1rem;
}

.admin-vacante-item {
  position: relative;
  background: #111;
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  cursor: grab;
}

.admin-vacante-item:active {
  cursor: grabbing;
}

.admin-vacante-item.dragging {
  opacity: 0.35;
  cursor: grabbing;
}

.admin-vacante-item.drag-over {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.admin-vacante-item img {
  width: 100%;
  display: block;
  transition: transform 0.3s ease;
}

.btn-delete-vacante {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  opacity: 0.85;
  transition: opacity 0.2s;
  z-index: 1;
}

.btn-delete-vacante:hover {
  opacity: 1;
}

.vacante-menu {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 2;
}

.btn-menu-vacante {
  width: 24px;
  height: 24px;
  background: rgba(17, 17, 17, 0.88);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  padding-bottom: 5px;
}

.btn-menu-vacante:hover,
.vacante-menu.is-open .btn-menu-vacante {
  background: #222;
  border-color: #777;
}

.vacante-menu-panel {
  position: absolute;
  top: 28px;
  left: 0;
  min-width: 126px;
  background: #181818;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45);
  display: none;
  overflow: hidden;
}

.vacante-menu.is-open .vacante-menu-panel {
  display: block;
}

.btn-phone-vacante,
.btn-rotate-vacante {
  width: 100%;
  background: transparent;
  color: var(--text);
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.78rem;
  line-height: 1.2;
  padding: 0.55rem 0.7rem;
  text-align: left;
  white-space: nowrap;
}

.btn-phone-vacante:hover,
.btn-rotate-vacante:hover {
  background: #2a2a2a;
}

.vacante-phone-badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  background: rgba(22, 163, 74, 0.92);
  color: #fff;
  border-radius: 3px;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.2rem 0.3rem;
  z-index: 1;
}

.upload-btn-replace {
  background: #3a2020;
  border-color: #5a2020;
  margin-top: 0.5rem;
}

.upload-btn-replace:hover {
  background: #4a2020;
}

.cupones-count,
.admin-drag-help {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.75rem;
}

.admin-cupon-item {
  padding-bottom: 38px;
}

.admin-cupon-item > img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: contain;
  background: #fff;
}

.cupon-drag-handle,
.btn-rotate-cupon,
.btn-delete-cupon {
  position: absolute;
  bottom: 7px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cupon-drag-handle {
  left: 7px;
  width: 28px;
  color: var(--muted);
  cursor: grab;
}

.btn-rotate-cupon,
.btn-delete-cupon {
  background: #252525;
  cursor: pointer;
  font-size: 0.9rem;
  width: 28px;
}

.btn-rotate-cupon {
  right: 41px;
}

.btn-delete-cupon {
  right: 7px;
  background: var(--danger);
  border-color: var(--danger);
}

.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.admin-modal {
  background: #1e1e1e;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem;
  max-width: 360px;
  width: 90%;
}

.admin-modal-small {
  max-width: 340px;
}

.admin-modal-msg {
  margin: 0 0 1.2rem;
  white-space: pre-line;
  font-size: 0.9rem;
  line-height: 1.5;
}

.admin-modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.btn-modal {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
}

.btn-modal-cancel {
  background: #333;
  color: #ccc;
}

.btn-modal-cancel:hover {
  background: #444;
}

.btn-modal-confirm {
  background: var(--danger);
  color: #fff;
}

.btn-modal-confirm:hover {
  background: #b91c1c;
}

.admin-phone-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.45rem;
}

.admin-phone-input {
  width: 100%;
  background: #111;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.75rem;
  font-family: var(--font);
  font-size: 0.95rem;
  border-radius: 3px;
  outline: none;
  margin-bottom: 1rem;
}

@media (max-width: 767px) {
  .admin-main {
    padding: 1rem;
  }

  .admin-vacantes-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .admin-header {
    padding: 0.6rem 1rem;
  }

  .admin-section-tabs {
    overflow-x: auto;
  }
}
