:root {
  --bg: #F7F3EC;
  --card-bg: #fff;
  --card-border: #EDE4D6;
  --row-border: #F2ECE1;
  --head-bg: #FAF6EF;
  --ink: #1A1A1A;
  --pink: #E91E8A;
  --pink-dark: #D81B7C;
  --muted: #888;
  --muted-2: #AAA;
  --green-bg: #E6F5EA;
  --green-fg: #2C8A4B;
  --red-bg: #FCE4E4;
  --red-fg: #C23636;
  --wa-green: #25D366;
  --font-display: "Unbounded", sans-serif;
  --font-body: "Manrope", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
}

a { color: var(--pink-dark); text-decoration: none; }
input, textarea, select { font-family: var(--font-body); }
.hidden { display: none !important; }

/* LOGIN */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--ink);
}
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.login-logo img { width: 40px; height: 40px; object-fit: cover; border-radius: 9px; }
.login-logo span { font-family: var(--font-display); font-weight: 800; font-size: 16px; color: var(--ink); }
.login-logo small { display: block; color: var(--muted); font-weight: 600; font-size: 11px; letter-spacing: 0.06em; }
.login-card h1 { font-family: var(--font-display); font-size: 20px; margin: 0 0 4px; }
.login-card p.sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 700; font-size: 13px; color: #555; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
.field textarea { resize: vertical; min-height: 70px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 100px;
  padding: 12px 22px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  font-family: var(--font-body);
}
.btn-primary { background: var(--ink); color: #fff; width: 100%; padding: 13px; }
.btn-primary:hover { background: #333; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #333; }
.btn-pink { background: var(--pink); color: #fff; }
.btn-pink:hover { background: var(--pink-dark); }
.btn-ghost { background: var(--row-border); color: var(--ink); }
.btn-ghost:hover { background: #e9e1d2; }
.btn-wa { background: var(--wa-green); color: #fff; white-space: nowrap; }
.btn-icon {
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  background: var(--row-border);
  font-size: 14px;
}
.btn-icon.danger { background: var(--red-bg); }
.btn-sm { padding: 8px 16px; font-size: 13px; }

.error-msg {
  background: var(--red-bg);
  color: var(--red-fg);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.ok-msg {
  background: var(--green-bg);
  color: var(--green-fg);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* APP SHELL */
.app { display: none; min-height: 100vh; }
.app.active { display: flex; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--ink);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; text-decoration: none; }
.sidebar .brand img { width: 38px; height: 38px; object-fit: cover; border-radius: 9px; }
.sidebar .brand-text { font-family: var(--font-display); font-weight: 800; font-size: 15px; color: #fff; }
.sidebar .brand-text small { display: block; color: #888; font-weight: 600; font-size: 11px; letter-spacing: 0.08em; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  color: #ccc;
  border: none;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  font-family: var(--font-body);
}
.nav-item .icon { font-size: 17px; }
.nav-item:hover { background: #262626; color: #fff; }
.nav-item.active { background: var(--pink); color: #fff; }
.nav-item .badge { margin-left: auto; background: var(--pink); color: #fff; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 100px; }
.nav-item.active .badge { background: rgba(255,255,255,0.25); }

.sidebar-footer { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid #333; }
.sidebar-footer .owner { font-size: 13px; font-weight: 700; color: #fff; }
.sidebar-footer .email { font-size: 12px; color: #888; margin-bottom: 10px; }
.sidebar-footer .logout { font-size: 13px; color: #999; cursor: pointer; }
.sidebar-footer .logout:hover { color: #fff; }
.sidebar-footer .view-site { font-size: 13px; color: #999; display: block; margin-top: 6px; }
.sidebar-footer .view-site:hover { color: #fff; }

.main { flex: 1; min-width: 0; padding: 32px 40px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 32px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-family: var(--font-display); font-weight: 800; font-size: 26px; color: var(--ink); margin: 0 0 4px; }
.page-head .sub { font-size: 14px; color: var(--muted); }

.card {
  background: var(--card-bg);
  border-radius: 16px;
  border: 1px solid var(--card-border);
  padding: 24px;
}
.card + .card { margin-top: 20px; }

/* DASHBOARD */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 18px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: 16px; padding: 22px; border: 1px solid var(--card-border); }
.stat-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.stat-value { font-family: var(--font-display); font-weight: 800; font-size: 28px; color: var(--ink); }
.msg-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--row-border); }
.msg-row:last-child { border-bottom: none; }
.msg-row .name { font-weight: 700; font-size: 14px; color: var(--ink); }
.msg-row .preview { font-size: 13px; color: var(--muted); }
.msg-row .date { font-size: 12px; color: var(--muted-2); white-space: nowrap; }

/* PRODUCTOS TABLE */
.table-wrap { background: #fff; border-radius: 16px; border: 1px solid var(--card-border); overflow: hidden; }
.table-head, .table-row {
  display: grid;
  grid-template-columns: 1fr 140px 100px 100px 80px;
  align-items: center;
  padding: 14px 20px;
  gap: 8px;
}
.table-head { background: var(--head-bg); font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.table-row { border-top: 1px solid var(--row-border); font-size: 14px; }
.table-row .p-name { font-weight: 700; color: var(--ink); }
.table-row .p-cat, .table-row .p-price { color: #666; }
.status-badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 100px; display: inline-block; }
.status-activo { background: var(--green-bg); color: var(--green-fg); }
.status-agotado { background: var(--red-bg); color: var(--red-fg); }
.row-actions { display: flex; gap: 8px; }
.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* FOTOS */
.fotos-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(220px,1fr)); gap: 18px; }
.foto-card { background: #fff; border-radius: 16px; border: 1px solid var(--card-border); overflow: hidden; }
.foto-thumb { width: 100%; height: 160px; background: var(--head-bg); display: flex; align-items: center; justify-content: center; font-size: 36px; overflow: hidden; position: relative; }
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; }
.foto-thumb .upload-btn { position: absolute; bottom: 8px; right: 8px; background: rgba(26,26,26,0.75); color: #fff; font-size: 11px; font-weight: 700; padding: 6px 10px; border-radius: 100px; cursor: pointer; }
.foto-body { padding: 12px 14px; }
.foto-body input { width: 100%; border: 1px solid var(--card-border); border-radius: 8px; padding: 8px 10px; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.foto-cat { font-size: 11px; color: #999; text-transform: uppercase; font-weight: 700; letter-spacing: 0.04em; }
.foto-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.foto-actions select { flex: 1; margin-right: 8px; font-size: 12px; padding: 6px 8px; border: 1px solid var(--card-border); border-radius: 8px; }

/* SERVICIOS */
.servicios-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(280px,1fr)); gap: 18px; }
.servicio-card { background: #fff; border-radius: 16px; border: 1px solid var(--card-border); padding: 20px; }
.servicio-card .emoji-preview { font-size: 22px; margin-bottom: 8px; }
.servicio-card .title-input { width: 100%; border: none; border-bottom: 1px solid var(--row-border); font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--ink); margin-bottom: 10px; padding: 4px 0; }
.servicio-card .title-input:focus { outline: none; border-bottom-color: var(--pink); }
.servicio-card textarea { width: 100%; border: 1px solid var(--card-border); border-radius: 10px; padding: 10px; font-size: 13px; color: #555; resize: vertical; }

/* MENSAJES */
.mensajes-grid { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.mensajes-list { background: #fff; border-radius: 16px; border: 1px solid var(--card-border); overflow: hidden; }
.mensaje-item { display: block; width: 100%; text-align: left; border: none; border-bottom: 1px solid var(--row-border); padding: 16px 18px; cursor: pointer; background: transparent; font-family: var(--font-body); }
.mensaje-item:last-child { border-bottom: none; }
.mensaje-item.selected { background: var(--head-bg); }
.mensaje-item .top-row { display: flex; justify-content: space-between; align-items: center; }
.mensaje-item .name { font-weight: 700; font-size: 14px; color: var(--ink); }
.mensaje-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pink); display: inline-block; }
.mensaje-item .preview { font-size: 13px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mensaje-item .date { font-size: 11px; color: var(--muted-2); margin-top: 6px; }
.mensaje-detail { background: #fff; border-radius: 16px; border: 1px solid var(--card-border); padding: 26px; min-height: 200px; }
.mensaje-detail .head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.mensaje-detail .name { font-weight: 800; font-size: 18px; color: var(--ink); }
.mensaje-detail .meta { font-size: 13px; color: var(--muted); }
.mensaje-detail .body { font-size: 15px; color: #333; line-height: 1.7; background: var(--head-bg); padding: 18px; border-radius: 12px; white-space: pre-wrap; }
.mensaje-detail .actions-row { margin-top: 16px; display: flex; gap: 10px; }

/* CONTACTO / FORM PANELS */
.form-panel { max-width: 560px; display: flex; flex-direction: column; gap: 16px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 160px; }

/* TOAST */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 14px 22px;
  border-radius: 12px;
  z-index: 200;
  animation: zg-toast 0.25s ease-out;
}
@keyframes zg-toast { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  padding: 20px;
}
.modal-box {
  background: #fff;
  border-radius: 18px;
  padding: 28px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box .modal-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: var(--ink); }

@media (max-width: 900px) {
  .mensajes-grid { grid-template-columns: 1fr; }
  .table-head { display: none; }
  .table-row { grid-template-columns: 1fr; row-gap: 6px; }
}
@media (max-width: 720px) {
  .app.active { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; overflow-x: auto; padding: 12px; align-items: center; }
  .sidebar .brand { display: none; }
  .sidebar-footer { display: none; }
  .main { padding: 20px; }
}
