:root {
  --primary: #eba211;
  --primary-dark: #c98700;
  --dark: #343c43;
  --dark-2: #23292f;
  --gray: #9f9f9e;
  --gray-light: #e7e6e5;
  --light: #f7f6f4;
  --white: #ffffff;
  --danger: #d64545;
  --success: #2e9e4f;
  --radius: 12px;
  --font: 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--light);
  color: var(--dark);
}

a { text-decoration: none; color: inherit; }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--dark-2), var(--dark));
}
.login-card {
  background: var(--white);
  padding: 2.5rem 2.25rem;
  border-radius: var(--radius);
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  text-align: center;
}
.login-card__logo { width: 72px; height: 72px; object-fit: contain; margin-bottom: .75rem; }
.login-card h1 { font-size: 1.3rem; margin: 0 0 .25rem; }
.login-card__sub { color: var(--gray); font-size: .9rem; margin: 0 0 1.25rem; }
.login-card label { display: block; text-align: left; font-size: .85rem; font-weight: 600; margin: .75rem 0 .3rem; }
.login-card input[type=text], .login-card input[type=password] {
  width: 100%; padding: .65rem .8rem; border: 1px solid var(--gray-light); border-radius: 8px; font-size: .95rem;
}
.login-card__error {
  background: #fdecec; color: var(--danger); padding: .6rem .8rem; border-radius: 8px; font-size: .85rem;
  margin-bottom: .5rem; display: flex; gap: .4rem; align-items: center; text-align: left;
}
.login-card .btn-primary { width: 100%; margin-top: 1.25rem; justify-content: center; }

/* ---------- Botones ---------- */
.btn-primary, .btn-outline {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .6rem 1.1rem; border-radius: 8px; font-size: .9rem; font-weight: 600;
  border: none; cursor: pointer; transition: .2s;
}
.btn-primary { background: var(--primary); color: var(--dark-2); }
.btn-primary:hover { background: var(--primary-dark); color: var(--white); }
.btn-outline { background: var(--white); color: var(--dark); border: 1px solid var(--gray-light); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-dark); }

.icon-btn {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1px solid var(--gray-light); background: var(--white); cursor: pointer; color: var(--dark);
}
.icon-btn:hover { background: var(--gray-light); }
.icon-btn--danger:hover { background: #fdecec; color: var(--danger); border-color: #f4b9b9; }

/* ---------- Topbar ---------- */
.topbar-admin {
  background: var(--dark-2); color: var(--white);
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1.5rem;
}
.topbar-admin__brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.topbar-admin__brand img { height: 32px; }
.topbar-admin__user { display: flex; align-items: center; gap: .8rem; font-size: .9rem; }
.topbar-admin__logout { display: flex; align-items: center; gap: .3rem; color: var(--primary-light, #ffc94d); }
.topbar-admin__logout:hover { color: var(--primary); }

/* ---------- Main ---------- */
.admin-main { max-width: 1200px; margin: 0 auto; padding: 1.75rem 1.5rem 3rem; }
.admin-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.admin-head h1 { margin: 0 0 .25rem; font-size: 1.5rem; }
.admin-head p { margin: 0; color: var(--gray); font-size: .9rem; max-width: 520px; }

.admin-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; flex-wrap: wrap; gap: .75rem; }
.admin-search { position: relative; }
.admin-search i { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--gray); }
.admin-search input { padding: .55rem .8rem .55rem 2.1rem; border: 1px solid var(--gray-light); border-radius: 8px; width: 260px; font-size: .9rem; }
.admin-toolbar__right { display: flex; align-items: center; gap: .8rem; }
.admin-count { color: var(--gray); font-size: .85rem; }

/* ---------- Tabla ---------- */
.table-wrap { background: var(--white); border-radius: var(--radius); overflow: auto; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; table-layout: fixed; }
.admin-table th, .admin-table td { padding: .7rem .8rem; border-bottom: 1px solid var(--gray-light); text-align: left; overflow: hidden; }
.admin-table th { background: var(--light); font-weight: 700; cursor: pointer; position: relative; user-select: none; white-space: nowrap; }
.admin-table th.col-handle, .admin-table th.col-img, .admin-table th.col-acciones { cursor: default; }
.sort-icon { font-size: .75rem; margin-left: .3rem; color: var(--gray); }
.admin-table th.sorted-asc .sort-icon::before { content: "\f149"; }
.admin-table th.sorted-desc .sort-icon::before { content: "\f12e"; }

.col-handle { width: 34px; }
.col-img { width: 70px; }
.col-acciones { width: 120px; }

.admin-table tbody tr:nth-child(even) { background: #fbfbfa; }
.admin-table tbody tr.dragging { opacity: .4; }
.admin-table tbody tr.drag-over { box-shadow: inset 0 2px 0 var(--primary); }

.drag-handle { cursor: grab; color: var(--gray); }
.drag-handle:active { cursor: grabbing; }

.row-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; display: block; background: var(--gray-light); }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge--activo { background: #e6f6ea; color: var(--success); }
.badge--inactivo { background: #f1f1f0; color: var(--gray); }

.resize-handle { position: absolute; right: 0; top: 0; width: 6px; height: 100%; cursor: col-resize; }

.row-actions { display: flex; gap: .4rem; }

.table-empty { text-align: center; padding: 3rem 1rem; color: var(--gray); }
.table-empty i { font-size: 2rem; display: block; margin-bottom: .5rem; }

/* ---------- Modal ---------- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(20,22,24,.55);
  align-items: center; justify-content: center; z-index: 100; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal-card { background: var(--white); border-radius: var(--radius); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; }
.modal-card__head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--gray-light); }
.modal-card__head h2 { margin: 0; font-size: 1.15rem; }
.modal-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--gray); }
.modal-close:hover { color: var(--dark); }

#formProyecto { padding: 1.2rem 1.4rem 1.4rem; }
#formProyecto label { display: block; font-size: .85rem; font-weight: 600; margin: .8rem 0 .3rem; }
#formProyecto input[type=text], #formProyecto select {
  width: 100%; padding: .55rem .75rem; border: 1px solid var(--gray-light); border-radius: 8px; font-size: .9rem;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.switch-row { display: flex; align-items: center; gap: .5rem; font-weight: 500 !important; cursor: pointer; }
.switch-row input { width: auto !important; }

.modal-card__actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.3rem; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--gray-light); border-radius: 10px; padding: 1.2rem; text-align: center;
  cursor: pointer; transition: .2s; position: relative;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: #fff9ec; }
.dropzone__placeholder i { font-size: 1.8rem; color: var(--primary); }
.dropzone__placeholder p { margin: .4rem 0 .1rem; font-weight: 600; font-size: .9rem; }
.dropzone__placeholder span { font-size: .78rem; color: var(--gray); }
.dropzone__preview { max-width: 100%; max-height: 160px; border-radius: 8px; margin: 0 auto; display: block; }

/* ---------- Editor de texto enriquecido ---------- */
.rte { background: var(--white); border-radius: 8px; }
.rte .ql-toolbar { border-color: var(--gray-light); border-radius: 8px 8px 0 0; }
.rte .ql-container { border-color: var(--gray-light); border-radius: 0 0 8px 8px; font-family: var(--font); font-size: .9rem; min-height: 130px; }

/* ---------- Galería ---------- */
.galeria-section { margin-top: .8rem; }
.galeria-hint { font-size: .82rem; color: var(--gray); margin: .2rem 0 0; }
.dropzone--compact { padding: .8rem; margin-top: .5rem; }
.dropzone--compact .dropzone__placeholder i { font-size: 1.4rem; }
.dropzone--compact .dropzone__placeholder p { font-size: .82rem; margin: .3rem 0 0; }

.galeria-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .6rem; margin-top: .7rem; }
.galeria-item { position: relative; border-radius: 8px; overflow: hidden; aspect-ratio: 1; cursor: grab; background: var(--gray-light); }
.galeria-item.dragging { opacity: .4; }
.galeria-item.drag-over { outline: 2px solid var(--primary); outline-offset: -2px; }
.galeria-item img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.galeria-item__quitar {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(20,22,24,.7); color: var(--white); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: .7rem;
}
.galeria-item__quitar:hover { background: var(--danger); }
.galeria-item--subiendo { display: flex; align-items: center; justify-content: center; }
.galeria-item--subiendo .mini-spinner {
  width: 20px; height: 20px; border: 3px solid var(--gray-light); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 1s linear infinite;
}

/* ---------- Loading overlay ---------- */
.loading-overlay {
  display: none; position: fixed; inset: 0; background: rgba(20,22,24,.65); z-index: 200;
  align-items: center; justify-content: center;
}
.loading-overlay.open { display: flex; }
.loading-overlay__box { background: var(--white); padding: 1.5rem 1.8rem; border-radius: var(--radius); text-align: center; width: 280px; }
.loading-overlay__spinner {
  width: 34px; height: 34px; border: 4px solid var(--gray-light); border-top-color: var(--primary);
  border-radius: 50%; margin: 0 auto .8rem; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay__box p { margin: 0 0 .6rem; font-weight: 600; }
.loading-overlay__box small { color: var(--gray); }
.progress-bar { background: var(--gray-light); border-radius: 999px; height: 8px; overflow: hidden; margin-bottom: .6rem; }
.progress-bar__fill { background: var(--primary); height: 100%; width: 0%; transition: width .15s; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 1.2rem; right: 1.2rem; background: var(--dark-2); color: var(--white);
  padding: .75rem 1.1rem; border-radius: 8px; font-size: .9rem; opacity: 0; transform: translateY(10px);
  transition: .25s; pointer-events: none; z-index: 300; max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast--error { background: var(--danger); }

@media (max-width: 720px) {
  .admin-toolbar { flex-direction: column; align-items: stretch; }
  .admin-search input { width: 100%; }
  .form-row { grid-template-columns: 1fr; }
}
