/* Paleta — Anel Arqueo */
:root {
  --bg-main: #fdf6f1;
  --bg-secondary: #f4e7dc;
  --surface: #fffaf7;
  --latte: #b89b84;
  --cafe-humo: #8d7461;
  --text-main: #4b3d35;
  --text-muted: #7a6a60;
  --border: #e7d8cc;
  --accent-soft: #e8c5b0;
  --accent: #c99884;

  --font-sans: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --radius-lg: 1rem;
  --radius-md: 0.75rem;
  --shadow-soft: 0 4px 24px rgb(139 116 97 / 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-main);
  background: var(--bg-main);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -20%, var(--accent-soft), transparent),
    linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-main) 35%);
}

.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  inset: 0;
  width: 0;
  height: 0;
  overflow: hidden;
}

.app {
  max-width: 32rem;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
  min-height: 100dvh;
}

body.splash-done .splash {
  display: none;
}

body.splash-done #app.is-hidden {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
}

/* Splash */
.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg-main);
  color: var(--accent-soft);
  animation: splash-out 0.4s ease forwards 2.4s;
}

@keyframes splash-out {
  to {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

.splash__inner {
  text-align: center;
  padding: 2rem 1.5rem 5.5rem;
  max-width: 22rem;
  animation: fade-up 0.55s ease;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.splash__emoji {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 8vw, 2.75rem);
  line-height: 1;
  letter-spacing: 0.2em;
}

.splash__emoji span {
  display: inline-block;
}

.splash__title {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: clamp(1.2rem, 4.2vw, 1.45rem);
  line-height: 1.35;
  color: var(--text-main);
  margin: 0 0 0.65rem;
}

.splash__credit {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.splash__wave {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  line-height: 0;
  pointer-events: none;
}

.splash__wave svg {
  display: block;
  width: 100%;
  height: min(3rem, 10vw);
}

/* Header */
.header {
  padding: 1.25rem 0 0.75rem;
  text-align: center;
}

.header__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-main);
}

.header__subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--cafe-humo);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  box-shadow: var(--shadow-soft);
}

/* Form */
.form-fields-row {
  display: grid;
  grid-template-columns: minmax(4.5rem, 0.85fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.5rem 0.5rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.form-fields-row .field {
  margin-bottom: 0;
  min-width: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field--qty input {
  text-align: center;
}

.field input,
.field select {
  appearance: none;
  font-family: inherit;
  font-size: 1.05rem;
  min-height: 3rem;
  padding: 0.65rem 0.85rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-main);
  color: var(--text-main);
  width: 100%;
}

.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238d7461'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.1rem;
  padding-right: 2.25rem;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--latte);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-error {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

/* Hide number spinners (cleaner touch UI) */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 3rem;
  padding: 0.65rem 1.25rem;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.1s,
    box-shadow 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn--block {
  width: 100%;
}

.btn--primary {
  background: linear-gradient(160deg, var(--latte), var(--cafe-humo));
  color: var(--surface);
  border-color: var(--cafe-humo);
  box-shadow: 0 4px 14px rgb(139 116 97 / 0.35);
}

.btn--primary:hover {
  filter: brightness(1.06);
}

.btn--ghost {
  background: transparent;
  color: var(--cafe-humo);
  border-color: var(--border);
  margin-top: 0.75rem;
}

.btn--ghost:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text-main);
}

.btn--share {
  background: var(--surface);
  color: var(--cafe-humo);
  border: 2px solid var(--latte);
  box-shadow: 0 2px 12px rgb(139 116 97 / 0.12);
}

.btn--share:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text-main);
}

.btn--share:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.share-status {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--cafe-humo);
  text-align: center;
}

.share-status.is-error {
  color: var(--accent);
}

.btn--danger {
  min-height: 2.75rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.92rem;
  background: transparent;
  color: var(--cafe-humo);
  border: 2px solid var(--border);
}

.btn--danger:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text-main);
}

/* Totals */
.total-card {
  background: linear-gradient(145deg, var(--surface) 0%, var(--bg-secondary) 100%);
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.total-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.total-amount {
  font-family: var(--font-display);
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
}

/* Breakdown */
.breakdown {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.breakdown-rollup {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 0.9rem;
  background: linear-gradient(160deg, var(--surface) 0%, var(--bg-secondary) 100%);
  box-shadow: var(--shadow-soft);
}

.breakdown-rollup__eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cafe-humo);
}

.breakdown-rollup__trio {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem 0.5rem;
  text-align: center;
}

.breakdown-rollup__cell {
  padding: 0.5rem 0.25rem;
  border-radius: var(--radius-md);
  background: var(--bg-main);
  border: 1px solid var(--border);
}

.breakdown-rollup__num {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
  line-height: 1.2;
}

.breakdown-rollup__lbl {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: lowercase;
  color: var(--text-muted);
}

.breakdown-rollup__meta {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-muted);
  text-align: center;
}

.breakdown-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.95rem 0.95rem 0.85rem;
  background: var(--bg-main);
}

.breakdown-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.breakdown-card__head h3 {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  margin: 0;
  color: var(--cafe-humo);
}

.breakdown-card__value {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--latte);
}

.breakdown-trio {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}

.breakdown-trio__cell {
  text-align: center;
  padding: 0.5rem 0.2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
}

.breakdown-trio__num {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
}

.breakdown-trio__lbl {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.breakdown-card__detail {
  margin: 0.65rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

.breakdown-card__raw {
  margin: 0.55rem 0 0;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.45;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--border);
}

/* History */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
  padding: 1rem 0.5rem;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  align-items: start;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-main);
}

.history-item__body {
  min-width: 0;
}

.history-item__line {
  font-weight: 700;
  color: var(--text-main);
  font-size: 0.97rem;
}

.history-item__meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.history-item__value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--cafe-humo);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.history-item__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  min-width: 5rem;
}

.history-item .btn--delete {
  width: 100%;
}

@media (max-width: 23.5rem) {
  .form-fields-row {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    align-items: stretch;
  }

  .field--qty input {
    text-align: left;
  }

  .breakdown-rollup__trio,
  .breakdown-trio {
    grid-template-columns: 1fr;
  }
}
