:root {
  --bg: #f6f5f1; --surface: #fff; --ink: #1d1f22; --muted: #6b6f76; --line: #e4e2db;
  --accent: #1f4e79; --accent-ink: #fff; --sun: #f2b705;
  --ok: #1e7a46; --ok-bg: #e7f4ec; --err: #b42318; --err-bg: #fdecea; --warn: #8a5a00; --warn-bg: #fff4d6;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: .2rem 0 .6rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
h3 { font-size: .9rem; margin: 1.2rem 0 .4rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* topo */
.top { display: flex; align-items: center; gap: 1.2rem; padding: .7rem 1.2rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; gap: .5rem; }
.brand.big { font-size: 1.3rem; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 0 4px rgba(242,183,5,.2); }
.top nav { display: flex; gap: .2rem; flex-wrap: wrap; flex: 1; }
.top nav a { padding: .4rem .7rem; border-radius: 8px; text-decoration: none; color: var(--muted); }
.top nav a.on, .top nav a:hover { background: var(--bg); color: var(--ink); }
.warn-dot { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--err); color: #fff; font-size: 11px; }
.me { display: flex; align-items: center; gap: .8rem; }
.me a { color: var(--ink); text-decoration: none; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 1.2rem 16px 4rem; }

/* componentes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card.subtle { background: transparent; box-shadow: none; }
.card.narrow { max-width: 480px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #c9c6bc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.wide { width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.link.danger { color: var(--err); }
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .8rem; background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.badge { display: inline-block; font-size: .75rem; padding: .15rem .55rem; border-radius: 99px; background: #eceae4; color: var(--muted); font-weight: 600; white-space: nowrap; }
.s-otimizado { background: #e6eefb; color: #1f4e79; }
.s-publicado { background: var(--ok-bg); color: var(--ok); }
.s-pausado { background: var(--warn-bg); color: var(--warn); }
.s-erro { background: var(--err-bg); color: var(--err); }

/* formulários */
label { display: block; font-size: .85rem; font-weight: 600; color: #3a3d42; margin-bottom: .8rem; }
input, select, textarea { display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-weight: 400; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,78,121,.25); border-color: var(--accent); }
input[readonly] { background: var(--bg); color: var(--muted); }
input[type=checkbox], input[type=radio] { display: inline; width: auto; margin: 0 .35rem 0 0; }
textarea { resize: vertical; }
label.check { display: inline-flex; align-items: center; font-weight: 400; margin: 0 .8rem 0 0; }
label.missing input { border-color: var(--err); background: #fffafa; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.span2 { grid-column: span 2; }
.form-foot { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 1rem; margin-top: .4rem; }
.counter { float: right; font-weight: 400; color: var(--muted); }
.counter.over { color: var(--err); font-weight: 700; }
.field-note { padding-top: .2rem; font-size: .9rem; }
form.inline { display: flex; gap: .5rem; margin: .6rem 0; }
form.inline input { margin: 0; max-width: 240px; }

/* listas */
.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.search input { margin: 0; min-width: 240px; }
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tabs a { padding: .35rem .75rem; border-radius: 99px; text-decoration: none; color: var(--muted); border: 1px solid var(--line); background: var(--surface); font-size: .88rem; }
.tabs a span { color: #9a9ea5; margin-left: .2rem; }
.tabs a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs a.on span { color: #cfd2d6; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card table.list { border: 0; }
table.list th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
table.list td { padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list:not(.static) tbody tr { cursor: pointer; }
table.list:not(.static) tbody tr:hover { background: #fbfaf7; }
.thumb { width: 56px; }
.thumb img { width: 44px; height: 44px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--line); display: block; }
.pname { color: var(--ink); text-decoration: none; font-weight: 600; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.zero, .neg { color: var(--err); font-weight: 700; }
.pos { color: var(--ok); font-weight: 700; }
.row-actions { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.row-actions form { margin: 0; }
details.pop form { display: flex; gap: .4rem; margin-top: .4rem; }
details.pop input { margin: 0; }
.import-box { display: grid; grid-template-columns: 1fr auto; gap: .4rem 1rem; align-items: center; margin-top: 1rem; }
.import-box p { margin: .2rem 0 0; }
.import-box details { grid-column: 1 / -1; }
.empty form { margin-top: .6rem; }
@media (max-width: 860px) { .import-box { grid-template-columns: 1fr; } }
.empty {text-align: center; padding: 3rem 1rem; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

/* página do produto */
.back { display: inline-block; margin-bottom: .4rem; text-decoration: none; font-size: .9rem; }
.meta { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; font-size: .9rem; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; margin-top: .8rem; align-items: start; }
.col-side { position: sticky; top: 70px; }
.notes { margin: 0 0 1rem; padding: .7rem 1rem .7rem 2rem; background: var(--warn-bg); border-radius: 8px; color: #5c4300; font-size: .9rem; }
.notes li + li { margin-top: .25rem; }
.pics { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .7rem; }
.pics figure { margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.pics img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; }
.pics figcaption { padding: .4rem .5rem; display: flex; flex-wrap: wrap; gap: .2rem; font-size: .8rem; }
.pics figcaption label.check { font-size: .8rem; }
.sticky-save { position: sticky; bottom: 0; padding: .8rem 0; background: linear-gradient(transparent, var(--bg) 35%); text-align: right; }
.stock-big { font-size: 2.4rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stock-big small { font-size: 1rem; color: var(--muted); font-weight: 400; }
.stock-form input { margin: 0 0 .5rem; }
.seg { display: flex; gap: .8rem; margin: .8rem 0 .5rem; }
.seg label { margin: 0; font-weight: 400; display: inline-flex; align-items: center; }
.moves, .log { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.moves li, .log li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.moves li span:first-child { display: inline-block; min-width: 2.4rem; }
.log .lv-error { color: var(--err); }
.log .lv-warn { color: var(--warn); }
.log pre { white-space: pre-wrap; word-break: break-all; background: var(--bg); padding: .5rem; border-radius: 6px; font-size: .78rem; }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 0; font-size: .92rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
code { background: var(--bg); padding: .1rem .35rem; border-radius: 4px; font-size: .85rem; }
.ok-line { color: var(--ok); }

/* login */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-box { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 2rem 1.6rem; box-shadow: 0 8px 30px rgba(0,0,0,.06); }

@media (max-width: 860px) {
  .cols { grid-template-columns: 1fr; }
  .col-side { position: static; order: -1; }
  .grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .search input { min-width: 0; }
  .top { gap: .4rem .8rem; padding: .6rem 16px; position: static; }
  .top .brand { flex: 1; }
  .top nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; margin: 0 -8px; }
  .top nav a { white-space: nowrap; }
}
