:root {
  /* Palette taken from the Pamilyang Salazar crest */
  --night: #140c07;
  --leather: #24160d;
  --leather-2: #33200f;
  --burgundy: #6e1414;
  --burgundy-2: #8f1d1d;
  --gold: #d4a64a;
  --gold-2: #f0cf85;
  --gold-dim: #9c7a35;
  --sunset: #e8792b;
  --paper: #f3e7cc;
  --paper-2: #e8d6ae;
  --card: #fffaf0;
  --ink: #2b1a0e;
  --muted: #74603f;
  --line: #d9c08d;
  --accent: var(--burgundy);
  --ok: #2f6b2f;
  --warn: #a86a00;
  --bad: #a3221a;
  --radius: 12px;
  font-family: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper) radial-gradient(ellipse at top, #fbf3df, transparent 60%); }
h1, h2, h3, .brand { font-family: "Rye", Georgia, serif; font-weight: 400; color: var(--burgundy); letter-spacing: .3px; }
h2 { margin: 0 0 .75rem; font-size: 1.6rem; }
h3 { margin: 1.5rem 0 .6rem; font-size: 1.15rem; }
a { color: var(--burgundy); }
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--gold); background: var(--night); margin: 0; font-family: "Rye", serif; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.center { text-align: center; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.err { color: var(--bad); min-height: 1.2em; margin: .4rem 0; font-weight: 600; }
.error { border-color: var(--bad) !important; color: var(--bad); }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes glow { 0%, 100% { filter: drop-shadow(0 0 18px rgba(232,121,43,.35)) drop-shadow(0 10px 30px rgba(0,0,0,.6)); }
                  50% { filter: drop-shadow(0 0 34px rgba(240,207,133,.55)) drop-shadow(0 10px 30px rgba(0,0,0,.6)); } }
@keyframes float { 0% { transform: translateY(0); opacity: 0; } 10% { opacity: .9; } 100% { transform: translateY(-110vh); opacity: 0; } }
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes growx { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- Shell ---------- */
header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .55rem 1.2rem; color: var(--paper);
  background: linear-gradient(180deg, var(--leather-2), var(--night));
  border-bottom: 2px solid var(--gold-dim);
  box-shadow: 0 2px 12px rgba(0,0,0,.35);
}
header .brand { display: flex; align-items: center; gap: .7rem; color: var(--gold-2); font-size: 1.3rem; text-decoration: none; }
header .brand img { width: 46px; height: 46px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.6)); }
header .brand small { display: block; font-family: "Source Sans 3", sans-serif; font-size: .78rem; color: var(--gold); opacity: .85; letter-spacing: 1.5px; text-transform: uppercase; }
header .me { display: flex; align-items: center; gap: .6rem; font-size: .95rem; color: var(--paper-2); }
header .badge { background: rgba(212,166,74,.15); color: var(--gold-2); border: 1px solid rgba(212,166,74,.4); }
header button { color: var(--gold-2); border-color: rgba(212,166,74,.45); background: transparent; }
header button:hover { border-color: var(--gold-2); }
nav {
  display: flex; gap: .25rem; overflow-x: auto; padding: .45rem 1rem; scrollbar-width: thin;
  background: linear-gradient(180deg, #2a1a0f, #1d120a); border-bottom: 1px solid #000;
}
nav a {
  padding: .45rem .85rem; border-radius: 7px; text-decoration: none; color: var(--paper-2); white-space: nowrap; font-weight: 600; transition: background .15s, color .15s;
}
nav a:hover { background: rgba(212,166,74,.12); color: var(--gold-2); }
nav a.active { background: linear-gradient(180deg, var(--burgundy-2), var(--burgundy)); color: var(--gold-2); box-shadow: inset 0 0 0 1px rgba(240,207,133,.35); }
main { max-width: 1180px; margin: 0 auto; padding: 1.3rem 1rem 4rem; animation: rise .35s ease both; }

/* ---------- Building blocks ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: 0 1px 0 rgba(0,0,0,.03), 0 6px 18px -12px rgba(60,30,10,.35); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.page-head h2 { margin: 0; }
.grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.two-col { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.stat span { display: block; color: var(--muted); font-size: .9rem; }
.stat b { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.stat.accent { background: linear-gradient(160deg, var(--burgundy-2), var(--burgundy)); color: var(--gold-2); border-color: var(--burgundy); }
.stat.accent span { color: rgba(240,207,133,.8); }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .8rem; font-weight: 700; background: var(--paper-2); color: var(--ink); text-transform: capitalize; white-space: nowrap; }
.badge.ok { background: #dcebd3; color: var(--ok); }
.badge.warn { background: #f6e2b8; color: var(--warn); }
.badge.bad { background: #f3d0cc; color: var(--bad); }
.badge.info { background: #d9e4ef; color: #24507a; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; padding: .45rem .9rem;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; display: inline-block;
  transition: transform .1s, box-shadow .15s, border-color .15s, background .15s;
}
button:hover, .btn:hover { border-color: var(--burgundy); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: linear-gradient(180deg, var(--burgundy-2), var(--burgundy)); color: var(--gold-2); border-color: #4a0c0c; box-shadow: inset 0 1px 0 rgba(255,255,255,.12); }
.primary:hover { box-shadow: 0 4px 14px -4px rgba(110,20,20,.6), inset 0 1px 0 rgba(255,255,255,.12); border-color: var(--gold-dim); }
.ghost { background: transparent; }
.danger { color: var(--bad); border-color: #e3b3ad; }
.small-btn { padding: .2rem .55rem; font-size: .85rem; }
.wide { width: 100%; }
.link { background: none; border: none; padding: 0; color: var(--burgundy); text-decoration: underline; font-weight: 600; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.actions { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }

label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .92rem; }
label.check { flex-direction: row; align-items: center; gap: .4rem; }
input, select, textarea {
  font: inherit; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(212,166,74,.55); border-color: var(--gold-dim); }
textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
.form-grid .full { grid-column: 1 / -1; }
.filters { display: flex; gap: .8rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }

.split { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.split div { background: var(--paper); border: 1px dashed var(--line); border-radius: 8px; padding: .5rem .7rem; }
.split span { display: block; font-size: .8rem; color: var(--muted); }
.split b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs button.active { background: linear-gradient(180deg, var(--burgundy-2), var(--burgundy)); color: var(--gold-2); border-color: var(--burgundy); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: .55rem .7rem; border-bottom: 1px solid #eadcbc; text-align: left; vertical-align: middle; }
th { background: linear-gradient(180deg, #efe0bd, var(--paper-2)); font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; color: #5c4526; white-space: nowrap; }
tbody tr:hover { background: #fbf2dc; }
tfoot td { font-weight: 700; background: var(--paper-2); }
tr.voided td { color: #a99a84; text-decoration: line-through; }
tr.voided td:last-child, tr.voided td:nth-last-child(2) { text-decoration: none; }
tr.clickable { cursor: pointer; }

.list { display: flex; flex-direction: column; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.list li { display: flex; justify-content: space-between; gap: .6rem; align-items: center; padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.list li:last-child { border-bottom: 0; }

.bar { height: 10px; border-radius: 6px; background: linear-gradient(90deg, var(--burgundy), var(--sunset)); min-width: 2px; transform-origin: left; animation: growx .6s ease both; }
.bar-cell { width: 35%; }

details.card > summary { cursor: pointer; font-weight: 700; color: var(--burgundy); }
details.card[open] > summary { margin-bottom: .9rem; }

/* ---------- Login ---------- */
.login {
  position: relative; overflow: hidden; min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem;
  background:
    radial-gradient(ellipse 80% 45% at 50% 105%, rgba(232,121,43,.55), transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(143,29,29,.55), transparent 75%),
    radial-gradient(ellipse at 50% 30%, #2b1a0e 0%, var(--night) 70%);
  color: var(--paper);
}
.login::before { /* faint ridge line */
  content: ""; position: absolute; inset: auto 0 0 0; height: 32vh; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.55)),
              radial-gradient(120% 60% at 20% 100%, #1a0f08 40%, transparent 41%),
              radial-gradient(110% 55% at 80% 100%, #160c06 40%, transparent 41%);
}
.embers { position: absolute; inset: 0; pointer-events: none; }
.embers i {
  position: absolute; bottom: -10px; width: 4px; height: 4px; border-radius: 50%;
  background: radial-gradient(circle, #ffd28a, rgba(232,121,43,0));
  animation: float linear infinite;
}
.login-wrap { position: relative; z-index: 1; width: min(400px, 100%); display: flex; flex-direction: column; align-items: center; animation: rise .6s ease both; }
.login-logo { width: min(250px, 62vw); height: auto; margin-bottom: -18px; animation: glow 5s ease-in-out infinite; position: relative; z-index: 2; }
.login .card {
  width: 100%; padding: 2.2rem 1.7rem 1.5rem; color: var(--paper);
  background: linear-gradient(180deg, rgba(51,32,15,.92), rgba(24,14,8,.95));
  border: 1px solid rgba(212,166,74,.55); border-radius: 16px;
  box-shadow: 0 25px 60px -20px rgba(0,0,0,.8), inset 0 1px 0 rgba(240,207,133,.15);
  backdrop-filter: blur(4px);
}
.login h1 {
  margin: 0; font-size: 1.75rem; text-align: center;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold-2), var(--gold), var(--gold-2), var(--gold-dim));
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 6s linear infinite;
}
.login .tagline { text-align: center; margin: .3rem 0 0; color: var(--gold); font-size: .8rem; letter-spacing: 2.5px; text-transform: uppercase; }
.login form { display: flex; flex-direction: column; gap: .85rem; margin-top: 1.3rem; }
.login label { color: var(--paper-2); }
.login input { background: rgba(0,0,0,.35); color: var(--paper); border-color: rgba(212,166,74,.35); padding: .65rem .75rem; }
.login input:focus { border-color: var(--gold); outline: 2px solid rgba(212,166,74,.35); }
.login .primary { padding: .7rem; font-size: 1.05rem; letter-spacing: .5px; }
.login .muted { color: #b49c74; }
.login .err { color: #ff9a85; }
.motto { margin-top: 1.1rem; text-align: center; color: var(--gold); font-family: "Rye", serif; font-size: .82rem; letter-spacing: 1.5px; opacity: .85; }
.motto span { color: var(--sunset); margin: 0 .4rem; }

/* ---------- Dashboard ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 16px; padding: 1.6rem 1.6rem 1.4rem; margin-bottom: 1.2rem; color: var(--paper);
  background:
    radial-gradient(ellipse 70% 120% at 85% 120%, rgba(232,121,43,.55), transparent 60%),
    radial-gradient(ellipse 60% 90% at 70% 110%, rgba(143,29,29,.6), transparent 65%),
    linear-gradient(120deg, var(--night), var(--leather-2) 60%, #3a1c10);
  border: 1px solid var(--gold-dim);
  box-shadow: 0 18px 40px -22px rgba(40,15,5,.8);
}
.hero.has-banner { background-size: cover; background-position: center; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(20,12,7,.85) 0%, rgba(20,12,7,.35) 60%, transparent); pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.hero-logo { position: absolute; z-index: 1; right: 1.2rem; top: 50%; transform: translateY(-50%); width: 150px; opacity: .95; animation: glow 6s ease-in-out infinite; }
.hero .eyebrow { color: var(--gold); text-transform: uppercase; letter-spacing: 2.5px; font-size: .78rem; margin: 0; }
.hero h2 { color: var(--gold-2); font-size: 2rem; margin: .25rem 0 .2rem; }
.hero p { margin: 0; color: var(--paper-2); max-width: 60ch; }
.hero .quick { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.hero .quick .btn { background: rgba(0,0,0,.35); color: var(--gold-2); border-color: rgba(212,166,74,.45); }
.hero .quick .btn:hover { background: rgba(212,166,74,.15); border-color: var(--gold-2); }
.hero .quick .btn.primary { background: linear-gradient(180deg, var(--burgundy-2), var(--burgundy)); border-color: var(--gold-dim); }

.kpis { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi {
  position: relative; display: flex; gap: .8rem; align-items: center; padding: 1rem 1.1rem;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 20px -16px rgba(60,30,10,.5); animation: rise .45s ease both;
}
.kpi:nth-child(2) { animation-delay: .05s; } .kpi:nth-child(3) { animation-delay: .1s; } .kpi:nth-child(4) { animation-delay: .15s; }
.kpi .ico { flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(160deg, var(--leather-2), var(--night)); color: var(--gold-2); border: 1px solid var(--gold-dim); }
.kpi .ico svg { width: 24px; height: 24px; }
.kpi span { display: block; color: var(--muted); font-size: .85rem; }
.kpi b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.kpi em { display: block; font-style: normal; font-size: .8rem; color: var(--muted); }
.kpi.accent { background: linear-gradient(160deg, var(--burgundy-2), var(--burgundy)); border-color: #4a0c0c; color: var(--gold-2); }
.kpi.accent span, .kpi.accent em { color: rgba(240,207,133,.8); }
.kpi.accent .ico { background: rgba(0,0,0,.25); }

.panel-title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: 0 0 .7rem; }
.panel-title h3 { margin: 0; }
.panel-title a { font-size: .88rem; font-weight: 600; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: .5rem; align-items: end; height: 170px; padding-top: .5rem; }
.week .col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: .3rem; }
.week .col .v { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.week .col .b { width: 100%; max-width: 46px; border-radius: 7px 7px 3px 3px; min-height: 3px; transform-origin: bottom; animation: grow .7s cubic-bezier(.2,.8,.2,1) both;
  background: linear-gradient(180deg, var(--sunset), var(--burgundy)); }
.week .col.today .b { background: linear-gradient(180deg, var(--gold-2), var(--gold-dim)); box-shadow: 0 0 0 2px rgba(212,166,74,.35); }
.week .col .d { font-size: .78rem; font-weight: 700; color: var(--muted); }
.week .col.today .d { color: var(--burgundy); }

.meter { height: 8px; background: #eadcbc; border-radius: 6px; overflow: hidden; margin-top: .3rem; }
.meter > i { display: block; height: 100%; border-radius: 6px; transform-origin: left; animation: growx .6s ease both; }
.meter.warn > i { background: linear-gradient(90deg, #d08a1a, #f0b54a); }
.meter.bad > i { background: linear-gradient(90deg, #8f1d1d, #d2452f); }
.stock-row { padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.stock-row:last-child { border-bottom: 0; }
.stock-row .top { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }

.empty { text-align: center; color: var(--muted); padding: 1.2rem .5rem; }
.empty .big { font-size: 1.8rem; display: block; margin-bottom: .2rem; }

/* ---------- Modal & toast ---------- */
dialog { border: 1px solid var(--gold-dim); border-radius: 14px; padding: 0; width: min(460px, 94vw); background: var(--card); color: var(--ink); box-shadow: 0 30px 60px -20px rgba(0,0,0,.6); }
dialog::backdrop { background: rgba(20,12,7,.6); backdrop-filter: blur(2px); }
.modal { padding: 1.2rem 1.3rem; display: flex; flex-direction: column; gap: .8rem; }
.modal h3 { margin: 0; }
.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 100; animation: rise .25s ease both;
  background: var(--ok); color: #fff; padding: .7rem 1.1rem; border-radius: 8px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.toast.bad { background: var(--bad); }

@media (max-width: 720px) {
  .hero-logo { width: 90px; right: .6rem; top: 1rem; transform: none; opacity: .55; }
  .hero h2 { font-size: 1.5rem; }
}
@media (max-width: 640px) {
  header { padding: .5rem .8rem; }
  header .brand img { width: 38px; height: 38px; }
  main { padding: 1rem .6rem 4rem; }
  .split b { font-size: 1rem; }
  th, td { padding: .45rem .5rem; }
  .week { height: 140px; gap: .3rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Record sale: cart ---------- */
.sale-layout { display: grid; gap: 1.1rem; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
.sale-layout > .card { margin: 0; }
.step { display: flex; align-items: center; gap: .5rem; margin: 0; }
.step > span { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--burgundy); color: var(--gold-2); font-size: .9rem; font-family: "Source Sans 3", sans-serif; font-weight: 700; }
.step em { font-style: normal; font-size: .75rem; }
.step em:empty { display: none; }
.cart { display: flex; flex-direction: column; gap: .7rem; border-top: 3px solid var(--gold); }
.cart .panel-title { margin: 0; }
.cart-lines { list-style: none; margin: 0; padding: 0; max-height: 340px; overflow: auto; }
.cart-lines li { display: grid; grid-template-columns: minmax(0, 1fr) 4.2rem 5.5rem auto; gap: .5rem; align-items: center; padding: .45rem 0; border-bottom: 1px dashed var(--line); animation: pop .25s ease-out; }
.cart-lines li:last-child { border-bottom: 0; }
.cart-lines .ci { display: flex; flex-direction: column; min-width: 0; }
.cart-lines .ci b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-lines input { padding: .3rem .4rem; text-align: center; }
.cart-lines .num { text-align: right; font-variant-numeric: tabular-nums; }
.cart-lines .rm { padding: .2rem .5rem; }
.split .grand { background: var(--burgundy); border: 1px solid var(--gold-dim); }
.split .grand span { color: var(--gold-2); opacity: .9; }
.split .grand b { color: #fff; }
.receipt { margin-top: 1.1rem; border-left: 4px solid var(--ok, #3c7a3c); animation: pop .3s ease-out; }
.receipt .panel-title h3 { margin: 0; }
.receipt-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: .6rem; margin-top: .3rem; border-top: 2px solid var(--line); }
.receipt-total b { font-size: 1.35rem; }
.strike { text-decoration: line-through; opacity: .6; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (max-width: 860px) { .sale-layout { grid-template-columns: 1fr; } }
