:root {
  --paper: #E7EAE1;
  --paper-2: #DEE2D6;
  --ink: #1B2723;
  --ink-soft: #445048;
  --teal: #24443C;
  --teal-2: #2F5A50;
  --gold: #B07E2C;
  --gold-soft: #DDBD84;
  --line: #C4CBBB;
  --card: #F2F4EC;
  --red: #A6402F;
  --font-display: "Iowan Old Style", "Palatino Linotype", "URW Palladio L", Palatino, "Noto Serif", serif;
  --font-body: "Seravek", "Gill Sans Nova", "Segoe UI", "Noto Sans", Arial, sans-serif;
  --font-mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #122019; --paper-2: #182720; --ink: #E9ECE2; --ink-soft: #B7C2B6;
    --teal: #6FA79A; --teal-2: #86BDAF; --gold: #E0A94E; --gold-soft: #8A6B36;
    --line: #2C3B34; --card: #17251E; --red: #E08370;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
}
a { color: inherit; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

header.admin-bar {
  border-bottom: 1px solid var(--line);
}
header.admin-bar .admin-bar-top { display: flex; justify-content: space-between; align-items: center; padding: 16px 0 12px; }
.brand { font-family: var(--font-display); font-size: 1.2rem; }
.brand .sub { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); margin-left: 6px; }
.logout { font-size: 0.85rem; color: var(--ink-soft); text-decoration: none; border-bottom: 1px solid var(--line); }
.logout:hover { color: var(--red); border-color: var(--red); }

.admin-nav { display: flex; gap: 22px; padding-bottom: 14px; flex-wrap: wrap; }
.admin-nav a {
  font-size: 0.86rem; color: var(--ink-soft); text-decoration: none; padding-bottom: 4px;
  border-bottom: 2px solid transparent;
}
.admin-nav a:hover { color: var(--ink); }
.admin-nav a.active { color: var(--teal-2); border-color: var(--gold); font-weight: 600; }

main { padding: 36px 0 64px; }

h1 { font-family: var(--font-display); font-size: 1.7rem; margin: 0 0 6px; }
.subtitle { color: var(--ink-soft); font-size: 0.92rem; margin: 0 0 28px; }

.filters { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input[type="search"] {
  flex: 1; min-width: 220px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 3px;
  background: var(--card); color: var(--ink); font-family: var(--font-body); font-size: 0.92rem;
}
.filters .btn { padding: 10px 16px; }
.filters .clear-search {
  font-size: 0.85rem; color: var(--ink-soft); text-decoration: none; border-bottom: 1px solid var(--line);
  align-self: center;
}
.filters .clear-search:hover { color: var(--red); border-color: var(--red); }

.multiselect { position: relative; }
.ms-toggle {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: 3px; background: var(--card); color: var(--ink); font-size: 0.9rem; cursor: pointer;
  min-width: 168px; justify-content: space-between; font-family: var(--font-body);
}
.ms-toggle:hover { border-color: var(--gold); }
.ms-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.ms-clear { color: var(--ink-soft); font-size: 1.05rem; line-height: 1; padding: 0 2px; }
.ms-clear:hover { color: var(--red); }
.ms-arrow { font-size: 0.65rem; color: var(--ink-soft); }
.ms-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; width: 260px;
  background: var(--card); border: 1px solid var(--line); border-radius: 4px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22); padding: 10px; display: flex; flex-direction: column; gap: 6px;
}
.ms-panel[hidden] { display: none; }
.ms-option { display: flex; align-items: center; gap: 10px; padding: 7px 6px; font-size: 0.9rem; border-radius: 3px; cursor: pointer; }
.ms-option:hover { background: var(--paper-2); }
.ms-all { font-weight: 600; }
.ms-divider { height: 1px; background: var(--line); margin: 2px 0; }
.ms-scroll { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.ms-apply { margin-top: 6px; width: 100%; justify-content: center; }

table.candidatos { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.candidatos th {
  text-align: left; font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-soft); padding: 10px 14px; border-bottom: 1px solid var(--line);
}
table.candidatos td { padding: 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.candidatos tr:hover { background: var(--card); }
table.candidatos a.row-link { text-decoration: none; color: var(--ink); font-weight: 600; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 4px; }
.table-scroll table { min-width: 720px; }
.table-scroll table.tight { min-width: 0; width: 100%; table-layout: fixed; }

table.tight th, table.tight td { padding: 9px 8px; font-size: 0.82rem; }
table.tight th { font-size: 0.6rem; }
table.tight td.subtexto { font-size: 0.74rem; color: var(--ink-soft); margin-top: 2px; }
table.tight .codigo-cell { font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-soft); }
.link-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  font-size: 0.74rem; color: var(--ink-soft); text-decoration: underline;
}
.link-btn:hover { color: var(--red); }

table.tight .acoes-cell { text-align: right; }
.acoes-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.acoes-row form { display: inline-flex; margin: 0; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  flex-shrink: 0; border-radius: 50%; border: none; background: none; cursor: pointer; color: var(--ink-soft); padding: 0;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.icon-btn.whatsapp { background: #25D366; color: #fff; }
.icon-btn.whatsapp:hover { background: #1FAE55; color: #fff; }
.icon-btn.whatsapp svg { width: 16px; height: 16px; }
.icon-btn.trash svg { width: 21px; height: 21px; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-family: var(--font-mono); letter-spacing: 0.03em; }
.pill-novo { background: color-mix(in srgb, var(--gold) 22%, transparent); color: var(--gold); }
.pill-em_analise { background: color-mix(in srgb, var(--teal) 18%, transparent); color: var(--teal-2); }
.pill-aprovado { background: color-mix(in srgb, #3B7A4A 20%, transparent); color: #3B7A4A; }
.pill-rejeitado { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); }
.pill-btn { border: none; cursor: pointer; }

.empty { padding: 40px 20px; text-align: center; color: var(--ink-soft); border: 1px dashed var(--line); border-radius: 4px; }

/* cadastros: serviços, clientes, profissionais */
.cadastro-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 28px; }
.cadastro-card { border: 1px solid var(--line); border-radius: 5px; padding: 16px 18px; background: var(--card); }
.cadastro-card.inativo { opacity: 0.55; }
.cadastro-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.cadastro-card-meta { font-size: 0.82rem; color: var(--ink-soft); margin-bottom: 4px; }
.cadastro-card details { margin-top: 10px; }
.cadastro-card summary { font-size: 0.82rem; color: var(--teal-2); cursor: pointer; }
.cadastro-edit-form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.cadastro-toggle { margin-top: 10px; }
.cadastro-toggle .btn { padding: 6px 12px; font-size: 0.78rem; }
.cadastro-form-panel { max-width: 460px; }
.cadastro-form-panel .field { margin-bottom: 14px; }

/* totais (cartões de resumo) */
.totals-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 24px; }
.total-card { flex: 1; min-width: 160px; border: 1px solid var(--line); border-radius: 5px; padding: 16px 18px; background: var(--card); }
.total-card .label { font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 6px; display: block; }
.total-card .value { font-family: var(--font-display); font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.total-card.pago .value { color: #3B7A4A; }
.total-card.pendente .value { color: var(--red); }

/* filtros com campo de data */
.filter-label {
  display: flex; flex-direction: column; gap: 4px;
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-soft);
}
.filters input[type="date"] {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 3px;
  background: var(--card); color: var(--ink); font-family: var(--font-body); font-size: 0.88rem;
}
.filters select {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 3px;
  background: var(--card); color: var(--ink); font-family: var(--font-body); font-size: 0.9rem;
}

/* mobile: formulário de filtros e cabeçalho empilham */
@media (max-width: 720px) {
  .filters { flex-direction: column; align-items: stretch; }
  .filters input[type="search"],
  .filter-label input[type="date"],
  .filters select,
  .multiselect,
  .ms-toggle { width: 100%; }
  .filters .btn, .filters .clear-search { align-self: flex-start; }
  header.admin-bar .admin-bar-top { flex-wrap: wrap; gap: 8px; }
  .admin-nav { gap: 14px; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 10px; }
  .totals-row { flex-direction: column; }
}

/* mobile: tabela densa (Vendas) vira lista de cartões, sem rolagem horizontal */
@media (max-width: 720px) {
  table.tight { display: block; width: 100%; }
  table.tight colgroup { display: none; }
  table.tight thead { display: none; }
  table.tight tbody { display: block; }
  table.tight tr {
    display: block; border: 1px solid var(--line); border-radius: 6px;
    margin-bottom: 12px; background: var(--card); padding: 4px 0;
  }
  table.tight tr:last-child { margin-bottom: 0; }
  table.tight td {
    display: block; width: auto !important; padding: 7px 14px; border-bottom: none; font-size: 0.86rem;
  }
  table.tight td[data-label]::before {
    content: attr(data-label); display: block; font-family: var(--font-mono); font-size: 0.6rem;
    letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 2px;
  }
  table.tight td.codigo-cell { padding-top: 14px; }
  table.tight td.acoes-cell { text-align: left; padding-top: 10px; padding-bottom: 14px; }
  .acoes-row { justify-content: flex-start; gap: 20px; }
  .acoes-row .icon-btn { width: 42px; height: 42px; }
  .acoes-row .icon-btn svg { width: 21px; height: 21px; }
  .acoes-row .icon-btn.trash svg { width: 26px; height: 26px; }
}

/* login */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 360px; border: 1px solid var(--line); border-radius: 6px; padding: 36px 32px; background: var(--card); }
.login-card h1 { text-align: center; margin-bottom: 4px; }
.login-card .subtitle { text-align: center; margin-bottom: 24px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; font-family: var(--font-mono); color: var(--ink-soft); margin-bottom: 8px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 3px;
  background: var(--paper); color: var(--ink); font-family: var(--font-body); font-size: 0.95rem;
}
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 3px; border: 1px solid transparent; font-weight: 600; font-size: 0.9rem; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--teal); color: var(--paper); width: 100%; justify-content: center; }
.btn-primary:hover { background: var(--teal-2); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }
.error { color: var(--red); font-size: 0.85rem; margin-bottom: 16px; text-align: center; }

/* detail page */
.back-link { display: inline-block; margin-bottom: 20px; font-size: 0.85rem; color: var(--ink-soft); text-decoration: none; }
.back-link:hover { color: var(--teal-2); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
@media (max-width: 760px) { .detail-grid { grid-template-columns: 1fr; } }
.panel { border: 1px solid var(--line); border-radius: 4px; padding: 24px; background: var(--card); }
.panel h2 { font-family: var(--font-display); font-size: 1.1rem; margin: 0 0 16px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--ink-soft); }
.kv .v { text-align: right; }
.status-form { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.raw-text { white-space: pre-wrap; font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink-soft); max-height: 320px; overflow-y: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 14px; }

/* PDF viewer overlay */
.pdf-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 28px; }
.pdf-modal[hidden] { display: none; }
.pdf-modal-backdrop { position: absolute; inset: 0; background: rgba(10, 16, 14, 0.72); }
.pdf-modal-content {
  position: relative; z-index: 1; width: 100%; max-width: 860px; height: 100%; max-height: 90vh;
  background: var(--card); border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.pdf-modal-close {
  align-self: flex-end; margin: 10px 10px 0 0; background: var(--paper); border: 1px solid var(--line);
  border-radius: 3px; padding: 8px 14px; font-size: 0.85rem; font-weight: 600; color: var(--ink); cursor: pointer;
}
.pdf-modal-close:hover { border-color: var(--red); color: var(--red); }
.pdf-modal-content iframe { flex: 1; width: 100%; border: none; margin-top: 6px; background: #fff; }
@media (max-width: 700px) {
  .pdf-modal { padding: 0; }
  .pdf-modal-content { max-width: none; max-height: none; border-radius: 0; }
}

/* aviso de erro (ex: senha incorreta ao excluir) */
.error-banner {
  background: color-mix(in srgb, var(--red) 14%, transparent);
  border: 1px solid var(--red); color: var(--red); border-radius: 4px;
  padding: 12px 16px; font-size: 0.88rem; margin-bottom: 20px;
}

/* banners fixos do PWA (instalar app / ativar notificações) — empilham sem sobrepor */
#pwaBannerStack {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.install-banner-fixo {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--teal); color: var(--paper); padding: 14px 16px;
  border-top: 1px solid color-mix(in srgb, var(--paper) 18%, transparent);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.25);
}
.install-banner-text { font-size: 0.86rem; line-height: 1.35; flex: 1; }
.install-banner-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.btn-gold-inline {
  background: var(--gold); color: #1B2723; border: none; border-radius: 4px;
  padding: 9px 14px; font-size: 0.82rem; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.install-banner-close {
  background: none; border: none; color: var(--paper); font-size: 1.3rem; line-height: 1;
  cursor: pointer; padding: 4px;
}
