/* WSoft Personal — estilos do painel
   As cores da marca ficam nas variáveis abaixo para facilitar ajustes. */

:root {
  --brand-900: #0a1f47;
  --brand-800: #0d2d66;
  --brand-700: #134a9e;
  --brand-600: #1a5fd6;
  --brand-500: #1f6fe8;
  --brand-100: #e6eeff;
  --brand-50:  #f2f6ff;

  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cdd5df;
  --text: #0f1b2d;
  --text-2: #475467;
  --text-3: #6b7a90;

  --success: #12805c;  --success-bg: #e6f6ef;
  --warning: #a15c07;  --warning-bg: #fff4e0;
  --danger:  #c02f2f;  --danger-bg:  #fdecec;
  --info:    #1f4fd1;  --info-bg:    #e9f0ff;
  --neutral: #4b5565;  --neutral-bg: #eef1f5;
  --purple:  #6941c6;  --purple-bg:  #f1ecfd;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --sidebar-w: 248px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; color: var(--text); }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--text-3); }
.icon { flex-shrink: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85em; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }

/* ---------- Layout ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--brand-900); color: #c7d2e3;
  padding: 18px 14px; z-index: 40;
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.sidebar__brand strong { display: block; color: #fff; font-size: 1.05rem; letter-spacing: .2px; }
.sidebar__brand span { display: block; font-size: .78rem; color: #8ea0bd; }
.sidebar .sidebar__close { display: none; margin-left: auto; color: #c7d2e3; }
.sidebar__nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: #c7d2e3; font-weight: 500; font-size: .95rem;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link.is-active { background: var(--brand-600); color: #fff; }
.nav-link--button { width: 100%; background: none; border: 0; cursor: pointer; font: inherit; }
.sidebar__footer { border-top: 1px solid rgba(255,255,255,.08); padding-top: 14px; display: grid; gap: 8px; }
.sidebar__user { display: flex; align-items: center; gap: 10px; padding: 0 8px; min-width: 0; }
.sidebar__user div { min-width: 0; }
.sidebar__user strong { display: block; color: #fff; font-size: .9rem; }
.sidebar__user span { display: block; font-size: .78rem; color: #8ea0bd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700;
  background: var(--brand-700); color: #fff;
}
.sidebar-backdrop { display: none; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: 60px; padding: 0 28px;
  background: rgba(244, 246, 250, .9); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.topbar .topbar__menu { display: none; }
.topbar__title { font-weight: 600; color: var(--text-2); }
.env-pill {
  margin-left: auto; font-size: .78rem; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  background: var(--warning-bg); color: var(--warning); border: 1px solid #f5d7a8;
}
.content { padding: 28px; width: 100%; max-width: 1280px; }

/* ---------- Cabeçalho de página ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 + p { margin-top: 4px; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: .9rem; margin-bottom: 8px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px;
}
.card + .card { margin-top: 20px; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card__title { margin-bottom: 16px; }
.card__head .card__title { margin: 0; }
.card--flush { padding: 0; }
.card--flush .card__head { padding: 18px 22px 0; }
.empty { text-align: center; color: var(--text-3); padding: 40px 20px; }
.empty .icon { color: var(--border-strong); margin-bottom: 8px; }
.empty p + .btn { margin-top: 14px; }

.grid { display: grid; gap: 20px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid > .card + .card { margin-top: 0; }

/* Indicadores */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; display: flex; gap: 14px; align-items: flex-start;
  color: inherit;
}
a.kpi:hover { text-decoration: none; border-color: var(--border-strong); }
.kpi__icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.kpi__label { font-size: .85rem; color: var(--text-3); font-weight: 500; }
.kpi__value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi__hint { font-size: .78rem; color: var(--text-3); margin-top: 2px; }
.tone-info    { background: var(--info-bg); color: var(--info); }
.tone-success { background: var(--success-bg); color: var(--success); }
.tone-warning { background: var(--warning-bg); color: var(--warning); }
.tone-danger  { background: var(--danger-bg); color: var(--danger); }
.tone-neutral { background: var(--neutral-bg); color: var(--neutral); }
.tone-purple  { background: var(--purple-bg); color: var(--purple); }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
  text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-3); font-weight: 600; padding: 12px 16px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .cell-main { font-weight: 600; color: var(--text); }
.table .cell-sub { display: block; font-size: .8rem; color: var(--text-3); font-weight: 400; }
.table a.cell-main:hover { color: var(--brand-600); }
.card--flush .table th:first-child, .card--flush .table td:first-child { padding-left: 22px; }
.card--flush .table th:last-child, .card--flush .table td:last-child { padding-right: 22px; }

/* ---------- Etiquetas de status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--warning { background: var(--warning-bg); color: var(--warning); }
.badge--danger  { background: var(--danger-bg); color: var(--danger); }
.badge--info    { background: var(--info-bg); color: var(--info); }
.badge--neutral { background: var(--neutral-bg); color: var(--neutral); }
.badge--purple  { background: var(--purple-bg); color: var(--purple); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: background .15s, border-color .15s, box-shadow .15s; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn:focus-visible, .icon-btn:focus-visible, .nav-link:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(47, 107, 255, .35); outline-offset: 1px;
}
.btn--primary { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn--primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { background: #a32626; }
.btn--ghost-danger { color: var(--danger); border-color: #f2c4c4; }
.btn--ghost-danger:hover { background: var(--danger-bg); }
.btn--sm { min-height: 32px; padding: 4px 12px; font-size: .85rem; }
.btn--block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .65; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; background: none; border-radius: var(--radius-sm); color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: rgba(15, 27, 45, .06); }

/* ---------- Formulários ---------- */
.form { display: grid; gap: 16px; align-content: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.form-grid .span-2 { grid-column: span 2; }
.field { display: grid; gap: 6px; align-content: start; }
.field label { font-weight: 600; font-size: .88rem; color: var(--text-2); }
.req { color: var(--danger); }
.field input, .field select, .field textarea, .filters input, .filters select {
  width: 100%; min-height: 42px; padding: 9px 12px;
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .filters input:focus, .filters select:focus {
  border-color: var(--brand-500);
}
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field__help { color: var(--text-3); font-size: .8rem; }
.field__error { color: var(--danger); font-size: .82rem; font-weight: 500; }
.field--check { grid-template-columns: auto 1fr; align-items: center; }
.field--check input { width: 18px; min-height: 18px; order: -1; }
.form__actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding-top: 4px; }

/* Filtros de lista */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.filters .filter { display: grid; gap: 4px; min-width: 150px; flex: 1; }
.filters .filter--grow { flex: 3; min-width: 220px; }
.filters label { font-size: .76rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.filters input, .filters select { height: 40px; min-height: 40px; padding: 0 10px; line-height: normal; }
.filters .btn { height: 40px; min-height: 40px; }
.search-input { position: relative; }
.search-input .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search-input input { padding-left: 36px; }

/* ---------- Detalhes (lista de definição) ---------- */
.details { display: grid; gap: 0; margin: 0; }
.details > div { display: grid; grid-template-columns: 180px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.details > div:last-child { border-bottom: 0; }
.details dt { color: var(--text-3); font-size: .88rem; }
.details dd { margin: 0; font-weight: 500; word-break: break-word; }

/* ---------- Alertas ---------- */
.alerts { display: grid; gap: 10px; margin-bottom: 20px; }
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm); font-size: .92rem; border: 1px solid transparent;
}
.alert > span { flex: 1; padding-top: 1px; }
.alert--success { background: var(--success-bg); color: #0b5d43; border-color: #bfe8d6; }
.alert--error   { background: var(--danger-bg); color: #8f1f1f; border-color: #f4c7c7; }
.alert--warning { background: var(--warning-bg); color: #7a4504; border-color: #f5d7a8; }
.alert--info    { background: var(--info-bg); color: #173f9e; border-color: #c9d8ff; }
.alert__close { width: 26px; height: 26px; color: inherit; margin: -3px -4px 0 0; }

/* Caixa de link copiável */
.copy-box { display: flex; gap: 8px; align-items: stretch; }
.copy-box input { flex: 1; min-width: 0; min-height: 40px; padding: 8px 12px; font: inherit; font-size: .88rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-2); }

/* Paginação */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 22px; border-top: 1px solid var(--border); font-size: .88rem; color: var(--text-3); flex-wrap: wrap; }
.pagination__links { display: flex; gap: 6px; }

/* ---------- Modal de confirmação ---------- */
dialog.modal {
  border: 0; border-radius: var(--radius); padding: 0; width: min(460px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg); color: var(--text);
}
dialog.modal::backdrop { background: rgba(11, 27, 51, .55); }
.modal__body { padding: 24px; display: grid; gap: 10px; }
.modal__icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--danger-bg); color: var(--danger); }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; background: var(--surface-2); border-top: 1px solid var(--border); }

/* ---------- Login ---------- */
.auth-page { background: linear-gradient(135deg, #1f6fe8 0%, #0d3a8a 55%, #0a2a6b 100%); }
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth__panel { width: 100%; max-width: 420px; background: var(--surface); border-radius: 16px; padding: 32px; box-shadow: var(--shadow-lg); }
.auth__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth__brand strong { display: block; font-size: 1.1rem; }
.auth__brand span { display: block; font-size: .82rem; color: var(--text-3); }
.auth__panel h1 { font-size: 1.35rem; }
.auth__panel .muted { margin: 4px 0 22px; }
.auth__footer { margin-top: 18px; color: rgba(255,255,255,.55); font-size: .82rem; }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .app.menu-open .sidebar { transform: none; }
  .app.menu-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(11, 27, 51, .5); z-index: 30; }
  .sidebar .sidebar__close { display: inline-grid; }
  .main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .topbar .topbar__menu { display: inline-grid; }
  .content { padding: 20px 16px; }
  .grid--2, .grid--3 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.3rem; }
  .kpis { gap: 10px; }
  .kpi { padding: 14px; flex-direction: column; gap: 10px; }
  .kpi__value { font-size: 1.25rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .details > div { grid-template-columns: 1fr; gap: 2px; }
  .page-head__actions, .page-head__actions .btn { width: 100%; }
  .form__actions .btn { flex: 1; }
  .filters { padding: 14px 16px; }
  .filters .filter { min-width: calc(50% - 5px); }
  .card { padding: 18px 16px; }
  .card--flush { padding: 0; }
  .card--flush .card__head { padding: 16px 16px 0; }
  .auth__panel { padding: 24px 20px; }

  /* Tabelas viram cartões no celular */
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table--stack tr:last-child { border-bottom: 0; }
  .table--stack td { border: 0; padding: 3px 0 !important; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table--stack td::before { content: attr(data-label); color: var(--text-3); font-size: .8rem; text-align: left; flex-shrink: 0; }
  .table--stack td.cell-first { display: block; text-align: left; padding-bottom: 6px !important; }
  .table--stack td.cell-first::before { content: none; }
  .table--stack .num { text-align: right; }
}

/* ---------- Assinaturas ---------- */
.grid--3-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.small { font-size: .82rem; }
.help-card .steps { margin: 0 0 14px; padding-left: 20px; display: grid; gap: 10px; color: var(--text-2); font-size: .92rem; }
.highlight-card { border-color: #c9d8ff; background: linear-gradient(180deg, var(--brand-50), var(--surface)); }
.highlight-card .card__title { margin-bottom: 4px; }
.highlight-card + .grid, .card + .grid, .grid + .card, .alert + .grid { margin-top: 20px; }
.link-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn--whatsapp { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn--whatsapp:hover { background: #178a45; border-color: #178a45; }
.page-head__actions form { display: contents; }
.alert form { margin-left: auto; }
.retorno { text-align: center; display: grid; gap: 12px; justify-items: center; }
@media (max-width: 900px) {
  .grid--3-1 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .copy-box { flex-direction: column; }
  .link-actions .btn { flex: 1; }
  .alert { flex-wrap: wrap; }
}

/* ---------- Dashboard e pagamentos ---------- */
.kpis + .card, .kpis + .grid, .dash-lists + .card { margin-top: 20px; }
.alert + .kpis { margin-top: 0; }
.alerts + .alert, .alert + .alert { margin-top: 10px; }
.alert + .kpis, .alert + .card { margin-top: 20px; }
.mini-list { list-style: none; margin: 0; padding: 8px 0 6px; }
.mini-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 22px; border-top: 1px solid var(--border); }
.mini-list li:first-child { border-top: 0; }
.mini-list .cell-main { font-weight: 600; color: var(--text); }
.mini-list .cell-sub { display: block; font-size: .8rem; color: var(--text-3); }
.totals { display: flex; gap: 22px; flex-wrap: wrap; padding: 12px 22px; font-size: .9rem; color: var(--text-2); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.text-success { color: var(--success); }
.page-note { margin-top: 14px; }
@media (max-width: 640px) {
  .mini-list li { padding: 10px 16px; }
  .totals { padding: 12px 16px; gap: 14px; }
}
.narrow-card { max-width: 560px; }
.card__head form { display: contents; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .85em; background: rgba(15,27,45,.06); padding: 1px 5px; border-radius: 4px; }
.form__actions--start { justify-content: flex-start; }
.highlight-card--danger { border-color: #f4c7c7; background: linear-gradient(180deg, var(--danger-bg), var(--surface)); }
.highlight-card + .highlight-card { margin-top: 20px; }
.cidade-uf { display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 12px; align-items: start; }
.field__help--ok { color: var(--success); }
.field__help--aviso { color: var(--warning); }
.field__help--erro { color: var(--danger); }
.link-actions form { display: contents; }
.mini-note { padding: 0 22px 14px; }
.auth__link { margin-top: 18px; text-align: center; font-size: .9rem; }
.auth__panel > .btn--block { margin-top: 18px; }
