/* Jussara — identidade da família Julia (Grupo Jurubeba): verde, areia, madeira + roxo juçara */
:root {
  --leaf: #248539;
  --leaf-dark: #1d6a30;
  --leaf-soft: #edf8ef;
  --forest: #233221;
  --forest-2: #3b5c35;
  --ink: #233221;
  --muted: #3b5c35;
  --sand-50: #fbf8f2;
  --sand-100: #f4ecdc;
  --sand-200: #e9d8bb;
  --wood: #8a5e38;
  --berry: #6b2f7a;
  --berry-soft: #f3eaf6;
  --white: #ffffff;
  --line: #e9d8bb;
  --cream: #fbf8f2;
  --danger: #9b2c23;
  --danger-soft: #fbe9e7;
  --warn: #8a4b12;
  --warn-soft: #fbefdc;
  --ok: #1d6a30;
  --shadow: 0 1px 2px rgba(35, 50, 33, 0.04), 0 10px 26px -14px rgba(35, 50, 33, 0.28);
  --display: "Fredoka", "DM Sans", system-ui, sans-serif;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.hidden { display: none !important; }

body {
  margin: 0;
  background: var(--sand-50);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; background: none; }
p { margin: 0 0 10px; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; line-height: 1.15; }
h2 { font-size: 1.15rem; margin-bottom: 8px; }
h3 { font-size: 1rem; margin: 14px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
s { text-decoration-thickness: 1px; }
:focus-visible { outline: 3px solid #7ccc89; outline-offset: 2px; }

/* Logo */
.logo-mark { flex-shrink: 0; display: block; }
.logo-full { display: flex; align-items: center; gap: 8px; }
.logo-full span { font-family: var(--display); font-weight: 600; font-size: 2.3rem; line-height: 1; color: var(--leaf); }
.small-logo span { font-size: 1.5rem; }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: 22px;
  background: var(--leaf); color: #fff; font-weight: 700; font-size: 0.93rem;
  transition: background 0.15s; text-align: center;
}
.btn:hover { background: var(--leaf-dark); }
.btn.secondary { background: var(--white); color: var(--leaf-dark); border: 1px solid var(--line); }
.btn.secondary:hover { background: var(--leaf-soft); border-color: #7ccc89; }
.btn.ghost { background: transparent; color: var(--forest); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--sand-100); }
.btn.full { width: 100%; min-height: 52px; border-radius: 26px; font-size: 1rem; margin-top: 14px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.link { padding: 6px 0; color: var(--leaf-dark); text-decoration: underline; font-weight: 500; }
.chip {
  min-height: 40px; padding: 0 16px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--white); color: var(--forest-2); font-weight: 700; font-size: 0.9rem; white-space: nowrap;
}
.chip.active { background: var(--forest); border-color: var(--forest); color: #fff; }

/* Campos */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field > span { font-size: 0.8rem; font-weight: 700; color: #314a2d; }
input:not([type="checkbox"]):not([type="file"]), select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--white);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #4db861; box-shadow: 0 0 0 4px #d6f0da; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--leaf); vertical-align: middle; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.notice { padding: 12px 14px; border-radius: 14px; background: var(--sand-100); color: var(--forest); font-size: 0.93rem; }

/* Login e telas de aviso */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--forest); }
.login-card { width: min(100%, 420px); background: var(--sand-50); border-radius: 24px; padding: 28px 24px; box-shadow: var(--shadow); }
.login-card h1 { margin-top: 12px; }
.login-card .logo-full { margin-bottom: 8px; }
.login-card form { margin-top: 14px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }

/* Estrutura */
.app-shell { min-height: 100vh; display: flex; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 6px; }
.unit-chip { font-size: 0.78rem; font-weight: 700; padding: 8px 12px; border-radius: 16px; background: var(--berry-soft); color: #5a2568; }
.content { flex: 1; padding: 10px 16px 104px; max-width: 1180px; width: 100%; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40; width: 264px; max-width: 86vw;
  background: var(--forest); color: #fff; padding: 20px 14px; display: flex; flex-direction: column;
  transform: translateX(-102%); transition: transform 0.2s ease; overflow-y: auto;
}
.menu-open .sidebar { transform: none; }
.scrim { display: none; position: fixed; inset: 0; z-index: 35; background: rgba(35, 50, 33, 0.5); }
.menu-open .scrim { display: block; }
.side-brand { display: flex; align-items: center; gap: 8px; padding: 0 8px 8px; }
.side-brand span { font-family: var(--display); font-weight: 600; font-size: 1.7rem; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-group { font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: #bcd1b8; padding: 14px 12px 4px; }
.side-link { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 12px; color: #fff; font-weight: 500; text-align: left; }
.side-link:hover { background: #293c26; }
.side-link.active { background: var(--forest-2); font-weight: 700; }
.side-badge { margin-left: auto; font-size: 0.75rem; font-weight: 700; background: #d9a8e6; color: #2b1233; border-radius: 10px; padding: 2px 8px; }
.side-user { margin-top: auto; padding: 16px 12px 0; display: flex; flex-direction: column; gap: 8px; font-size: 0.85rem; color: #dce8da; }
.side-out { align-self: flex-start; min-height: 40px; padding: 0 16px; border-radius: 20px; border: 1px solid #4d7445; color: #fff; font-weight: 700; }
.side-out:hover { background: #293c26; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: center; gap: 4px;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); background: var(--white); border-top: 1px solid var(--sand-100);
}
.tab { flex: 1; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 0.7rem; font-weight: 500; color: var(--forest-2); border-radius: 12px; }
.tab.active { color: var(--leaf-dark); font-weight: 700; }
.tab-plus { width: 56px; height: 56px; border-radius: 28px; background: var(--leaf); color: #fff; display: flex; align-items: center; justify-content: center; margin-top: -24px; box-shadow: 0 8px 18px -8px rgba(35, 50, 33, 0.6); flex-shrink: 0; }

.subtabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; margin-bottom: 4px; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }

/* Blocos */
.section-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head p { margin: 2px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.panel { background: var(--white); border: 1px solid var(--sand-100); border-radius: 20px; padding: 16px; box-shadow: var(--shadow); }
.report-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--white); border: 1px solid var(--sand-100); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat strong { font-family: var(--display); font-weight: 600; font-size: 1.45rem; line-height: 1.15; overflow-wrap: anywhere; }
.stat.dark { background: var(--forest); border-color: var(--forest); color: #fff; }
.stat.dark .small { color: #bcd1b8; }
.item-card { padding: 10px 0; border-top: 1px solid var(--sand-100); }
.item-card:first-of-type { border-top: 0; }
.item-card p { margin: 0; }
.hello { margin: 4px 0 14px; }
.hello p { margin: 2px 0 0; }
.block-title { margin: 18px 0 8px; }
.todo { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--sand-100); }
.todo-ico { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.todo-ico.purple { background: var(--berry-soft); color: #5a2568; }
.todo-ico.green { background: var(--leaf-soft); color: var(--leaf-dark); }
.todo-ico.amber { background: var(--warn-soft); color: var(--warn); }
.todo-ico.sand { background: var(--sand-100); color: #5c4424; }
.todo-text { flex: 1; min-width: 0; }
.todo-text strong { display: block; font-size: 0.95rem; }
.todo-text span { font-size: 0.82rem; color: var(--muted); }
.action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.action-card { min-height: 78px; border-radius: 18px; border: 1px solid var(--sand-100); background: var(--white); display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 12px; font-weight: 700; font-size: 0.93rem; text-align: left; color: var(--forest); }
.action-card:hover { border-color: #7ccc89; background: var(--leaf-soft); }
.action-card .ico { color: var(--leaf-dark); }

.badge { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 4px 10px; border-radius: 12px; background: var(--sand-100); color: #5c4424; white-space: nowrap; }
.badge.ok { background: var(--leaf-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; align-items: center; }
.filters > * { flex: 1 1 180px; }
.filters .check { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; font-weight: 500; }

/* Tabelas: cartões no celular */
.table-wrap { background: transparent; }
table { width: 100%; border-collapse: collapse; }
thead { display: none; }
tbody tr { display: block; background: var(--white); border: 1px solid var(--sand-100); border-radius: 16px; padding: 10px 14px; margin-bottom: 10px; }
td { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 5px 0; text-align: right; overflow-wrap: anywhere; }
td::before { content: attr(data-label); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: #314a2d; text-align: left; flex-shrink: 0; }
td:first-child { font-weight: 700; font-size: 1rem; text-align: left; justify-content: flex-start; }
td:first-child::before { content: none; }
td .actions { justify-content: flex-end; }
.empty-row td { justify-content: center; text-align: center; font-weight: 400; color: var(--muted); }
.empty-row td::before { content: none; }

/* Contagem na plataforma */
.count-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--sand-100); }
.count-item input { width: 96px; text-align: center; font-weight: 700; font-size: 1.1rem; }
.delta { margin-top: 4px; font-weight: 700; font-size: 0.85rem; color: var(--muted); }
.delta.neg { color: var(--danger); }
.delta.pos { color: var(--ok); }

/* Janelas */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(35, 50, 33, 0.55); }
.modal-card { width: 100%; max-width: 620px; max-height: 92vh; overflow: auto; background: var(--sand-50); border-radius: 24px 24px 0 0; padding: 20px 18px calc(22px + env(safe-area-inset-bottom)); box-shadow: var(--shadow); }
.modal-card .section-head { align-items: center; }
.modal-card .section-head h2 { margin: 0; font-size: 1.3rem; }

/* Compra com vários itens */
.bulk-search { border: 2px solid var(--leaf) !important; border-radius: 14px !important; min-height: 50px !important; font-size: 1rem; }
.bulk-results { display: flex; flex-direction: column; margin: 6px 0 10px; border-radius: 14px; overflow: hidden; }
.bulk-results:not(:empty) { border: 1px solid var(--line); background: var(--white); }
.bulk-results button { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 46px; padding: 0 14px; text-align: left; border-top: 1px solid var(--sand-100); font-weight: 500; }
.bulk-results button:first-child { border-top: 0; }
.bulk-results button:hover { background: var(--leaf-soft); }
.bulk-results button span { font-size: 0.8rem; font-weight: 700; color: var(--leaf-dark); }
.bulk-results p { margin: 0; padding: 10px 14px; }
.bulk-line { background: var(--white); border: 1px solid var(--sand-100); border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.bulk-line-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bulk-line-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.bulk-price { display: flex; flex-direction: column; gap: 2px; font-size: 0.72rem; font-weight: 700; color: #314a2d; }
.bulk-price input { width: 104px !important; }
.bulk-sub { font-weight: 700; min-width: 84px; text-align: right; padding-bottom: 12px; }
.bulk-total { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 12px 2px 0; border-top: 1px solid var(--line); margin-top: 6px; }
.bulk-total strong { font-family: var(--display); font-weight: 600; font-size: 1.5rem; }

/* Contagem por link */
.pub { max-width: 640px; margin: 0 auto; padding: 0 14px 48px; }
.pub-head { margin: 0 -14px 14px; padding: 16px 16px 14px; background: var(--forest); color: #fff; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; z-index: 5; }
.pub-head-row { display: flex; align-items: center; gap: 10px; }
.pub-head-row strong { display: block; font-family: var(--display); font-weight: 600; font-size: 1.3rem; line-height: 1.1; }
.pub-head-row span { font-size: 0.85rem; color: #dce8da; }
.pub-progress { font-size: 0.85rem; display: flex; flex-direction: column; gap: 6px; }
.pub-bar { height: 8px; border-radius: 4px; background: var(--forest-2); overflow: hidden; }
#pubBarFill { height: 8px; width: 0; border-radius: 4px; background: #6fd07e; transition: width 0.2s; }
.pub-search { margin-top: 10px; }
.pub-cat { margin: 18px 0 6px; font-family: var(--sans); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #314a2d; }
.pub-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; margin-bottom: 8px; background: var(--white); border: 1px solid var(--sand-100); border-radius: 16px; }
.pub-row.missing { border: 2px solid #b5392f; }
.pub-name { min-width: 0; }
.pub-name strong { display: block; overflow-wrap: anywhere; }
.stepper { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.stepper button { width: 50px; height: 50px; border-radius: 14px; border: 1px solid var(--line); background: var(--sand-50); font-size: 1.6rem; line-height: 1; color: var(--ink); touch-action: manipulation; }
.stepper input { width: 70px !important; min-height: 50px !important; text-align: center; font-size: 1.15rem; font-weight: 700; padding: 0 4px !important; }
.pub-end { margin-top: 20px; }
.sign-pad { display: block; width: 100%; height: 170px; background: var(--white); border: 1px dashed var(--forest-2); border-radius: 14px; touch-action: none; }
.pub-confirm { display: block; margin: 12px 0; }
.signature-box { margin-top: 12px; }
.signature-box img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--white); margin-top: 4px; }
.qr-box { text-align: center; margin: 8px 0 14px; }
.qr-box img { max-width: 100%; height: auto; background: #fff; border-radius: 12px; }
.qr-box p { overflow-wrap: anywhere; }

/* Computador */
@media (min-width: 900px) {
  .sidebar { position: sticky; top: 0; height: 100vh; transform: none; flex-shrink: 0; width: 244px; }
  .scrim, .tabbar, .topbar { display: none !important; }
  .content { padding: 28px 32px 48px; }
  h1 { font-size: 2rem; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field.wide { grid-column: 1 / -1; }
  .report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel.wide { grid-column: 1 / -1; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
  .action-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
  .modal { align-items: center; padding: 20px; }
  .modal-card { border-radius: 24px; padding: 24px; }

  .table-wrap { background: var(--white); border: 1px solid var(--sand-100); border-radius: 20px; overflow-x: auto; box-shadow: var(--shadow); }
  thead { display: table-header-group; }
  tbody tr { display: table-row; background: none; border: 0; border-radius: 0; padding: 0; margin: 0; }
  th { padding: 12px; text-align: left; font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; color: #314a2d; white-space: nowrap; }
  td { display: table-cell; padding: 13px 12px; border-top: 1px solid var(--sand-100); text-align: left; vertical-align: middle; overflow-wrap: normal; }
  .panel .table-wrap { box-shadow: none; }
  td::before { content: none; }
  td:first-child { font-size: inherit; font-weight: 500; }
  td .actions { justify-content: flex-start; }
}

@media print {
  .sidebar, .tabbar, .topbar, .subtabs, .actions, .filters, .btn, .scrim { display: none !important; }
  body, .content, .panel, .table-wrap { background: #fff; box-shadow: none; }
  .content { padding: 0; max-width: none; }
}

/* Relatórios */
.bar-cell { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.bar-track { flex: 1; min-width: 60px; max-width: 220px; height: 10px; border-radius: 5px; background: var(--sand-100); overflow: hidden; }
.bar-fill { height: 10px; border-radius: 5px; background: var(--berry); }
.bar-cell span { font-weight: 700; white-space: nowrap; }
.filters .field { margin-bottom: 0; }
@media (min-width: 900px) { .bar-cell { justify-content: flex-start; } }
