:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e4e9;
  --text: #1a1d23;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  /* Page gutter + width cap shared by the topbar and .container so the brand,
     the page title and the tables all start on the same vertical line. */
  --gutter: 1.5rem;
  --page-max: 1920px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- layout ---- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  /* On screens wider than --page-max the content is centred; keep the topbar
     contents on the same edges instead of hugging the window borders. */
  padding: 0 max(var(--gutter), calc((100% - var(--page-max)) / 2 + var(--gutter)));
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { font-weight: 700; font-size: 1rem; display: flex; align-items: center; color: var(--text); }
.topbar .brand:hover { text-decoration: none; }
/* The uploaded logo (Administração › Site e SEO): as tall as the bar allows, never stretched. */
.topbar .brand img { height: 2.25rem; max-width: 13rem; object-fit: contain; display: block; }
.topbar nav { display: flex; gap: .25rem; flex: 1; }
.topbar nav a {
  padding: .5rem .85rem;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
}
.topbar nav a:hover { background: var(--bg); text-decoration: none; }
.topbar nav a.active { background: #eef2ff; color: var(--primary); }
.topbar .user { color: var(--muted); font-size: .85rem; }

.nav-dropdown { position: relative; }
.nav-dropdown > summary {
  padding: .5rem .85rem;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .3rem;
}
.nav-dropdown > summary::-webkit-details-marker { display: none; }
.nav-dropdown > summary:hover { background: var(--bg); }
.nav-dropdown.active > summary { background: #eef2ff; color: var(--primary); }
.nav-dropdown > summary::after { content: "▾"; font-size: .7rem; }
.nav-dropdown[open] > summary::after { content: "▴"; }
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 180px;
  padding: .3rem;
  z-index: 20;
}
.nav-dropdown-menu a {
  display: block;
  padding: .45rem .6rem;
  border-radius: 6px;
  color: var(--text);
  font-weight: 500;
  font-size: .88rem;
}
.nav-dropdown-menu a:hover { background: var(--bg); text-decoration: none; }
.nav-dropdown-menu a.active { background: #eef2ff; color: var(--primary); }

.container { max-width: var(--page-max); margin: 1.5rem auto; padding: 0 var(--gutter); }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  gap: 1rem;
}
.page-head h1 { font-size: 1.4rem; margin: 0; }

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.95); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(.95); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: .35rem .6rem; font-size: .8rem; }

/* Small circular icon action (e.g. "release back to CRM control") that
   shouldn't compete visually with the row's main buttons. */
.btn-icon {
  width: 1.6rem; height: 1.6rem; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .85rem; line-height: 1; background: var(--surface);
  border: 1px solid var(--border); color: var(--muted); cursor: pointer;
}
.btn-icon:hover { color: var(--text); border-color: var(--text); }

/* ---- cards ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
/* Two-up layout for form-ish pages (e.g. "Minha conta"): cards sit side by
   side on wide screens and stack on narrow ones. align-items:start keeps a
   short card from stretching to match a taller neighbour. */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 1rem; align-items: start; }
/* Inputs inside a wide card shouldn't stretch edge to edge. */
.form-narrow { max-width: 28rem; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.card h3 { margin: 0 0 .15rem; font-size: 1rem; }
.card .sub { color: var(--muted); font-size: .8rem; }
.card .details { margin: .75rem 0; font-size: .85rem; color: var(--muted); }
.card .details strong { color: var(--text); font-weight: 600; }
.card-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.card-unassigned { border-color: var(--amber); border-left-width: 3px; }
/* Grid items default to min-width:auto, so a single unshrinkable child (e.g. a
   <select> with a long option) would stretch the card past its column and clip
   whatever sits beside it. Let the card shrink to the column instead. */
.grid > .card { min-width: 0; }

/* "Enviar leads por:" sender selector next to the Leads page buttons. */
.dispatch-conn { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.dispatch-conn select {
  max-width: 24rem;
  padding: .45rem .6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

/* Connection sharing (superadmin): chips for the accounts already shared with,
   plus a collapsible checklist to add several accounts in one go. */
.share-chip { background: var(--muted); margin: .15rem .25rem 0 0; max-width: 100%; overflow-wrap: anywhere; }
.share-picker { margin-top: .4rem; }
.share-picker > summary { cursor: pointer; color: var(--primary); font-weight: 500; }
.share-list {
  max-height: 11rem;
  overflow-y: auto;
  margin: .4rem 0;
  padding: .2rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.share-opt {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  padding: .3rem .4rem;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}
.share-opt:hover { background: var(--bg); }
.share-opt input { margin-top: .2rem; flex-shrink: 0; }
.share-opt > span { min-width: 0; overflow-wrap: anywhere; }
.share-email { display: block; color: var(--muted); font-size: .78rem; }

/* ---- badges ---- */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  color: #fff;
}
.badge-active { background: var(--green); }
.badge-inactive { background: var(--red); }
.badge-connected { background: var(--green); }
.badge-disconnected { background: var(--red); }

/* ---- limit bar ---- */
.limit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
}
.limit-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: .6rem; }
.limit-track { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.limit-fill { height: 100%; background: var(--primary); border-radius: 999px; }
.limit-fill.full { background: var(--red); }
.limit-note { color: var(--muted); font-size: .82rem; margin: .5rem 0 0; }

/* ---- tables ---- */
/* Every table lives in a .table-wrap: it carries the card look and scrolls
   horizontally when the columns need more room than the viewport has, so the
   table can never end up wider than the toolbar/title above it. */
.table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--bg); font-weight: 600; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }

/* Wide data tables (leads, email log): keep cells on one line and let the one
   .cell-grow column (the free-text subject) soak up the leftover width,
   truncating with an ellipsis instead of pushing the other columns around. */
table.table-fit td, table.table-fit th { white-space: nowrap; }
table.table-fit td.cell-grow {
  width: 100%;
  min-width: 14rem;
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
td input[type="number"] { width: 4rem; padding: .3rem .4rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; }

/* Shared look for inline table fields (phone, WhatsApp group id, role
   select, etc) — use this class instead of matching on [type=...] so every
   such field gets the same size/border/focus treatment regardless of tag. */
.field-input {
  width: 100%;
  max-width: 10.5rem;
  padding: .3rem .5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  text-align: left;
  display: block;
  background: var(--surface);
  color: var(--text);
}
.field-input:focus, td input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ---- switch (toggle) ---- */
.switch { position: relative; display: inline-flex; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 34px;
  height: 19px;
  background: var(--border);
  border-radius: 999px;
  transition: background .15s;
  flex-shrink: 0;
}
.switch-track::before {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
  transition: transform .15s;
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::before { transform: translateX(15px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px rgba(37,99,235,.25); }
.switch input:disabled + .switch-track { opacity: .45; }
.switch:has(input:disabled) { cursor: not-allowed; }

/* ---- tabs (simple, no JS framework — see switchCrmTab) ---- */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tab-btn {
  padding: .5rem .9rem;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
a.tab-btn { text-decoration: none; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---- forms ---- */
.field { margin-bottom: .85rem; }
.field label { display: block; font-weight: 500; margin-bottom: .3rem; font-size: .85rem; }
.field input, .field select {
  width: 100%;
  padding: .5rem .65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: var(--surface);
}

/* ---- modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 420px;
  width: 100%;
  /* Taller than the screen: scroll inside the dialog instead of clipping top and bottom. */
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
}
.modal h2 { margin: 0 0 1rem; font-size: 1.15rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; flex-wrap: wrap; }
/* Dense action row (lead detail modal: up to five small buttons). */
.modal-actions-sm { gap: .4rem; margin-top: 1rem; }
.qr-box { display: flex; justify-content: center; margin: 1rem 0; }
.qr-box img { width: 260px; height: 260px; border: 1px solid var(--border); border-radius: 8px; }
.qr-status { display: flex; align-items: center; gap: .5rem; justify-content: center; color: var(--muted); font-size: .9rem; }

/* ---- lead list import dialog (leadsimport.html) ---- */
.modal-wide { max-width: 940px; max-height: 92vh; overflow-y: auto; }
.modal input[type="file"].drop {
  padding: 1rem; border: 2px dashed var(--border); border-radius: 10px;
  background: var(--bg); cursor: pointer;
}
.modal input[type="file"].drop:hover { border-color: var(--primary); }
.import-options, .import-map {
  display: grid; gap: 0 .85rem;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.import-file { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin: .25rem 0 .5rem; }
.import-h { margin: 1rem 0 .5rem; font-size: .95rem; }
.import-stats { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .75rem; align-items: center; }
.badge-muted { background: var(--muted); }
.badge-warn { background: var(--amber); }
.import-origin { flex-wrap: wrap; }
.import-origin select {
  padding: .45rem .65rem; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; background: var(--surface); min-width: 15rem; max-width: 100%;
}
.import-origin-warn { flex-basis: 100%; font-size: .8rem; }

/* ---- "Distribuir leads pendentes" progress (leadsdistribute.html) ---- */
.progress { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; margin: .5rem 0 .6rem; }
.progress > div { height: 100%; background: var(--primary); transition: width .3s; }
.dist-failures { margin: 0 0 .5rem; padding-left: 1.1rem; font-size: .85rem; }
.dist-failures li { margin-bottom: .25rem; }

/* ---- misc ---- */
.banner {
  display: flex; gap: .6rem; align-items: center;
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .88rem;
}
.banner-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 2rem; width: 100%; max-width: 360px; }
.login-box h1 { margin: 0 0 1.25rem; font-size: 1.3rem; text-align: center; }
/* Public account pages (signup, confirmation, "esqueci a senha") share the login box, a bit wider. */
.login-box.wide { max-width: 420px; }
/* The signup form: wider, fields side by side, so it fits without scrolling. */
.login-box.xwide { max-width: 640px; }
.auth-grid { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
@media (min-width: 600px) { .auth-grid { grid-template-columns: 1fr 1fr; } }
.auth-brand { color: inherit; text-decoration: none; }
.auth-title { margin: 0 0 .5rem; font-size: 1.15rem; text-align: center; }
.auth-text { margin: 0 0 1rem; color: var(--muted); font-size: .9rem; text-align: center; line-height: 1.5; }
.auth-text strong { color: var(--text, inherit); }
.auth-hint { display: block; margin-top: .25rem; color: var(--muted); font-size: .78rem; }
.auth-actions { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.auth-actions .btn { justify-content: center; }
.auth-foot { margin: 1rem 0 0; text-align: center; font-size: .85rem; color: var(--muted); }
.auth-foot a, .auth-forgot { color: var(--primary); }
.auth-forgot { display: inline-block; margin-top: .35rem; font-size: .8rem; }
.auth-plan { background: var(--bg, #f3f4f6); border: 1px solid var(--border); border-radius: 8px; padding: .55rem .75rem; margin-bottom: 1rem; font-size: .85rem; text-align: center; }
/* Termos de Uso e Política de Privacidade: a long text, read on a phone as often as on a desktop. */
.legal-page { max-width: 820px; margin: 0 auto; padding: 1rem 1rem 3rem; }
.legal-nav { display: flex; flex-wrap: wrap; gap: .5rem 1rem; justify-content: space-between; align-items: center; padding: .5rem 0 1rem; font-size: .85rem; }
.legal-brand { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.legal-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 1.5rem 1.25rem; line-height: 1.65; }
.legal-card h1 { margin: 0 0 .25rem; font-size: 1.5rem; }
.legal-card h2 { margin: 1.75rem 0 .5rem; font-size: 1.05rem; scroll-margin-top: 1rem; }
.legal-card p, .legal-card li { font-size: .93rem; }
.legal-card ul { padding-left: 1.2rem; }
.legal-date { margin: 0 0 1rem; color: var(--muted); font-size: .85rem; }
.legal-foot { margin: 1rem 0 0; text-align: center; color: var(--muted); font-size: .8rem; }
@media (min-width: 700px) { .legal-card { padding: 2.25rem 2.5rem; } }
.auth-legal { margin: 1rem 0 0; text-align: center; font-size: .78rem; color: var(--muted); }
.auth-legal a { color: var(--muted); text-decoration: underline; }
.chk-group.auth-accept label { font-size: .85rem; font-weight: 400; line-height: 1.4; white-space: normal; align-items: flex-start; }
.auth-accept input { margin-right: .4rem; }
.auth-code { font-size: 1.6rem; letter-spacing: .35rem; text-align: center; }
.auth-more { margin-top: 1rem; font-size: .85rem; }
.auth-more summary { cursor: pointer; color: var(--muted); }
.auth-more form { margin-top: .75rem; }
/* The field only a robot sees: out of the screen, not display:none (some robots skip those). */
.auth-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.form-error { color: var(--red); font-size: .85rem; margin-bottom: .75rem; }
.form-success { color: var(--green); font-size: .85rem; margin-bottom: .75rem; }
.muted { color: var(--muted); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toolbar {
  display: flex;
  gap: .6rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .65rem .85rem;
}
.toolbar label { color: var(--muted); font-size: .82rem; font-weight: 500; white-space: nowrap; }
.toolbar select, .toolbar input {
  padding: .45rem .65rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  font: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.toolbar select:focus, .toolbar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.toolbar input::placeholder { color: #9aa1ad; }
.toolbar .search { flex: 1; max-width: 360px; }
.pager { display: flex; gap: .5rem; justify-content: center; margin-top: 1rem; }

/* Group of small labelled checkboxes (atuação: Corretor / Venda / Locação).
   .field input is full-width by default; undo that for checkboxes. */
.chk-group { display: flex; flex-wrap: wrap; gap: .25rem .85rem; }
.chk-group label { display: inline-flex; align-items: center; gap: .3rem; font-size: .82rem; white-space: nowrap; cursor: pointer; margin: 0; font-weight: 400; }
.field .chk-group input, .chk-group input { width: auto; padding: 0; margin: 0; }

/* ---- scheduled social posts (social.html, social.js) ---- */
.field textarea {
  width: 100%;
  padding: .5rem .65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: var(--surface);
  resize: vertical;
}
.badge-blue { background: var(--primary); }
.badge-orange { background: #f97316; }
.btn-danger-outline { color: var(--red); border-color: #fecaca; }
.btn-danger-outline:hover { background: #fef2f2; }

/* Wide: three equal columns. The form is two cards (1: the post, 2: the file and when), the viewer is
   the third column all the way down (sticky, scrolling inside itself when the mockups are taller than
   the screen), and under the form: the agendas below column 1, the recurrences below column 2, then
   the history. Medium: two columns, form / viewer / lists. Narrow: one column. */
.social-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.social-form { grid-column: 1 / span 2; grid-row: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem; align-items: stretch; min-width: 0; scroll-margin-top: 72px; }
.social-col { display: flex; flex-direction: column; min-width: 0; }
.social-viewer { grid-column: 3; grid-row: 1 / span 4; position: sticky; top: 72px; min-width: 0;
  max-height: calc(100vh - 88px); overflow-y: auto; }
.list-agendas { grid-column: 1; grid-row: 2; }
.list-series { grid-column: 2; grid-row: 2; }
.social-filters { grid-column: 1 / span 2; grid-row: 3; margin: 0; }
.list-history { grid-column: 1 / span 2; grid-row: 4; }
.social-lists { display: contents; }
@media (max-width: 1280px) {
  .social-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .social-form { grid-column: 1 / -1; grid-row: 1; }
  .social-viewer { grid-column: 1 / -1; grid-row: 2; position: static; max-height: none; overflow: visible; }
  .list-agendas { grid-column: 1; grid-row: 3; }
  .list-series { grid-column: 2; grid-row: 3; }
  .social-filters { grid-column: 1 / -1; grid-row: 4; }
  .list-history { grid-column: 1 / -1; grid-row: 5; }
}
@media (max-width: 760px) {
  .social-grid { grid-template-columns: minmax(0, 1fr); }
  .social-form { grid-template-columns: minmax(0, 1fr); }
  .list-agendas { grid-column: 1; grid-row: 3; }
  .list-series { grid-column: 1; grid-row: 4; }
  .social-filters { grid-row: 5; }
  .list-history { grid-row: 6; }
}
.social-form [hidden], .social-grid [hidden], .emoji-pop[hidden] { display: none !important; }

.social-file { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.social-existing { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; padding: .25rem; }

/* Destinations in the form: just a list of switches (the limits of the format are the tooltip). */
.dest-list { display: grid; gap: .4rem; }
.dest { display: grid; gap: .3rem; min-width: 0; padding: .45rem .65rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; }
.dest:has(input[name="dest"]:checked) { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.12); }
.dest-off, .dest.incompat { opacity: .65; }
.field .dest-head { display: flex; align-items: center; gap: .5rem; margin: 0; font-weight: 600; font-size: .85rem; cursor: pointer; }
.dest .switch input { width: 0; height: 0; padding: 0; border: 0; }
.dest-warn { margin: 0; font-size: .74rem; color: var(--red); }
.dest-warn.soft { color: #b45309; }
.dest-missing { margin: 0; padding: .35rem .5rem; font-size: .76rem; color: #92400e; background: #fffbeb;
  border: 1px solid #fde68a; border-radius: 8px; }
.field select.dest-target { font-size: .78rem; padding: .3rem .4rem; }

/* The right-hand panel: the mockups of the destinations, or the details of a post opened from the
   lists (the .viewer-detail hides the mockups until "Voltar"). */
.viewer-bar { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .25rem .75rem; margin-bottom: .85rem; }
.social-viewer:has(.viewer-detail) #social-preview { display: none; }

/* The mockups: a 9:16 phone screen for stories and Reels, a card for the Facebook feed. The file, the
   account name and the caption are put in by social.js. Everything inside a mockup is in em, and the
   font grows with the width of its box, so the mockup scales as a whole. */
/* Only the destinations that are switched on are shown, two side by side (three: two above, one
   below). A mockup is as wide as fits the screen's height for the rows it takes: --rows is 1 with one
   or two mockups and 2 from three on (more than four scroll inside the panel); never narrower than
   170px. */
.pv-grid { --rows: 2; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem .8rem; justify-items: center; align-items: start; }
.pv-grid[data-count="0"], .pv-grid[data-count="1"] { grid-template-columns: minmax(0, 1fr); }
.pv-grid[data-count="1"], .pv-grid[data-count="2"] { --rows: 1; }
.pvbox { container-type: inline-size; margin: 0; width: 100%; min-width: 0;
  max-width: max(170px, calc(((100vh - 11rem) / var(--rows) - 2.4rem) * 9 / 16)); }
.pvbox:not(.on) { display: none; }
.pvbox figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .4rem; font-size: .85rem; }
.pvbox-state { font-size: .72rem; font-weight: 600; color: var(--red); }
.pv { position: relative; overflow: hidden; border-radius: 1.1em; background: #111827; color: #fff;
  font-size: .8rem; font-size: clamp(.7rem, 4.6cqw, 1.05rem); line-height: 1.25; }
.pv-story, .pv-reels { aspect-ratio: 9 / 16; }
.pv-media { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #1f2937; }
.pv-media img, .pv-media video { display: block; width: 100%; height: 100%; object-fit: cover; }
.pv-empty { padding: 0 .8em; color: rgba(255,255,255,.55); font-size: 1.05em; text-align: center; }
.pv-top { position: absolute; top: 0; left: 0; right: 0; padding: .6em .7em 1.4em; background: linear-gradient(rgba(0,0,0,.55), transparent); }
.pv-bar { display: block; height: 2px; margin-bottom: .5em; border-radius: 2px; background: rgba(255,255,255,.85); }
.pv-who { display: flex; align-items: center; gap: .5em; min-width: 0; }
.pv-avatar { display: inline-block; flex-shrink: 0; width: 1.9em; height: 1.9em; border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #ec4899, #8b5cf6); }
.pv-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-who small { opacity: .75; font-size: .85em; white-space: nowrap; }
.pv-reply { position: absolute; left: .7em; right: .7em; bottom: .7em; padding: .4em .9em; border: 1px solid rgba(255,255,255,.7);
  border-radius: 999px; opacity: .9; }
.pv-cap { white-space: pre-wrap; word-break: break-word; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.pv-cap:empty { display: none; }
.pv-cap-center { position: absolute; left: 0; right: 0; bottom: 0; padding: 1.6em .8em .8em; text-align: center;
  background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.pv-side { position: absolute; right: .6em; bottom: 5.5em; display: flex; flex-direction: column; gap: .9em; font-size: 1.5em; text-align: center; }
.pv-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: grid; gap: .4em; padding: 1.6em .8em .8em;
  background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.pv-fb-feed, .pv-ig-feed { background: #fff; color: var(--text); border: 1px solid var(--border); }
.pv-fb-feed .pv-media, .pv-ig-feed .pv-media { position: relative; inset: auto; aspect-ratio: 4 / 5; background: #e5e7eb; }
.pv-fb-feed .pv-empty, .pv-ig-feed .pv-empty { color: var(--muted); }
.pv-feedhead { display: flex; align-items: center; gap: .6em; padding: .7em .8em; }
.pv-feedhead > div { display: grid; min-width: 0; }
.pv-feedhead small { color: var(--muted); font-size: .85em; }
.pv-fb-feed .pv-cap { padding: 0 .8em .6em; -webkit-line-clamp: 3; }
.pv-ig-feed .pv-cap { padding: 0 .8em .8em; -webkit-line-clamp: 3; }
.pv-igfoot { justify-content: space-between; padding: .5em .8em; border-top: 0; color: var(--text); font-size: 1.1em; }
.pv-feedfoot { display: flex; justify-content: space-around; padding: .6em .4em; border-top: 1px solid var(--border); color: var(--muted); font-size: .9em; }
.social-recbox { border: 1px solid var(--border); border-radius: 8px; padding: .75rem; margin-bottom: .85rem; display: grid; gap: .75rem; }
.rec-times { display: flex; flex-wrap: wrap; gap: .75rem; }
.social-buttons { display: flex; flex-wrap: wrap; gap: .5rem; }
.social-actions { margin-top: auto; display: grid; gap: .6rem; }
.social-error:empty { display: none; }
.social-error { margin: 0; }
/* Medium screens: the viewer is a full-width band, so its mockups sit in as many columns as fit. */
@media (max-width: 1280px) {
  .pv-grid, .pv-grid[data-count="1"], .pv-grid[data-count="0"] { --rows: 1; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
}

/* Weekday buttons: a checkbox hidden behind a label that looks like a pill. */
.wd-pills { display: flex; flex-wrap: wrap; gap: .35rem; }
.field .wd { position: relative; display: inline-block; margin: 0; font-weight: 500; }
.field .wd input { position: absolute; opacity: 0; width: 0; height: 0; padding: 0; }
.wd span {
  display: inline-flex; align-items: center; justify-content: center; width: 3rem; height: 2rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  font-size: .78rem; font-weight: 500; color: var(--muted); cursor: pointer;
}
.wd input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.wd input:focus-visible + span { box-shadow: 0 0 0 3px rgba(37,99,235,.25); }

.emoji-wrap { position: relative; }
.emoji-pop {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; width: 21.5rem; max-width: 80vw;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: .5rem;
}
.emoji-tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); padding-bottom: .4rem; }
.emoji-tabs button, .emoji-grid button { border: 0; background: none; border-radius: 6px; cursor: pointer; font-size: 1.15rem; line-height: 1; padding: .3rem; }
.emoji-tabs button:hover, .emoji-tabs button.on, .emoji-grid button:hover { background: var(--bg); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; height: 14rem; overflow-y: auto; align-content: start; margin-top: .4rem; }

/* Lists: the three cards are placed in the page grid (see .list-agendas, .list-series, .list-history). */
.social-list { padding: 0; overflow: hidden; min-width: 0; }
.social-list > h3, .social-list .list-head { padding: .8rem 1rem; margin: 0; border-bottom: 1px solid var(--border); }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.social-list ul { list-style: none; margin: 0; padding: 0; }
.list-agendas ul, .list-series ul { max-height: 15rem; overflow-y: auto; }
.post-row { display: flex; align-items: center; gap: .7rem; padding: .6rem 1rem; border-top: 1px solid var(--border); cursor: pointer; }
.post-row:first-child { border-top: 0; }
.post-row:hover { background: var(--bg); }
.post-row.selected { background: #eef2ff; }
.post-row.faded { opacity: .7; }
.row-main { flex: 1; min-width: 0; }
.row-main p { margin: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; flex-shrink: 0; }
.social-grid .sm { font-size: .8rem; margin: 0; }
.social-grid .ok { color: #047857; }
.social-grid .err { color: var(--red); overflow-wrap: anywhere; }
.social-grid .thumb { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--bg); flex-shrink: 0; }
.social-grid .thumb-empty { display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }

/* Selecting history rows to delete in bulk. */
.row-check { display: none; align-items: center; margin: 0; }
.social-selecting #social-history .row-check { display: flex; }
.sel-only { display: none; gap: .4rem; }
.social-selecting .sel-only { display: inline-flex; }
.social-selecting [data-select-toggle] { display: none; }

/* The details of a post: the file on the left, what is known about it on the right. */
.viewer-detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
.viewer-detail > .viewer-bar, .viewer-detail > .form-error, .viewer-detail > .form-success { margin: 0; }
@media (max-width: 1280px) and (min-width: 761px) {
  .viewer-detail { grid-template-columns: minmax(0, 360px) minmax(0, 1fr); }
  .viewer-detail > .viewer-bar, .viewer-detail > .form-error, .viewer-detail > .form-success { grid-column: 1 / -1; }
}
.social-stage { background: #0b0f19; border-radius: 8px; display: flex; align-items: center; justify-content: center; min-height: 10rem; overflow: hidden; }
.social-stage img, .social-stage video { display: block; max-width: 100%; max-height: 55vh; }
.social-stage p { margin: 0; padding: 2.5rem 1rem; color: rgba(255,255,255,.7); font-size: .8rem; text-align: center; }
.social-info { display: grid; gap: .3rem; }
.social-info p { margin: 0; }
.social-title { font-weight: 600; word-break: break-word; }
.social-caption { white-space: pre-wrap; word-break: break-word; }
.social-caption:empty { display: none; }
.social-actions-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
