@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/inter-regular.woff2") format("woff2");
}

@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/inter-medium.woff2") format("woff2");
}

@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/inter-semibold.woff2") format("woff2");
}

@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/inter-bold.woff2") format("woff2");
}

:root {
  --green: #178056;
  --green-bright: #1e9e6a;
  --green-dark: #0e6a40;
  --ink: #163028;
  --muted: #24362f;
  --card: #ffffff;
  --line: #e1eee7;
  --field: #d5e4dc;
  --red: #b91c36;
  --red-dark: #9f1239;
  --shadow: 0 10px 28px rgba(24, 70, 48, 0.08), 0 1px 2px rgba(24, 70, 48, 0.04);
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; touch-action: manipulation; }

body {
  min-height: 100dvh;
  color: var(--ink);
  font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background:
    radial-gradient(900px 420px at 50% -80px, #dff6ea, transparent 70%),
    linear-gradient(180deg, #d7f3e4 0%, #f4f7f2 46%, #fff1e6 100%);
}

button, input, select, textarea { font: inherit; color: inherit; scroll-margin-bottom: 150px; }

button { cursor: pointer; touch-action: manipulation; }

:focus-visible {
  outline: 3px solid #0b3d28;
  outline-offset: 2px;
}

.app {
  width: min(480px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  background: linear-gradient(180deg, #e8f7f0 0%, #f7fbf8 42%, #fff6ef 100%);
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(16px + env(safe-area-inset-top)) 18px 8px;
  color: var(--ink);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: #fff;
  color: var(--green-bright);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  flex: 0 0 auto;
}

.brand-mark svg { width: 26px; height: 26px; }

.eyebrow {
  margin: 0;
  color: var(--green-dark);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 700;
}

h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  font-weight: 700;
}

main { padding: 4px 16px 20px; }

#app-view { padding-bottom: calc(136px + env(safe-area-inset-bottom)); }

#auth-view {
  margin-top: 12px;
  padding: 22px 18px 18px;
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.lead, .hint, .field-hint, .install-note, .count, .meta, .type {
  color: var(--muted);
}

.lead { margin: 0 0 18px; font-size: 1rem; }

.hint, .install-note, .field-hint {
  margin: 6px 0 0;
  font-size: 0.92rem;
  font-weight: 500;
}

.count {
  margin: 8px 0 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--green-dark);
}

.install-note { margin-top: 16px; }

.screen-intro { margin: 6px 0 14px; }

.screen-intro h2 { margin-bottom: 4px; font-size: 1.55rem; }

.hero-mark {
  width: 84px;
  height: 84px;
  margin-bottom: 14px;
  border-radius: 28px;
  background: #fff;
  color: var(--green-bright);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.hero-mark svg { width: 40px; height: 40px; }

label, .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  font-weight: 700;
}

.field > label { margin: 0; }

input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1.5px solid var(--field);
  border-radius: 16px;
  background: #fff;
  font-weight: 500;
  font-size: 16px;
}

textarea { min-height: 132px; resize: vertical; border-radius: 18px; }

input::placeholder, textarea::placeholder { color: #3e524a; font-weight: 500; }

select {
  appearance: none;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%23178056' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 42px;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

button, .file-button {
  min-height: 48px;
  min-width: 44px;
  border-radius: 999px;
  border: 0;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  padding: 12px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-icon { width: 18px; height: 18px; flex: 0 0 auto; }

#auth-submit, #show-add, #invoice-close, .file-button, .stack > button { width: 100%; }

button.ghost, .file-button {
  background: #f3faf6;
  color: var(--green-dark);
  border: 1.5px solid #b7e0cc;
}

.file-button.file-button-primary {
  background: var(--green);
  color: #fff;
  border-color: transparent;
}

button.danger {
  background: #fff5f6;
  color: var(--red-dark);
  border: 1.5px solid #f0c2c8;
}

button.recording {
  background: #fde8ea;
  color: var(--red-dark);
  border: 1.5px solid #f0c2c8;
}

.file-button {
  position: relative;
  margin: 0 0 12px;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

.file-button:focus-within {
  outline: 3px solid #0b3d28;
  outline-offset: 2px;
}

.text-button {
  display: flex;
  width: 100%;
  margin-top: 4px;
  background: transparent;
  color: var(--green-dark);
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: 48px;
}

.progress {
  height: 10px;
  margin: 4px 0 12px;
  background: #e3f0e9;
  border-radius: 999px;
  overflow: hidden;
}

.progress > div {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--green-bright));
}

.stack { display: flex; flex-direction: column; gap: 10px; }

.stack > * { margin: 0; }

.intake-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0 0 16px;
}

button.choice {
  flex-direction: column;
  gap: 10px;
  min-height: 118px;
  padding: 16px 10px;
  background: #fff;
  color: var(--ink);
  border-radius: 22px;
  border: 0;
  box-shadow: var(--shadow);
  font-size: 1rem;
}

.choice-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #e7f6ee;
  color: var(--green-dark);
  display: grid;
  place-items: center;
}

.choice-icon svg { width: 24px; height: 24px; }

#add-form, #intake-text, #intake-audio, #intake-preview, .card {
  background: var(--card);
  border-radius: 22px;
  padding: 16px;
  box-shadow: var(--shadow);
}

#add-form, #intake-text, #intake-audio, #intake-preview { margin: 4px 0 14px; }

#intake-audio .form-actions { flex-wrap: wrap; }

#intake-audio .form-actions > * { flex: 1 1 8rem; margin: 0; }

#intake-audio .form-actions > .file-button { width: auto; }

#intake-items { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }

#intake-items article > button.ghost,
#intake-items article > button.danger {
  width: 100%;
  margin-top: 8px;
}

.form-actions, .card-actions {
  display: flex;
  gap: 8px;
}

.form-actions > *, .card-actions > * { flex: 1; margin: 0; }

.status {
  min-height: 1.45em;
  margin: 0 0 8px;
  font-weight: 700;
}

.status.error { color: var(--red-dark); }

.status.ok { color: var(--green-dark); }

#list, .invoice-list, #invoice-lines {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.invoice-list { margin-top: 4px; }

.card-main {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.card-body { flex: 1; min-width: 0; }

.photo {
  width: 96px;
  height: 96px;
  border-radius: 20px;
  overflow: hidden;
  flex: 0 0 auto;
  background: #e7f4ee;
  box-shadow: inset 0 0 0 1px rgba(23, 80, 50, 0.06);
}

.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h2.brand {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.total {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.type, .meta {
  margin: 2px 0 0;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.lots {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.chip, .badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.chip {
  background: #f1f5f3;
  color: #24362f;
}

.badge.vencido { background: #f8d0d6; color: #8e1b32; }
.badge.soon { background: #c2410c; color: #fff; }
.badge.month { background: #ffe14a; color: #3f2a00; }
.badge.ok { background: #d5f3e4; color: #0e6a40; }
.badge.illegible { background: #e6e9ed; color: #3e4a55; }

.card-actions { margin-top: 14px; }

.stepper {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  width: max-content;
  max-width: 100%;
  height: 52px;
  padding: 4px;
  border-radius: 999px;
  background: #f3f6f4;
  border: 1px solid #e1ebe6;
  gap: 2px;
}

button.stepper-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--green);
  border: 0;
  box-shadow: 0 1px 2px rgba(20, 60, 40, 0.08);
}

button.stepper-btn svg { width: 18px; height: 18px; }

.stepper input {
  width: 3rem;
  min-height: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.lots-edit { margin-top: 8px; }

.raise-choice {
  min-inline-size: 0;
  width: 100%;
  margin: 4px 0 12px;
  padding: 10px 12px 12px;
  border: 1.5px solid var(--field);
  border-radius: 16px;
  background: #f7fbf8;
  scroll-margin-top: 12px;
  scroll-margin-bottom: 150px;
}

.raise-choice legend {
  padding: 0 4px;
  font-size: 0.92rem;
  font-weight: 700;
}

.raise-block {
  margin: 6px 0 0;
  color: var(--red-dark);
  font-size: 0.92rem;
  font-weight: 700;
}

.raise-choice label {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin: 8px 0 0;
  font-weight: 600;
}

.raise-choice input {
  width: 1.25rem;
  height: 1.25rem;
  min-height: 0;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  accent-color: var(--green);
}

.lot-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.lot-edit .date-input {
  flex: 1 1 9rem;
  width: auto;
  min-width: 8.5rem;
  margin: 0;
}

.lot-edit button.danger {
  flex: 0 0 auto;
  width: auto;
  min-width: 88px;
  margin: 0;
}

.card > button.ghost { width: 100%; margin-top: 4px; }

.empty {
  padding: 28px 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  text-align: center;
  box-shadow: var(--shadow);
}

button.banner {
  display: flex;
  width: 100%;
  margin: 2px 0 14px;
  padding: 12px 14px;
  background: #fff;
  color: var(--red-dark);
  border: 1.5px solid #e35d6a;
  border-radius: 22px;
  box-shadow: 0 8px 24px rgba(180, 40, 50, 0.1);
  text-align: left;
  justify-content: flex-start;
  gap: 12px;
}

.banner-flag {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-weight: 800;
  font-size: 1.25rem;
}

.banner-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

#invoice-banner-text {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--red-dark);
}

.banner-note {
  font-size: 0.82rem;
  font-weight: 600;
  color: #7f1d33;
}

.banner-chevron { width: 22px; height: 22px; flex: 0 0 auto; color: var(--red-dark); }

button.invoice-row {
  display: flex;
  width: 100%;
  min-height: 72px;
  margin: 0;
  padding: 14px 16px;
  background: #fff;
  color: var(--ink);
  border: 0;
  border-radius: 22px;
  box-shadow: var(--shadow);
  text-align: left;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
}

button.invoice-row.open {
  border: 1.5px solid #e35d6a;
  box-shadow: 0 8px 24px rgba(180, 40, 50, 0.1);
}

button.invoice-row.open strong { color: var(--red-dark); }

.invoice-row strong { font-size: 1rem; font-weight: 800; }

.invoice-figures {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.invoice-progress, .progress-count {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.progress-count {
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef6f2;
  color: var(--ink);
  font-size: 0.95rem;
}

.invoice-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  padding: 14px 16px;
  background: #fff;
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.invoice-summary .invoice-progress {
  font-size: 1.45rem;
  color: var(--ink);
}

.invoice-summary .line-alert {
  width: auto;
  margin: 0;
  min-height: 36px;
}

#invoice-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#invoice-back {
  width: auto;
  align-self: flex-start;
  padding-inline: 14px;
  background: #fff;
  border-color: transparent;
  box-shadow: var(--shadow);
}

#panel-facturas:has(#invoice-view:not([hidden])) .facturas-home { display: none; }

#invoice-tasks {
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* The chat button sits above the nav and covers the last link at 390px. */
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

#invoice-classic { display: contents; }

#task-lines {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#capture-start { width: 100%; }

#capture-stage {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#capture-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 42vh;
  object-fit: cover;
  background: #10241c;
  border-radius: 18px;
}

#capture-pending {
  margin: 0;
  font-weight: 800;
  color: var(--green-dark);
}

#capture-note { margin: 0; }

#capture-note:empty { display: none; }

#capture-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#capture-actions > button { width: 100%; }

#capture-failures {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.capture-fail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.capture-fail button {
  flex: 0 0 auto;
  background: #fff5f6;
  color: var(--red-dark);
  border: 1.5px solid #f0c2c8;
}

.task-row .card-top { align-items: flex-start; }

.task-row .brand {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.task-check { white-space: nowrap; }

.task-expected {
  margin-top: 8px;
  color: var(--ink);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.task-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.task-actions > button {
  flex: 1 1 0;
  min-width: 0;
  padding-inline: 10px;
}

#task-hidden,
#task-back {
  justify-content: center;
  text-align: center;
}

.line-alert {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  margin: 12px 0 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-weight: 800;
  letter-spacing: -0.02em;
}

p.line-alert {
  display: flex;
  width: 100%;
  min-height: 44px;
  border-radius: 14px;
  font-size: 1.05rem;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.card-top .badge, .card-top .progress-count { flex: 0 0 auto; }

.account-card { margin-bottom: 12px; }

.store-email {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.card.flash {
  box-shadow: 0 0 0 3px var(--green), var(--shadow);
}

.tabbar {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 0;
  height: calc(68px + env(safe-area-inset-bottom));
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid rgba(23, 128, 86, 0.08);
  box-shadow: 0 -10px 30px rgba(24, 70, 48, 0.08);
  overflow: visible;
}

button.tab {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 48px;
  height: auto;
  padding: 4px 2px 2px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.15;
  flex-direction: column;
  justify-content: flex-end;
  gap: 3px;
  box-shadow: none;
}

button.tab svg { width: 22px; height: 22px; }

button.tab.is-active { color: var(--green-dark); }

.tab-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.tab-main { overflow: visible; }

.tab-main-btn {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--green-bright);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 20px rgba(30, 158, 106, 0.34), 0 0 0 4px #f4fbf7;
}

.tab-main-btn svg { width: 26px; height: 26px; color: #fff; }

button.tab-main.is-active .tab-main-btn {
  background: var(--green-bright);
  box-shadow: 0 10px 22px rgba(30, 158, 106, 0.4), 0 0 0 4px #d7f3e6;
}

@media (min-width: 560px) {
  body { padding: 24px 16px; }

  .app {
    min-height: calc(100dvh - 48px);
    border-radius: 32px;
    box-shadow: 0 24px 70px rgba(22, 70, 48, 0.14);
  }

  .tabbar {
    bottom: 24px;
    width: min(480px, calc(100% - 32px));
    border-radius: 0 0 32px 32px;
  }
}

.feedback-fab {
  position: fixed;
  z-index: 35;
  right: max(16px, calc(50% - 224px));
  bottom: calc(84px + env(safe-area-inset-bottom));
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: 50%;
  box-shadow: 0 8px 18px rgba(24, 70, 48, 0.18);
}

.feedback-fab svg { width: 22px; height: 22px; }

.feedback-pop {
  position: fixed;
  z-index: 36;
  right: max(16px, calc(50% - 224px));
  bottom: calc(140px + env(safe-area-inset-bottom));
  width: min(320px, calc(100% - 32px));
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.feedback-pop textarea { min-height: 96px; margin: 0 0 8px; }

.feedback-toast {
  position: fixed;
  z-index: 37;
  right: max(16px, calc(50% - 224px));
  bottom: calc(140px + env(safe-area-inset-bottom));
  max-width: min(280px, calc(100% - 32px));
  margin: 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-weight: 700;
}

.feedback-toast.ok { color: var(--green-dark); }

.feedback-toast.error { color: var(--red-dark); }

.feedback-toast.is-raised { bottom: calc(332px + env(safe-area-inset-bottom)); }

@media (min-width: 560px) {
  .feedback-fab { bottom: 120px; }
  .feedback-pop { bottom: 176px; }
  .feedback-toast { bottom: 176px; }
  .feedback-toast.is-raised { bottom: 368px; }
}

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card.flash { box-shadow: var(--shadow); }
}
