* { box-sizing: border-box; margin: 0; }
:root {
  --bg: #0d1117; --panel: #161b22; --border: #30363d; --fg: #e6edf3; --muted: #8b949e;
  --accent: #2f81f7; --green: #3fb950; --red: #f85149; --yellow: #d29922; --orange: #f0883e;
}
body { background: var(--bg); color: var(--fg); font: 14px/1.45 system-ui, Segoe UI, sans-serif; }
.hidden { display: none !important; }

.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 32px; width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login-box h1 { font-size: 20px; text-align: center; margin-bottom: 8px; }

header { display: flex; align-items: center; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 5; }
header h1 { font-size: 18px; }
.src-tabs { display: flex; gap: 4px; background: var(--panel); border-radius: 8px; padding: 3px; }
.src-tab { background: none; border: 0; color: var(--muted); padding: 5px 14px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.src-tab.active { background: var(--accent); color: #fff; }
#logoutBtn { margin-left: auto; }

#criteriaBox { margin: 14px 20px 0; }
.crit-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; display: flex; gap: 10px; align-items: center; }
.crit-card .desc { color: var(--muted); flex: 1; font-size: 13px; }

nav#tabs { display: flex; gap: 6px; padding: 14px 20px 0; flex-wrap: wrap; }
nav#tabs button { background: var(--panel); border: 1px solid var(--border); color: var(--muted); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; }
nav#tabs button.active { color: var(--fg); border-color: var(--accent); background: #1c2432; }

.filters { display: flex; gap: 8px; padding: 12px 20px; flex-wrap: wrap; }
.filters input, .filters select { flex: 1; min-width: 130px; }
#search { flex: 3; }

input, select, textarea { background: #0d1117; border: 1px solid var(--border); color: var(--fg); border-radius: 8px; padding: 8px 10px; font: inherit; }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--border); padding: 7px 12px; background: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; color: var(--muted); }
button.small { padding: 4px 9px; font-size: 12.5px; }

#list { padding: 0 20px 40px; display: flex; flex-direction: column; gap: 10px; }
.car { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.car .top { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.car .info { flex: 1; min-width: 260px; }
.car .title { font-weight: 700; font-size: 15px; color: var(--fg); text-decoration: none; }
.car .title:hover { text-decoration: underline; }
.car .meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.car .side { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.price { text-align: right; margin-right: 4px; }
.price b { font-size: 15px; }
.price .bid { color: var(--muted); font-size: 11.5px; display: block; }
.badge { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 9px; background: #21262d; color: var(--muted); }
.badge.hoje { background: var(--orange); color: #000; }
.badge.novo { background: var(--accent); color: #fff; }
.badge.escolhido { background: var(--yellow); color: #000; }
.badge.vendido { background: var(--red); color: #fff; }

.progress { margin-top: 10px; }
.progress .bar { height: 8px; border-radius: 4px; background: #21262d; overflow: hidden; }
.progress .bar > div { height: 100%; background: var(--green); transition: width .5s; }
.progress .msg { color: var(--muted); font-size: 12px; margin-top: 4px; }
.erro-analise { color: var(--red); font-size: 12.5px; margin-top: 8px; }

.verdict-btn { margin-top: 8px; background: transparent; color: var(--yellow); border-color: var(--yellow); }
.analysis { margin-top: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: #10151c; font-size: 13.5px; }
.analysis .ver { font-weight: 600; margin-bottom: 8px; }
.analysis .facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 3px 20px; margin-bottom: 8px; }
.analysis .facts span { color: var(--muted); }
.analysis .resumo { color: var(--muted); white-space: pre-line; margin-top: 8px; }

.ledger { margin-top: 10px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.ledger .lrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 12px; border-bottom: 1px solid var(--border); }
.ledger .lrow:nth-child(odd) { background: #131922; }
.ledger .lrow:last-child { border-bottom: 0; }
.ledger .lrow.total { font-weight: 700; background: #1c2432; }
.ledger .lrow.lucro { font-weight: 700; }
.ledger .lrow.lucro.pos { color: var(--green); }
.ledger .lrow.lucro.neg { color: var(--red); }
.ledger input { width: 110px; text-align: right; padding: 3px 8px; font-family: ui-monospace, monospace; }
.ledger .val { font-family: ui-monospace, monospace; }
.ledger .faixa { color: var(--muted); font-size: 11px; }

.crit-form { display: flex; flex-direction: column; gap: 10px; min-width: 420px; }
.crit-form .row { display: flex; gap: 10px; }
.crit-form .row > div { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.crit-form .row.end { justify-content: flex-end; }
.crit-form label { font-size: 13px; font-weight: 600; }
.hint { color: var(--muted); font-size: 12px; }
dialog { background: var(--panel); color: var(--fg); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
dialog::backdrop { background: rgba(0,0,0,.6); }

.empty { color: var(--muted); padding: 30px; text-align: center; }
.err { color: var(--red); font-size: 13px; min-height: 16px; }
#toast { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
#toast div { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--green); border-radius: 8px; padding: 10px 14px; }
.placeholder { text-align: center; padding: 60px 20px; color: var(--muted); }
@media (max-width: 640px) { .crit-form { min-width: unset; } }
