:root {
  font-family: "Avenir Next", Avenir, system-ui, sans-serif;
  color: #292033;
  background: #fbf7f2;
  line-height: 1.5;
  --plum: #382450;
  --accent: #603984;
  --accent-hover: #4c296c;
  --muted: #675972;
  --lavender: #f1e6fb;
  --outline: #b99ec9;
  --border: #e6dbea;
  --paper: #fffdfb;
  --heading-font: Baskerville, Georgia, serif;
  --content: min(100% - 3rem, 73rem);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body { margin: 0; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { color: var(--plum); }
h1, h2 {
  font-family: var(--heading-font);
  font-weight: 600;
  line-height: 1.08;
}
h1 { font-size: clamp(2.2rem, 4.5vw, 3.25rem); }
h2 { font-size: clamp(1.65rem, 3vw, 2rem); }
h3 { font-size: 1.1rem; line-height: 1.3; }
ul { list-style: none; padding: 0; margin: 0; }

.app-bar {
  position: sticky;
  z-index: 1;
  top: 0;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
}

.app-bar-inner {
  width: var(--content);
  margin-inline: auto;
  min-height: 4.5rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
}

.wordmark {
  width: fit-content;
  color: var(--plum);
  font: 600 1.65rem/1 var(--heading-font);
  text-decoration: none;
}

.app-bar form { justify-self: end; }
nav { display: flex; gap: .25rem; flex-wrap: wrap; }
nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: .5rem .85rem;
  border-radius: .65rem;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
nav a:hover,
nav a[aria-current] {
  background: var(--lavender);
  color: var(--accent-hover);
}
nav a[aria-current] { box-shadow: inset 0 -2px var(--outline); }

#workspace,
#workspace-status {
  width: var(--content);
  margin-inline: auto;
}

#workspace { padding-block: clamp(1rem, 3vw, 2rem) 3rem; }
#workspace-status { margin-block: 1rem; }

.page-banner {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  overflow: hidden;
  margin-bottom: clamp(1rem, 3vw, 1.75rem);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  background: var(--lavender);
}

.page-intro {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: .7rem;
  padding: clamp(1.35rem, 3.3vw, 2.4rem);
}
.page-intro p {
  max-width: 34ch;
  color: var(--muted);
  font-weight: 500;
}
.page-intro button { margin-top: .3rem; }

.brand-art {
  display: grid;
  place-items: center;
  min-height: 13.5rem;
  padding: 1rem;
  background-color: var(--lavender);
  background-image:
    linear-gradient(90deg, var(--lavender), rgba(241, 230, 251, .18) 48%, rgba(252, 236, 220, .23)),
    url("./portada-luli.jpg");
  background-position: center, center 55%;
  background-size: cover;
}

.brand-logo {
  display: block;
  width: min(100%, 9.875rem);
  height: auto;
  border-radius: 50%;
  box-shadow: 0 .5rem 1.65rem rgba(48, 28, 60, .2);
}

.screen { min-width: 0; scroll-margin-top: 5.5rem; }
.home-screen, .calculator-screen, .orders-screen { display: grid; align-items: start; gap: 1rem; }
.card {
  min-width: 0;
  padding: clamp(1rem, 3vw, 1.65rem);
  border: 1px solid var(--border);
  border-radius: 1.15rem;
  background: var(--paper);
  box-shadow: 0 4px 16px rgba(56, 36, 80, .045);
}
.card > h2 { margin-bottom: .85rem; }
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .6rem;
  margin-bottom: 1rem;
}

.order-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
  margin: .85rem 0 0;
}
.order-metric {
  display: grid;
  align-content: space-between;
  gap: .35rem;
  border-top: 3px solid var(--outline);
}
.order-metric dt { color: var(--muted); font-weight: 650; font-size: .9rem; }
.order-metric dd {
  color: var(--plum);
  font: 600 clamp(1.8rem, 4vw, 2.6rem)/1 var(--heading-font);
  text-align: start;
}
.sales-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sales-summary .order-metric { background: #fcf8fd; }
.sales-summary dd { font-size: clamp(1.25rem, 3.5vw, 2.5rem); overflow-wrap: anywhere; }
.sales-note { margin-top: .45rem; color: var(--muted); font-size: .86rem; }
.section-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent-hover);
  font-size: .9rem;
  font-weight: 700;
  text-underline-offset: .2em;
}
#no-recent-orders { color: var(--muted); }
#recent-orders li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7.5rem minmax(0, 13rem);
  align-items: center;
  gap: .9rem;
  padding-block: .75rem;
  border-top: 1px solid var(--border);
  overflow-wrap: anywhere;
}
#recent-orders p { color: var(--muted); font-size: .86rem; }
.order-state {
  justify-self: start;
  padding: .2rem .55rem;
  border-radius: .5rem;
  background: var(--lavender);
  color: var(--plum);
  font-size: .8rem;
  font-weight: 700;
}
.order-state[data-status="Pendiente"] { background: #f9edd9; color: #664615; }
.order-state[data-status="Entregado"] { background: #e8f0e6; color: #345237; }
.order-state[data-status="Cancelado"] { background: #f6e8eb; color: #76384a; }
.recent-order-total { color: var(--plum); text-align: end; }
.order-financials {
  display: grid;
  gap: .3rem;
  margin: .6rem 0;
  color: var(--plum);
  font-size: .9rem;
}
.order-financials > div {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  column-gap: .6rem;
}
#order-total:not(:empty) {
  padding: .15rem .75rem;
  border-radius: .6rem;
  background: var(--lavender);
}

label, .currency-label {
  display: block;
  min-width: 0;
  font-size: .92rem;
  font-weight: 650;
}
input, select, textarea, button { font: inherit; }
input, select, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: .6rem .72rem;
  margin: .3rem 0 .85rem;
  border: 1px solid var(--outline);
  border-radius: .6rem;
  background: white;
  color: inherit;
  font-size: 1rem;
  font-weight: 500;
}
input::placeholder { color: var(--muted); opacity: 1; }
input[type="file"] {
  padding: .45rem;
  background: #faf5fc;
}
input::file-selector-button {
  margin-right: .45rem;
  padding: .3rem .5rem;
  border: 0;
  border-radius: .35rem;
  background: var(--lavender);
  color: var(--plum);
  cursor: pointer;
}
textarea { resize: vertical; }
small, .hint { color: var(--muted); font-weight: 500; }
.hint { margin-bottom: .7rem; font-size: .88rem; }

fieldset { min-width: 0; border: 0; padding: 0; margin: .3rem 0 .55rem; }
legend { margin-bottom: .5rem; padding: 0; color: var(--plum); font-weight: 750; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .75rem; }
.extra-costs { grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.75rem), 1fr)); }
.currency-label strong {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin-top: .3rem;
  color: var(--accent);
}
#sale-format {
  padding: .6rem .75rem;
  border-radius: .55rem;
  background: var(--lavender);
  color: var(--plum);
}

button {
  min-height: 44px;
  max-width: 100%;
  padding: .58rem .85rem;
  border: 1px solid var(--accent);
  border-radius: .65rem;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--accent-hover); }
form button[type="submit"],
form button:not([type]),
.result button { width: 100%; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid #8b4ab2; outline-offset: 2px; }
.secondary, button.sign-out {
  width: auto;
  border-color: var(--outline);
  background: transparent;
  color: var(--accent-hover);
}
.secondary:hover:not(:disabled), button.sign-out:hover { background: var(--lavender); }
button.sign-out { padding-inline: .75rem; font-size: .9rem; white-space: nowrap; }

.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(4.5rem, .3fr) auto;
  gap: 0 .55rem;
  align-items: end;
}
.entry button { margin-bottom: .85rem; }
.ingredient-entry {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: .45rem;
  padding: .75rem .75rem 0;
  border: 1px solid var(--border);
  border-radius: .75rem;
  background: #fcf8fd;
}
.ingredient-name { grid-column: 1 / -1; }
.ingredient-entry [data-remove] { justify-self: end; }
#calculator { container-type: inline-size; }
@container (min-width: 44rem) {
  .ingredient-entry {
    grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)) auto;
  }
  .ingredient-name { grid-column: auto; }
}
#add-ingredient, #add-order-line, #remove-image { margin-bottom: .65rem; }

.photo-preview {
  display: block;
  width: 8rem;
  height: 8rem;
  margin-bottom: .5rem;
  border-radius: .65rem;
  object-fit: cover;
}
.result { background: var(--lavender); }
.price {
  color: var(--accent-hover);
  font: 600 clamp(2.1rem, 5vw, 3.4rem)/1.05 var(--heading-font);
  overflow-wrap: anywhere;
}
.result dl > div, #order-history li {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: .6rem;
  padding-block: .65rem;
  border-top: 1px solid var(--border);
}
dd { margin: 0; text-align: right; font-weight: 700; }
#error, .login-card [role="alert"] { margin-block: .65rem; color: #8d2940; }
#status:not(:empty), #order-status:not(:empty) { margin-top: .6rem; }
#status:empty, #order-status:empty, #catalog-status:empty, #order-hint:empty, #order-total:empty { display: none; }
#catalog-status, #empty, #order-total { margin-bottom: .7rem; }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.75rem), 1fr));
  gap: 1rem;
}
.catalog-grid li {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 1.05rem;
  background: var(--paper);
  box-shadow: 0 4px 16px rgba(56, 36, 80, .045);
}
.catalog-grid li:not(:has(img)) { border-top: 4px solid #d5b5f3; }
.catalog-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}
.product-detail {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: .48rem;
  min-width: 0;
  padding: 1rem;
  overflow-wrap: anywhere;
}
.product-category { color: var(--accent); font-size: .8rem; font-weight: 750; }
.product-price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: .55rem;
  color: var(--muted);
  font-size: .86rem;
}
.product-price strong { color: var(--plum); font-size: 1.05rem; }
.product-description { font-size: .89rem; color: var(--muted); }
.product-detail button { margin-top: auto; font-size: .86rem; }
.product-detail > :nth-last-child(2) { margin-bottom: .35rem; }

#order-history li { flex-wrap: wrap; }
#order-history li > div { min-width: 0; overflow-wrap: anywhere; }
#order-history li p { margin-block: .25rem; }

.login-page {
  display: grid;
  align-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 1rem;
}
.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  width: min(100%, 56rem);
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  background: var(--paper);
  box-shadow: 0 1rem 3.5rem rgba(56, 36, 80, .09);
}
.login-layout .brand-art {
  background-image: linear-gradient(rgba(241, 230, 251, .2), rgba(248, 234, 216, .3)), url("./portada-luli.jpg");
}
.login-layout .brand-logo { width: min(100%, 13rem); }
.login-card { align-self: center; padding: clamp(1.2rem, 4vw, 2.75rem); }
.login-card h1 { margin-bottom: 1rem; font-size: clamp(2rem, 5vw, 2.75rem); }

@media (min-width: 800px) {
  .orders-screen,
  .calculator-screen:has(> .result:not([hidden])) { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
  .result { position: sticky; top: 5.5rem; }
}

@media (max-width: 700px) {
  :root { --content: calc(100% - 1.5rem); }
  .app-bar-inner {
    min-height: auto;
    grid-template-columns: 1fr auto;
    gap: .2rem .75rem;
    padding-block: .55rem;
  }
  .wordmark { font-size: 1.45rem; }
  nav { grid-area: 2 / 1 / 3 / -1; }
  nav a { padding-inline: .55rem; }
  .order-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #recent-orders li { grid-template-columns: minmax(0, 1fr) minmax(0, auto); gap: .35rem .65rem; }
  .recent-order-total { grid-column: 1 / -1; text-align: start; }
  .screen { scroll-margin-top: 7.5rem; }
  .page-banner { grid-template-columns: minmax(0, 1fr) minmax(6rem, 34%); }
  .page-intro { padding: 1rem .25rem 1rem 1rem; }
  .brand-art { min-height: 10.5rem; padding: .5rem; }
  .brand-logo { width: min(100%, 5.875rem); }
  .login-layout { grid-template-columns: minmax(0, 1fr); width: min(100%, 28rem); }
  .login-layout .brand-art { min-height: 10rem; }
  .login-layout .brand-logo { width: min(100%, 7.5rem); }
}

@media (max-width: 420px) {
  nav { gap: .15rem; }
  nav a { padding-inline: .45rem; font-size: .85rem; }
  .page-intro h1 { font-size: 1.9rem; }
  .page-intro p { font-size: .88rem; }
  #print-catalog { font-size: .83rem; }
  #order-lines .entry { grid-template-columns: minmax(0, 1fr) auto; }
  #order-lines .entry label:first-child { grid-column: 1 / -1; }
}

@media print {
  .app-bar, button, .calculator-screen, .orders-screen, .page-intro p { display: none !important; }
  body, .page-banner, .brand-art { background: white; }
  #workspace { width: 100%; padding: 0; }
  .page-banner { margin-bottom: .75rem; border: 0; grid-template-columns: 1fr auto; }
  .page-intro { padding: 0; }
  .page-intro h1 { font-size: 2rem; }
  .brand-art { min-height: 0; padding: 0; }
  .brand-logo { width: 4rem; box-shadow: none; }
  .catalog-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; }
  .catalog-grid li { break-inside: avoid; box-shadow: none; }
  .catalog-grid img { aspect-ratio: 2 / 1; }
  .product-detail { gap: .2rem; padding: .45rem; }
}
