:root {
  color: #35251f;
  background: #fff8f1;
  font-family: "Inter", system-ui, sans-serif;
  font-synthesis: none;
  --ink: #35251f;
  --muted: #66554d;
  --brand: #973c29;
  --brand-dark: #753020;
  --line: #ebdcd2;
  --soft: #fff5ed;
  --shadow: 0 14px 36px #562b1910;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: radial-gradient(ellipse at 18% 0%, #ffe5d6, transparent 34rem); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; transform: none; }
:focus-visible { outline: 3px solid #145e53; outline-offset: 3px; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h2 { font-size: 1.18rem; letter-spacing: -.025em; margin-bottom: 1rem; }
section[id] { scroll-margin-top: 1rem; }

.skip {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 10;
  padding: .65rem .9rem;
  background: white;
  transform: translateY(-160%);
}
.skip:focus { transform: none; }
.app { max-width: 72rem; margin: auto; padding: 1.25rem 1.35rem 3rem; }
.topbar, .section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.topbar { margin-bottom: 1.15rem; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  text-decoration: none;
  font-weight: 850;
  letter-spacing: -.045em;
  font-size: clamp(1.08rem, 4.5vw, 1.45rem);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  flex: 0 0 auto;
  border: 1px solid #f2c8b7;
  border-radius: 1rem;
  background: #fff3e8;
  font-size: 1.42rem;
}
.profile { color: var(--muted); }
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  min-height: 13.5rem;
  padding: 2.1rem clamp(1.3rem, 5vw, 3.1rem);
  border-radius: 1.6rem;
  color: white;
  background: radial-gradient(ellipse at 88% 32%, #9f4d30, transparent 48%), #7d3223;
  box-shadow: 0 16px 35px #7d322326;
}
.hero h1 {
  margin-bottom: 1.15rem;
  max-width: 17ch;
  font-size: clamp(2.05rem, 5vw, 3.55rem);
  line-height: 1.06;
  letter-spacing: -.07em;
}
.hero-actions, .backup-actions, .dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
}
.hero :focus-visible { outline-color: #fff6d8; }
.hero-graphic {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 8.5rem;
  aspect-ratio: 1;
  border: 1px solid #ffdab477;
  border-radius: 45% 55% 55% 45%;
  background: #ffe3bc1c;
  font-size: 4.4rem;
  transform: rotate(-13deg);
}
.btn, .mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: .58rem .95rem;
  border: 1px solid transparent;
  border-radius: .66rem;
  font-weight: 740;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-primary { background: var(--brand); color: white; }
.btn-light { background: #fff8f1; color: var(--brand-dark); }
.btn-outline { border-color: #f4c1ab; color: white; }
.btn-secondary, .mini-btn { background: #fff0e6; color: #773523; border-color: #f0d5c6; }
.btn-danger { background: #923326; color: white; }
@media (hover: hover) {
  .btn:not(:disabled):hover, .mini-btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px #562b192c;
  }
}
.section-title { margin: 1.65rem 0 .85rem; }
.section-title h2 { margin: 0; }
.section-title span { font-size: .82rem; color: var(--muted); text-align: right; }
.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
}
.metric, .panel {
  background: white;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-width: 0;
}
.metric { border-radius: 1rem; padding: .9rem 1.05rem; }
.metric.accent { border-color: #d3e5df; background: #eff8f5; }
.metric.accent strong { color: #215f51; }
.metric span, .metric small { display: block; color: var(--muted); font-size: .82rem; }
.metric strong {
  display: block;
  margin: .23rem 0;
  font-size: clamp(1.15rem, 2.6vw, 1.65rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}
.panel { margin-top: .95rem; padding: 1.28rem; border-radius: 1.15rem; }
.panel > .section-title { margin-top: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: .95rem; }
.payment-grid, .form-grid, .report-grid, .add-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}
.payment-grid div { min-width: 0; padding: .65rem .75rem; background: var(--soft); border-radius: .65rem; overflow-wrap: anywhere; }
.payment-grid span { display: block; font-size: .82rem; color: var(--muted); }
.payment-grid strong { display: block; margin-top: .18rem; font-variant-numeric: tabular-nums; }

.full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: .32rem; font-size: .86rem; font-weight: 660; min-width: 0; }
label small { font-weight: 450; color: var(--muted); }
input, select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  background: white;
  color: var(--ink);
  border: 1px solid #b6a096;
  border-radius: .63rem;
  padding: .43rem .58rem;
  font-size: 1rem;
}
input[type="date"] { min-inline-size: 0; }
.sale-total {
  display: grid;
  gap: .2rem;
  padding: .72rem .85rem;
  background: var(--soft);
  border-radius: .65rem;
  overflow-wrap: anywhere;
}
.sale-total strong { font-size: 1.6rem; color: var(--brand-dark); }
.sale-total small, .muted, .note, .notice {
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.5;
}
.muted { margin: .75rem 0 0; }
.field-help { margin: -.35rem 0 0; }
.note, .notice { margin: .8rem 0 0; padding: .65rem .8rem; background: #fff3dc; border-radius: .65rem; }
.notice { border: 1px solid #e4bc7f; color: #5d3d2b; }
.add-grid {
  grid-template-columns: 1.5fr 1fr 1fr auto;
  align-items: end;
  padding: .85rem;
  border: 1px solid var(--line);
  border-radius: .85rem;
  background: var(--soft);
}
.flavors { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-top: .9rem; }
.flavor { min-width: 0; padding: .85rem; border: 1px solid var(--line); border-radius: .85rem; }
.flavor-head { display: flex; justify-content: space-between; align-items: start; gap: .45rem; }
.flavor h3 { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.flavor small { display: block; margin: .45rem 0 .65rem; color: var(--muted); overflow-wrap: anywhere; }
.qty { white-space: nowrap; border-radius: 2rem; background: #eaf5ef; padding: .28rem .46rem; color: #235d50; font-size: .78rem; font-weight: 730; }
.flavor-actions, .entry-controls { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.mini-btn { font-size: .84rem; padding-inline: .68rem; }

.entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  padding: .72rem 0;
  border-bottom: 1px solid var(--line);
}
.entry:first-child { padding-top: 0; }
.entry:last-child { border-bottom: 0; }
.details { min-width: 0; overflow-wrap: anywhere; }
.details strong { display: block; font-size: .96rem; }
.details small { display: block; margin-top: .23rem; color: var(--muted); line-height: 1.5; }
.entry-controls select { width: auto; max-width: 100%; }
.empty { color: var(--muted); margin-bottom: 0; font-size: .9rem; }
.more { margin-top: .6rem; }
.report-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; }
.backup-actions { margin-top: .85rem; }

dialog {
  width: min(32rem, calc(100% - 1.5rem));
  max-height: calc(100% - 1.5rem);
  overflow: auto;
  padding: clamp(1rem, 5vw, 1.55rem);
  border: 1px solid var(--line);
  border-radius: 1.15rem;
  color: var(--ink);
  background: white;
  box-shadow: 0 16px 65px #2617104d;
}
dialog::backdrop { background: #2e1c18aa; }
dialog p { line-height: 1.5; }
.form-error { color: #872f22; margin: 0; }
.form-error:empty { margin: -0.35rem 0 0; }
footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .45rem;
  padding-top: 1rem;
  margin-top: 1.55rem;
  border-top: 1px solid var(--line);
  font-size: .84rem;
  font-weight: 740;
}
footer span { color: var(--muted); font-weight: 450; }

.toast {
  position: fixed;
  z-index: 5;
  inset: auto 0 max(1rem, env(safe-area-inset-bottom)) 0;
  width: max-content;
  max-width: calc(100% - 1.5rem);
  margin: auto;
  border-radius: .8rem;
  padding: .75rem 1rem;
  color: white;
  background: #3c2a24;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(.45rem);
  pointer-events: none;
  text-align: center;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }

@media (max-width: 58rem) {
  .add-grid, .flavors { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 42rem) {
  .app { padding: 1rem .75rem 3rem; }
  .topbar { gap: .55rem; }
  .profile { font-size: .75rem; }
  .hero { min-height: auto; padding: 1.35rem 1.1rem; }
  .hero-graphic { display: none; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
  .metric, .panel { padding: .8rem; }
  .two-col, .flavors { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .flavors { gap: .6rem; }
  .report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-grid button { grid-column: 1 / -1; }
  .entry { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 24rem) {
  .brand-mark { width: 2.2rem; height: 2.2rem; }
  .form-grid, .add-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: no-preference) {
  .hero { animation: appear .38s ease-out both; }
  @keyframes appear {
    from { opacity: .4; transform: translateY(-.45rem); }
    to { opacity: 1; transform: none; }
  }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
