/* MAX CRM — estilos */
:root {
  --blue: #1264d9; --blue-dark: #0d52b5; --blue-soft: #e8f0fc;
  --navy: #071d34; --navy-2: #0c2a4a;
  --ink: #0b1c32; --muted: #5e6b7c; --line: #dce4ec; --bg: #f3f6f9; --card: #fff;
  --ok: #15803d; --ok-bg: #e7f6ec; --warn: #b45309; --warn-bg: #fdf3e2; --err: #b91c1c; --err-bg: #fdecec;
  --radius: 10px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 "Segoe UI", Inter, system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { line-height: 1.25; }
h2 { font-size: 17px; margin: 0 0 12px; }
small { display: block; color: var(--muted); font-size: 12.5px; }
:focus-visible { outline: 3px solid #3385f6; outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 18px; height: 18px; flex-shrink: 0; vertical-align: -4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.lead { font-size: 16px; margin: 0 0 18px; }

/* Estrutura */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex-shrink: 0; background: var(--navy); color: #c9d6e4; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px 20px; color: #fff; }
.brand img { height: 46px; width: auto; }
.brand span { font-weight: 700; letter-spacing: 2px; font-size: 13px; color: #9fb0c3; border-left: 1px solid #ffffff33; padding-left: 10px; }
.brand:hover { text-decoration: none; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 8px; color: #c9d6e4; font-weight: 600; }
.sidebar nav a:hover { background: #ffffff12; text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--blue); color: #fff; }
.sidebar-foot { border-top: 1px solid #ffffff1a; padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.me { display: flex; align-items: center; gap: 10px; color: #fff; }
.me:hover { text-decoration: none; }
.me small { color: #9fb0c3; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--blue); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.link-btn { background: none; border: 0; color: #9fb0c3; font: inherit; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.link-btn:hover { color: #fff; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 16px 28px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 21px; margin: 0; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; cursor: pointer; color: var(--ink); }
.menu-btn .ic { width: 24px; height: 24px; }
.content { padding: 24px 28px 48px; max-width: 1280px; width: 100%; }

/* Componentes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.card.narrow { max-width: 720px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + section { margin-top: 18px; }
.empty { color: var(--muted); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #b8c6d4; text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--blue); min-height: 34px; padding: 0 10px; }
.btn-wa { background: #25d366; border-color: #25d366; color: #fff; min-height: 34px; }
.btn-danger { background: #fff; color: var(--err); border-color: #f1c4c4; }
.btn-danger:hover { background: var(--err-bg); }
.btn-block { width: 100%; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: #eef2f6; color: #44546a; white-space: nowrap; }
.s-ativo { background: var(--ok-bg); color: var(--ok); }
.s-em_risco { background: var(--warn-bg); color: var(--warn); }
.s-inativo, .s-bloqueado { background: var(--err-bg); color: var(--err); }
.s-prospect { background: var(--blue-soft); color: var(--blue-dark); }
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.alert-ok { background: var(--ok-bg); border-color: #bfe5cb; color: #14532d; }
.alert-erro { background: var(--err-bg); border-color: #f1c4c4; color: #7f1d1d; }
.alert-aviso { background: var(--warn-bg); border-color: #f3d9a8; color: #78350f; }
.warn { color: var(--warn); }

/* Painel */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; border-top: 4px solid var(--line); color: var(--ink); }
.stat:hover { text-decoration: none; border-color: #b8c6d4; }
.stat-label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.stat-value { display: block; font-size: 28px; font-weight: 800; }
.stat-ativo { border-top-color: var(--ok); }
.stat-em_risco { border-top-color: #f59e0b; }
.stat-inativo { border-top-color: var(--err); }
.stat-prospect { border-top-color: var(--blue); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid #eef2f6; }
.list li:first-child { border-top: 0; }
.list a { color: var(--ink); }
.roadmap { background: var(--blue-soft); border-color: #cddcf3; }

/* Tabelas */
.table-wrap { overflow-x: auto; padding: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #f8fafc; white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid #eef2f6; vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td a b { color: var(--ink); }
.table .num { text-align: right; }
.table tr.inactive td { opacity: .55; }
.table-compact th, .table-compact td { font-size: 12.5px; padding: 7px 10px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }

/* Formulários */
.form label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13.5px; margin-bottom: 14px; flex: 1; min-width: 0; }
.form small { font-weight: 400; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--ink); background: #fff; border: 1px solid #c9d4df; border-radius: 8px; padding: 9px 11px; min-height: 40px; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 2px solid #1264d933; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--blue); flex-shrink: 0; }
input[type="file"] { padding: 7px; }
.form .check, label.check { flex-direction: row; align-items: center; gap: 9px; font-weight: 500; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > label { flex: 1 1 180px; }
.row > .col-2 { flex: 2 1 300px; }
.row > .col-s { flex: 0 1 120px; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-weight: 700; font-size: 15px; margin-bottom: 12px; color: var(--navy-2); padding: 0; }
fieldset + fieldset { border-top: 1px solid #eef2f6; padding-top: 18px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex: 1; }
.filters label { margin: 0; }
.filters .grow { flex: 1 1 260px; }
.filters select { width: auto; }
.filters .check { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; padding: 14px 18px; }
.inline-form label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; }
.inline-form input { width: 120px; }
.subform { margin-top: 12px; border-top: 1px solid #eef2f6; padding-top: 12px; }
.subform summary { cursor: pointer; color: var(--blue); font-weight: 700; margin-bottom: 12px; }
.danger-zone { margin-top: 8px; }
.dl { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13.5px; }
.dl dd { margin: 0; }
.obs { background: #f8fafc; border-radius: 8px; padding: 10px 12px; margin: 14px 0 0; white-space: normal; }
.contacts { list-style: none; margin: 0; padding: 0; }
.contacts li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid #eef2f6; flex-wrap: wrap; }
.contacts li:first-child { border-top: 0; }
.contacts form { display: inline; }
.list form { display: inline; }

/* Importação */
.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 18px; counter-reset: s; flex-wrap: wrap; }
.steps li { counter-increment: s; display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; font-size: 14px; }
.steps li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: #e2e8ef; font-size: 13px; }
.steps li + li::after { order: -1; content: ""; width: 26px; height: 2px; background: var(--line); }
.steps .current { color: var(--ink); }
.steps .current::before { background: var(--blue); color: #fff; }
.steps .done::before { content: "✓"; background: var(--ok); color: #fff; }
.choice { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.choice .check { border: 1px solid var(--line); border-radius: 8px; padding: 12px; align-items: flex-start; }
.choice .check span { display: flex; flex-direction: column; }
.bullets { padding-left: 18px; margin: 0 0 12px; }
.bullets li { margin-bottom: 6px; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 14px; margin-bottom: 8px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; font-size: 13px; color: var(--ink); }
.tab.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.confirm-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.confirm-bar p { margin: 0; }

/* Login / instalação */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, var(--navy) 0%, #0c3a6b 100%); }
.auth-card { background: #fff; width: 100%; max-width: 420px; border-radius: 14px; padding: 32px 28px; box-shadow: 0 20px 50px #0005; }
.auth-card h1 { font-size: 21px; margin: 0 0 14px; }
.auth-logo { display: block; height: 70px; width: auto; margin: 0 auto 22px; }

/* Celular */
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; visibility: hidden; }
  .sidebar.open { transform: none; visibility: visible; box-shadow: 0 0 40px #0006; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 18px 16px 40px; }
  .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dl { grid-template-columns: 130px 1fr; }
}
@media (max-width: 640px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .table td { border: 0; padding: 4px 14px; display: flex; gap: 10px; }
  .table td[data-label]::before { content: attr(data-label); flex: 0 0 110px; color: var(--muted); font-size: 12.5px; }
  .table td > a, .table td > span, .table td > b { min-width: 0; }
  .table .num { text-align: left; }
  .filters select { flex: 1 1 140px; }
  .toolbar > .btn, .toolbar > .actions { width: 100%; }
  .toolbar > .btn { justify-content: center; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
