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

:root {
  --color-bg: #f7f5f2;
  --color-surface: #ffffff;
  --color-border: #e2ddd8;
  --color-text: #1a1714;
  --color-text-muted: #6b6560;
  --color-accent: #c0622a;
  --color-accent-light: #fdf0ea;
  --color-success: #2d7a46;
  --color-success-light: #edf7f1;
  --color-warning: #9a6e00;
  --color-warning-light: #fdf8e7;
  --color-error: #c0392b;
  --color-error-light: #fdf0ef;
  --color-disabled-bg: #f0ede9;
  --color-disabled-text: #a09893;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --transition: 0.15s ease;
}

html { font-size: 16px; }

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  min-height: 100dvh;
}

/* ── Layout ── */
.section { min-height: 100dvh; }
.section--center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.hidden { display: none !important; }
.mt-sm { margin-top: 0.75rem; }
.mt-md { margin-top: 1.25rem; }

/* ── Spinner ── */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text { color: var(--color-text-muted); font-size: 0.95rem; }

/* ── Cards ── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow);
}

.card--error { border-color: var(--color-error); background: var(--color-error-light); }
.card--success { border-color: var(--color-success); background: var(--color-success-light); }
.card--warning { border-color: var(--color-warning); background: var(--color-warning-light); }

.card__icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.card__title { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.5rem; }
.card__body { font-size: 0.95rem; color: var(--color-text-muted); margin-bottom: 0.5rem; }
.card__hint { font-size: 0.85rem; color: var(--color-text-muted); margin-top: 0.75rem; }

/* ── Header ── */
.page-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.page-header__logo { font-size: 1.75rem; line-height: 1; }
.page-header__title { font-size: 1.1rem; font-weight: 700; }
.page-header__subtitle { font-size: 0.85rem; color: var(--color-text-muted); }

/* ── Section title ── */
.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  padding: 1.25rem 0 0.75rem;
  color: var(--color-text);
}

/* ── Products list ── */
.products-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.25rem; }

.product-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  transition: border-color var(--transition);
}

.product-row:focus-within { border-color: var(--color-accent); }

.product-row--expired {
  background: var(--color-disabled-bg);
  border-color: var(--color-border);
  opacity: 0.7;
}

.product-info { flex: 1; min-width: 0; }
.product-name { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-unit { font-size: 0.8rem; color: var(--color-text-muted); }

.product-cutoff {
  font-size: 0.75rem;
  color: var(--color-error);
  font-weight: 500;
}

.product-cutoff--expired { color: var(--color-disabled-text); }

.product-qty {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.qty-input {
  width: 70px;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 1rem;
  text-align: center;
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color var(--transition);
}

.qty-input:focus { outline: none; border-color: var(--color-accent); background: #fff; }
.qty-input:disabled { background: var(--color-disabled-bg); color: var(--color-disabled-text); cursor: not-allowed; }

/* ── Field ── */
.field { margin-bottom: 1rem; }
.field__label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.375rem; }
.field__textarea {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.625rem 0.875rem;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  background: var(--color-surface);
  transition: border-color var(--transition);
}
.field__textarea:focus { outline: none; border-color: var(--color-accent); }

/* ── Form error ── */
.form-error {
  background: var(--color-error-light);
  border: 1px solid var(--color-error);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: var(--color-error);
  margin-bottom: 1rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), background var(--transition);
  text-decoration: none;
  gap: 0.5rem;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: var(--color-accent); color: #fff; }
.btn--primary:hover:not(:disabled) { opacity: 0.88; }

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
}
.btn--secondary:hover:not(:disabled) { background: var(--color-accent-light); }

.btn--ghost { background: transparent; color: var(--color-text-muted); }
.btn--ghost:hover:not(:disabled) { background: var(--color-border); }

.btn--full { width: 100%; }

/* ── Pedido ID ── */
.pedido-id {
  font-family: monospace;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--color-success);
  margin: 0.5rem 0 1rem;
}

/* ── History list ── */
.history-list { display: flex; flex-direction: column; gap: 0.75rem; }

.history-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.history-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

.history-card__date { font-size: 0.8rem; color: var(--color-text-muted); }
.history-card__status { font-size: 0.75rem; font-weight: 600; padding: 0.2rem 0.6rem; border-radius: 20px; white-space: nowrap; }

.status--recebido { background: #e8f0fe; color: #1a56cc; }
.status--em_producao { background: #fff3cd; color: #856404; }
.status--finalizado { background: var(--color-success-light); color: var(--color-success); }
.status--entregue { background: #f0f0f0; color: #555; }

.history-card__itens { font-size: 0.88rem; color: var(--color-text-muted); margin-bottom: 0.75rem; }
.history-card__item { margin-bottom: 0.2rem; }

.history-card__pedido-id { font-size: 0.75rem; color: var(--color-text-muted); font-family: monospace; margin-bottom: 0.75rem; }

.history-card__actions { display: flex; justify-content: flex-end; }

.btn--repeat { font-size: 0.85rem; padding: 0.45rem 0.9rem; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}
