:root {
  --ink: #23222A;
  --ink-soft: #6B6670;
  --paper: #F7F5F3;
  --paper-alt: #FFFFFF;
  --line: #E6E1DD;
  --red: #B3151A;
  --red-dark: #7E0F13;
  --red-soft: #F6DCDC;
  --ok: #2F7A4F;
  --erro: #B3151A;
  --pendente: #C6842B;
  --radius: 10px;
  --font-body: 'Manrope', -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
}

h1, h2, h3 { font-weight: 800; margin: 0 0 6px; }

.hidden { display: none !important; }

.screen { display: none; }
.screen.is-active { display: block; }

/* ---------- Login ---------- */

#screen-login.is-active {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 15%, rgba(179,21,26,0.16), transparent 45%),
    var(--ink);
  padding: 24px;
}

.login-card {
  background: var(--paper-alt);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.35);
  border-top: 4px solid var(--red);
}

.login-card__brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.login-card__logo { height: 42px; width: auto; flex-shrink: 0; }
.topbar__logo { height: 30px; width: auto; flex-shrink: 0; }

.login-card__brand p { margin: 2px 0 0; color: var(--ink-soft); font-size: 0.85rem; }

.login-card__note { font-size: 0.78rem; color: var(--ink-soft); margin-top: 18px; text-align: center; }

/* ---------- Forms ---------- */

form { display: flex; flex-direction: column; gap: 14px; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

label.checkbox { flex-direction: row; align-items: center; font-weight: 500; }
label.checkbox input { width: auto; }

input, select, textarea {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--red);
  outline-offset: 1px;
}

input:disabled {
  background: var(--line);
  color: var(--ink-soft);
  cursor: not-allowed;
}

.btn {
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
}
.btn:hover { background: var(--red); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn--full { width: 100%; }
.btn--small { padding: 7px 14px; font-size: 0.82rem; }
.btn--tiny { padding: 5px 10px; font-size: 0.75rem; }
.btn--ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn--ghost:hover { background: var(--ink); color: #fff; }
.btn--cart { background: var(--red); position: relative; }
.btn--cart:hover { background: var(--red-dark); }

.cart-badge {
  background: #fff;
  color: var(--red);
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: 20px;
  padding: 1px 7px;
  margin-left: 6px;
}

.feedback { font-size: 0.85rem; min-height: 1.1em; margin: 0; }
.feedback--erro { color: var(--erro); }
.feedback--sucesso { color: var(--ok); }

.hint { color: var(--ink-soft); font-size: 0.88rem; }
.hint--small { font-size: 0.78rem; margin-top: -6px; }
.hint--small a { color: var(--red); font-weight: 700; }

/* ---------- App shell ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: var(--paper-alt);
  border-bottom: 3px solid var(--red);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.topbar__brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.tabs { display: flex; gap: 6px; flex: 1; }

.tab-btn {
  background: none;
  border: none;
  padding: 8px 14px;
  border-radius: 20px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.tab-btn.is-active { background: var(--red-soft); color: var(--red-dark); }

.topbar__actions { display: flex; align-items: center; gap: 16px; }

.topbar__user { display: flex; align-items: center; gap: 14px; text-align: right; }
.topbar__user div { display: flex; flex-direction: column; line-height: 1.2; }
.topbar__user span { font-size: 0.75rem; color: var(--ink-soft); }

.content { max-width: 1080px; margin: 0 auto; padding: 32px 24px 80px; }

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ---------- Catálogo ---------- */

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.product-card {
  background: var(--paper-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.product-card__foto-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #fff;
  background: var(--red);
  padding: 3px 10px;
  display: inline-block;
}

.product-card img { width: 100%; height: 140px; object-fit: cover; display: block; background: var(--paper); }
.product-card__body { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.product-card__field { font-size: 0.85rem; margin: 0; }
.product-card__field strong { color: var(--ink-soft); font-weight: 700; display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.product-card__disponivel { font-size: 0.8rem; color: var(--red-dark); font-weight: 700; }

/* ---------- Tabelas ---------- */

.table-wrap { overflow-x: auto; margin-top: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--ink-soft); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }

.badge { padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; }
.badge--ok { background: #DCEEE1; color: var(--ok); }
.badge--erro { background: var(--red-soft); color: var(--red-dark); }
.badge--pendente { background: #F1E3C8; color: var(--pendente); }

/* ---------- Admin ---------- */

.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 18px; }

.card {
  background: var(--paper-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 20px;
}
.admin-grid .card { margin-top: 0; }

.allocation-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.allocation-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.allocation-row__nome { font-size: 0.85rem; }
.allocation-row__nome small { color: var(--ink-soft); }
.allocation-input { width: 90px; padding: 6px 8px; }

/* ---------- Carrinho ---------- */

.cart-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}
.cart-item__info { font-size: 0.85rem; }
.cart-item__info strong { display: block; }
.cart-item__info span { color: var(--ink-soft); font-size: 0.78rem; }

/* ---------- Modal ---------- */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(35,34,42,0.55);
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal.is-open { display: flex; }

.modal__box {
  background: var(--paper-alt);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 420px;
  position: relative;
  border-top: 4px solid var(--red);
}

.modal__box--wide {
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal__title {
  text-align: center;
  letter-spacing: 0.04em;
  margin-bottom: 20px;
}

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

.modal__close {
  position: absolute;
  top: 14px; right: 14px;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--ink-soft);
}

/* ---------- Responsivo ---------- */

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 14px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .admin-grid { grid-template-columns: 1fr; }
}
