/* Ruleca Kids · colores tomados del logo */
:root {
  --navy: #283252;
  --navy-2: #343f63;
  --coral: #ef5455;
  --coral-dark: #d43c3e;
  --yellow: #f9d343;
  --bg: #fbf7ef;
  --card: #ffffff;
  --text: #283252;
  --muted: #6f7590;
  --line: #e9e3d6;
  --ok: #2f9e6e;
  --warn: #d98a12;
  --danger: #d43c3e;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(40, 50, 82, .07), 0 6px 18px rgba(40, 50, 82, .06);
  --titulo: "Roboto", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, .brand, nav.tabs button, .btn, .precio, .total-row { font-family: var(--titulo); }
h1 { font-weight: 700; }
h2 { font-size: 18px; font-weight: 600; margin: 0 0 10px; }
.spacer { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.error { color: var(--danger); font-size: 14px; margin: 0; white-space: pre-line; }

/* ───────── Login ───────── */
.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px; background: var(--navy);
  background-image: radial-gradient(circle at 20% 10%, var(--navy-2) 0, transparent 45%); }
.login-card { width: min(400px, 100%); background: var(--card); border-radius: 24px; padding: 26px 22px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3); outline: 3px dashed var(--yellow); outline-offset: -12px; }
.login-logo { display: block; margin: 0 auto 6px; width: 150px; height: 150px; }
.login h1 { text-align: center; font-size: 22px; margin: 0 0 18px; }
.login form { display: grid; gap: 12px; }
.login .muted { margin: 16px 0 4px; }

/* ───────── Header y tabs ───────── */
header.top { background: var(--navy); color: #fff; border-bottom: 3px dashed var(--yellow); }
.top-in { display: flex; align-items: center; gap: 10px; padding: 10px 16px; max-width: 1100px; margin: 0 auto; position: relative; }
.top-logo { width: 44px; height: 44px; }
.brand { font-weight: 900; font-size: 22px; color: var(--coral); letter-spacing: .3px; }
.brand span { color: var(--yellow); }
.btn-user { background: rgba(255, 255, 255, .1); border: 0; color: #fff; border-radius: 12px; padding: 6px 12px;
  cursor: pointer; text-align: right; line-height: 1.15; max-width: 50vw; }
.btn-user span { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-user small { color: var(--yellow); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.menu { position: absolute; right: 16px; top: calc(100% + 4px); z-index: 20; background: #fff; color: var(--text);
  border-radius: 14px; box-shadow: 0 12px 30px rgba(0, 0, 0, .18); overflow: hidden; min-width: 210px; }
.menu button { display: block; width: 100%; text-align: left; padding: 12px 16px; border: 0; background: none; cursor: pointer; }
.menu button:hover { background: var(--bg); }

nav.tabs { position: sticky; top: 0; z-index: 10; background: var(--bg); display: flex; gap: 6px;
  padding: 10px 16px; max-width: 1100px; margin: 0 auto; overflow-x: auto; }
nav.tabs button { flex: 1 0 auto; border: 0; background: transparent; padding: 9px 12px; border-radius: 12px;
  font-weight: 600; font-size: 15px; color: var(--muted); cursor: pointer; }
nav.tabs button.active { background: var(--coral); color: #fff; }
main { max-width: 1100px; margin: 0 auto; padding: 6px 16px 90px; }

/* ───────── Controles ───────── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
label .opt { font-weight: 400; }
input, select { width: 100%; margin-top: 4px; padding: 10px 12px; border: 1.5px solid var(--line);
  border-radius: 12px; background: #fff; }
input:focus, select:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(40, 50, 82, .12); }

.btn { border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 600; cursor: pointer;
  background: #f1ece2; color: var(--navy); white-space: nowrap; }
.btn.primary { background: var(--coral); color: #fff; }
.btn.primary:hover { background: var(--coral-dark); }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1.5px solid #f3c6c6; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; padding: 14px; font-size: 17px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.toolbar input { flex: 1 1 220px; margin: 0; }
.toolbar select { flex: 0 1 150px; margin: 0; }

/* ───────── Inventario ───────── */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.item { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column; }
.item .foto { aspect-ratio: 4 / 3; background: #f3eee4; display: flex; align-items: center; justify-content: center;
  color: #cfc6b5; font-size: 34px; }
.item .foto { position: relative; overflow: hidden; }
.item .foto img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.item .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.item .desc { font-weight: 700; }
.item .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.item .acciones { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; }
.item .acciones .btn { flex: 1; }
.precio { font-weight: 600; font-size: 16px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px;
  text-transform: uppercase; letter-spacing: .3px; background: #eee; }
.badge.Nene { background: #dde6fa; color: #2d4c9a; }
.badge.Nena { background: #fde1e1; color: #b8323a; }
.badge.Unisex { background: #fdf1c7; color: #8a6a00; }
.badge.admin { background: var(--navy); color: var(--yellow); }
.badge.vendedor { background: #e7eaf3; color: var(--navy); }
.badge.off { background: #eee; color: #888; }
.stock { font-weight: 700; font-size: 13px; }
.stock.ok { color: var(--ok); }
.stock.bajo { color: var(--warn); }
.stock.cero { color: var(--danger); }

/* ───────── Venta ───────── */
.resultados { display: flex; flex-direction: column; margin-top: 8px; }
.res { display: flex; gap: 10px; align-items: center; padding: 8px 2px; border-top: 1px solid var(--line); }
.res:first-child { border-top: 0; }
.thumb { width: 50px; height: 50px; border-radius: 12px; background: #f3eee4; flex: 0 0 50px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; color: #cfc6b5; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.res .info { flex: 1; min-width: 0; }
.res .info .desc { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linea { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.linea:first-child { border-top: 0; }
.linea .desc { font-weight: 600; }
.linea .campos { grid-column: 1 / -1; display: flex; gap: 8px; align-items: end; }
.linea .campos label { flex: 1; }
.linea .sub { flex: 1; font-weight: 700; text-align: right; padding-bottom: 10px; }
.total-row { display: flex; justify-content: space-between; align-items: center; font-size: 18px;
  padding: 12px 0; border-top: 2px dashed var(--yellow); margin-top: 6px; }
.total-row strong { font-size: 24px; }
.vacio { text-align: center; color: var(--muted); padding: 18px 8px; }

/* ───────── Historial y usuarios ───────── */
.venta { border-top: 1px solid var(--line); padding: 10px 0; }
.venta:first-child { border-top: 0; }
.venta summary { display: flex; justify-content: space-between; gap: 10px; cursor: pointer; list-style: none; }
.venta summary::-webkit-details-marker { display: none; }
.venta ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.usr { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 10px; }
.usr .avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--navy); color: var(--yellow);
  display: flex; align-items: center; justify-content: center; font-family: var(--titulo); font-weight: 700; flex: 0 0 40px; }
.usr .info { flex: 1; min-width: 0; }
.usr .info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usr.inactivo { opacity: .6; }

/* ───────── Colecciones ───────── */
.col { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px;
  border-left: 5px solid var(--yellow); }
.col .cab { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.col .cab h3 { font-family: var(--titulo); font-size: 18px; margin: 0; flex: 1; min-width: 160px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { background: #f1ece2; border-radius: 99px; padding: 3px 10px; font-size: 13px; }
.chip.falta { background: #fbe4e4; color: var(--danger); }
.cod-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.cod-item:first-child { border-top: 0; }
.cod-item .info { flex: 1; min-width: 0; }

/* ───────── Diálogos ───────── */
dialog { border: 0; border-radius: 20px; padding: 0; width: min(560px, calc(100% - 24px));
  max-height: calc(100% - 24px); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); color: var(--text); }
dialog::backdrop { background: rgba(40, 50, 82, .5); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.dlg-head h2 { margin: 0; }
.dlg-body { padding: 14px 16px; display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.dlg-body .full { grid-column: 1 / -1; }
.dlg-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line);
  position: sticky; bottom: 0; background: #fff; }
.foto-box { display: flex; gap: 12px; align-items: center; }
.foto-prev { width: 96px; height: 96px; border-radius: 14px; background: #f3eee4; overflow: hidden; flex: 0 0 96px;
  display: flex; align-items: center; justify-content: center; color: #cfc6b5; font-size: 28px; }
.foto-prev img { width: 100%; height: 100%; object-fit: cover; }
.foto-btns { display: flex; flex-direction: column; gap: 6px; }

/* ───────── Avisos ───────── */
#toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(140px);
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 14px; max-width: calc(100% - 32px);
  white-space: pre-line; transition: transform .25s; z-index: 50; box-shadow: var(--shadow); }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); }
#cargando { position: fixed; inset: 0; background: rgba(251, 247, 239, .75); display: flex; align-items: center;
  justify-content: center; z-index: 60; font-family: var(--titulo); font-weight: 600; color: var(--navy); gap: 10px; }
.spinner { width: 34px; height: 34px; border: 4px solid #f6dcdc; border-top-color: var(--coral); border-radius: 50%;
  animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .dlg-body { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .item .acciones { flex-direction: column; }
  .brand { font-size: 19px; }
  nav.tabs button { font-size: 14px; padding: 8px 10px; }
}
