* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
:root {
  --cream: #f6f6f6;
  --cream-2: #ececec;
  --gold: #6b6b6b;
  --ink: #2b2b2b;
  --ink-2: #5f5f5f;
  --line: #e0e0e0;
  --danger: #b04a4a;
  --ok: #6b8e6a;
}
body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  font-size: 14px;
}
h1, h2, h3 { font-family: 'Bodoni Moda', Georgia, serif; font-weight: 500; }
a { color: var(--gold); }
code { background: var(--cream-2); padding: 2px 6px; border-radius: 3px; font-size: 12px; }
pre { background: var(--cream-2); padding: 12px; border-radius: 4px; font-size: 12px; overflow-x: auto; }

/* Login / setup / primer arranque */
#login, #setup, #primer-run {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
}
.card {
  background: white;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 4px 30px rgba(0,0,0,.06);
  width: 100%;
  max-width: 460px;
  display: grid;
  gap: 16px;
}
.card h1 { font-size: 32px; }
.card label { display: block; font-size: 13px; color: var(--ink-2); }
.card input, .card select, .card textarea {
  width: 100%; padding: 10px 12px; margin-top: 4px;
  border: 1px solid var(--line); border-radius: 4px;
  font: inherit; background: white;
}
button {
  padding: 10px 16px; border: none; border-radius: 4px;
  background: var(--ink); color: white; cursor: pointer;
  font: inherit; font-size: 14px;
}
button:hover:not(:disabled) { opacity: .9; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.danger { background: var(--danger); }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* Panel layout */
#panel { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
aside {
  background: white;
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  display: flex; flex-direction: column;
}
aside h2 { font-size: 22px; margin-bottom: 24px; padding-left: 8px; }
aside nav { display: grid; gap: 2px; flex: 1; }
aside nav button {
  background: transparent; color: var(--ink); text-align: left;
  padding: 10px 12px; border-radius: 4px; font-size: 14px;
}
aside nav button:hover { background: var(--cream-2); }
aside nav button.activo { background: var(--ink); color: white; }
aside nav button.solo-admin { display: none; }
body.es-admin aside nav button.solo-admin { display: block; }
.usuario { border-top: 1px solid var(--line); padding-top: 16px; font-size: 13px; display: grid; gap: 8px; }
.usuario span { color: var(--ink-2); padding: 0 8px; }
main { padding: 32px; overflow-y: auto; max-height: 100vh; }

/* Tablas */
.header-seccion { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.header-seccion h1 { font-size: 32px; }
table { width: 100%; background: white; border-radius: 6px; overflow: hidden; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { background: var(--cream-2); font-weight: 500; color: var(--ink-2); font-size: 13px; }
tr:last-child td { border-bottom: none; }
.acciones button { padding: 6px 10px; font-size: 12px; margin-right: 4px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; text-transform: capitalize; }
.badge.nueva { background: #2b2b2b; color: #fff; }
.badge.vista { background: #e6e6e6; color: #2b2b2b; }
.badge.contactada { background: #d4d4d4; color: #2b2b2b; }
.badge.ganada { background: #fff; color: #2b2b2b; border: 1px solid #2b2b2b; }
.badge.perdida { background: #fff; color: #6b6b6b; border: 1px dashed #9a9a9a; }

.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; display: block; }
.galeria-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.galeria-item { position: relative; }
.galeria-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; }
.galeria-item .marca-principal {
  position: absolute; top: 8px; right: 8px;
  background: var(--gold); color: white;
  padding: 2px 8px; border-radius: 12px; font-size: 11px;
}
.galeria-item button {
  position: absolute; bottom: 8px; left: 8px;
  font-size: 11px; padding: 4px 8px;
  background: rgba(255,255,255,.95); color: var(--ink);
}

/* Modal */
#modal { margin: auto; border: 0; padding: 0; background: transparent; width: calc(100% - 32px); max-width: 640px; max-height: 90vh; overflow: visible; }
#modal::backdrop { background: rgba(0,0,0,.4); }
.modal-card { background: white; border-radius: 8px; padding: 32px; width: 100%; max-height: 90vh; overflow-y: auto; position: relative; }
.cerrar { position: absolute; top: 12px; right: 12px; background: transparent; color: var(--ink-2); font-size: 28px; padding: 0 10px; line-height: 1; }
.cerrar:hover { color: var(--ink); }
.modal-card form.detalle { display: grid; gap: 12px; }
.modal-card form.detalle h2 { font-size: 24px; margin-bottom: 8px; }
.modal-card form.detalle label { display: block; font-size: 13px; color: var(--ink-2); }
.modal-card form.detalle input, .modal-card form.detalle select, .modal-card form.detalle textarea {
  width: 100%; padding: 10px 12px; margin-top: 4px;
  border: 1px solid var(--line); border-radius: 4px;
  font: inherit; background: white;
}
.modal-card form.detalle textarea { min-height: 80px; }

/* Detalle cotización */
.detalle-cot { display: grid; gap: 20px; }
.detalle-cot section { background: white; padding: 20px; border-radius: 6px; }
.detalle-cot h3 { font-size: 20px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.detalle-cot dl { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; }
.detalle-cot dt { color: var(--ink-2); font-size: 13px; }
.detalle-cot dd { font-size: 14px; }
.total-box { background: var(--ink); color: white; padding: 24px; border-radius: 6px; text-align: center; }
.total-box .etiqueta { color: rgba(255,255,255,.7); font-size: 13px; letter-spacing: 1px; text-transform: uppercase; }
.total-box .num { font-size: 42px; font-family: 'Bodoni Moda', Georgia, serif; margin-top: 4px; }

/* Toast */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: white; padding: 12px 20px; border-radius: 4px; z-index: 200; box-shadow: 0 4px 20px rgba(0,0,0,.15); }
.toast.error { background: var(--danger); }

.tabla-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 6px; }
.tabla-scroll table { min-width: 560px; }
.nota-catalogo { background: white; border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; margin: -8px 0 20px; font-size: 13px; color: var(--ink-2); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Vacío */
.vacio { text-align: center; color: var(--ink-2); padding: 40px; background: white; border-radius: 6px; }

/* Responsive */
@media (max-width: 768px) {
  #panel { grid-template-columns: 1fr; }
  aside { border-right: none; border-bottom: 1px solid var(--line); }
  main { max-height: none; padding: 20px; min-width: 0; }
  .detalle-cot dl { grid-template-columns: 1fr; gap: 2px 0; }
  .detalle-cot dd { margin-bottom: 8px; }
  .modal-card { padding: 24px 18px; }
}
