/* ============================================================
   Conta.Ai — design tokens
   Paleta extraida diretamente da logo real: navy profundo e azul
   medio (marca "Conta.Ai") + dourado (as barras do icone) como
   acento pontual. Nada de teal/laranja genericos.
   ============================================================ */

:root {
  /* Neutros / tinta */
  --ink: #0d1b2a;
  --ink-strong: #061019;
  --muted: #5b6b78;
  --muted-soft: #8b98a3;
  --line: #dbe3ea;
  --line-soft: #eaeff3;

  /* Superficies */
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #f5f8fb;

  /* Marca — extraida da logo (navy #16365f / azul #128ac1) */
  --primary: #0f6f9e;
  --primary-strong: #0b567c;
  --primary-soft: #e2f1f7;
  --primary-tint: #bfe1ee;
  --navy: #123a5c;
  --navy-deep: #0a2036;

  /* Acento dourado — extraido das barras do icone */
  --accent: #c79a3e;
  --accent-strong: #a67c2c;
  --accent-soft: #f8efdc;

  /* Status */
  --green: #1b7a56;
  --green-soft: #e1f4ea;
  --yellow: #96650f;
  --yellow-soft: #fcf0d8;
  --red: #b23a2c;
  --red-soft: #fbe5e1;
  --slate: #5c6b78;
  --slate-soft: #e8edf1;

  /* Sidebar */
  --sidebar: #0a2036;
  --sidebar-soft: #123a5c;
  --sidebar-line: rgba(255, 255, 255, 0.09);
  --sidebar-ink: rgba(255, 255, 255, 0.66);

  /* Elevacao */
  --shadow-sm: 0 1px 2px rgba(8, 22, 36, 0.07);
  --shadow-soft: 0 10px 26px rgba(8, 22, 36, 0.08);
  --shadow: 0 18px 44px -10px rgba(8, 22, 36, 0.18), 0 3px 10px rgba(8, 22, 36, 0.06);
  --shadow-lg: 0 30px 70px -14px rgba(4, 12, 20, 0.35);

  /* Forma */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  /* Tipografia */
  --font-sans: "Inter", ui-sans-serif, "Segoe UI", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  background:
    radial-gradient(1100px 460px at 100% -10%, rgba(15, 111, 158, 0.07), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 320px),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}

/* ============================================================
   Login — cabe inteiro em 100vh, sem scroll, cartao unico
   ============================================================ */

body.auth-mode {
  display: block;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(900px 560px at 50% -8%, rgba(15, 111, 158, 0.4), transparent 62%),
    linear-gradient(165deg, #0a2036, #071219 68%),
    url("data:image/svg+xml,%3Csvg width='120' height='120' viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.06'%3E%3Cpath d='M0 30h120M0 90h120M30 0v120M90 0v120'/%3E%3C/g%3E%3C/svg%3E");
}

body.auth-mode .sidebar,
body.auth-mode .topbar {
  display: none;
}

body.auth-mode .shell {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr;
}

body.auth-mode .content {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-y: auto;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 29px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink-strong);
}

h2 {
  font-size: 18px;
  font-weight: 750;
  line-height: 1.25;
  letter-spacing: -0.005em;
  color: var(--ink-strong);
}

h3 {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink-strong);
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 12px;
  background: linear-gradient(190deg, var(--sidebar-soft), var(--sidebar) 55%);
  color: white;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 6px 8px 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--sidebar-line);
}

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--surface-soft);
  overflow: hidden;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  padding: 5px;
}

.brand strong {
  display: block;
  color: white;
  font-size: 16.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand span,
.eyebrow,
.muted {
  color: var(--muted);
}

.brand span,
.eyebrow {
  display: block;
  font-size: 11.5px;
}

.brand span {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.52);
}

.eyebrow {
  margin-bottom: 5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav {
  display: grid;
  gap: 3px;
}

.nav-item,
.button,
.icon-button {
  border: 0;
  cursor: pointer;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 9px;
  background: transparent;
  color: var(--sidebar-ink);
  text-align: left;
  font-weight: 650;
  font-size: 14px;
  outline: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: white;
}

.nav-item.active {
  background: var(--sidebar-line);
  color: white;
  font-weight: 750;
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-item:focus-visible,
.button:focus-visible,
.icon-button:focus-visible,
[data-filter]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   Shell / topbar
   ============================================================ */

.shell {
  min-width: 0;
}

.topbar {
  min-height: 84px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 20px 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(238, 242, 246, 0.86);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
  background-image: radial-gradient(circle, var(--line) 1.3px, transparent 1.3px);
  background-position: 0 100%;
  background-repeat: repeat-x;
  background-size: 9px 1px, auto;
}

.topbar > div:first-child {
  min-width: 0;
}

.topbar-actions,
.toolbar,
.actions,
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.actions {
  gap: 8px;
}

.actions .button {
  min-height: 33px;
  padding: 0 11px;
  font-size: 12.5px;
}

.content {
  padding: 22px 30px 34px;
}

/* ============================================================
   Botoes
   ============================================================ */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 9px;
  font-weight: 750;
  font-size: 13.5px;
  letter-spacing: -0.005em;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button.primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 10px 20px -6px rgba(15, 111, 158, 0.45);
}

.button.primary:hover {
  background: var(--primary-strong);
}

.button.ghost {
  background: var(--surface);
  color: var(--primary-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.button.ghost:hover {
  border-color: var(--primary-tint);
  background: var(--primary-soft);
}

.button.danger {
  background: var(--red-soft);
  color: var(--red);
}

.button.danger:hover {
  background: #f7d7d1;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--line);
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-button:hover {
  background: var(--red-soft);
  color: var(--red);
}

/* ============================================================
   Grids
   ============================================================ */

.grid {
  display: grid;
  gap: 16px;
}

.metrics {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.two-col {
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.45fr);
}

/* ============================================================
   Cartao de login (unico, centralizado, pequeno e tratado)
   ============================================================ */

.auth-panel {
  position: relative;
  width: min(420px, 100%);
  max-height: 100%;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
}

.auth-panel::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.auth-panel .panel-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  padding: 30px 32px 6px;
  border-bottom: 0;
}

.auth-panel .panel-head::before {
  content: "";
  width: 62px;
  height: 48px;
  margin-bottom: 8px;
  background: url("assets/conta-ai-mark.png") center / contain no-repeat;
  filter: drop-shadow(0 6px 14px rgba(10, 58, 92, 0.28));
}

.auth-panel .panel-head > div {
  display: contents;
}

.auth-panel .panel-head .eyebrow {
  color: var(--primary);
}

.auth-panel .panel-head h2 {
  font-size: 20px;
}

.auth-panel .panel-head p.muted {
  max-width: 300px;
  font-size: 13px;
  line-height: 1.45;
}

.auth-panel .panel-body {
  padding: 14px 32px 28px;
}

.auth-panel .field input {
  min-height: 43px;
  font-size: 14.5px;
}

.auth-panel .form-actions {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.auth-panel .form-actions .button.primary {
  order: 1;
  width: 100%;
}

.auth-panel .form-actions .button.ghost {
  order: 2;
  min-height: auto;
  padding: 2px;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-panel .form-actions .button.ghost:hover {
  background: none;
  color: var(--primary-strong);
}

.auth-panel .panel-body > p.muted {
  margin-top: 14px;
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

/* ============================================================
   Paineis / cards
   ============================================================ */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head p.muted {
  margin-top: 3px;
  font-size: 13px;
  line-height: 1.4;
}

.panel-body {
  padding: 20px;
}

.metric {
  position: relative;
  min-height: 96px;
  padding: 16px 18px;
  overflow: hidden;
}

.metric::after {
  content: "";
  position: absolute;
  inset: auto -24px -36px auto;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: var(--primary-soft);
}

.metric span {
  position: relative;
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric strong {
  position: relative;
  display: block;
  margin-top: 13px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--ink-strong);
}

/* ============================================================
   Tabelas
   ============================================================ */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

.compact-data {
  min-width: 0;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:hover {
  background: var(--surface-soft);
}

tr:last-child td {
  border-bottom: 0;
}

/* ============================================================
   Badges de status
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 10px 0 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-transform: capitalize;
  white-space: nowrap;
  background: var(--slate-soft);
  color: var(--slate);
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

.status-paga,
.status-resolvida,
.status-ativo,
.status-validado,
.status-confere {
  background: var(--green-soft);
  color: var(--green);
}

.status-pendente,
.status-enviada,
.status-aberta,
.status-em-acompanhamento,
.status-conferencia-manual,
.status-aguardando-comprovante {
  background: var(--yellow-soft);
  color: var(--yellow);
}

.status-vencida,
.status-divergente {
  background: var(--red-soft);
  color: var(--red);
}

.status-cancelada,
.status-pausado,
.status-encerrado,
.status-adiada,
.status-nao-validado {
  background: var(--slate-soft);
  color: var(--slate);
}

/* ============================================================
   Filtros e campos
   ============================================================ */

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #d4dee5;
  border-radius: 9px;
  padding: 9px 11px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary-tint);
  box-shadow: 0 0 0 3px rgba(15, 111, 158, 0.14);
}

.field textarea {
  min-height: 90px;
  resize: vertical;
}

/* Campos com valores que pedem leitura precisa (contabil) ganham
   uma fonte monoespacada, como a linha digitavel de uma guia. */
input[name="document"],
input[name="controlNumber"],
input[name="paymentLine"],
input[name="paymentIdentifier"],
input[name="value"],
input[name="honorarium"],
input[name="feeDueDay"],
input[name="whatsapp"] {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.01em;
}

.list {
  display: grid;
  gap: 9px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(320px, 0.72fr);
  gap: 16px;
  align-items: start;
}

.settings-wide {
  grid-column: 1 / -1;
}

.compact-panel {
  min-height: 0;
}

.compact-list {
  max-height: 360px;
  overflow: auto;
}

.compact-list::-webkit-scrollbar {
  width: 8px;
}

.compact-list::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 99px;
}

.activity-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--accent);
  flex: 0 0 auto;
  margin-top: 6px;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.activity {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 3px 0;
}

/* ============================================================
   Modal
   ============================================================ */

.modal {
  width: min(820px, calc(100vw - 28px));
  max-height: calc(100vh - 32px);
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: var(--shadow-lg);
}

.modal::backdrop {
  background: rgba(4, 12, 20, 0.55);
  backdrop-filter: blur(3px);
}

.modal-box {
  padding: 0;
  max-height: calc(100vh - 32px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  background-image: radial-gradient(circle, var(--line) 1.3px, transparent 1.3px);
  background-position: 0 100%;
  background-repeat: repeat-x;
  background-size: 9px 1px, auto;
}

#modal-body {
  padding: 22px;
  overflow: auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.full {
  grid-column: 1 / -1;
}

.form-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.empty {
  padding: 34px;
  color: var(--muted-soft);
  text-align: center;
  font-size: 13.5px;
}

.notice {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 700;
  font-size: 13.5px;
}

.notice.error {
  background: var(--red-soft);
  color: var(--red);
}

/* ============================================================
   Importacao e conferencia de guias
   A linha pontilhada evoca a perfuracao de destacar um boleto —
   reforca visualmente que este e o momento de "conferir e soltar".
   ============================================================ */

.import-box,
.review-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.import-box {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.review-card {
  margin-top: 16px;
  overflow: hidden;
  background: var(--surface);
}

.review-card .panel-head {
  background: var(--surface-soft);
  background-image: radial-gradient(circle, var(--line) 1.3px, transparent 1.3px);
  background-position: 0 100%;
  background-repeat: repeat-x;
  background-size: 9px 1px, auto;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.summary-grid div {
  min-height: 78px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.summary-grid span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.summary-grid strong {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}

.bar-chart {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 96px 1fr 42px;
  gap: 10px;
  align-items: center;
}

.bar-row strong {
  text-transform: capitalize;
  font-size: 13px;
}

.bar-row > span {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--muted);
  font-size: 13px;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-strong));
}

/* ============================================================
   Responsivo
   ============================================================ */

@media (max-width: 1080px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
  }

  .brand {
    border-bottom: 0;
    padding: 0;
    margin-bottom: 0;
    min-height: auto;
  }

  .brand span {
    display: none;
  }

  .nav {
    grid-template-columns: repeat(5, minmax(108px, 1fr));
    gap: 4px;
    overflow-x: auto;
  }

  .nav-item {
    justify-content: center;
    padding: 0 8px;
  }

  .nav-item span {
    display: none;
  }

  .nav-icon {
    width: 20px;
    height: 20px;
  }

  .metrics,
  .two-col,
  .filters,
  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 700px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px 18px;
    gap: 12px;
  }

  .content {
    padding: 16px;
  }

  .metrics,
  .two-col,
  .filters,
  .settings-grid,
  .summary-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 560px) {
  .auth-panel .panel-head {
    padding: 18px 28px 4px;
  }

  .auth-panel .panel-head::before {
    width: 48px;
    height: 37px;
    margin-bottom: 4px;
  }

  .auth-panel .panel-body {
    padding: 10px 28px 20px;
  }

  .auth-panel .panel-body > p.muted {
    margin-top: 8px;
  }
}
