:root {
  --cream: #FDF8F2;
  --cream2: #F7EFE3;
  --cream3: #EFE3D0;
  --brown-light: #C8956C;
  --brown: #9B6340;
  --brown-dark: #6B3F24;
  --choco: #3D1F0D;
  --rose: #D4826A;
  --rose-dim: rgba(212,130,106,0.12);
  --gold: #C9973A;
  --gold-dim: rgba(201,151,58,0.15);
  --green: #5A8A60;
  --green-dim: rgba(90,138,96,0.12);
  --red: #B84040;
  --red-dim: rgba(184,64,64,0.1);
  --text: #2C1810;
  --text2: #7A5A48;
  --text3: #B09080;
  --border: rgba(107,63,36,0.15);
  --border2: rgba(107,63,36,0.3);
  --r: 8px;
  --r2: 14px;
  --sans: "DM Sans", sans-serif;
  --serif: "Playfair Display", serif;
  --mono: "DM Mono", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--sans); background: var(--cream); color: var(--text); min-height: 100vh; font-size: 14px; line-height: 1.6; }

/* ── AUTH ── */
#auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; background: linear-gradient(150deg, var(--choco) 0%, var(--brown-dark) 55%, var(--brown) 100%); }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-brand { text-align: center; margin-bottom: 2rem; }
.auth-brand .logo { font-size: 52px; display: block; margin-bottom: 0.5rem; }
.auth-brand h1 { font-family: var(--serif); font-size: 30px; color: var(--cream); letter-spacing: 1px; }
.auth-brand p { font-size: 13px; color: rgba(253,248,242,0.5); margin-top: 4px; font-style: italic; }
.auth-card { background: var(--cream); border-radius: 18px; padding: 2rem; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.auth-tabs { display: flex; border-bottom: 1.5px solid var(--border); margin-bottom: 1.5rem; }
.auth-tab { flex: 1; padding: 10px; text-align: center; border: none; background: none; font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--text3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1.5px; transition: all 0.2s; }
.auth-tab.active { color: var(--brown-dark); border-bottom-color: var(--brown); }

/* ── FORMS ── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 12px; font-weight: 500; color: var(--text2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
input, select, textarea { width: 100%; padding: 10px 13px; border: 1.5px solid var(--border); border-radius: var(--r); background: white; font-family: var(--sans); font-size: 14px; color: var(--text); outline: none; transition: border-color 0.2s; appearance: none; -webkit-appearance: none; }
input:focus, select:focus { border-color: var(--brown-light); box-shadow: 0 0 0 3px rgba(200,149,108,0.15); }
select option { background: white; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.section-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--brown); margin: 1.25rem 0 0.75rem; display: flex; align-items: center; gap: 8px; }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.ins-row { display: grid; grid-template-columns: 1fr 90px 60px 30px; gap: 8px; align-items: center; margin-bottom: 8px; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 18px; border: none; border-radius: var(--r); font-family: var(--sans); font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn-primary { background: var(--brown-dark); color: white; width: 100%; padding: 12px; font-size: 14px; }
.btn-primary:hover { background: var(--choco); }
.btn-ghost { background: transparent; color: var(--text2); border: 1.5px solid var(--border2); }
.btn-ghost:hover { background: var(--cream2); color: var(--text); }
.btn-danger-sm { background: var(--red-dim); color: var(--red); border: 1px solid rgba(184,64,64,0.2); padding: 5px 10px; font-size: 11px; }
.btn-edit-sm { background: var(--gold-dim); color: var(--gold); border: 1px solid rgba(201,151,58,0.25); padding: 5px 10px; font-size: 11px; }
.btn-sm { background: var(--cream2); color: var(--text2); border: 1.5px solid var(--border); padding: 6px 12px; font-size: 12px; }
.btn-sm:hover { border-color: var(--border2); color: var(--text); }
.btn-rose { background: var(--rose); color: white; }
.btn-rose:hover { background: var(--brown-light); }

/* ── LAYOUT ── */
#app-screen { display: none; min-height: 100vh; }
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 235px; background: var(--choco); border-right: 1px solid rgba(255,255,255,0.06); display: flex; flex-direction: column; z-index: 100; overflow-y: auto; }
.sidebar-brand { padding: 1.25rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.07); display: flex; align-items: center; gap: 10px; }
.sidebar-brand .logo-ic { font-size: 26px; }
.sidebar-brand h2 { font-family: var(--serif); font-size: 20px; color: var(--cream); font-weight: 700; }
.sidebar-brand h2 span { color: var(--brown-light); }
.sidebar-user { padding: 1rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.07); }
.user-row { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: rgba(200,149,108,0.25); border: 1.5px solid rgba(200,149,108,0.4); display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 15px; font-weight: 700; color: var(--brown-light); flex-shrink: 0; }
.user-info p { font-size: 13px; font-weight: 600; color: var(--cream); }
.user-info span { font-size: 11px; color: rgba(253,248,242,0.4); }
.sidebar-nav { flex: 1; padding: 1rem 0; }
.nav-section { padding: 0.5rem 1.5rem 0.25rem; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px; color: rgba(253,248,242,0.3); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 1.5rem; color: rgba(253,248,242,0.55); cursor: pointer; transition: all 0.15s; font-size: 13px; font-weight: 500; border: none; background: none; width: 100%; text-align: left; border-left: 3px solid transparent; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--cream); }
.nav-item.active { background: rgba(200,149,108,0.12); color: var(--brown-light); border-left-color: var(--brown-light); font-weight: 600; }
.nav-item .ni { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer { padding: 1rem 1.5rem; border-top: 1px solid rgba(255,255,255,0.07); }
.btn-logout { width: 100%; padding: 8px 12px; background: transparent; border: 1px solid rgba(255,255,255,0.1); border-radius: var(--r); color: rgba(253,248,242,0.4); font-family: var(--sans); font-size: 12px; font-weight: 500; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: all 0.2s; }
.btn-logout:hover { border-color: var(--red); color: var(--red); }
.main { margin-left: 235px; min-height: 100vh; padding: 2rem; }
.page { display: none; }
.page.active { display: block; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 2rem; gap: 1rem; flex-wrap: wrap; }
.page-title h1 { font-family: var(--serif); font-size: 28px; color: var(--choco); font-weight: 700; }
.page-title p { font-size: 13px; color: var(--text2); margin-top: 3px; font-style: italic; }

/* ── CARDS ── */
.card { background: white; border: 1.5px solid var(--border); border-radius: var(--r2); padding: 1.25rem 1.5rem; box-shadow: 0 2px 12px rgba(61,31,13,0.06); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 1.5px solid var(--border); }
.card-head h3 { font-size: 13px; font-weight: 600; color: var(--brown-dark); text-transform: uppercase; letter-spacing: 0.5px; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.g3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; }
.g4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; }

/* ── STATS ── */
.stat-card { background: white; border: 1.5px solid var(--border); border-radius: var(--r2); padding: 1.25rem; position: relative; overflow: hidden; }
.stat-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--brown-light); }
.stat-card.gold::before { background: var(--gold); }
.stat-card.green::before { background: var(--green); }
.stat-card.rose::before { background: var(--rose); }
.stat-card[onclick] { cursor: pointer; }
.stat-card[onclick]:hover { border-color: var(--border2); transform: translateY(-1px); transition: all 0.15s; }
.stat-icon { font-size: 24px; margin-bottom: 0.75rem; display: block; opacity: 0.75; }
.stat-value { font-family: var(--serif); font-size: 30px; font-weight: 700; color: var(--choco); line-height: 1; }
.stat-label { font-size: 11px; color: var(--text3); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 8px 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text3); border-bottom: 1.5px solid var(--border); background: var(--cream2); }
td { padding: 10px 12px; border-bottom: 1px solid rgba(107,63,36,0.07); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(253,248,242,0.7); }

/* ── BADGES ── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.badge-brown { background: var(--cream2); color: var(--brown-dark); border: 1px solid var(--border); }
.badge-gold { background: var(--gold-dim); color: var(--gold); border: 1px solid rgba(201,151,58,0.25); }
.badge-green { background: var(--green-dim); color: var(--green); border: 1px solid rgba(90,138,96,0.2); }
.badge-rose { background: var(--rose-dim); color: var(--rose); border: 1px solid rgba(212,130,106,0.2); }

/* ── MODAL ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(61,31,13,0.55); backdrop-filter: blur(4px); z-index: 1000; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.open { display: flex; }
.modal { background: white; border: 1.5px solid var(--border2); border-radius: 18px; width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(61,31,13,0.2); }
.modal-head { padding: 1.25rem 1.5rem; border-bottom: 1.5px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-family: var(--serif); font-size: 20px; color: var(--choco); }
.modal-close { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--border); background: var(--cream2); cursor: pointer; font-size: 17px; display: flex; align-items: center; justify-content: center; color: var(--text3); transition: all 0.2s; }
.modal-close:hover { border-color: var(--red); color: var(--red); }
.modal-body { padding: 1.5rem; }
.modal-foot { padding: 1rem 1.5rem; border-top: 1.5px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── PRECIFICAÇÃO ── */
.result-panel { background: var(--choco); border-radius: var(--r2); padding: 1.75rem; text-align: center; box-shadow: 0 8px 30px rgba(61,31,13,0.2); position: relative; overflow: hidden; margin-bottom: 1rem; }
.result-panel::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--brown-light), transparent); }
.result-label { font-size: 10px; color: rgba(253,248,242,0.45); letter-spacing: 2px; text-transform: uppercase; font-weight: 600; }
.result-price { font-family: var(--serif); font-size: 52px; font-weight: 700; color: var(--brown-light); display: block; line-height: 1.1; margin: 0.5rem 0; }
.result-unit { font-size: 11px; color: rgba(253,248,242,0.45); font-style: italic; }
.bkrow { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(107,63,36,0.08); font-size: 13px; }
.bkrow:last-child { border-bottom: none; }
.bkrow .lbl { color: var(--text2); }
.bkrow .val { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--text); }
.bkrow .val.pos { color: var(--green); }
.bkrow.total { margin-top: 4px; padding-top: 12px; border-top: 2px solid var(--border2); border-bottom: none; }
.bkrow.total .lbl { font-weight: 700; font-family: var(--serif); font-size: 15px; color: var(--choco); }
.bkrow.total .val { color: var(--brown-dark); font-size: 16px; font-weight: 700; }

/* ── OUTROS CUSTOS ── */
.outro-item { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 7px 10px; border-radius: var(--r); border: 1.5px solid transparent; transition: border-color 0.15s, background 0.15s; user-select: none; }
.outro-item:hover { background: rgba(200,149,108,0.06); border-color: var(--border); }
.outro-item.selected { border-color: var(--brown-light); background: rgba(200,149,108,0.1); }
.outro-check { width: 16px; height: 16px; flex-shrink: 0; border: 1.5px solid var(--border2); border-radius: 3px; display: flex; align-items: center; justify-content: center; font-size: 11px; color: transparent; transition: all 0.15s; }
.outro-item.selected .outro-check { border-color: var(--brown-light); background: var(--brown-light); color: white; }

/* ── CARDS DE ENTIDADES ── */
.produto-card { background: white; border: 1.5px solid var(--border); border-radius: var(--r2); padding: 1.25rem; transition: border-color 0.2s; }
.produto-card:hover { border-color: var(--border2); }
.outro-custo-card { background: white; border: 1.5px solid var(--border); border-radius: var(--r2); padding: 1.25rem; position: relative; overflow: hidden; transition: border-color 0.2s; }
.outro-custo-card:hover { border-color: var(--border2); }

/* ── MISC ── */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-state .ei { font-size: 44px; margin-bottom: 1rem; opacity: 0.3; display: block; }
.empty-state p { font-size: 13px; color: var(--text3); font-style: italic; }
.welcome-bar { background: linear-gradient(135deg, var(--choco), var(--brown-dark)); border-radius: var(--r2); padding: 1.5rem 2rem; margin-bottom: 1.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.welcome-bar h2 { font-family: var(--serif); font-size: 22px; color: var(--cream); }
.welcome-bar p { font-size: 13px; color: rgba(253,248,242,0.6); margin-top: 3px; font-style: italic; }
.welcome-bar .wi { font-size: 44px; opacity: 0.5; }
.toast-wrap { position: fixed; bottom: 2rem; right: 2rem; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--choco); border: 1px solid rgba(200,149,108,0.3); border-radius: var(--r); padding: 11px 16px; font-size: 13px; color: var(--cream); max-width: 300px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); animation: tIn 0.3s ease; }
.toast.ok { border-left: 3px solid var(--green); }
.toast.err { border-left: 3px solid var(--red); }
@keyframes tIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.actions { display: flex; gap: 6px; }
.hidden { display: none !important; }
.filtros-row { display: flex; gap: 10px; margin-bottom: 1rem; flex-wrap: wrap; }
.filtros-row input { flex: 1; min-width: 200px; }
.filtros-row select { width: 160px; flex-shrink: 0; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { opacity: 0.4; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .bottom-nav { display: flex !important; }
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; width: 260px; z-index: 200; }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.4); }
  .main { margin-left: 0; padding: 1rem; padding-bottom: 5rem; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .page-title h1 { font-size: 22px; }
  .result-price { font-size: 38px; }
  .filtros-row { flex-direction: column; }
  .filtros-row input, .filtros-row select { width: 100%; }
  .table-wrap { font-size: 12px; }
  td, th { padding: 7px 8px; }
  .welcome-bar { padding: 1rem 1.25rem; }
  .welcome-bar .wi { display: none; }
  .modal { border-radius: 16px 16px 0 0; position: fixed; bottom: 0; left: 0; right: 0; max-width: 100%; max-height: 92vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .ins-row { grid-template-columns: 1fr 80px 50px 28px; }
}
@media (min-width: 769px) {
  .hamburger { display: none !important; }
  .bottom-nav { display: none !important; }
}
