:root {
  --bg: #f3f2ef; --panel: #fff; --ink: #0e0e0f; --muted: #5d5d63; --line: #e2dfd8; --soft: #f7f6f3;
  --volt: #d4ff3a; --sale: #c2410c; --ok: #157f3d; --ok-bg: #e5f5ea; --warn: #9a5b00; --warn-bg: #fff3dc;
  --danger: #b42318; --danger-bg: #fdecea; --info: #1d4fd8; --info-bg: #e7eeff;
  --radius: 16px; --ease: cubic-bezier(.22,1,.36,1);
  --font-display: 'Rubik', system-ui, sans-serif; --font-body: 'Nunito Sans', system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; line-height: 1.1; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--ink); position: relative; overflow: hidden; }
.login::before { content: ''; position: absolute; width: 520px; height: 520px; border-radius: 50%; background: var(--volt); filter: blur(120px); opacity: .25; top: -120px; right: -120px; }
.login-card { position: relative; width: min(400px, 100%); background: #fff; border-radius: 24px; padding: 32px; display: grid; gap: 18px; animation: rise .6s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(20px); } }
.logo { font-family: var(--font-display); font-weight: 900; font-size: 26px; letter-spacing: -.03em; }
.logo span { background: var(--ink); color: var(--volt); padding: 0 6px; border-radius: 6px; margin-left: 2px; display: inline-block; transform: skewX(-8deg); }
.login-card p { margin: 0; color: var(--muted); }

/* Layout */
.shell { display: grid; min-height: 100vh; }
@media (min-width: 960px) { .shell { grid-template-columns: 240px 1fr; } }
.side { background: var(--ink); color: #cfcfd4; padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; z-index: 20; }
.side .logo { color: #fff; padding: 4px 10px 18px; }
.side .logo span { background: var(--volt); color: var(--ink); }
.side nav { display: flex; gap: 4px; overflow-x: auto; }
@media (min-width: 960px) { .side { height: 100vh; } .side nav { flex-direction: column; overflow: visible; } }
@media (max-width: 959px) { .side { flex-direction: row; align-items: center; padding: 10px 12px; } .side .logo { padding: 0 8px 0 0; font-size: 20px; } .side .spacer, .side .side-foot .label { display: none; } }
.nav-btn { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 0; background: none; color: inherit; font-weight: 700; white-space: nowrap; text-align: left; transition: background-color .2s, color .2s; }
.nav-btn:hover { background: #1f1f23; color: #fff; }
.nav-btn[aria-current="page"] { background: var(--volt); color: var(--ink); }
.nav-btn .pill { margin-left: auto; background: #ff5a1f; color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; }
.side .spacer { flex: 1; }
.side-foot { display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 959px) { .side-foot { flex-direction: row; margin-left: auto; } }
.content { padding: 24px 16px 80px; min-width: 0; }
@media (min-width: 768px) { .content { padding: 32px 36px 80px; } }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 32px; font-weight: 900; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* Botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1.5px solid transparent; font-weight: 800; font-size: 14.5px; transition: background-color .2s, transform .15s, border-color .2s; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #2b2b30; }
.btn-volt { background: var(--volt); color: var(--ink); }
.btn-volt:hover { background: #e2ff70; }
.btn-ghost { background: #fff; border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #f9d7d3; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 10px; border: 0; background: none; transition: background-color .2s; }
.icon-btn:hover { background: var(--soft); }

/* Cards / stats */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); margin-bottom: 22px; }
@media (min-width: 1100px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--panel); border-radius: var(--radius); padding: 18px 20px; display: grid; gap: 4px; animation: rise .5s var(--ease) both; }
.stat:nth-child(2) { animation-delay: .05s; } .stat:nth-child(3) { animation-delay: .1s; } .stat:nth-child(4) { animation-delay: .15s; }
.stat span { color: var(--muted); font-weight: 700; font-size: 13.5px; }
.stat strong { font-family: var(--font-display); font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.stat.accent { background: var(--ink); color: #fff; } .stat.accent span { color: #aaa; } .stat.accent strong { color: var(--volt); }
.panels { display: grid; gap: 14px; }
@media (min-width: 1100px) { .panels { grid-template-columns: 1.4fr 1fr; } }
.panel { background: var(--panel); border-radius: var(--radius); padding: 20px; min-width: 0; }
.panel h2 { font-size: 17px; margin-bottom: 14px; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border: 0; }
.muted { color: var(--muted); }

/* Toolbar + tabela */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.input, .select, .textarea { min-height: 44px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; padding: 0 12px; width: 100%; transition: border-color .2s, box-shadow .2s; }
.textarea { padding: 10px 12px; min-height: 110px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: 0; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(14,14,15,.08); }
.toolbar .input { max-width: 320px; }
.toolbar .select { width: auto; }
.table-wrap { background: var(--panel); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--soft); position: sticky; top: 0; }
tbody tr { transition: background-color .15s; }
tbody tr:hover { background: #fbfaf8; }
.prod-cell { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.thumb { width: 56px; height: 56px; border-radius: 12px; display: grid; place-items: center; padding: 4px; flex: none; overflow: hidden; position: relative; }
.thumb .kx-art { width: 100%; }
.thumb .kx-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.prod-cell strong { display: block; font-family: var(--font-display); font-weight: 700; }
.prod-cell small { color: var(--muted); }
.price-input { width: 96px; min-height: 36px; border-radius: 8px; border: 1.5px solid transparent; background: var(--soft); padding: 0 8px; font-weight: 800; transition: border-color .2s, background-color .2s; }
.price-input:hover { border-color: var(--line); }
.price-input:focus { outline: 0; border-color: var(--ink); background: #fff; }
.price-input.saved { border-color: var(--ok); background: var(--ok-bg); }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 800; white-space: nowrap; }
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.off { background: #eee; color: #555; }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.danger { background: var(--danger-bg); color: var(--danger); }
.tag.info { background: var(--info-bg); color: var(--info); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; vertical-align: middle; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #cfccc5; transition: background-color .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .25s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 2px; }
.empty-row { text-align: center; padding: 40px; color: var(--muted); }

/* Editor (drawer) */
.backdrop { position: fixed; inset: 0; background: rgba(14,14,15,.45); z-index: 50; opacity: 0; transition: opacity .25s; }
.backdrop.show { opacity: 1; }
.editor { position: fixed; top: 0; right: 0; bottom: 0; width: min(980px, 100%); background: var(--bg); z-index: 60; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .4s var(--ease); }
.editor.open { transform: none; }
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.editor-head h2 { font-size: 20px; }
.editor-body { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: 16px; align-content: start; }
@media (min-width: 860px) { .editor-body { grid-template-columns: 1fr 320px; } .editor-side { position: sticky; top: 0; align-self: start; } }
.editor-foot { display: flex; justify-content: space-between; gap: 10px; padding: 14px 20px; background: #fff; border-top: 1px solid var(--line); flex-wrap: wrap; }
.editor-foot .right { display: flex; gap: 10px; margin-left: auto; }
.fgrid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.fgrid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .fgrid { grid-template-columns: 1fr; } }
.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-weight: 800; font-size: 13.5px; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.field .err { font-size: 12.5px; color: var(--danger); font-weight: 700; }
.money { position: relative; }
.money input { padding-left: 28px; }
.money::before { content: '€'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 800; }
.preview { border-radius: 18px; aspect-ratio: 1.05; display: grid; place-items: center; padding: 8%; position: relative; overflow: hidden; transition: background-color .3s; }
.preview .kx-art { width: 100%; }
.preview .kx-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.colors { display: flex; gap: 10px; }
.color-field { display: grid; gap: 4px; justify-items: center; font-size: 12px; color: var(--muted); font-weight: 700; }
.color-field input { width: 52px; height: 44px; border-radius: 10px; border: 1.5px solid var(--line); padding: 3px; background: #fff; cursor: pointer; }
.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 16px; text-align: center; background: #fff; transition: border-color .2s, background-color .2s; }
.drop.over { border-color: var(--ink); background: #fbffe9; }
.drop p { margin: 0 0 10px; color: var(--muted); font-size: 13.5px; }
.sizes-table { width: 100%; min-width: 0; }
.sizes-table td, .sizes-table th { padding: 6px; border: 0; background: none; }
.sizes-table input { min-height: 38px; }
.size-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.toggles { display: grid; gap: 10px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fff; border-radius: 12px; padding: 10px 14px; }
.toggle-row strong { display: block; font-size: 14px; }
.toggle-row small { color: var(--muted); }

/* Modal confirm */
.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 80; padding: 16px; }
.modal-card { background: #fff; border-radius: 20px; padding: 24px; width: min(420px, 100%); display: grid; gap: 12px; animation: rise .3s var(--ease); position: relative; z-index: 1; }
.modal-card p { margin: 0; color: var(--muted); }
.modal-card .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* Encomendas */
.order-items { margin: 6px 0 0; padding: 0; list-style: none; font-size: 13.5px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 160%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 700; z-index: 99; transition: transform .4s cubic-bezier(.34,1.56,.64,1); display: flex; gap: 10px; align-items: center; max-width: calc(100% - 32px); }
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }
.toast::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--volt); flex: none; }
.toast.error::before { background: #fff; }

.fade-in { animation: rise .4s var(--ease) both; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

/* Galeria do editor */
.gal { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.gal:empty { display: none; }
.gal-item { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--soft); border: 1px solid var(--line); }
.gal-item .kx-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-main { position: absolute; left: 4px; bottom: 4px; background: var(--ink); color: var(--volt); font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 999px; }
.gal-btn { position: absolute; bottom: 4px; left: 4px; width: 28px; height: 28px; border-radius: 8px; border: 0; background: rgba(255,255,255,.92); display: grid; place-items: center; font-size: 13px; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.gal-btn.gal-rm { left: auto; right: 4px; top: 4px; bottom: auto; color: var(--danger); }
.gal-btn svg.i { width: 14px; height: 14px; }
.ref { font-family: ui-monospace, monospace; font-size: 12px; background: var(--soft); border: 1px solid var(--line); padding: 0 5px; border-radius: 5px; }

/* Importar */
.import-grid { display: grid; gap: 14px; }
@media (min-width: 1100px) { .import-grid { grid-template-columns: minmax(0, 1fr) 340px; } }
.drop-xl { padding: 36px 20px; }
.drop-xl > svg.i { width: 34px; height: 34px; margin-bottom: 8px; }
.drop-xl p { font-size: 15px; }
.drop-xl p strong { color: var(--ink); font-size: 17px; }
.radio { display: flex; align-items: center; gap: 8px; min-height: 36px; font-size: 14px; cursor: pointer; }
.radio input { width: 18px; height: 18px; accent-color: var(--ink); }
.howto { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13.5px; }
.howto code, .hint code { font-size: 12px; background: var(--soft); border: 1px solid var(--line); padding: 0 4px; border-radius: 4px; }
.imp-summary { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.imp-table { min-width: 560px; }
.imp-table tr.is-skip { opacity: .55; }
.imp-thumbs { display: flex; gap: 4px; align-items: center; }
.imp-thumbs img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; background: var(--soft); }
.imp-thumbs span { font-size: 12px; font-weight: 800; color: var(--muted); }
.imp-foot { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.imp-foot .btn { margin-left: auto; }
.progress { flex: 1 1 100%; height: 8px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--ink); border-radius: inherit; transition: width .3s var(--ease); }

/* Paginação da lista de produtos */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 16px 0 8px; }
.pager-input { width: 72px; display: inline-block; padding: 6px 8px; text-align: center; }

/* Margem e preço do fornecedor */
.pct { position: relative; max-width: 160px; }
.pct input { padding-right: 30px; }
.pct span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 800; }
.price-input[readonly], .input[readonly] { background: transparent; border-style: dashed; cursor: default; }
.cost-note { display: block; margin-top: 4px; color: var(--muted); font-size: 11.5px; white-space: nowrap; }

/* Árvore de categorias */
.main-row td { background: rgba(0,0,0,.03); }
.main-row [data-k="name"] { font-weight: 800; }
.cat-sub { display: flex; align-items: center; gap: 8px; padding-left: 18px; }
.cat-sub::before { content: '›'; color: var(--muted); font-weight: 800; }

.order-cancel { margin-top: 8px; color: var(--danger); }
.order-cancel svg { width: 15px; height: 15px; }
