:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #6b7385;
  --line: #e4e7ec;
  --brand: #2d3277;
  --accent: #ffe600;
  --pos: #1f8a5b;
  --neg: #d14343;
  --warn-bg: #fff6db;
  --warn-line: #f0d27a;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif; }
a { color: var(--brand); }
code { background: #eef0f4; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

.top { display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  background: var(--brand); color: #fff; padding: 10px 24px; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.brand span { color: var(--accent); }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
.top nav a { color: #dfe2ff; text-decoration: none; padding: 6px 12px; border-radius: 6px; }
.top nav a:hover { background: rgba(255,255,255,.08); }
.top nav a.active { background: rgba(255,255,255,.16); color: #fff; }
.sync { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.sync select { padding: 5px; border-radius: 6px; border: 0; }
.sync button { background: var(--accent); color: #222; }
#sync-status { color: #cfd3ff; font-size: 12.5px; max-width: 340px; }

main { max-width: 1240px; margin: 0 auto; padding: 20px 24px 60px; }
h2 { margin: 0 0 8px; font-size: 19px; }
h3 { margin: 0 0 12px; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.pos { color: var(--pos); }
.neg { color: var(--neg) !important; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; }
.card.empty { border-left: 4px solid var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid2 > .card { margin-bottom: 18px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

button, .button { background: var(--brand); color: #fff; border: 0; border-radius: 6px; padding: 7px 14px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; }
button:disabled { opacity: .6; cursor: wait; }
button.secondary { background: #eef0f4; color: var(--text); }
button.link { background: none; color: var(--neg); padding: 0; font-weight: 400; }
input, select { font: inherit; padding: 6px 8px; border: 1px solid #cfd4dc; border-radius: 6px; background: #fff; }
input.money { width: 110px; text-align: right; }
label { display: inline-flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 6px; }
form.inline { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin: 12px 0; }
form.stack { display: flex; flex-direction: column; gap: 12px; max-width: 520px; }
form.stack input { width: 100%; }
form.stack button { align-self: flex-start; }
.inline-del { display: inline; }
.actions { margin-top: 14px; display: flex; justify-content: flex-end; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid var(--line); background: #fff; }
.flash.ok { border-color: #a8dcc2; background: #effaf4; }
.flash.error { border-color: #f1b0b0; background: #fdf0f0; }
.flash.warn { border-color: var(--warn-line); background: var(--warn-bg); }
.ok-line { color: var(--pos); }

.period { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.shortcuts { display: flex; gap: 6px; flex-wrap: wrap; margin-right: 8px; }
.chip { padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line);
  text-decoration: none; color: var(--text); }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 24px; font-weight: 700; margin: 4px 0; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: .3px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; }
.breakdown td { padding: 6px 8px; }
.breakdown tr.strong td { font-weight: 700; }
.breakdown tr.subtotal td { background: #f3f5fa; }
td.strong { font-weight: 700; }
.detail-costs li.subtotal { font-weight: 600; background: #eef1f7; padding: 2px 4px; margin: 2px -4px; }
.breakdown tr.total td { border-top: 2px solid var(--text); border-bottom: 0; }
.barcell { width: 30%; }
.bar { height: 8px; background: #f0a8a8; border-radius: 4px; margin-top: 6px; }
.chart { position: relative; height: 290px; }

.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px;
  background: #e8eaff; color: var(--brand); margin-left: 4px; vertical-align: 1px; }
.tag.warn { background: var(--warn-bg); color: #8a6100; border: 1px solid var(--warn-line); }

table.sales tbody.order tr.summary { cursor: pointer; }
table.sales tbody.order tr.summary:hover { background: #f8f9fb; }
table.sales tr.detail { display: none; }
table.sales tbody.order.open tr.detail { display: table-row; }
table.sales tbody.order.open tr.summary { background: #f3f5fa; }
tr.detail td { background: #fafbfc; }
.detail-item { margin: 4px 0 10px; }
.detail-costs { list-style: none; padding: 0; margin: 6px 0 0; max-width: 380px; }
.detail-costs li { display: flex; justify-content: space-between; padding: 2px 0; font-variant-numeric: tabular-nums; }
.detail-costs li.strong { font-weight: 700; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }

table.products tr.missing { background: var(--warn-bg); }
table.products tr.missing input[name=product_cost] { border-color: #e2b23c; }

.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.actions-inline { display: flex; gap: 8px; }
.lot-card { display: block; text-decoration: none; color: inherit; transition: border-color .15s; }
.lot-card:hover { border-color: var(--brand); }
.lot-profit { text-align: right; }
.lot-profit .value { font-size: 22px; font-weight: 700; }
.progress { height: 8px; background: #eceef3; border-radius: 4px; margin: 12px 0; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); border-radius: 4px; }
.lot-stats { display: flex; gap: 28px; flex-wrap: wrap; }
.lot-stats > div { display: flex; flex-direction: column; font-size: 13px; }
.lot-stats .muted { font-size: 12px; }
.tag.status-vendendo { background: #e5f5ec; color: var(--pos); }
.tag.status-esgotada { background: #eceef3; color: var(--muted); }
.tag.status-na-fila, .tag.status-a-caminho, .tag.status-recebendo { background: #fff6db; color: #8a6100; }
.warn-text { color: #8a6100; }
.inline-forms { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.inline-forms form.inline { margin: 0; }
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login-card label { width: 100%; }
.login-card input[type=password] { width: 100%; }
.login-brand { color: var(--brand); font-size: 24px; text-align: center; margin-bottom: 6px; }
.login-brand span { color: #c9a800; }
.logout button { background: none; color: #cfd3ff; padding: 6px 8px; font-weight: 400; }
tr.selected td { background: #f3f5fa; font-weight: 600; }
form.stack.wide { max-width: none; }
form.stack .inline { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
form.stack .inline input { width: auto; }
table.lot-items { max-width: 760px; }
table.lot-items td { border-bottom: 0; padding: 4px 8px 4px 0; }
.steps li { margin-bottom: 8px; }
.explain { padding-left: 18px; }
.explain li { margin-bottom: 6px; }
