/* Químicos · FaleAgro — mobile-first, agrícola/profissional */

:root {
  --green: #1b4332;
  --green-mid: #2d6a4f;
  --green-light: #d8f3dc;
  --green-soft: #95d5b2;
  --amber: #e9c46a;
  --amber-bg: #fff6df;
  --orange: #e76f51;
  --red: #c1121f;
  --red-soft: #fde8ea;
  --blue: #1d6a8a;
  --blue-soft: #e6f4fa;
  --bg: #f3f1ea;
  --card: #ffffff;
  --text: #14201a;
  --muted: #5a655e;
  --border: #ddd8cc;
  --shadow: 0 2px 8px rgba(27, 67, 50, 0.08);
  --radius: 14px;
  --tap: 48px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --max: 720px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

button,
a,
input,
select,
textarea,
.chip,
.tab,
.btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 10% -20%, #2d6a4f33, transparent),
    var(--bg);
  min-height: 100dvh;
  padding-bottom: calc(20px + var(--safe-bottom));
}

/* Header */
.header {
  background: linear-gradient(145deg, var(--green) 0%, #245c42 55%, var(--green-mid) 100%);
  color: #fff;
  padding: 1rem 1.1rem 1.15rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 1.35rem;
  flex-shrink: 0;
}

.header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: 0.01em;
}

.brand-dot {
  opacity: 0.7;
  font-weight: 400;
}

.subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  opacity: 0.85;
}

.alert-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  white-space: nowrap;
}

.badge.warn {
  background: var(--amber);
  color: #3a2e0a;
}

.badge.danger {
  background: #ffb4b8;
  color: #5c0a12;
}

/* Tabs */
.tabs {
  display: flex;
  background: var(--green);
  position: sticky;
  top: 0;
  z-index: 20;
  max-width: 100%;
  box-shadow: var(--shadow);
}

.tab {
  flex: 1;
  min-height: var(--tap);
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
  padding: 0.7rem 0.4rem;
  border-bottom: 3px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab.active {
  color: #fff;
  border-bottom-color: var(--amber);
  background: rgba(255, 255, 255, 0.06);
}

.tab-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
}

/* Main */
.main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px 12px 0;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.search-wrap {
  flex: 1;
  min-width: 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.filters-alert .chip {
  font-size: 0.8rem;
}

.chip {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  background: var(--green-mid);
  border-color: var(--green-mid);
  color: #fff;
}

.chip-warn.active {
  background: #b45309;
  border-color: #b45309;
}

.summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
  font-size: 0.82rem;
  color: var(--muted);
}

.summary-pill {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
}

/* Product cards */
.product-list,
.movement-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.product-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.12s ease;
}

.product-card:active {
  transform: scale(0.985);
}

.product-card.alert-low {
  border-left: 4px solid var(--orange);
}

.product-card.alert-exp {
  border-left: 4px solid var(--amber);
}

.product-card.alert-expired {
  border-left: 4px solid var(--red);
}

.pc-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.pc-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.pc-ai {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.pc-qty {
  text-align: right;
  flex-shrink: 0;
}

.pc-qty-num {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--green);
  line-height: 1.1;
}

.pc-qty-unit {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.pc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  align-items: center;
}

.tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--green-light);
  color: var(--green);
}

.tag.defensivo {
  background: #e8f5e9;
  color: #1b5e20;
}
.tag.fertilizante {
  background: #e3f2fd;
  color: #0d47a1;
}
.tag.adjuvante {
  background: #f3e5f5;
  color: #6a1b9a;
}
.tag.outro {
  background: #eceff1;
  color: #37474f;
}

.tag.warn {
  background: var(--amber-bg);
  color: #8a5a00;
}
.tag.danger {
  background: var(--red-soft);
  color: var(--red);
}

.pc-loc {
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: auto;
}

/* Movements */
.movement-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}

.movement-item.compact {
  padding: 8px 10px;
  border-radius: 10px;
}

.mov-kind {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.1rem;
}

.mov-kind.entrada {
  background: var(--green-light);
  color: var(--green);
}

.mov-kind.saida {
  background: var(--red-soft);
  color: var(--red);
}

.mov-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.mov-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.mov-qty {
  font-weight: 800;
  font-size: 1.05rem;
  white-space: nowrap;
}

.mov-qty.entrada {
  color: var(--green-mid);
}
.mov-qty.saida {
  color: var(--red);
}

/* Alerts panel */
.alert-section {
  margin-bottom: 18px;
}

.alert-section h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.alert-dot.danger {
  background: var(--red);
}
.alert-dot.warn {
  background: #d97706;
}
.alert-dot.orange {
  background: var(--orange);
}

/* Forms / inputs */
.label {
  display: block;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted);
  margin: 10px 0 4px;
}

.input {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
}

.input:focus {
  outline: 2px solid var(--green-soft);
  border-color: var(--green-mid);
}

.search {
  padding-left: 0.9rem;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

textarea.input {
  resize: vertical;
  min-height: 64px;
}

/* Buttons */
.btn {
  min-height: 44px;
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary {
  background: var(--green-mid);
  color: #fff;
}

.btn-primary:active {
  background: var(--green);
}

.btn-ghost {
  background: #eef2ef;
  color: var(--text);
}

.btn-danger {
  background: var(--red-soft);
  color: var(--red);
}

.btn-in {
  background: var(--green-light);
  color: var(--green);
}

.btn-out {
  background: #ffe8e0;
  color: #9a3412;
}

.btn-icon {
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
}

/* Modal */
.modal {
  border: none;
  border-radius: 18px;
  padding: 0;
  width: min(96vw, 440px);
  max-height: 90dvh;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
  background: var(--card);
}

.modal::backdrop {
  background: rgba(15, 30, 22, 0.55);
  backdrop-filter: blur(2px);
}

.modal form,
.modal-detail {
  padding: 1.1rem 1.15rem 1.2rem;
  overflow: auto;
}

.modal h2 {
  margin: 0 0 4px;
  font-size: 1.2rem;
}

.modal-sub {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}

.kind-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 4px;
}

.kind-btn {
  min-height: 44px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
}

.kind-btn.active[data-kind="entrada"] {
  border-color: var(--green-mid);
  background: var(--green-light);
  color: var(--green);
}

.kind-btn.active[data-kind="saida"] {
  border-color: var(--orange);
  background: #ffe8e0;
  color: #9a3412;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.detail-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.detail-body {
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.detail-body dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
}

.detail-body dt {
  font-weight: 650;
  color: var(--text);
}

.detail-body dd {
  margin: 0;
}

.detail-qty {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--green);
  margin: 6px 0 10px;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.detail-mov-title {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 1rem;
  font-size: 0.95rem;
}

.empty.success {
  color: var(--green-mid);
  font-weight: 600;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 12px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--green);
  color: #fff;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 650;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}

.toast.error {
  background: var(--red);
}

@media (min-width: 640px) {
  .header h1 {
    font-size: 1.5rem;
  }
  .detail-actions {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 520px) {
  .header-inner {
    flex-direction: column;
    gap: 10px;
  }
  .header h1 {
    white-space: nowrap;
    font-size: 1.25rem;
  }
  .alert-badges {
    justify-content: flex-start;
  }
}
