:root {
  --color-primario: #2e5339;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #f4f6f4;
  color: #1c2a1e;
  padding-bottom: 70px;
}

header {
  background: var(--color-primario);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 1.1rem;
  margin: 0;
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

#syncBadge {
  font-size: 0.75rem;
  background: #c0392b;
  padding: 3px 8px;
  border-radius: 10px;
}

#syncBadge.ok {
  background: #3d7a4a;
}

#syncStatus {
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.15);
  padding: 3px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

#syncStatus.ok {
  background: rgba(255, 255, 255, 0.12);
  opacity: 0.75;
}

main {
  padding: 12px;
  max-width: 640px;
  margin: 0 auto;
}

nav.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #d8ddd6;
  display: flex;
  z-index: 10;
}

.toast-container {
  position: fixed;
  bottom: 78px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: 100%;
  padding: 0 16px;
}

.toast {
  background: var(--color-primario);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 100%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

nav.tabbar a {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
  font-size: 0.72rem;
  color: #4a5a4c;
  text-decoration: none;
}

nav.tabbar a.active {
  color: var(--color-primario);
  font-weight: 600;
}

.card {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: #3a4a3c;
}

input, select, textarea {
  width: 100%;
  padding: 10px;
  font-size: 1rem;
  border: 1px solid #c7cfc6;
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
}

textarea { min-height: 60px; }

button {
  font-size: 1rem;
  padding: 11px 16px;
  border-radius: 8px;
  border: none;
  background: var(--color-primario);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

button.secondary {
  background: #e2e7e0;
  color: var(--color-primario);
}

button.danger {
  background: #c0392b;
}

button:disabled {
  opacity: 0.5;
}

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #eceeeb;
}

.list-item:last-child { border-bottom: none; }

.muted { color: #71806f; font-size: 0.8rem; }

.pill {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: #eef1ed;
  color: #4a5a4c;
}

.pill.pendiente { background: #fdecea; color: #c0392b; }
.pill.sincronizado { background: #e6f4ea; color: var(--color-primario); }

.orden-realizada {
  padding: 8px 0;
  border-bottom: 1px solid #eceeeb;
}

.orden-realizada:last-child { border-bottom: none; }

.orden-realizada summary {
  cursor: pointer;
  font-size: 0.9rem;
}

.tabla-orden {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.85rem;
}

.tabla-orden th, .tabla-orden td {
  text-align: left;
  padding: 6px 4px;
  border-bottom: 1px solid #eceeeb;
}

.tabla-orden th {
  color: #71806f;
  font-weight: 600;
  font-size: 0.75rem;
}

.hidden { display: none !important; }

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

h2 { font-size: 1rem; margin: 4px 0 12px; color: var(--color-primario); }

.empty-state {
  text-align: center;
  color: #8a978a;
  padding: 24px 0;
  font-size: 0.9rem;
}

.subtabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 4px;
}

.subtabs a {
  flex: 0 0 auto;
  padding: 7px 12px;
  border-radius: 16px;
  background: #e2e7e0;
  color: var(--color-primario);
  text-decoration: none;
  font-size: 0.82rem;
  white-space: nowrap;
}

.subtabs a.active {
  background: var(--color-primario);
  color: #fff;
  font-weight: 600;
}

.tipo-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.tipo-toggle button {
  flex: 1;
  background: #e2e7e0;
  color: var(--color-primario);
}

.tipo-toggle button.active {
  background: var(--color-primario);
  color: #fff;
}

.saldo-orden {
  background: #f4f6f4;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 0.85rem;
}

.saldo-orden .item { display: flex; justify-content: space-between; padding: 3px 0; }

.producto-row {
  margin-bottom: 8px;
  align-items: center;
}

.producto-row select { flex: 2; }
.producto-row input { flex: 1; }
.producto-row button {
  flex: 0 0 auto;
  padding: 10px 12px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}

.checkbox-field input[type="checkbox"] {
  width: auto;
}

.fila-aplicacion {
  margin-bottom: 10px;
}

.fila-aplicacion .pendienteRow {
  font-size: 0.78rem;
  margin-top: -6px;
}
