/* Atlas Pay - identidade visual Atlas Desenvolvimento Web (azul-marinho + ciano) */
:root {
  --bg: #040a14;
  --bg-2: #07101f;
  --surface: #0a1624;
  --surface-2: #0f1f33;
  --border: rgba(63, 208, 255, .14);
  --border-strong: rgba(63, 208, 255, .32);
  --text: #e8f1fa;
  --muted: #8aa0b8;
  --accent: #3fd0ff;
  --accent-2: #0a8fc4;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; font-family: var(--font); font-size: 15px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  background-image: radial-gradient(900px 420px at 85% -10%, rgba(63, 208, 255, .10), transparent 60%),
                    radial-gradient(700px 380px at -10% 10%, rgba(10, 143, 196, .10), transparent 60%);
  background-attachment: fixed;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Cabeçalho ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; backdrop-filter: blur(14px);
  background: rgba(4, 10, 20, .82); border-bottom: 1px solid var(--border);
}
.topbar__in { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: .02em; }
.brand:hover { text-decoration: none; }
.brand img { width: 36px; height: 36px; object-fit: contain; filter: drop-shadow(0 0 8px rgba(63, 208, 255, .35)); }
.brand small { display: block; font-size: .68rem; font-weight: 500; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a { color: var(--muted); padding: 8px 14px; border-radius: 999px; font-weight: 500; font-size: .92rem; }
.nav a:hover { color: var(--text); text-decoration: none; background: rgba(63, 208, 255, .07); }
.nav a[aria-current="page"] { color: var(--accent); background: rgba(63, 208, 255, .12); }
.topbar__user { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: .85rem; color: var(--muted); min-width: 0; }
.topbar__user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

/* ---------- Layout ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.card { background: linear-gradient(180deg, var(--surface), var(--bg-2)); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card--pad { padding: 20px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row--end { justify-content: flex-end; }
.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- Botões ---------- */
.btn {
  appearance: none; border: 1px solid var(--border-strong); background: transparent; color: var(--text);
  font: inherit; font-weight: 600; font-size: .9rem; padding: 9px 16px; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: .18s; white-space: nowrap;
}
.btn:hover { background: rgba(63, 208, 255, .1); text-decoration: none; }
.btn:focus-visible, .input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #021019; border-color: transparent; box-shadow: 0 6px 22px -8px rgba(63, 208, 255, .65); }
.btn--primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn--danger { border-color: rgba(248, 113, 113, .5); color: var(--danger); }
.btn--danger:hover { background: rgba(248, 113, 113, .12); }
.btn--sm { padding: 6px 12px; font-size: .82rem; }
.btn--block { width: 100%; padding: 12px 16px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; filter: none; }

/* ---------- Formulários ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: .8rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.input, select.input, textarea.input {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: #4e6580; }
.input:hover { border-color: var(--border-strong); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(63, 208, 255, .15); outline: none; }
.input[readonly] { color: var(--muted); background: var(--bg-2); }
textarea.input { resize: vertical; min-height: 84px; }
.hint { font-size: .75rem; color: var(--muted); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); }
.form-grid .full { grid-column: 1 / -1; }
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: .88rem; border: 1px solid; }
.alert--erro { color: #fecaca; background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .35); }
.alert--info { color: #bae6fd; background: rgba(63, 208, 255, .08); border-color: var(--border-strong); }
.alert--aviso { color: #fde68a; background: rgba(251, 191, 36, .08); border-color: rgba(251, 191, 36, .35); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: .9rem; }
.switch input { accent-color: var(--accent); width: 18px; height: 18px; }

/* ---------- Filtros ---------- */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; padding: 14px 16px; margin-bottom: 14px; }
.filters .field { min-width: 170px; flex: 1 1 170px; }

/* ---------- Tabelas (viram cartões no celular) ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid rgba(63, 208, 255, .07); vertical-align: middle; }
.table tbody tr:hover { background: rgba(63, 208, 255, .04); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn { margin-left: 6px; }
.cell-title { font-weight: 600; }
.cell-sub { font-size: .8rem; color: var(--muted); }
.table-foot { padding: 12px 16px; border-top: 1px solid var(--border); font-size: .85rem; color: var(--muted); display: flex; gap: 18px; flex-wrap: wrap; }
.table-foot strong { color: var(--text); }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ---------- Badges de status ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; border: 1px solid; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--pendente { color: var(--warn); background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .3); }
.badge--pago, .badge--ativo { color: var(--ok); background: rgba(52, 211, 153, .1); border-color: rgba(52, 211, 153, .3); }
.badge--atrasado, .badge--inativo { color: var(--danger); background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .3); }
.badge--cancelado, .badge--encerrado { color: var(--muted); background: rgba(138, 160, 184, .1); border-color: rgba(138, 160, 184, .3); }

/* ---------- Modal ---------- */
dialog.modal { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 0; width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: 0 30px 80px -20px #000; }
dialog.modal::backdrop { background: rgba(2, 6, 12, .75); backdrop-filter: blur(3px); }
.modal__head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal__body { padding: 20px 22px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); flex-wrap: wrap; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, .06); }

/* ---------- Toast ---------- */
#toasts { position: fixed; right: 16px; bottom: calc(16px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px; z-index: 200; max-width: calc(100vw - 32px); }
.toast { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-size: .9rem; animation: up .25s ease; }
.toast--ok { border-color: rgba(52, 211, 153, .5); } .toast--erro { border-color: rgba(248, 113, 113, .6); }
@keyframes up { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Área do cliente ---------- */
.hero { padding: 24px; display: flex; gap: 18px; justify-content: space-between; flex-wrap: wrap; align-items: center; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px 22px; }
.kv dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 2px; }
.kv dd { margin: 0; font-weight: 600; }
.progress { height: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 999px; }
.summary { display: flex; gap: 22px; flex-wrap: wrap; font-size: .9rem; color: var(--muted); }
.summary strong { color: var(--text); font-size: 1.1rem; display: block; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; padding: 11px 16px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--accent); border-color: var(--accent); }
.next-due { border-color: rgba(251, 191, 36, .4); }
.contract-pick { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--muted); padding: 8px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-size: .88rem; font-weight: 600; }
.chip[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: rgba(63, 208, 255, .1); }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth__card { width: min(420px, 100%); padding: 32px 28px; }
.auth__logo { display: grid; place-items: center; margin-bottom: 18px; }
.auth__logo img { width: 84px; filter: drop-shadow(0 0 18px rgba(63, 208, 255, .5)); }
.auth h1 { text-align: center; font-size: 1.5rem; }
.auth .sub { text-align: center; color: var(--muted); margin: 6px 0 22px; }
.credit { text-align: center; margin-top: 20px; font-size: .78rem; color: var(--muted); }
.credit a { color: var(--muted); }
.credit a:hover { color: var(--accent); }
.footer { text-align: center; padding: 24px 16px 36px; font-size: .78rem; color: var(--muted); border-top: 1px solid var(--border); }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255, 255, 255, .25); border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 60px; color: var(--muted); gap: 10px; }
.preview { max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.preview table { font-size: .85rem; }
.preview .table th, .preview .table td { padding: 7px 12px; }

/* ---------- Responsivo ---------- */
@media (max-width: 860px) {
  .grid--4, .grid--3 { grid-template-columns: repeat(2, 1fr); }
  .topbar__in { flex-wrap: wrap; gap: 8px 12px; padding: 10px 14px; }
  .nav { order: 3; width: 100%; margin: 0; overflow-x: auto; }
  .topbar__user span { display: none; }
  .container { padding: 20px 14px 50px; }
}
@media (max-width: 640px) {
  .form-grid, .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .page-head { align-items: stretch; }
  .page-head .btn { width: 100%; }
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  table.responsive tr:last-child { border-bottom: 0; }
  table.responsive td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 14px; text-align: right; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; text-align: left; flex: none; padding-top: 2px; }
  table.responsive td.actions { justify-content: flex-end; padding-top: 10px; }
  table.responsive td.actions::before, table.responsive td[data-label=""]::before { display: none; }
  .modal__foot .btn { flex: 1; }
  #toasts { left: 16px; right: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.auth__nota { text-align: center; margin: 16px 0 0; }
.cell-actions-end { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.row > .input { flex: 1; min-width: 0; }
.preview__nota { padding: 8px 12px; }
.row--between { justify-content: space-between; }
.tight { margin: 4px 0 0; }
