:root {
  --bg: #111327;
  --panel: #1A1C3A;
  --dark: #0C0D1E;
  --accent: #D97706;
  --accent-dark: #BF571B;
  --text: #F2D091;
  --muted: #C6B98C;
  --border: #2E3155;
  --danger: #BF571B;
  --success: #3a7d44;
  --radius: 12px;
  --font: "Jost", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-heading: "Playfair Display", Georgia, "Times New Roman", serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--font-heading); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #111327, #2A1F3D);
  padding: 1.5rem;
}

.login-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: min(380px, 100%);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.3rem;
}

.login-card .sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.8rem; }

/* ---------- Formularios ---------- */
.field { margin-bottom: 0.75rem; }

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #0F1129;
  color: var(--text);
}

.field textarea { resize: vertical; min-height: 70px; }

.image-upload-row { margin-top: 0.5rem; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.field.checkbox {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.field.checkbox input { width: auto; }
.field.checkbox label { margin: 0; }

.btn {
  display: inline-block;
  padding: 0.65rem 1.4rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-primary { background: var(--accent); color: var(--dark); }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }

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

.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

.btn-block { width: 100%; }

.error-msg { color: var(--danger); font-size: 0.85rem; margin-top: 0.75rem; min-height: 1.2em; }

/* ---------- Layout admin ---------- */
.admin-topbar {
  background: var(--dark);
  color: #fff;
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.admin-topbar .brand { font-weight: 700; font-size: 1.1rem; color: var(--accent); }

.admin-topbar .brand span { color: var(--accent); }

.admin-topbar .user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.admin-body {
  max-width: 1000px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }

.tab {
  padding: 0.6rem 1.3rem;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--cream);
}

.tab.active { background: var(--dark); color: #fff; border-color: var(--dark); }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; }

th, td {
  text-align: left;
  padding: 0.8rem 1rem;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th { background: #20234A; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }

tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.ok { background: rgba(58, 125, 68, 0.18); color: #8fcf97; }
.badge.off { background: rgba(191, 87, 27, 0.18); color: #e8945c; }

.actions { display: flex; gap: 0.4rem; }

.cat-cell { display: flex; align-items: center; gap: 0.6rem; }
.cat-cell img { width: 38px; height: 38px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: min(520px, 100%);
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
}

.modal h2 { font-size: 1.3rem; margin-bottom: 1.2rem; }

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

/* ---------- QR ---------- */
.qr-section {
  margin-top: 2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}

.qr-section h3 { margin-bottom: 0.4rem; }
.qr-section p { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.2rem; }
.qr-section img { width: 180px; height: 180px; margin: 0 auto; border: 1px solid var(--border); border-radius: 8px; }
.qr-section .url { margin-top: 1rem; font-family: monospace; font-size: 0.85rem; color: var(--accent-dark); word-break: break-all; }

@media (max-width: 640px) {
  th, td { padding: 0.55rem 0.6rem; font-size: 0.85rem; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .hide-sm { display: none; }
}
