:root {
  --navy: #233589;
  --navy-light: #3a4bb0;
  --bg: #f4f5f9;
  --border: #dcdfec;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: #1a1a1a;
}

header {
  background: var(--navy);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 18px;
  margin: 0;
  letter-spacing: 0.5px;
}

header .subtitle {
  font-size: 12px;
  opacity: 0.8;
}

.header-nav {
  display: flex;
  gap: 8px;
}

.header-nav a {
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.15s ease;
}

.header-nav a:hover {
  background: rgba(255, 255, 255, 0.22);
}

.layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 24px;
  padding: 24px;
  align-items: start;
}

/* ---- Pantalla de categorías ---- */

.landing {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px;
}

.landing-title {
  text-align: center;
  color: var(--navy);
  font-size: 22px;
  margin-bottom: 24px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 700px) {
  .category-grid { grid-template-columns: repeat(2, 1fr); }
}

.category-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.category-card:hover:not(.category-card-disabled) {
  border-color: var(--navy);
  box-shadow: 0 4px 14px rgba(35, 53, 137, 0.15);
}

.category-card-disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.category-card-name {
  color: var(--navy);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
}

.category-card-desc {
  color: #777;
  font-size: 12px;
}

.back-link {
  background: none;
  border: none;
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 12px;
}

.back-link:hover { text-decoration: underline; }

@media (max-width: 950px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}

.panel + .panel { margin-top: 18px; }

.panel h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--navy);
  margin: 0 0 12px;
}

label.field {
  display: block;
  margin-bottom: 14px;
}

label.field span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #444;
  margin-bottom: 4px;
}

input[type="text"],
input[type="password"],
input[type="email"] {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.radio-group {
  display: flex;
  gap: 16px;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.radio-group label.radio-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.field-hint {
  font-size: 11px;
  color: #888;
  margin-top: 5px;
  line-height: 1.4;
}

label.field > input[type="number"] {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.generic-price-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 18px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--border);
}

.generic-price-row:last-child { border-bottom: none; }

.generic-price-row .generic-price-res {
  font-size: 11px;
  font-weight: 600;
  color: #666;
  letter-spacing: 0.3px;
}

.hist-acciones {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.precio-tachado {
  text-decoration: line-through;
  color: #999;
  font-size: 0.55em;
  font-weight: 400;
  margin-right: 6px;
}

.qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #eef0f6;
}

.qty-row:last-child { border-bottom: none; }

.qty-row-label { display: flex; flex-direction: column; }
.qty-row-name { font-size: 13px; font-weight: 600; }
.qty-row-detail { font-size: 11px; color: #777; }
.qty-row-price { font-size: 11px; color: var(--navy); font-weight: 600; }

.qty-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.qty-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f7f8fc;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}

.qty-btn:hover { background: #eceffa; }

.qty-stepper input[type="number"] {
  width: 44px;
  text-align: center;
  padding: 5px 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}

details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  margin: 4px 0 8px;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

button.primary,
a.primary {
  flex: 1;
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

button.primary:disabled {
  background: #9aa2c9;
  cursor: not-allowed;
}

button.secondary,
a.secondary {
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--navy);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

/* ---- Vista previa ---- */

.preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-page1 {
  width: 100%;
  max-width: 620px;
  aspect-ratio: 210 / 297;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 18px rgba(0,0,0,0.08);
}

.preview-page1-photo img { width: 100%; display: block; }

.preview-page1-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 14px 24px 20px;
}

.cover-heading {
  line-height: 1.3;
  text-align: center;
  margin-bottom: 24px;
}

.cover-heading-1 { color: var(--navy); font-weight: 700; font-size: 27px; }
.cover-heading-2 { color: var(--navy); font-weight: 400; font-size: 22px; }

.cover-client-name {
  color: var(--navy);
  font-weight: 400;
  font-size: 15px;
  letter-spacing: 0.5px;
  line-height: 1.2;
  margin-bottom: 4px;
}

.cover-tagline {
  color: var(--navy);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.3px;
}

.preview-page3 {
  width: 100%;
  max-width: 620px;
  aspect-ratio: 210 / 297;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 18px rgba(0,0,0,0.08);
}

.preview-hero { position: relative; }
.preview-hero img { width: 100%; display: block; }
.preview-hero-titulo {
  position: absolute;
  top: 4%;
  left: 4%;
  right: 4%;
  color: var(--navy);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
}

.preview-banner {
  background: var(--navy);
  color: #fff;
  text-align: center;
  font-size: 15px;
  padding: 10px 8px;
}

.preview-body {
  flex: 1;
  padding: 14px 18px 6px;
  display: flex;
  flex-direction: column;
}

.preview-meta {
  font-size: 10px;
  color: #888;
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

#previewCircles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 4px;
  margin-bottom: 8px;
}

.circle-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 18%;
  min-width: 70px;
}

.circle-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}

.circle-label {
  font-size: 8.5px;
  text-align: center;
  color: var(--navy);
  font-weight: 600;
  line-height: 1.2;
}

.circle-label small { font-weight: 400; color: #666; }

.circle-photo {
  position: relative;
  width: 52px;
  height: 52px;
  margin-bottom: 4px;
}

.circle-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}

.circle-photo-qty {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: var(--navy);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 15px;
  height: 15px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #fff;
}

.empty-hint {
  font-size: 12px;
  color: #999;
  text-align: center;
  padding: 20px 0;
}

.plan-title {
  text-align: center;
  color: var(--navy);
  font-size: 20px;
  font-weight: 400;
  margin: 4px 0 10px;
}

.pay-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.pay-card {
  background: #ecefF9;
  border: 1px solid var(--navy);
  border-radius: 8px;
  padding: 10px 12px;
}

.pay-card-title {
  color: var(--navy);
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.2px;
  margin-bottom: 4px;
}

.pay-card-sub {
  color: var(--navy);
  font-size: 9px;
  line-height: 1.4;
}

.pay-card-strike-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 0 2px;
}

.pay-card-strike {
  font-size: 11px;
  color: #999;
  text-decoration: line-through;
}

.discount-badge {
  background: #d63a3a;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.cuotas-vineta {
  color: #d63a3a;
  font-weight: 700;
  font-size: 10px;
  margin-top: 4px;
}

.pay-card-price {
  color: var(--navy);
  font-weight: 700;
  font-size: 21px;
  line-height: 1.2;
  margin: 2px 0 4px;
}

.pay-card-price span {
  font-size: 11px;
  font-weight: 400;
}

.pay-card-price-single {
  color: var(--navy);
  font-weight: 700;
  font-size: 24px;
  text-align: right;
  margin-top: 4px;
}

.pay-card-fine {
  font-size: 7.5px;
  color: #777;
  line-height: 1.3;
  margin-top: 4px;
}

.price-disclaimer {
  font-size: 8px;
  color: #999;
  margin-top: auto;
  padding-top: 6px;
}

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

.fixed-pages-toggle summary { font-size: 12px; color: #555; }
.fixed-pages-preview {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}
.fixed-pages-preview img {
  width: 120px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* ---- Vista previa genérica (categorías con plantilla propia, ej. cámaras) ---- */

.preview-generic-cover {
  position: relative;
  width: 100%;
  max-width: 420px;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0,0,0,0.08);
}

.preview-generic-cover img { width: 100%; display: block; }

.preview-generic-cover-name {
  position: absolute;
  left: 8%;
  top: 68%;
  color: #fff;
  font-weight: 700;
  font-size: 5.5vw;
  max-width: 84%;
}

@media (min-width: 420px) {
  .preview-generic-cover-name { font-size: 22px; }
}

.preview-generic-body {
  width: 100%;
  max-width: 480px;
  margin-top: 12px;
}

#genericCircles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 4px;
  margin-bottom: 12px;
}

/* ---- Historial y panel de precios ---- */

.page-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar label {
  font-size: 13px;
  font-weight: 600;
  color: #444;
}

.toolbar select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  min-width: 260px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #666;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
}

.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.data-table .prod-nombre { font-weight: 600; }
.data-table .prod-detalle { font-size: 11px; color: #777; margin-top: 2px; }
.data-table .prod-thumb { width: 36px; height: 36px; border-radius: 6px; object-fit: contain; border: 1px solid var(--border); background: #fff; }

.data-table input[type="number"] {
  width: 90px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}

.data-table input.dirty {
  border-color: #d99a1f;
  background: #fff9ec;
}

.res-price-row { display: flex; align-items: center; gap: 4px; margin-bottom: 3px; }
.res-price-row span { font-size: 10px; color: #888; width: 32px; }

.badge-custom {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--navy);
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 6px;
}

.status-msg {
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.status-msg.info { background: #eef1fb; color: var(--navy); }
.status-msg.ok { background: #e6f6ea; color: #1c7a37; }
.status-msg.error { background: #fdecec; color: #b5271a; }

.add-item-form {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 16px;
}

.add-item-form label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #444;
  margin-bottom: 4px;
}

.add-item-form input,
.add-item-form select {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}

.btn-link {
  background: none;
  border: none;
  color: #b5271a;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #888;
  font-size: 14px;
}

.panel h2 small {
  display: block;
  text-transform: none;
  letter-spacing: normal;
  color: #999;
  font-size: 11px;
  font-weight: 400;
  margin-top: 2px;
}

.ganancia-box {
  background: #f7f8fc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}

.ganancia-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
}

.ganancia-total {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 8px;
  font-weight: 700;
  color: var(--navy);
  font-size: 15px;
}

.ganancia-margen {
  font-weight: 600;
  color: #1c7a37;
}

.ganancia-warning { color: #b5271a; }

.ganancia-config { margin-top: 12px; }

.ganancia-config input[type="number"] {
  width: 110px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}

.ganancia-config-inline {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 20px;
  margin-bottom: 18px;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #444;
  cursor: pointer;
}

/* Control de acceso (assets/auth-guard.js) */

body.auth-pending > *:not(.auth-overlay) { display: none !important; }

.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.auth-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 32px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 24px rgba(35, 53, 137, 0.1);
}

.auth-card h2 {
  color: var(--navy);
  margin: 0 0 10px;
  font-size: 18px;
}

.auth-card p { font-size: 13px; color: #555; margin: 0 0 14px; }

.auth-card form { text-align: left; }

.auth-card .primary,
.auth-card .secondary {
  width: 100%;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-bar-info {
  font-size: 12px;
  color: #fff;
  opacity: 0.85;
}

.user-bar .btn-link {
  color: #fff;
  opacity: 0.85;
}
