/* Tema Gitea + guarda-chuva verde — paleta Gitea/Primer, system fonts */
:root {
  --gitea-blue: #4183c4;
  --gitea-blue-hover: #3876b3;
  --bg-app: #f6f8fa;
  --bg-card: #ffffff;
  --bg-soft: #f2f5f8;
  --bg-hover: #eaeef2;
  --text: #181c21;
  --text-2: #40474d;
  --text-muted: #697077;
  --border: #d0d7de;
  --success: #1a7f37;
  --warning: #9a6700;
  --error: #d1242f;
  --umbrella-green: #22c55e;
  --font-sans:
    -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial,
    "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji";
  --font-mono:
    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg-app);
  font-size: 14px;
  line-height: 1.5;
}
a {
  color: var(--gitea-blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* header */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar img {
  width: 26px;
  height: 26px;
}
.topbar h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}
.topbar .sub {
  color: var(--text-muted);
  font-size: 12px;
}

.wrap {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 20px;
}

/* abas */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
}
.tab {
  padding: 10px 16px;
  color: var(--text-2);
  font-weight: 500;
  border-bottom: 2px solid transparent;
}
.tab:hover {
  color: var(--text);
  text-decoration: none;
  background: var(--bg-soft);
}
.tab.active {
  color: var(--gitea-blue);
  border-bottom-color: var(--gitea-blue);
}

/* filtros */
.filters {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--gitea-blue);
  box-shadow: 0 0 0 2px rgba(65, 131, 196, 0.2);
}
.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 14px;
  background: var(--bg-soft);
  color: var(--text);
}
.btn:hover {
  background: var(--bg-hover);
}
.btn-primary {
  background: var(--gitea-blue);
  border-color: var(--gitea-blue);
  color: #fff;
}
.btn-primary:hover {
  background: var(--gitea-blue-hover);
}
.btn-green {
  background: #1f883d;
  border-color: rgba(31, 136, 61, 0.9);
  color: #fff;
  font-weight: 500;
  padding: 7px 16px;
}
.btn-green:hover {
  background: #1a7f37;
  border-color: #1a7f37;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* modal de confirmação */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(27, 31, 36, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.modal {
  width: 100%;
  max-width: 420px;
  margin: 0 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(31, 35, 40, 0.2);
  padding: 20px;
  transform: translateY(-8px) scale(0.98);
  transition: transform 0.15s ease;
}
.modal-overlay.show .modal {
  transform: translateY(0) scale(1);
}
.modal h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--text);
}
.modal p {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-2);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* grid de cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.1s;
}
.card:hover {
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
}
.card .photo {
  aspect-ratio: 4/3;
  background: var(--bg-soft) center/cover no-repeat;
}
.card .body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.card .ref {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.card .price {
  font-weight: 600;
  font-size: 15px;
}
.card .meta {
  font-size: 12px;
  color: var(--text-2);
}
.card .loc {
  font-size: 13px;
}
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(26, 127, 55, 0.12);
  color: var(--success);
  font-weight: 600;
}
.badge-gray {
  background: var(--bg-hover);
  color: var(--text-muted);
}

.muted {
  color: var(--text-muted);
}
.count {
  margin: 16px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

/* paginador */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  align-items: center;
  margin: 22px 0 30px;
}
.page-btn {
  font-family: inherit;
  font-size: 13px;
  min-width: 34px;
  padding: 6px 10px;
  cursor: pointer;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.page-btn:hover:not(:disabled) {
  background: var(--bg-hover);
}
.page-btn.active {
  background: var(--gitea-blue);
  border-color: var(--gitea-blue);
  color: #fff;
  font-weight: 600;
}
.page-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.page-gap {
  color: var(--text-muted);
  padding: 0 2px;
}

/* revisar */
.review {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 24px;
  align-items: start;
}
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}
.panel h2 {
  font-size: 14px;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.form-row {
  display: flex;
  gap: 12px;
}
.form-row .field {
  flex: 1;
}
.field input,
.field select,
.field textarea {
  width: 100%;
}
textarea {
  resize: vertical;
  min-height: 120px;
  font-family: var(--font-sans);
}
.hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* campo obrigatório (vermelho) — ex: Código do anúncio (código próprio no Pro) */
.field-required label {
  color: var(--error);
  font-weight: 600;
}
.field-required input {
  border-color: var(--error);
  background: var(--bg-card);
  font-weight: 600;
}
.field-required input::placeholder {
  color: #e7969c;
  font-weight: 400;
}
.field-required input:focus {
  box-shadow: 0 0 0 2px rgba(209, 36, 47, 0.2);
}
.field-required .hint {
  color: var(--error);
}

/* galeria de fotos */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.thumb {
  position: relative;
  aspect-ratio: 4/3;
  border: 2px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  cursor: grab;
  background: var(--bg-soft) center/cover;
}
.thumb.sel {
  border-color: var(--umbrella-green);
}
.thumb .chk {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 3px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--success);
}
.thumb .num {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 11px;
  padding: 0 5px;
  border-radius: 8px;
}
.thumb.dragging {
  opacity: 0.4;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 16px;
  border-radius: 6px;
  color: #fff;
  font-weight: 500;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  display: none;
  z-index: 50;
}
.toast.ok {
  background: var(--success);
}
.toast.err {
  background: var(--error);
}
.toast.show {
  display: block;
}
.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* postagem em lote */
.lote-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lote-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  font-size: 13px;
}
.lote-row .lc {
  font-family: var(--font-mono);
  font-weight: 600;
  min-width: 92px;
}
.lote-row .lm {
  color: var(--text-2);
}
.lote-row.pend {
  background: var(--bg-soft);
}
.lote-row.ok {
  border-color: #a7d3b0;
}
.lote-row.warn {
  border-color: #e6c78a;
}
.lote-row.err {
  border-color: #e8a7ac;
}

/* tabela do log */
.logtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.logtable th {
  text-align: left;
  padding: 9px 12px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.logtable td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.logtable tr:last-child td {
  border-bottom: none;
}
.logtable .mono {
  font-family: var(--font-mono);
}
.logtable td.muted {
  color: var(--text-muted);
}
.logtable tr.r-err td {
  background: rgba(209, 36, 47, 0.04);
}

/* badge de cota no header */
.quota-badge {
  font-size: 12px;
  color: var(--text-2);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 12px;
  white-space: nowrap;
}
.quota-badge b {
  color: var(--text);
}
.quota-badge.zero {
  color: var(--error);
  border-color: rgba(209, 36, 47, 0.4);
  background: rgba(209, 36, 47, 0.07);
}
.quota-badge.zero b {
  color: var(--error);
}

/* ---- analytics ---- */
.panel-h {
  font-size: 15px;
  margin: 0 0 14px;
  color: var(--text);
}
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.kpi-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  background: var(--bg-card);
}
.kpi-num {
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.1;
}
.kpi-num .kpi-sub {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 3px;
}
.kpi-lbl {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* gráfico de barras verticais (por dia) */
.chart-plot {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 180px;
  padding-top: 22px;
  border-bottom: 1px solid var(--border);
}
.cbar-col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}
.cbar {
  width: 62%;
  max-width: 34px;
  min-height: 2px;
  background: var(--gitea-blue);
  border-radius: 3px 3px 0 0;
}
.cbar-val {
  font-size: 11px;
  color: var(--text-2);
  margin-bottom: 3px;
}
.chart-x {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.chart-x div {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}

/* barras horizontais (por usuário) */
.hbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
}
.hbar-label {
  width: 210px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hbar-track {
  flex: 1;
  height: 18px;
  background: var(--bg-soft);
  border-radius: 4px;
  overflow: hidden;
}
.hbar-fill {
  height: 100%;
  min-width: 2px;
  background: var(--gitea-blue);
  border-radius: 4px;
}
.hbar-fill.zero {
  background: var(--border);
}
.hbar-num {
  width: 34px;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
}

/* tabela de gerenciar usuários */
.usertable td,
.usertable th {
  vertical-align: middle;
  white-space: nowrap;
}
.usertable td:first-child {
  width: 100%;
}
.usertable form {
  margin: 0;
}
.usertable .inline-form {
  display: flex;
  gap: 6px;
  align-items: center;
}
.usertable select,
.usertable input[type="number"],
.usertable input[type="text"] {
  margin: 0;
}
.tag {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.tag-ok {
  background: rgba(26, 127, 55, 0.12);
  color: var(--success);
}
.tag-warn {
  background: rgba(154, 103, 0, 0.14);
  color: var(--warning);
}
.tag-err {
  background: rgba(209, 36, 47, 0.12);
  color: var(--error);
}
