*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); min-height: 100vh; transition: background .25s, color .25s; }

/* ── LOGIN ── */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 60% 40%, #1e2a5e 0%, var(--bg) 70%);
}
.login-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 48px 40px; width: 380px;
  box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .brand { font-size: 2rem; font-weight: 800; letter-spacing: 2px; color: var(--accent); }
.login-logo .sub   { font-size: .75rem; color: var(--muted); margin-top: 4px; letter-spacing: 1px; }
.login-logo .company { font-size: .85rem; color: var(--accent2); font-weight: 600; margin-top: 6px; }

/* ── FORMS ── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 14px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: .9rem; outline: none;
  transition: border-color .2s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 80px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius); border: none;
  cursor: pointer; font-size: .88rem; font-weight: 600;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary  { background: var(--accent);  color: #fff; }
.btn-danger   { background: var(--red);     color: #fff; }
.btn-success  { background: var(--green);   color: #fff; }
.btn-warning  { background: var(--yellow);  color: #000; }
.btn-ghost    { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-sm       { padding: 6px 12px; font-size: .8rem; }
.btn-full     { width: 100%; justify-content: center; }

/* ── APP SHELL ── */
#app { display: none; height: 100vh; overflow: hidden; }
#app.visible { display: flex; flex-direction: column; }

/* ── HEADER ── */
header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-logo { height: 40px; width: auto; display: block; flex-shrink: 0; }
.header-brand { font-size: 1.1rem; font-weight: 800; color: var(--accent); letter-spacing: 1px; line-height: 1.1; }
.header-sub   { font-size: .66rem; color: var(--muted); line-height: 1.2; max-width: 340px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-badge {
  font-size: .8rem; color: var(--muted);
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px;
}
.user-badge span { color: var(--text); font-weight: 600; }

/* ── LAYOUT ── */
.layout { display: flex; flex: 1; overflow: hidden; }

/* ── SIDEBAR ── */
nav {
  width: 220px; background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px 0; flex-shrink: 0; overflow-y: auto;
}
.nav-section { padding: 8px 16px 4px; font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; cursor: pointer; font-size: .86rem;
  color: var(--muted); border-left: 3px solid transparent;
  transition: all .15s;
}
.nav-item:hover { color: var(--text); background: var(--card); }
.nav-item.active { color: var(--accent); border-left-color: var(--accent); background: rgba(79,124,255,.08); }
.nav-item .icon { font-size: 1rem; width: 18px; text-align: center; }

/* ── MAIN ── */
main { flex: 1; overflow-y: auto; padding: 28px; }

/* ── PAGE HEADER ── */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.page-header p  { font-size: .85rem; color: var(--muted); margin-top: 4px; }

/* ── CARDS / GRID ── */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow);
}
.card-title { font-size: .9rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; }

/* ── KPI ── */
.kpi-value { font-size: 2rem; font-weight: 800; color: var(--text); }
.kpi-label { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.kpi-delta { font-size: .8rem; margin-top: 6px; }
.kpi-delta.up   { color: var(--green); }
.kpi-delta.down { color: var(--red);   }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th { padding: 10px 12px; text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); border-bottom: 1px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid rgba(46,51,84,.5); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(79,124,255,.04); }
td input, td select { background: transparent; border: 1px solid transparent; color: var(--text); padding: 3px 6px; border-radius: 4px; width: 100%; font-size: .83rem; }
td input:focus, td select:focus { border-color: var(--accent); background: var(--surface); outline: none; }

/* ── FREIGHT TABLE (compact) ── */
#freight-table th { padding: 2px 8px; font-size: 11px; line-height: 1; }
#freight-table td { padding: 2px 8px; font-size: 12px; line-height: 1; max-height: 28px; border-bottom: none; }
#freight-table tr:last-child td { border-bottom: none; }
#freight-table td input { height: 22px; padding: 1px 6px; font-size: 12px; line-height: 1; }

/* ── MARKET TABLE (compact) ── */
#market-table th { padding: 4px 12px; font-size: 11px; line-height: 1; }
#market-table td { padding: 4px 12px; font-size: 13px; line-height: 1; height: 32px; border-bottom: none; }
#market-table tr:last-child td { border-bottom: none; }
#market-table td input { height: 24px; padding: 2px 6px; font-size: 13px; line-height: 1; }

/* ── PREÇOS TABLE (read-only, multi-group) ── */
#precos-table th { text-transform: none; padding: 8px 10px; }
#precos-table td { padding: 8px 10px; font-size: .83rem; }
#precos-table .precos-num { font-variant-numeric: tabular-nums; }
#precos-table .precos-group { text-align: center; font-size: .78rem; font-weight: 700; padding: 6px 8px; border-bottom: none; }
#precos-table .precos-group small { display: block; font-size: .65rem; font-weight: 400; opacity: .7; text-transform: none; letter-spacing: 0; margin-top: 2px; }
#precos-table .precos-sub { font-size: .7rem; padding: 4px 10px; white-space: nowrap; }
#precos-table .precos-group-bue      { background: rgba(255,180,0,.07);  border-bottom: 2px solid rgba(255,180,0,.35); }
#precos-table .precos-group-kanawa   { background: rgba(0,160,255,.07);  border-bottom: 2px solid rgba(0,160,255,.35); }
#precos-table .precos-group-super    { background: rgba(0,200,100,.07);  border-bottom: 2px solid rgba(0,200,100,.35); }
#precos-table .precos-group-ind      { background: rgba(180,0,255,.07);  border-bottom: 2px solid rgba(180,0,255,.35); }
#precos-table tbody tr:hover td      { background: rgba(79,124,255,.07); }
#precos-table tbody td.col-hover     { background: rgba(79,124,255,.10); }
#precos-table tbody tr:hover td.col-hover { background: rgba(79,124,255,.17); }

/* ── RATIO HINTS ── */
.ratio-hint {
  display: block;
  font-size: .70rem;
  color: var(--green);
  margin-top: 2px;
  white-space: nowrap;
  min-height: .85em;
}

/* ── BADGES ── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
}
.badge-green  { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-red    { background: rgba(239,68,68,.15);   color: var(--red); }
.badge-yellow { background: rgba(245,158,11,.15);  color: var(--yellow); }
.badge-blue   { background: rgba(79,124,255,.15);  color: var(--accent); }

/* ── CHAT ── */
#chat-messages {
  height: calc(100vh - 260px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 4px 0;
}
.msg { display: flex; gap: 12px; max-width: 85%; }
.msg.user  { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble {
  padding: 12px 16px; border-radius: 14px; font-size: .88rem; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.msg.user  .msg-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai    .msg-bubble { background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; background: var(--border); }
.chat-input-row { display: flex; gap: 10px; margin-top: 16px; }
.chat-input-row textarea { flex: 1; padding: 10px 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: .9rem; resize: none; height: 48px; outline: none; }
.chat-input-row textarea:focus { border-color: var(--accent); }

/* ── SIMULATOR ── */
.sim-result {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-top: 20px;
}
.sim-result h3 { font-size: 1rem; font-weight: 700; margin-bottom: 16px; color: var(--accent); }
.sim-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid rgba(46,51,84,.4); font-size: .88rem; }
.sim-row:last-child { border-bottom: none; }
.sim-row .label { color: var(--muted); }
.sim-row .value { font-weight: 600; }
.sim-row.total .value { color: var(--green); font-size: 1.1rem; }
.sim-row.alert .value { color: var(--red); }

/* ── ALERTS ── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: .85rem; margin-bottom: 12px; }
.alert-danger  { background: rgba(239,68,68,.12);  border: 1px solid rgba(239,68,68,.3);  color: var(--red); }

/* ── MODAL ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 32px; min-width: 400px; max-width: 560px;
  width: 90%; box-shadow: var(--shadow); max-height: 90vh; overflow-y: auto;
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 20px; color: var(--text); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ── TOAST ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 18px; font-size: .86rem;
  box-shadow: var(--shadow); animation: slideIn .25s ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes slideIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }

/* ── UTILS ── */
.flex        { display: flex; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.mt-1  { margin-top: 4px; }
.mt-2  { margin-top: 8px; }
.mt-3  { margin-top: 12px; }
.mt-4  { margin-top: 16px; }
.mb-4  { margin-bottom: 16px; }
.text-muted { color: var(--muted); font-size: .82rem; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  nav { width: 56px; }
  .nav-item span.label { display: none; }
  .nav-section { display: none; }
  main { padding: 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ══ MATRIZ MEGAZORD ══════════════════════════════════════════════════════════ */
.radio-row { display:flex; flex-wrap:wrap; gap:6px 14px; }
.radio-row label { display:flex; align-items:center; gap:5px; font-size:.81rem; cursor:pointer; white-space:nowrap; padding:4px 8px; border-radius:6px; border:1px solid var(--border); transition:border-color .15s,background .15s; }
.radio-row label:hover { border-color:var(--accent); background:rgba(79,124,255,.07); }
.radio-row input[type=radio] { accent-color:var(--accent); cursor:pointer; }
.radio-row input[type=radio]:checked + * { color:var(--accent); }

.obj-result { padding:10px 14px; border-radius:var(--radius); font-size:.82rem; border:1px solid var(--border); margin-top:8px; min-height:52px; transition:border-color .2s, background .2s; }
.obj-result .strategy-name { font-weight:700; font-size:.88rem; margin-bottom:3px; }
.obj-result .strategy-meta { color:var(--muted); font-size:.75rem; line-height:1.5; }
.obj-result .postura-tag   { font-weight:600; }

.postura-conservadora { border-color:var(--green)  !important; background:rgba(34,197,94,.07);  }
.postura-conservadora .postura-tag { color:var(--green); }
.postura-moderada     { border-color:var(--yellow) !important; background:rgba(245,158,11,.07); }
.postura-moderada     .postura-tag { color:var(--yellow); }
.postura-agressiva    { border-color:var(--accent2)!important; background:rgba(255,107,53,.07); }
.postura-agressiva    .postura-tag { color:var(--accent2); }

.sim-strategy-box { padding:9px 13px; border-radius:var(--radius); border:1px solid var(--border); background:var(--card); font-size:.8rem; margin-top:6px; }

/* ══ SOLICITAR PREÇO ════════════════════════════════════════════════════════ */
.sol-result-price {
  text-align: center; padding: 24px 20px; margin-bottom: 20px;
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--accent);
}
.sol-price-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.sol-price-value { font-size: 2.4rem; font-weight: 800; color: var(--accent); margin-top: 6px; }
.sol-price-unit  { font-size: .85rem; color: var(--muted); margin-top: 2px; }

.sol-section-title { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 16px 0 8px; }

.upload-area {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--card);
  border: 1px dashed var(--border); border-radius: var(--radius);
  transition: border-color .2s;
}
.upload-area:hover { border-color: var(--accent); }
.upload-area.has-file { border-color: var(--green); }

/* ══ CONDIÇÕES COMERCIAIS ════════════════════════════════════════════════════ */
.conditions-matrix-wrap { overflow-x: auto; }
.conditions-matrix { width: 100%; border-collapse: collapse; }
.conditions-matrix th, .conditions-matrix td {
  padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border);
}
.conditions-matrix tbody tr { cursor: pointer; transition: background 0.15s; }
.conditions-matrix tbody tr:hover { background: rgba(79,124,255,.04); }
.conditions-matrix tbody tr.active { background: rgba(79,124,255,.12); }

.conditions-detail {
  margin-top: 24px; padding: 20px; border-radius: 8px;
  background: rgba(255,255,255,.03); border: 1px solid var(--border);
}
.conditions-detail h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; color: var(--accent); }
.conditions-detail h3 { font-size: .85rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 20px 0 10px; }
.conditions-detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.conditions-detail-grid > div { font-size: 14px; }
.conditions-detail-grid strong { color: var(--muted); display: block; font-size: 12px; text-transform: uppercase; margin-bottom: 4px; }
.conditions-detail-note {
  font-style: italic; color: var(--muted); margin-bottom: 20px;
  padding: 12px; background: rgba(0,0,0,.2);
  border-left: 3px solid var(--accent); border-radius: 4px;
}
.conditions-detail-note:empty { display: none; }
.conditions-prices { width: 100%; border-collapse: collapse; }
.conditions-prices th, .conditions-prices td {
  padding: 8px 12px; text-align: right; border-bottom: 1px solid var(--border); font-size: .84rem;
}
.conditions-prices th:first-child, .conditions-prices td:first-child { text-align: left; }

/* ══ DASHBOARD ════════════════════════════════════════════════════════════════ */
.activity-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid rgba(46,51,84,.4); font-size: .84rem; }
.activity-row:last-child { border-bottom: none; }
.activity-detail { color: var(--text); }
.activity-meta   { font-size: .75rem; color: var(--muted); text-align: right; }

/* ══ SOLICITAR PREÇO — Proposta v2 ══════════════════════════════════════════ */
.proposta-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1.2fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .proposta-layout { grid-template-columns: 1fr; }
}

.proposta-form .field { display: block; margin-bottom: 14px; }
.proposta-form .field > span { display: block; font-size: 12px; text-transform: uppercase; color: var(--muted, #888); margin-bottom: 6px; letter-spacing: 0.4px; }
.proposta-form .field > em { font-style: normal; color: var(--muted, #888); font-weight: 400; }
.proposta-form .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.proposta-form input, .proposta-form select, .proposta-form textarea {
  width: 100%; padding: 10px 12px; border-radius: 6px;
  background: var(--input-bg, rgba(255,255,255,0.05));
  border: 1px solid var(--border, #333); color: inherit; font-size: 14px;
}
.proposta-form textarea { resize: vertical; font-family: inherit; }
.proposta-form .hint { display: block; font-size: 11px; color: var(--muted, #888); margin-top: 4px; }

.proposta-form #pr-submit { width: 100%; margin-top: 8px; padding: 12px; font-size: 15px; }
.proposta-form #pr-submit:disabled { opacity: 0.5; cursor: wait; }

.error-box { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; padding: 12px; border-radius: 6px; margin-top: 12px; font-size: 13px; }

.placeholder { color: var(--muted, #888); text-align: center; padding: 40px 20px; }
.placeholder p { margin: 8px 0; }

.ficha-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-top: 12px; }
.ficha-grid > div { display: flex; flex-direction: column; }
.ficha-grid strong { font-size: 11px; text-transform: uppercase; color: var(--muted, #888); margin-bottom: 2px; letter-spacing: 0.4px; }
.ficha-grid span { font-size: 15px; }

.badge { display: inline-block; font-size: 11px; padding: 3px 10px; border-radius: 999px; background: rgba(122,127,255,0.15); color: #9aa0ff; margin-left: 8px; vertical-align: middle; }
.badge.badge-gerente { background: rgba(251,191,36,0.15); color: #fbbf24; }
.badge.badge-admin   { background: rgba(239,68,68,0.15); color: #fca5a5; }

#pr-alertas-wrap { margin-top: 16px; }
#pr-alertas { margin: 8px 0 0; padding-left: 20px; font-size: 13px; color: var(--muted, #aaa); }
#pr-alertas li { margin-bottom: 4px; }

.msg-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.msg-body {
  white-space: pre-wrap; background: rgba(0,0,0,0.3); padding: 16px; border-radius: 6px;
  border-left: 3px solid var(--accent, #7a7fff); font-size: 13px; line-height: 1.6;
  max-height: 500px; overflow: auto; font-family: inherit;
}

/* Dropdowns — garantir contraste dentro das <option> */
select option {
  background-color: #1a1a1a;
  color: #e0e0e0;
}
select option:disabled,
select option[value=""] {
  color: #666;
}
select option:hover,
select option:checked {
  background-color: #2a2a2a;
  color: #ffffff;
}
/* Firefox precisa isto para respeitar o background da <option> */
select {
  background-color: var(--input-bg, rgba(255,255,255,0.05));
}

.form-actions {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
  margin-top: 8px;
}
.form-actions .btn { padding: 12px; font-size: 15px; }
@media (max-width: 500px) {
  .form-actions { grid-template-columns: 1fr; }
}
