:root {
  --bg: #3a1a60;
  --bg-2: #2a1148;
  --primary: #e99318;
  --primary-2: #ffb347;
  --ink: #1b1028;
  --paper: #fffaf3;
  --muted: #7a6b88;
  --line: #eadcc6;
  --white: #fff;
  --shadow: 0 28px 70px rgba(18, 6, 36, 0.38);
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  overflow: hidden;
}
body {
  margin: 0;
  font-family: Manrope, sans-serif;
  color: var(--ink);
  background-color: #3a1a60;
  background-image:
    radial-gradient(900px 420px at 8% -10%, #5a2d8f 0%, transparent 55%),
    radial-gradient(700px 380px at 100% 0%, #e9931826 0%, transparent 46%),
    linear-gradient(180deg, #3a1a60 0%, #2a1148 100%);
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background-color: #3a1a60;
  background-image:
    radial-gradient(900px 420px at 8% -10%, #5a2d8f 0%, transparent 55%),
    radial-gradient(700px 380px at 100% 0%, #e9931826 0%, transparent 46%),
    linear-gradient(180deg, #3a1a60 0%, #2a1148 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .45s ease;
}
.splash.is-gone {
  opacity: 0;
  pointer-events: none;
}
.splash-logo {
  height: 92px;
  width: auto;
  display: block;
  filter: drop-shadow(0 10px 24px rgba(0,0,0,.35));
}
.splash-spin {
  position: absolute;
  left: 50%;
  bottom: 30px;
  width: 28px;
  height: 28px;
  transform: translateX(-50%);
}
.splash-spin span {
  display: block;
  width: 100%;
  height: 100%;
  border: 3px solid rgba(233, 147, 24, .22);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: splash-spin 0.75s linear infinite;
}
@keyframes splash-spin {
  to { transform: rotate(360deg); }
}

.app {
  max-width: 1440px;
  margin: 0 auto;
  height: 100%;
  max-height: 100dvh;
  padding: 16px 18px 18px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  overflow: hidden;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo {
  height: 58px;
  width: auto;
  display: block;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.28));
}
.top-actions { display: flex; gap: 8px; }

.btn {
  font-family: inherit;
  font-weight: 700;
  border: 0;
  cursor: pointer;
  border-radius: 14px;
  padding: 11px 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn.primary {
  background: linear-gradient(180deg, #ffb347, var(--primary));
  color: #3a1a60;
  box-shadow: 0 10px 22px rgba(233,147,24,.28);
}
.btn.ghost {
  background: rgba(255,255,255,.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,.16);
}
.btn.tiny {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
}
.btn:disabled { opacity: .6; cursor: wait; }
#btnPdf.is-off {
  opacity: .45;
  cursor: not-allowed;
  box-shadow: none;
}

.mobile-tabs { display: none; gap: 8px; }
.tab {
  flex: 1;
  border: 0;
  background: rgba(255,255,255,.08);
  color: #fff;
  border-radius: 12px;
  padding: 10px;
  font-family: inherit;
  font-weight: 700;
}
.tab.is-on { background: var(--primary); color: #3a1a60; }

.split {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(340px, .92fr) minmax(420px, 1.08fr);
  gap: 14px;
  overflow: hidden;
}
.col {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.search-box, .chat-card, .sheet {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 22px;
}
.search-box { padding: 14px; flex: 0 0 auto; min-width: 0; }
.search-box label {
  display: block;
  color: #f3d7a6;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  min-width: 0;
}
.search-row input {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  outline: none;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-row input[type="search"]::-webkit-search-decoration,
.search-row input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}
.search-results {
  margin-top: 10px;
  max-height: 280px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hit {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 10px;
  align-items: center;
  background: #fff;
  border-radius: 14px;
  padding: 8px;
}
.hit img, .ph {
  width: 54px; height: 54px;
  object-fit: contain;
  border-radius: 10px;
  background: #f6efe4;
}
.ph { display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.hit h3 { margin: 0; font-size: 13px; line-height: 1.25; }
.hit small { color: var(--muted); }
.hit b { color: var(--bg); }

.chat-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(16, 6, 32, .35);
}
.thread {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bubble {
  max-width: 86%;
  padding: 12px 14px;
  border-radius: 18px;
  line-height: 1.45;
  font-size: 15px;
  white-space: pre-wrap;
}
.bubble.user {
  align-self: flex-end;
  background: linear-gradient(180deg, #ffb347, var(--primary));
  color: #3a1a60;
  border-bottom-right-radius: 6px;
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--paper);
  border-bottom-left-radius: 6px;
}
.bubble.status {
  align-self: center;
  background: transparent;
  color: #f3d7a6;
  font-size: 12px;
  padding: 0;
}
.bubble.error { background: #f8d4d0; color: #8a2a22; }

.composer {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
  background: rgba(0,0,0,.18);
  align-items: end;
  flex: 0 0 auto;
}
.attach {
  min-width: 48px;
  justify-content: center;
  color: #fff;
}
#btnMic.is-rec {
  background: var(--primary);
  color: #3a1a60;
  border-color: transparent;
  animation: mic-pulse 1s ease-in-out infinite;
}
@keyframes mic-pulse {
  50% { box-shadow: 0 0 0 6px rgba(233, 147, 24, .28); }
}
.bubble.voice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.composer textarea {
  resize: none;
  border: 0;
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  line-height: 1.35;
  height: 48px;
  min-height: 48px;
  max-height: 140px;
  outline: none;
  overflow-x: hidden;
  overflow-y: hidden;
  width: 100%;
  min-width: 0;
  display: block;
}
.send { min-width: 52px; justify-content: center; }

.sheet {
  min-height: 0;
  height: 100%;
  background: var(--paper);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 22px 10px;
}
.kicker {
  margin: 0;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.sheet-head h1 {
  margin: 4px 0 0;
  font-size: 28px;
  letter-spacing: -.03em;
}
.sheet-id { margin: 0; color: var(--muted); font-size: 12px; }

.items {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.empty {
  margin: 24px 8px;
  color: var(--muted);
  line-height: 1.5;
}
.card {
  display: grid;
  grid-template-columns: 74px 1fr auto;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}
.card img, .card .ph {
  width: 74px; height: 74px;
  object-fit: contain;
  border-radius: 12px;
  background: #f6efe4;
}
.card.is-confirma {
  border-color: #3a1a60;
  box-shadow: inset 3px 0 0 #3a1a60;
}
.tarja.confirma {
  background: #3a1a60;
  color: #ffb347;
  transform: rotate(-2deg);
  letter-spacing: .03em;
  text-transform: none;
}
.tarja {
  display: inline-block;
  background: var(--primary);
  color: #3a1a60;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 2px 7px;
  border-radius: 6px;
  transform: rotate(-3deg);
  margin: 0 6px 4px 0;
  vertical-align: middle;
}
.pedido-orig { color: var(--muted); font-size: 11px; margin-top: 2px; }
.meta { color: var(--muted); font-size: 12px; }
.price { text-align: right; }
.price b { display: block; font-size: 16px; color: var(--bg); }
.qty { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.qty button {
  width: 26px; height: 26px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  color: var(--bg);
}
.qty .kill {
  width: auto;
  padding: 0 8px;
  color: #9a3b32;
}

.totals {
  padding: 14px 22px 18px;
  border-top: 1px dashed var(--line);
  background: #fff6ea;
}
.minimo-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  background: var(--primary);
  color: #3a1a60;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  padding: 6px 10px;
  border-radius: 999px;
  transform: rotate(-2deg);
}
.minimo-badge[hidden] { display: none; }
.line {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--muted);
}
.line b { color: var(--ink); }
.grand {
  margin-top: 8px;
  align-items: baseline;
}
.grand span { font-weight: 800; color: var(--bg); }
.grand strong {
  font-size: 30px;
  color: var(--bg);
  letter-spacing: -.03em;
}

.cotta-status {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px 12px 12px;
  background: #3a1a60;
  border: 1px solid rgba(233, 147, 24, .42);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(18, 6, 36, .45);
  color: #fff;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.cotta-status.is-on {
  opacity: 1;
  transform: translateY(0);
}
.cotta-status-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex: 0 0 auto;
  mix-blend-mode: screen;
  filter: drop-shadow(0 0 10px rgba(233, 147, 24, .28));
}
.cotta-status-copy {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cotta-status-copy strong {
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--primary);
}
.cotta-status-copy span {
  font-size: 13px;
  line-height: 1.35;
  color: #f6efe4;
}
.cotta-status-spin {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(233, 147, 24, .22);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: splash-spin .75s linear infinite;
}

@media (max-width: 980px) {
  .app { padding: 10px; }
  .logo { height: 46px; }
  .mobile-tabs { display: flex; }
  .split { grid-template-columns: 1fr; }
  .col { display: none; min-height: 0; }
  .col.is-on { display: flex; }
  .cotta-status { right: 12px; bottom: 12px; min-width: 0; }
}
