:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1b1f27;
  --muted: #667085;
  --line: #e2e5ea;
  --brand: #0f766e;
  --brand-dark: #0b5953;
  --danger: #b42318;
  --warn-bg: #fff6e0;
  --warn-line: #f0c36d;
  --ok-bg: #e8f6ee;
  --ok-line: #8fd0a9;
  --err-bg: #fdecea;
  --err-line: #f1a29b;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151a;
    --card: #1b2028;
    --text: #e8eaee;
    --muted: #98a2b3;
    --line: #2d3440;
    --warn-bg: #3a2f13;
    --warn-line: #7a5f1c;
    --ok-bg: #12301f;
    --ok-line: #2d6b47;
    --err-bg: #3a1a17;
    --err-line: #7a2b25;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); }
h1 { font-size: 1.6rem; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
code { background: var(--bg); padding: 2px 6px; border-radius: 6px; font-size: .95em; user-select: all; }
.muted { color: var(--muted); }
small { color: var(--muted); }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem;
  padding: .75rem 1rem; background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar .brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topbar .brand small { font-weight: 400; margin-left: .25rem; }
.topbar nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: center; }
.topbar nav a { text-decoration: none; }
form.inline { display: inline; margin: 0; }

.container { max-width: 960px; margin: 0 auto; padding: 1rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.plain { display: grid; place-items: start center; padding: 1rem; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin: 1rem 0;
}
.card.narrow, .narrow { max-width: 460px; width: 100%; }
.plain .card { margin-top: 8vh; }

label { display: block; margin: .75rem 0; font-weight: 600; font-size: .95rem; }
label small { display: block; font-weight: 400; margin-top: .25rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: .25rem; padding: .6rem .7rem; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
button, .btn {
  display: inline-block; padding: .6rem 1rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  color: #fff; background: var(--brand); border: 0; border-radius: 8px;
}
button:hover, .btn:hover { background: var(--brand-dark); }
button.secondary { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
button.danger { background: var(--danger); }
button.link { background: none; color: var(--brand); padding: 0; font-weight: 400; text-decoration: underline; }
.form-grid { max-width: 640px; }

.alert { padding: .7rem .9rem; border-radius: 8px; margin: .75rem 0; border: 1px solid; }
.alert.success { background: var(--ok-bg); border-color: var(--ok-line); }
.alert.error { background: var(--err-bg); border-color: var(--err-line); }
.alert.warn { background: var(--warn-bg); border-color: var(--warn-line); }

.pw-field { position: relative; margin-top: .25rem; }
.pw-field input { margin-top: 0; padding-right: 2.9rem; }
.pw-toggle {
  position: absolute; top: 50%; right: .3rem; transform: translateY(-50%);
  display: grid; place-items: center; width: 2.4rem; height: 2.4rem; padding: 0;
  background: transparent; color: var(--muted); border-radius: 8px;
}
.pw-toggle:hover { background: transparent; color: var(--brand); }
.pw-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.copy-row { display: flex; gap: .5rem; align-items: stretch; }
.copy-row input { flex: 1; margin-top: 0; }
.copy-row button { flex: none; }
.handoff { border-color: var(--brand); }
.handoff textarea { margin-bottom: .75rem; font-size: .95rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin: 1rem 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; color: var(--muted); font-size: .9rem; }
.stat span { display: block; font-size: 1.5rem; font-weight: 700; color: var(--text); }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }
.filters input, .filters select { width: auto; margin: 0; flex: 1 1 180px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .85rem; color: var(--muted); }
tr:last-child td { border-bottom: 0; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge.ok { background: var(--ok-bg); color: #166534; border: 1px solid var(--ok-line); }
.badge.off { background: var(--err-bg); color: var(--danger); border: 1px solid var(--err-line); }
@media (prefers-color-scheme: dark) { .badge.ok { color: #7ee2a8; } .badge.off { color: #ffb4ab; } }

/* Painel: listas de categorias e produtos */
.row-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.row-form label { flex: 1 1 200px; margin: 0; }
.row-form button { flex: none; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.actions form { margin: 0; }
.actions .btn, .actions button { padding: .5rem .8rem; }
button.secondary:hover, .btn.secondary:hover { background: transparent; color: var(--brand-dark); }
.btn.secondary { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
button:disabled { opacity: .4; cursor: not-allowed; }
.card.item { margin: .6rem 0; }
.product { display: grid; grid-template-columns: 72px 1fr; gap: .75rem; align-items: start; }
.product .actions { grid-column: 1 / -1; margin-top: 0; }
.thumb { width: 72px; height: 72px; border-radius: 8px; overflow: hidden; background: var(--bg); display: grid; place-items: center; }
.thumb img { width: 72px; height: 72px; object-fit: cover; display: block; }
.thumb .emoji { font-size: 2rem; }
.preview { display: block; width: 160px; height: 160px; object-fit: cover; border-radius: 8px; margin: .5rem 0; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
label.check input[type="checkbox"] { width: auto; margin: 0; }
input[type="file"] { padding: .5rem; }
