* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px; background: #f5f5f5; color: #222;
  height: 100vh; overflow: hidden;
}
#app { display: flex; height: 100vh; }

/* Sidebar */
#sidebar {
  width: 180px; min-width: 180px; background: #1e1e2e;
  color: #cdd6f4; display: flex; flex-direction: column; padding: 16px 0;
}
#sidebar .brand { font-size: 16px; font-weight: 700; padding: 8px 20px 20px; color: #cba6f7; }
#sidebar ul { list-style: none; }
#sidebar li {
  padding: 10px 20px; cursor: pointer; border-radius: 6px;
  margin: 2px 8px; transition: background 0.15s;
}
#sidebar li:hover { background: #313244; }
#sidebar li.active { background: #45475a; color: #cba6f7; font-weight: 600; }

/* Content */
#content { flex: 1; overflow-y: auto; padding: 24px; }
.tab { display: none; }
.tab.active { display: block; }
h2 { font-size: 20px; margin-bottom: 20px; color: #1e1e2e; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-weight: 600; margin-bottom: 4px;
  color: #555; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
}
.form-group input, .form-group select {
  width: 100%; padding: 8px 10px; border: 1px solid #ddd;
  border-radius: 6px; font-size: 14px; background: #fff;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: #cba6f7;
  box-shadow: 0 0 0 2px rgba(203,166,247,0.2);
}

/* Buttons */
button {
  padding: 8px 16px; border-radius: 6px; border: none;
  cursor: pointer; font-size: 14px; font-weight: 600; transition: opacity 0.15s;
}
button:hover { opacity: 0.85; }
.btn-primary  { background: #cba6f7; color: #1e1e2e; }
.btn-secondary { background: #e0e0e0; color: #333; }
.btn-danger   { background: #f38ba8; color: #1e1e2e; }
.btn-sm       { padding: 4px 10px; font-size: 12px; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
th { background: #1e1e2e; color: #cdd6f4; padding: 10px 14px; text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
td { padding: 10px 14px; border-bottom: 1px solid #f0f0f0; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* Cards */
.card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); margin-bottom: 16px; }

/* Result panel */
.result-panel { background: #1e1e2e; color: #cdd6f4; border-radius: 10px; padding: 20px; }
.result-panel .result-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.result-panel .result-total {
  display: flex; justify-content: space-between;
  padding-top: 12px; margin-top: 8px; border-top: 1px solid #45475a;
  font-size: 18px; font-weight: 700; color: #a6e3a1;
}

/* Action bar */
.action-bar { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* Search */
.search-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.search-bar input { padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; width: 300px; }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 100;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 12px; padding: 24px; max-width: 480px; width: 90%; }
.modal h3 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Toast */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1e1e2e; color: #a6e3a1;
  padding: 12px 20px; border-radius: 8px;
  font-weight: 600; z-index: 200;
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
#toast.show { opacity: 1; }

/* Two-column layout */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.time-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== Auth Overlay ===== */
#auth-overlay {
  position: fixed; inset: 0;
  background: #1e1e2e;
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
}
.auth-card {
  background: #fff; border-radius: 12px; padding: 32px;
  width: 360px; max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.auth-brand    { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.auth-subtitle { text-align: center; color: #888; font-size: 13px; margin-bottom: 24px; }
.auth-card h2  { text-align: center; margin-bottom: 20px; color: #1e1e2e; font-size: 18px; }
.auth-err      { color: #f38ba8; font-size: 13px; min-height: 18px; margin: 6px 0; }

.auth-link {
  background: none; color: #888; font-size: 12px;
  width: 100%; margin-top: 6px; font-weight: 400;
  box-shadow: none;
}
.auth-link:hover { background: none; color: #555; opacity: 1; text-decoration: underline; }

/* ===== Logout button (sidebar footer) ===== */
.btn-logout {
  margin: auto 12px 12px;
  width: calc(100% - 24px);
  background: #313244; color: #cdd6f4;
  font-size: 12px; font-weight: 400;
  border-radius: 6px;
}
.btn-logout:hover { background: #f38ba8; color: #1e1e2e; opacity: 1; }

/* ===== Print — hide UI chrome, show only PDF content ===== */
@media print {
  #auth-overlay, #sidebar, .action-bar,
  .search-bar, .modal-overlay, #toast,
  .no-print { display: none !important; }
  #app { display: block; }
  #content { padding: 0; }
  body { background: white; overflow: auto; }
}

/* ===== Simulador de Marketplaces ===== */
.mkp-section {
  margin-top: 16px;
}
.mkp-section h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
  color: #6c7086; margin-bottom: 10px;
}
.mkp-cols {
  display: flex; gap: 12px;
}
.mkp-col {
  flex: 1; background: #1e1e2e; border-radius: 10px;
  padding: 14px; min-width: 0;
}
.mkp-col-header {
  font-size: 13px; font-weight: 700; color: #cdd6f4;
  text-align: center; margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid #45475a;
}
.mkp-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; color: #cdd6f4; margin-bottom: 6px;
}
.mkp-row span:first-child { color: #9399b2; }
.mkp-row span:last-child  { text-align: right; }
.mkp-pct { font-size: 10px; color: #6c7086; margin-left: 4px; }
.mkp-divider {
  border: none; border-top: 1px solid #45475a; margin: 8px 0;
}
.mkp-custos-total span:last-child { color: #f38ba8; font-weight: 700; }
.mkp-field {
  margin-top: 8px;
}
.mkp-field label {
  font-size: 11px; color: #9399b2; display: block; margin-bottom: 3px;
}
.mkp-field input {
  width: 100%; background: #313244; border: 1px solid #45475a;
  border-radius: 6px; color: #cdd6f4; padding: 6px 8px;
  font-size: 13px; box-sizing: border-box;
}
.mkp-field input:focus { border-color: #89b4fa; outline: none; }
.mkp-lucro-pos { color: #a6e3a1 !important; font-weight: 700; }
.mkp-lucro-neg { color: #f38ba8 !important; font-weight: 700; }
.mkp-roi { font-size: 11px; color: #9399b2; text-align: center; margin-top: 6px; }
.mkp-warn { font-size: 11px; color: #f38ba8; margin-top: 4px; }

/* Responsive: colunas empilham abaixo de 900px */
@media (max-width: 900px) {
  .mkp-cols { flex-direction: column; }
}

/* ===== Tabelas de configuração de marketplace ===== */
.mkp-cfg-section { margin-top: 20px; border-top: 1px solid #e0e0e0; padding-top: 16px; }
.mkp-cfg-section h3 { font-size: 13px; font-weight: 600; color: #555; margin-bottom: 12px; }
.mkp-cfg-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 14px; }
.mkp-cfg-table th {
  background: #f5f5f5; text-align: left; padding: 6px 8px;
  border-bottom: 2px solid #ddd; color: #333; font-weight: 600;
}
.mkp-cfg-table td { padding: 4px 6px; border-bottom: 1px solid #eee; }
.mkp-cfg-table input[type="number"] {
  width: 70px; padding: 3px 5px; border: 1px solid #ddd;
  border-radius: 4px; font-size: 12px;
}
.mkp-cfg-table input[readonly] { background: #f5f5f5; color: #999; }
.mkp-cfg-cpf-info { font-size: 11px; color: #888; font-style: italic; }
.mkp-contribuinte { display: flex; gap: 20px; margin-bottom: 12px; align-items: center; }
.mkp-contribuinte label { font-size: 13px; display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* ===== Dicas de campo e notas do painel de resultado ===== */
.field-hint {
  display: block; margin-top: 4px;
  font-size: 11px; color: #888; font-weight: 400;
  text-transform: none; letter-spacing: 0;
}
.result-note {
  display: flex; justify-content: space-between;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid #313244;
  font-size: 12px; color: #9399b2;
}
.result-note span:last-child { color: #cdd6f4; font-weight: 600; }
.result-warn {
  font-size: 11px; color: #fab387; margin-top: 8px; line-height: 1.4;
}
.result-warn:empty { display: none; }

/* Aviso explicativo dentro das configurações de marketplace */
.cfg-note {
  background: #eef1ff; border-left: 3px solid #7287fd;
  border-radius: 0 6px 6px 0; padding: 10px 12px;
  font-size: 12px; color: #4c4f69; line-height: 1.5;
  margin-bottom: 12px;
}
.cfg-note strong { color: #1e1e2e; }
.cfg-warn {
  color: #d20f39; font-size: 11px; margin-top: 4px; line-height: 1.4;
}
.cfg-warn:empty { display: none; }
.cfg-check {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 13px; cursor: pointer; margin-bottom: 10px; max-width: 520px;
}
.cfg-check input { margin-top: 2px; flex-shrink: 0; }
