/* Painel administrativo — funcional, rápido, responsivo. */
:root {
  --red: #8f1414;
  --red-dark: #5a0b0b;
  --gold: #c9a227;
  --gold-soft: #f6ecd0;
  --bg: #f6f3ee;
  --card: #ffffff;
  --ink: #221a16;
  --muted: #74675d;
  --line: #e7dfd3;
  --green: #1f8a4c;
  --green-bg: #e3f4ea;
  --minus: #b3261e;
  --minus-bg: #fbe6e4;
  --radius: 12px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--bg); font-size: 14px; }
a { color: var(--red); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid transparent;
  font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform .05s, background .15s, box-shadow .15s;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--red); color: #fff; }
.btn--primary:hover { background: #a51a1a; }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: #fff; border-color: #d6cbbb; }
.btn--danger { background: #fff; color: var(--minus); border-color: #efc6c2; }
.btn--danger:hover { background: var(--minus-bg); }
.btn--block { width: 100%; min-height: 44px; }
.btn--small { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn--plus { background: var(--green-bg); color: var(--green); border-color: #bfe3cd; }
.btn--plus:hover { background: #d2eddd; }
.btn--minus { background: var(--minus-bg); color: var(--minus); border-color: #f1c9c5; }
.btn--minus:hover { background: #f7d6d2; }
.btn--other { background: var(--gold-soft); color: #7a5b00; border-color: #eadba9; }
.btn--icon { min-width: 36px; padding: 0 9px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(120% 80% at 50% 0%, #9b1616, #5a0b0b 55%, #3d0606); }
.login__card { width: 100%; max-width: 360px; background: #fff; border-radius: 16px; padding: 26px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.4); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login__card img { margin: 0 auto; border-radius: 14px; }
.login__card h1 { margin: 4px 0 6px; font-size: 20px; letter-spacing: .12em; display: flex; flex-direction: column; }
.login__card h1 span { font-size: 13px; letter-spacing: 0; color: var(--muted); font-weight: 600; }
.login__card label { text-align: left; }

/* ---------- Formulários ---------- */
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 700; color: #4a3f37; }
input, select { font: inherit; font-size: 14.5px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); min-width: 0; }
input:focus, select:focus { outline: 2px solid rgba(143,20,20,.25); border-color: var(--red); }
.form-error { margin: 0; color: var(--minus); background: var(--minus-bg); border-radius: 8px; padding: 8px 10px; font-size: 13px; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Topo / toolbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px; padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, #8f1414, #6d0f0f); color: #fff;
  border-bottom: 2px solid var(--gold);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__brand img { border-radius: 8px; }
.topbar__brand div { display: flex; flex-direction: column; line-height: 1.1; }
.topbar__brand strong { letter-spacing: .2em; color: #f3dc9a; }
.topbar__brand span { font-size: 12px; opacity: .85; }
.topbar__actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.topbar .btn--ghost { color: #fff; border-color: rgba(255,255,255,.3); }
.topbar .btn--ghost:hover { background: rgba(255,255,255,.1); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 18px 4px; max-width: 1200px; margin: 0 auto; }
.toolbar input[type=search] { flex: 1 1 260px; }
.switch { flex-direction: row; align-items: center; gap: 7px; font-weight: 600; color: var(--muted); cursor: pointer; }
.switch input { width: 17px; height: 17px; accent-color: var(--red); }

.content { max-width: 1200px; margin: 0 auto; padding: 10px 18px 24px; }
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.empty { text-align: center; color: var(--muted); padding: 28px; margin: 0; }

/* ---------- Tabela ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #fbf9f5; }
tr:last-child td { border-bottom: 0; }
.users td.photo img { width: 44px; height: 52px; object-fit: cover; border-radius: 7px; display: block; background: #eee; box-shadow: 0 0 0 1px var(--line); }
.users .name strong { display: block; font-size: 15px; }
.users .name span { color: #8f1414; font-size: 13px; letter-spacing: .1em; }
.users td.pid code { font-family: var(--mono); font-size: 12px; background: #f4efe7; padding: 3px 6px; border-radius: 6px; }
.score-cell { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.score-cell b { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; }
.tier { font-size: 10.5px; font-weight: 800; padding: 2px 8px; border-radius: 999px; color: #fff; text-transform: uppercase; letter-spacing: .04em; }
.score-cell.bump b { animation: bump .6s ease-out; }
.score-cell.bump-up b { color: var(--green); }
.score-cell.bump-down b { color: var(--minus); }
@keyframes bump { 30% { transform: scale(1.25); } }

.actions { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.actions .quick { display: inline-flex; gap: 4px; }
.actions .quick .btn { min-width: 50px; padding: 0 8px; font-variant-numeric: tabular-nums; }
.actions .sep { width: 1px; height: 26px; background: var(--line); margin: 0 3px; }

/* Celular: cada linha vira um cartão */
@media (max-width: 760px) {
  .topbar { padding-left: 12px; padding-right: 12px; }
  .topbar__brand span { display: none; }
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar__actions { flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
  .topbar .btn { min-height: 32px; padding: 0 9px; font-size: 12.5px; }
  .toolbar, .content { padding-left: 12px; padding-right: 12px; }
  .toolbar .btn--primary { flex: 1 1 100%; }
  .table-wrap { background: transparent; border: 0; overflow: visible; }
  .users thead { display: none; }
  .users, .users tbody { display: block; }
  .users tr {
    display: grid; grid-template-columns: 52px 1fr auto; gap: 4px 12px; align-items: center;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px; margin-bottom: 10px;
  }
  .users td { border: 0; padding: 0; }
  .users td.photo { grid-row: span 2; }
  .users td.pid { grid-column: 2; grid-row: 2; }
  .users td.score { grid-column: 3; grid-row: 1 / span 2; }
  .users td.acts { grid-column: 1 / -1; padding-top: 10px; }
  .actions .quick { display: grid; grid-template-columns: repeat(5, 1fr); width: 100%; gap: 6px; }
  .actions .quick .btn { min-height: 44px; font-size: 15px; min-width: 0; }
  .actions .sep { display: none; }
  .actions .more { display: flex; gap: 6px; width: 100%; }
  .actions .more .btn { flex: 1; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ---------- Modais ---------- */
.modal { border: 0; border-radius: 16px; padding: 0; width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: 0 30px 80px rgba(0,0,0,.35); color: var(--ink); }
.modal--wide { width: min(820px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(30,10,10,.55); backdrop-filter: blur(2px); }
.modal > form, .modal > div { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.modal h2 { margin: 0; font-size: 18px; }
.modal__actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.modal__actions .spacer { flex: 1; }

.delta-input { display: grid; grid-template-columns: 56px 1fr 56px; gap: 8px; }
.delta-input input { text-align: center; font-size: 28px; font-weight: 900; padding: 6px; }
.delta-input .btn { font-size: 26px; min-height: 56px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 12.5px; font-weight: 600; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: #faf7f2; cursor: pointer; color: var(--ink); }
.chip:hover { border-color: var(--red); }
.chip.plus { color: var(--green); }
.chip.minus { color: var(--minus); }

.user-form { display: grid; grid-template-columns: 170px 1fr; gap: 18px; }
.user-form__photo { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.user-form__photo img { width: 100%; aspect-ratio: 5/6; object-fit: cover; border-radius: 10px; background: #eee; box-shadow: 0 0 0 1px var(--line); }
.user-form__fields { display: flex; flex-direction: column; gap: 10px; }
.file-btn { cursor: pointer; flex-direction: row; font-weight: 700; color: var(--ink); }
.link-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: #faf7f2; border: 1px dashed var(--line); border-radius: 9px; padding: 8px; }
.link-row code { flex: 1 1 200px; font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
@media (max-width: 640px) { .user-form { grid-template-columns: 1fr; } .user-form__photo img { max-width: 160px; margin: 0 auto; } }

.history-wrap { max-height: 60vh; overflow: auto; }
.history td { font-size: 13px; }
.history .d-plus { color: var(--green); font-weight: 800; }
.history .d-minus { color: var(--minus); font-weight: 800; }
.history .reason-edit { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; font: inherit; text-decoration: underline dotted; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; width: min(520px, calc(100vw - 20px)); }
.toast { display: flex; align-items: center; gap: 10px; background: #221a16; color: #fff; border-radius: 12px; padding: 10px 12px 10px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.3); animation: toastIn .2s ease-out; }
.toast.error { background: var(--minus); }
.toast__msg { flex: 1; font-weight: 600; }
.toast .btn { min-height: 30px; padding: 0 10px; font-size: 12.5px; background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.admin-footer { text-align: center; color: var(--muted); font-size: 11.5px; padding: 10px 18px 28px; }

/* ---------- Caixa de entrada ---------- */
.badge { display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; align-items: center; justify-content: center; background: #f3dc9a; color: #5a0b0b; font-size: 11.5px; font-weight: 900; }
.modal--xl { width: min(1180px, calc(100vw - 16px)); height: min(860px, calc(100vh - 16px)); }
.modal--xl > .inbox { display: flex; flex-direction: column; height: 100%; padding: 0; gap: 0; }
.inbox__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.inbox__title h2 { margin: 0; }
.inbox__title p { margin: 2px 0 0; }
.inbox__filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.inbox__filters select { padding: 6px 8px; font-size: 13px; }
.tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; background: #f4efe7; padding: 3px; border-radius: 10px; }
.tab { font: inherit; font-size: 12.5px; font-weight: 700; border: 0; background: transparent; padding: 6px 10px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.tab b { font-weight: 900; margin-left: 3px; color: var(--ink); }
.tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.inbox__body { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px 1fr; }
.inbox__list { list-style: none; margin: 0; padding: 0; overflow-y: auto; border-right: 1px solid var(--line); }
.inbox__list li { padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.inbox__list li:hover { background: #fbf8f3; }
.inbox__list li.active { background: #fbf1e0; box-shadow: inset 3px 0 0 var(--red); }
.inbox__list li.unread .it-subject { font-weight: 800; }
.it-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.it-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.it-subject { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.it-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.mbox { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; padding: 2px 7px; border-radius: 999px; background: #e8eef6; color: #26405c; }
.mbox--denuncia { background: var(--minus-bg); color: var(--minus); }
.mbox--contato { background: var(--green-bg); color: var(--green); }
.inbox__detail > * { flex-shrink: 0; }
.inbox__detail { overflow-y: auto; padding: 18px 20px 28px; display: flex; flex-direction: column; gap: 14px; }
.inbox__detail h3 { margin: 0; font-size: 20px; overflow-wrap: anywhere; }
.msg-head { display: flex; flex-direction: column; gap: 6px; }
.msg-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.msg-line strong { color: var(--ink); }
.auth { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; background: var(--green-bg); color: var(--green); }
.auth--warn { background: #fdf0d8; color: #8a5a00; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.55; background: #fbf9f5; border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 0; max-height: 420px; overflow-y: auto; font-family: inherit; }
.msg-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.msg-images a { display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #eee; aspect-ratio: 1; }
.msg-images img { width: 100%; height: 100%; object-fit: cover; display: block; }
.msg-files { display: flex; flex-wrap: wrap; gap: 6px; }
.panel { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #fff; }
.panel h4 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.panel .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.panel select, .panel input, .panel textarea { flex: 1 1 220px; }
.panel textarea { font: inherit; font-size: 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; min-height: 64px; max-height: 200px; resize: vertical; flex: 0 0 auto; }
.linked { display: flex; align-items: center; gap: 10px; }
.linked img { width: 40px; height: 48px; object-fit: cover; border-radius: 6px; }
.linked b { font-size: 20px; font-variant-numeric: tabular-nums; }
.suggest { font: inherit; font-size: 12.5px; border: 1px dashed var(--gold); background: var(--gold-soft); color: #6d5000; border-radius: 999px; padding: 4px 10px; cursor: pointer; font-weight: 700; }
.warn-note { font-size: 12px; color: #8a5a00; background: #fdf6e6; border-radius: 8px; padding: 8px 10px; margin: 0; }
.inbox__back { display: none; }
@media (max-width: 820px) {
  .modal--xl { height: calc(100vh - 16px); }
  .inbox__body { grid-template-columns: 1fr; }
  .inbox__list { border-right: 0; }
  .inbox__body.show-detail .inbox__list { display: none; }
  .inbox__body:not(.show-detail) .inbox__detail { display: none; }
  .inbox__back { display: inline-flex; align-self: flex-start; }
  .inbox__detail { padding: 14px; }
}

html, body { overflow-x: hidden; }
