:root {
  --bg: #ffffff;
  --surface: #f0f2f5;
  --surface2: #e4e7ed;
  --border: #c0c6d4;
  --accent: #0033cc;
  --accent2: #002299;
  --warn: #cc0000;
  --text: #1a1a2e;
  --muted: #6b7280;
  --green: #0033cc;
  --red: #cc0000;
  --yellow: #cc0000;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Mono', monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

/* ---- HEADER ---- */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.header-logo { height: 36px; width: auto; display: block; }
.header-logo.bg-remove { mix-blend-mode: multiply; }
.header-title { font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 800; letter-spacing: -0.5px; display: flex; align-items: center; gap: 12px; }
.header-title span { color: var(--accent); }
@media (min-width: 640px) { .header-logo { height: 44px; } }
.header-user { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.header-user .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface2); border: 1px solid var(--border); object-fit: cover; }
.header-user .btn-sair { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 4px 10px; border-radius: 6px; cursor: pointer; font-family: 'Syne', sans-serif; font-size: 10px; font-weight: 700; letter-spacing: 0.5px; transition: all 0.15s; }
.header-user .btn-sair:hover { color: var(--red); border-color: var(--red); }

/* ---- AUTH ---- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px 28px; width: 100%; max-width: 400px; }
.auth-title { font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 800; text-align: center; margin-bottom: 6px; }
.auth-title span { color: var(--accent); }
.auth-sub { text-align: center; color: var(--muted); font-size: 12px; margin-bottom: 24px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.auth-label { font-family: 'Syne', sans-serif; font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.auth-input {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-family: 'DM Mono', monospace; font-size: 15px;
  padding: 12px 14px; outline: none; width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(0,51,204,0.15); }
.auth-error { background: rgba(204,0,0,0.1); border: 1px solid rgba(204,0,0,0.3); border-radius: 8px; padding: 10px 14px; color: var(--red); font-size: 12px; margin-bottom: 14px; display: none; }
.auth-btn {
  width: 100%; padding: 12px; border-radius: 10px;
  font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 700;
  letter-spacing: 0.5px; cursor: pointer; border: none;
  transition: all 0.15s; margin-bottom: 10px;
}
.auth-btn.primary { background: var(--accent); color: #ffffff; }
.auth-btn.primary:active { background: #002299; }
.auth-btn.google { background: transparent; color: var(--text); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; gap: 8px; }
.auth-btn.google:active { background: var(--surface2); }
.auth-btn.google svg { width: 18px; height: 18px; flex-shrink: 0; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--muted); font-size: 11px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-link { text-align: center; font-size: 12px; color: var(--muted); margin-top: 4px; }
.auth-link a { color: var(--accent2); cursor: pointer; text-decoration: none; }
.auth-link a:hover { text-decoration: underline; }
.auth-loading { text-align: center; color: var(--muted); font-size: 13px; padding: 20px 0; }

/* ---- TAXA PANEL ---- */
.taxa-panel {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.taxa-group { display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; }
.taxa-label { font-family: 'Syne', sans-serif; font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; white-space: nowrap; }
.taxa-input-wrap { position: relative; display: flex; align-items: center; flex: 1 1 auto; }
.taxa-symbol { position: absolute; left: 10px; font-size: 13px; font-weight: 600; pointer-events: none; }
.taxa-symbol.usd { color: var(--accent); }
.taxa-symbol.pct { color: var(--yellow); }
.taxa-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'DM Mono', monospace;
  font-size: 15px;
  font-weight: 500;
  padding: 9px 10px 9px 24px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  min-width: 0;
}
.taxa-input.usd { color: var(--accent); border-color: rgba(0,51,204,0.35); }
.taxa-input.pct { color: var(--yellow); border-color: rgba(204,0,0,0.35); }
.taxa-input.usd:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(0,51,204,0.2); }
.taxa-input.pct:focus { border-color: var(--yellow); box-shadow: 0 0 0 2px rgba(204,0,0,0.2); }
.taxa-divider { display: none; }

/* ---- MAIN ---- */
.main { padding: 16px 16px 80px; max-width: 1700px; margin: 0 auto; }

.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.toolbar-top { display: flex; align-items: center; justify-content: space-between; }
.toolbar-right { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { font-family: 'Syne', sans-serif; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 2px; text-transform: uppercase; }
.count-badge { background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 2px 10px; font-size: 11px; color: var(--muted); margin-left: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 9px 14px; border-radius: 8px;
  font-family: 'Syne', sans-serif; font-size: 12px; font-weight: 700;
  letter-spacing: 0.3px; cursor: pointer; border: none;
  transition: all 0.15s; white-space: nowrap;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn-primary { background: var(--accent); color: #ffffff; }
.btn-primary:active { background: #002299; }
.btn-export { background: transparent; color: var(--accent2); border: 1px solid var(--accent2); }
.btn-export:active { background: rgba(0,34,153,0.1); }
.btn-import { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-import:active { background: rgba(204,0,0,0.1); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); padding: 7px 12px; font-size: 12px; }
.btn-danger:active { background: rgba(204,0,0,0.1); }
.btn-edit { background: transparent; color: var(--accent2); border: 1px solid var(--accent2); padding: 7px 12px; font-size: 12px; }
.btn-edit:active { background: rgba(0,34,153,0.1); }
.btn-cancel { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-cancel:active { color: var(--text); }
.btn-full { width: 100%; }

/* ---- TABLE ---- */
.table-wrap {
  background: var(--surface); border-radius: 12px;
  border: 1px solid var(--border); overflow: hidden; overflow-x: auto; display: none;
}
table { width: 100%; border-collapse: collapse; min-width: 560px; }
thead tr { background: var(--surface2); border-bottom: 1px solid var(--border); }
th {
  font-family: 'Syne', sans-serif; font-size: 10px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted);
  padding: 12px 14px; text-align: left; white-space: nowrap;
}
td { padding: 12px 14px; font-size: 13px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
tr.inativo td { opacity: 0.4; }
.col-produto { min-width: 160px; white-space: normal; word-break: break-word; }
.col-qtd { text-align: center; width: 60px; min-width: 60px; color: var(--muted); }
.col-valor { text-align: right; }
.col-ativo { text-align: center; width: 110px; min-width: 110px; }
.col-acoes { text-align: center; min-width: 120px; }
.val-usd { color: var(--accent); }
.val-brl { color: var(--accent2); }
.empty-row td { text-align: center; color: var(--muted); padding: 48px 16px; font-size: 13px; white-space: normal; }

.toggle-ativo {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 5px; width: 88px; padding: 5px 0; border-radius: 20px;
  font-family: 'Syne', sans-serif; font-size: 11px; font-weight: 700;
  cursor: pointer; border: none; transition: background 0.18s, color 0.18s;
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; letter-spacing: 0.3px; flex-shrink: 0;
}
.toggle-ativo.on { background: rgba(0,51,204,0.12); color: var(--accent); border: 1px solid rgba(0,51,204,0.35); }
.toggle-ativo.on:hover, .toggle-ativo.on:active { background: rgba(0,51,204,0.22); }
.toggle-ativo.off { background: rgba(107,117,145,0.1); color: var(--muted); border: 1px solid rgba(107,117,145,0.25); }
.toggle-ativo.off:hover, .toggle-ativo.off:active { background: rgba(107,117,145,0.2); color: var(--text); }

/* ---- CARDS (mobile) ---- */
.cards-list { display: flex; flex-direction: column; gap: 10px; }
.card-item { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.card-item.inativo { opacity: 0.45; border-style: dashed; }
.card-item-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-item-nome { font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 700; color: var(--text); word-break: break-word; flex: 1; }
.card-item-values { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.card-val { background: var(--surface2); border-radius: 8px; padding: 8px 10px; }
.card-val-label { font-size: 9px; font-family: 'Syne', sans-serif; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.card-val-value { font-size: 14px; font-weight: 500; }
.card-val-value.usd { color: var(--accent); }
.card-val-value.brl { color: var(--accent2); }
.card-item-actions { display: flex; gap: 8px; }
.card-item-actions .btn { flex: 1; }
.empty-cards { text-align: center; color: var(--muted); padding: 48px 16px; font-size: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }

/* ---- TOTALS ---- */
.totals-bar { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.total-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; transition: border-color 0.3s, background 0.3s; }
.total-card.over-limit { border-color: var(--warn); background: rgba(204,0,0,0.07); }
.total-card-label { font-family: 'Syne', sans-serif; font-size: 9px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; line-height: 1.3; }
.total-card-value { font-size: 16px; font-weight: 500; }
.total-card.usd .total-card-value { color: var(--accent); }
.total-card.brl .total-card-value { color: var(--accent2); }
.total-card.over-limit .total-card-value { color: var(--warn) !important; }
.total-card-diff { font-size: 10px; margin-top: 4px; color: var(--warn); display: none; }
.total-card-diff.visible { display: block; }

.bottom-bar { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }

/* ---- MODAL ---- */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.8); z-index: 200;
  align-items: flex-end; justify-content: center; backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px 20px 0 0; width: 100%; max-width: 100%;
  max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-drag { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 12px auto 4px; }
.modal-header {
  background: var(--surface); padding: 12px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 1;
}
.modal-title { font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 800; }
.modal-close {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 50%;
  color: var(--muted); font-size: 16px; cursor: pointer;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.modal-close:active { color: var(--text); }
.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-family: 'Syne', sans-serif; font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.form-input {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-family: 'DM Mono', monospace; font-size: 15px;
  padding: 12px 14px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%; -webkit-appearance: none;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(0,51,204,0.15); }
.form-input[readonly] { color: var(--muted); background: rgba(255,255,255,0.02); }
.form-input[readonly]:focus { border-color: var(--border); box-shadow: none; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-wrap { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.check-wrap input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.check-label { font-size: 15px; cursor: pointer; }
.modal-footer {
  padding: 12px 20px 20px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
  position: sticky; bottom: 0; background: var(--surface);
}

#fileImport { display: none; }

.produto-link { color: var(--accent2); text-decoration: none; border-bottom: 1px dashed rgba(0,34,153,0.4); transition: color 0.15s; }
.produto-link:active { color: #33bbff; }

@media (min-width: 640px) {
  .header { padding: 18px 40px; }
  .header-title { font-size: 21px; }
  .taxa-panel { padding: 13px 40px; gap: 20px; }
  .taxa-group { flex: 0 0 auto; }
  .taxa-input { width: auto; }
  .taxa-input.usd { width: 148px; }
  .taxa-input.pct { width: 120px; }
  .taxa-divider { display: block; width: 1px; height: 28px; background: var(--border); flex-shrink: 0; }
  .main { padding: 26px 40px 40px; }
  .toolbar { flex-direction: row; align-items: center; justify-content: space-between; }
  .toolbar-top { flex: 1; }
  .table-wrap { display: block; }
  .cards-list { display: none; }
  .totals-bar { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .total-card { padding: 14px 18px; }
  .total-card-label { font-size: 10px; }
  .total-card-value { font-size: 19px; }
  .bottom-bar { flex-direction: row; justify-content: flex-end; }
  .modal-overlay { align-items: center; }
  .modal { border-radius: 16px; width: 500px; max-width: 95vw; max-height: 90vh; }
  .modal-drag { display: none; }
  .modal-footer { flex-direction: row; justify-content: flex-end; padding: 13px 22px; }
  .btn-full { width: auto; }
  .modal-body { padding: 20px 22px; gap: 15px; }
  .modal-header { padding: 17px 22px; position: static; }
  .form-input { font-size: 14px; padding: 9px 13px; border-radius: 8px; }
  .check-wrap input[type=checkbox] { width: 17px; height: 17px; }
  .check-label { font-size: 14px; }

  .auth-card { padding: 40px 36px; }
  .auth-title { font-size: 26px; }
}
