:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --primary: #1a73e8; --primary-text: #fff; --danger: #c5221f; --dirty: #fff4c2; --sel: #e8f0fe;
  --new: #e6f4ea; --chip: #eef1f5; --err: #fce8e6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181d; --card: #1e2229; --text: #e6e8eb; --muted: #9aa1ab; --line: #2f343d;
    --primary: #8ab4f8; --primary-text: #0b1b33; --danger: #f28b82; --dirty: #4a4120; --sel: #23324d;
    --new: #1f3a2a; --chip: #2b3039; --err: #4a2523;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); padding-bottom: 70px; }
body.demo .topbar::after { content: "MODO DEMONSTRAÇÃO"; font-size: 11px; font-weight: 700; color: #b06000; margin-left: 12px; }
button, input, select { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--card); padding: 6px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
button:hover { filter: brightness(0.96); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 600; }
button.danger { color: var(--danger); border-color: var(--danger); }
button.ghost { background: transparent; }
button.link { border: 0; background: none; color: var(--primary); padding: 0 6px; }
input[type=text], input[type=search], select { border: 1px solid var(--line); background: var(--card); border-radius: 6px; padding: 6px 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; padding: 24px; }
.error { color: var(--danger); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 16px; }
.spacer { flex: 1; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 17px; margin: 0; }
.topbar-right { display: flex; gap: 10px; align-items: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 24px; }
.login { max-width: 560px; margin: 48px auto; }
.login h2 { margin-top: 0; font-size: 20px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 16px 0; }
.field input { width: 100%; }

main { padding: 12px 16px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.toolbar input[type=search] { flex: 1 1 260px; min-width: 200px; }

.bulkbar { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; opacity: .6; }
.bulkbar.active { opacity: 1; border-color: var(--primary); }
.bulk-sel { margin-bottom: 6px; }
.bulk-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.bulk-actions .group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bulk-actions input[type=text] { width: 150px; }
.chk { display: inline-flex; gap: 4px; align-items: center; }

.table-wrap { overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; max-height: calc(100vh - 290px); }
table { border-collapse: collapse; width: 100%; min-width: 1100px; }
th, td { border-bottom: 1px solid var(--line); padding: 0; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; background: var(--card); z-index: 2; padding: 8px 6px; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap; }
.c-chk { width: 34px; text-align: center; padding: 0 6px; cursor: default; }
.c-status { width: 70px; padding: 0 6px; }
.cell { display: flex; align-items: center; }
td input:not([type=checkbox]) { width: 100%; min-width: 90px; border: 0; background: transparent; padding: 7px 6px; border-radius: 0; }
td input:not([type=checkbox]):focus { outline: 2px solid var(--primary); outline-offset: -2px; background: var(--card); }
td.dirty { background: var(--dirty); }
tr.sel td { background: var(--sel); }
tr.sel td.dirty { background: var(--dirty); }
tr.isnew td { background: var(--new); }
td.labels { cursor: pointer; padding: 4px 6px; min-width: 140px; }
.chip { display: inline-block; background: var(--chip); border-radius: 10px; padding: 1px 8px; margin: 1px 2px; font-size: 12px; }
.badge { font-size: 11px; color: var(--muted); background: var(--chip); border-radius: 8px; padding: 0 5px; margin-right: 4px; cursor: help; }
.st { font-size: 11px; font-weight: 600; border-radius: 4px; padding: 1px 5px; }
.st.mod { background: var(--dirty); }
.st.new { background: var(--new); }
.st.err { background: var(--err); color: var(--danger); cursor: help; }

.pager { display: flex; gap: 8px; align-items: center; margin-top: 10px; }

.savebar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 10px 16px; background: var(--card); border-top: 2px solid var(--primary); z-index: 10; box-shadow: 0 -2px 10px rgba(0,0,0,.08); }
.savebar span { margin-right: auto; font-weight: 500; }

dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); min-width: 320px; max-width: 520px; }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h3 { margin-top: 0; }
.checks { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }

.busy { position: fixed; inset: 0; background: rgba(0,0,0,.3); display: flex; align-items: center; justify-content: center; gap: 12px; z-index: 50; color: #fff; font-weight: 600; }
.spinner { width: 28px; height: 28px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toasts { position: fixed; right: 16px; bottom: 72px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--primary); padding: 8px 12px; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.15); max-width: 380px; }
.toast.ok { border-left-color: #188038; }
.toast.warn { border-left-color: #e37400; }
.toast.err { border-left-color: var(--danger); }

@media (max-width: 700px) {
  main { padding: 8px; }
  .bulk-actions input[type=text] { width: 110px; }
}

.c-photo { width: 44px; padding: 3px 4px; cursor: pointer; }
.thumb { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; display: block; background: var(--chip); }
.thumb.profile { outline: 2px dashed var(--muted); outline-offset: 1px; opacity: .75; }
.thumb.empty { display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.photo-cols { display: flex; gap: 16px; margin: 8px 0; }
.photo-cols figure { margin: 0; text-align: center; }
.photo-cols img { width: 160px; height: 160px; border-radius: 50%; object-fit: cover; background: var(--chip); display: block; }
.photo-cols figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
