/*
 * Tema compartilhado do Nucleo Empresarial — identidade visual do Fiscal Flow.
 * Fonte dos valores: /workspace/flow_0ed5349/app/modules/client/static/portal-design.css
 * (acao #087b5c, hover #05634c, superficie #f5f8f7, tinta #18343e, topbar
 * #034236->#053e36 68px, sidebar #043f35->#02382f 250px, ativo
 * #11715a->#105646 com borda #22d6a0, tabelas #f2f7f4, login #033e35/#09895d).
 * NAO e uma copia do client.css do Flow: e uma camada sobre o Bootstrap 5,
 * do qual todos os templates do Nucleo dependem.
 */

:root {
  --flow-action: #087b5c;
  --flow-action-hover: #05634c;
  --flow-surface: #f5f8f7;
  --flow-ink: #18343e;
  --flow-muted: #637982;
  --flow-border: #dfe8e5;
  --flow-border-light: #edf3f0;
  --flow-radius: 12px;
  --flow-radius-sm: 7px;
  --flow-shadow: 0 2px 6px rgb(25 46 53 / 4%);
  --flow-focus: #17a680;
  --flow-status-ok: #047857;
  --flow-status-warn: #b45309;
  --flow-status-danger: #b91c1c;
  --flow-status-info: #0369a1;

  /* Remapeia o Bootstrap para a acao do Flow sem tocar nos templates. */
  --bs-primary: #087b5c;
  --bs-primary-rgb: 8, 123, 92;
  --bs-link-color: #087b5c;
  --bs-link-color-rgb: 8, 123, 92;
  --bs-link-hover-color: #05634c;
  --bs-body-bg: #f5f8f7;
  --bs-body-color: #18343e;
  --bs-border-color: #dfe8e5;
  --bs-secondary-color: #637982;
}

body {
  background: var(--flow-surface);
  color: var(--flow-ink);
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-size: 14px;
}

a { color: var(--flow-action); }
a:hover { color: var(--flow-action-hover); }
:focus-visible { outline: 3px solid var(--flow-focus); outline-offset: 3px; }

/* ---------- Topbar (novo, como no Flow) ---------- */
.flow-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: 68px;
  padding: 0 24px;
  background: linear-gradient(100deg, #034236, #053e36);
  border-bottom: 1px solid #176151;
  color: #fff;
}
.flow-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 100%;
  min-width: 0;
}
.flow-topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex-shrink: 0;
}
.health-brand-logo {
  width: 126px;
  height: 38px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}
.flow-brand-sep {
  width: 1px;
  height: 22px;
  background: rgb(255 255 255 / 25%);
}
.flow-brand-name {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .2px;
  opacity: .92;
  white-space: nowrap;
}
.flow-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-size: 12px;
}
.flow-topbar-empresa {
  max-width: 30vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.flow-topbar-usuario {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: .92;
}
.flow-topbar-sep {
  width: 1px;
  height: 20px;
  background: rgb(255 255 255 / 25%);
  flex-shrink: 0;
}
.btn-topbar {
  min-height: 34px;
  padding: 6px 14px;
  background: transparent;
  border: 1px solid #538f7e;
  border-radius: var(--flow-radius-sm);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.btn-topbar:hover { background: #176151; color: #fff; }

/* ---------- Sidebar (escura, como no Flow) ---------- */
.sidebar {
  background: linear-gradient(165deg, #043f35, #02382f);
  border-right: 1px solid #165e4e;
  color: #d1e4df;
  padding: 16px 12px 28px;
  scrollbar-width: thin;
  scrollbar-color: #387663 transparent;
}
@media (min-width: 992px) {
  .sidebar {
    flex: 0 0 250px;
    width: 250px;
    position: sticky;
    top: 68px;
    height: calc(100vh - 68px);
    overflow-y: auto;
  }
  .sidebar + .content-area {
    flex: 1 1 auto;
    width: auto;
    max-width: none;
    min-width: 0;
  }
}
@media (min-width: 768px) and (max-width: 991.98px) {
  .sidebar {
    position: sticky;
    top: 68px;
    height: calc(100vh - 68px);
    overflow-y: auto;
  }
}
.sidebar .list-group { gap: 0; }
/* bg-light e utilitario Bootstrap (!important): nao pode clarear a sidebar. */
.sidebar .bg-light { background-color: transparent !important; }
.sidebar .list-group-item {
  background: transparent;
  border: 0;
  color: #d1e4df;
}
.sidebar .list-group-item:not(.nav-link) {
  padding: 22px 12px 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #91b9a9;
}
.sidebar .nav-link,
.sidebar a.list-group-item.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin: 2px 0;
  border-radius: var(--flow-radius-sm);
  border-left: 3px solid transparent;
  color: #d1e4df;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.sidebar .nav-link i { width: 1.25rem; text-align: center; flex-shrink: 0; }
.sidebar .nav-link:hover {
  background: #105847;
  color: #fff;
}
.sidebar .nav-link.active {
  background: linear-gradient(100deg, #11715a, #105646);
  color: #fff;
  border-left-color: #22d6a0;
  font-weight: 700;
}
.sidebar .text-muted { color: #89afa3 !important; }
.sidebar .alert-info {
  background: rgb(255 255 255 / 7%);
  border: 1px solid #38705e;
  color: #d1e4df;
}
.sidebar .alert-info strong { color: #fff; }

/* ---------- Conteudo ---------- */
.content-area {
  padding: 30px clamp(18px, 2.5vw, 40px) 48px;
  min-width: 0;
}
.content-area > .d-flex:first-child {
  border-bottom-color: var(--flow-border) !important;
  margin-bottom: 24px !important;
}
.content-area h1.h2 {
  font-size: clamp(23px, 2vw, 29px);
  letter-spacing: -.7px;
  line-height: 1.25;
  color: var(--flow-ink);
}
.text-muted { color: var(--flow-muted) !important; }

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--flow-border);
  border-radius: var(--flow-radius);
  box-shadow: var(--flow-shadow);
  background: #fff;
}
.card-header {
  background: #f8fcf9;
  border-bottom-color: var(--flow-border-light);
}
.card-dashboard {
  border: 1px solid var(--flow-border);
  box-shadow: var(--flow-shadow);
}
.stat-card { border-left: 4px solid; }
.stat-card.receber { border-left-color: var(--flow-status-ok); }
.stat-card.pagar { border-left-color: var(--flow-status-danger); }
.stat-card.neutro { border-left-color: var(--flow-action); }

/* ---------- Botoes ---------- */
.btn {
  min-height: 38px;
  border-radius: var(--flow-radius-sm);
  font-size: 13px;
  font-weight: 600;
}
.btn-sm { min-height: 32px; font-size: 12px; }
.btn-primary {
  background: linear-gradient(125deg, #008565, #006b50);
  border-color: #007a5c;
  color: #fff;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 15%);
}
.btn-primary:hover, .btn-primary:focus {
  background: #005e48;
  border-color: #005e48;
  color: #fff;
}
.btn-outline-primary {
  color: var(--flow-action);
  border-color: #bdddd1;
  background: #fff;
}
.btn-outline-primary:hover {
  background: #edf8f2;
  color: var(--flow-action-hover);
  border-color: #bdddd1;
}
.btn-secondary {
  background: #fff;
  border-color: #bdddd1;
  color: var(--flow-action-hover);
}
.btn-secondary:hover { background: #edf8f2; color: var(--flow-action-hover); border-color: #bdddd1; }
.btn-outline-secondary {
  color: #49665d;
  border-color: #ceddd7;
  background: #fff;
}
.btn-outline-secondary:hover { background: #edf8f2; color: var(--flow-action-hover); border-color: #bdddd1; }
/* Cores de dominio preservadas (receber/pagar/status), so harmonizadas. */
.btn-success { background: var(--flow-status-ok); border-color: var(--flow-status-ok); }
.btn-success:hover { background: #065f46; border-color: #065f46; }
.btn-danger { background: var(--flow-status-danger); border-color: var(--flow-status-danger); }
.btn-danger:hover { background: #991b1b; border-color: #991b1b; }
.btn:disabled, button:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Tabelas ---------- */
.table {
  color: var(--flow-ink);
  font-size: 13px;
  --bs-table-hover-bg: #f3faf6;
  --bs-table-border-color: #edf3f0;
}
.table th {
  background-color: #f2f7f4;
  color: #536d64;
  font-size: 11px;
  font-weight: 600;
  padding: 13px 16px;
}
.table td {
  padding: 12px 16px;
  border-bottom-color: var(--flow-border-light);
}
.table-responsive {
  border: 1px solid var(--flow-border);
  border-radius: 10px;
  background: #fff;
  overflow-x: auto;
}
/* Tabelas dentro de cards nao ganham borda dupla. */
.card .table-responsive { border: 0; border-radius: 0; }

/* ---------- Formularios ---------- */
.form-label {
  color: #49665d;
  font-size: 13px;
  margin-bottom: 7px;
}
.form-control, .form-select {
  min-height: 42px;
  border-color: #ceddd7;
  border-radius: var(--flow-radius-sm);
  background-color: #fff;
  color: var(--flow-ink);
  font-size: 14px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--flow-focus);
  box-shadow: 0 0 0 .2rem rgb(8 123 92 / 15%);
}
.form-control[readonly] { background: #f2f6f4; color: var(--flow-muted); }
.form-check-input:checked, input[type="checkbox"], input[type="radio"] {
  accent-color: var(--flow-action);
}
.form-check-input:checked {
  background-color: var(--flow-action);
  border-color: var(--flow-action);
}
.form-text { color: var(--flow-muted); }

/* ---------- Componentes Bootstrap restantes ---------- */
.badge-situacao { font-size: .75rem; padding: .35em .65em; }
.alert { border-radius: 10px; }
.alert-info {
  background: #eaf6ef;
  border-color: #d1e9dd;
  color: #087354;
}
.dropdown-item.active, .dropdown-item:active { background-color: var(--flow-action); }
.page-link { color: var(--flow-action); }
.page-item.active .page-link { background-color: var(--flow-action); border-color: var(--flow-action); }
.nav-tabs .nav-link.active { color: var(--flow-action-hover); }
.modal-content { border-radius: 14px; border-color: var(--flow-border); }

/* ---------- Login / selecao de empresa (paginas soltas) ---------- */
body.flow-auth {
  background: var(--flow-surface);
  min-height: 100vh;
}
.flow-auth-card {
  border: 1px solid #e1e9e5;
  border-top: 5px solid #09895d;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgb(22 72 48 / 10%);
  overflow: hidden;
}
.flow-auth-card .card-header { background: #fff; }
.flow-auth-logo {
  display: block;
  width: 190px;
  max-width: 70%;
  height: auto;
  margin: 0 auto 14px;
}
.login-card { max-width: 400px; margin-top: 10vh; }
.empresa-card { max-width: 560px; margin-top: 10vh; }

/* ---------- Open Finance (tela migrada para a base unica) ---------- */
.of-page { max-width: 1100px; }
.of-eyebrow {
  color: var(--flow-action);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
}
.of-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.of-header h1 { font-size: clamp(23px, 2vw, 29px); letter-spacing: -.7px; margin: 6px 0; }
.of-header p { color: var(--flow-muted); margin: 0; }
.of-preview-badge {
  background: #e5f5ee;
  color: var(--flow-action);
  border: 1px solid #bdddd1;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.of-notice {
  background: #eaf6ef;
  border: 1px solid #d1e9dd;
  color: #087354;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.of-panel {
  background: #fff;
  border: 1px solid var(--flow-border);
  border-radius: var(--flow-radius);
  box-shadow: var(--flow-shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.of-panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.of-panel-heading span { color: var(--flow-action); font-size: 10px; font-weight: 700; letter-spacing: 1px; }
.of-panel-heading h2 { font-size: 17px; margin: 4px 0 0; }
.of-panel-heading small { color: var(--flow-muted); }
.of-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  border: 2px dashed #bdddd1;
  border-radius: var(--flow-radius);
  background: #f4f8f6;
  padding: 32px 20px;
  cursor: pointer;
  margin-bottom: 16px;
}
.of-dropzone:hover { border-color: var(--flow-action); }
.of-drop-icon { font-size: 28px; color: var(--flow-action); }
.of-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.of-summary article {
  background: #f4f8f6;
  border: 1px solid #e3ece8;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.of-summary span { font-size: 10px; color: var(--flow-muted); text-transform: uppercase; letter-spacing: .5px; }
.of-summary strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.of-table-wrap { overflow-x: auto; border: 1px solid var(--flow-border); border-radius: 10px; }
.of-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 0; }
.of-table th { background: #f2f7f4; color: #536d64; font-size: 11px; text-align: left; padding: 13px 16px; }
.of-table td { padding: 12px 16px; border-bottom: 1px solid var(--flow-border-light); }
.of-table tbody tr:hover { background: #f3faf6; }
.of-value { text-align: right; }
.of-confirmation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.of-confirmation span { display: block; color: var(--flow-muted); font-size: 12px; margin-top: 4px; }

/* ---------- Responsivo ---------- */
@media (max-width: 767.98px) {
  .flow-topbar { padding: 0 16px; }
  .flow-brand-name, .flow-topbar-empresa, .flow-topbar-usuario, .flow-topbar-sep { display: none; }
  .sidebar {
    min-height: auto;
    height: auto;
    max-height: 46vh;
    overflow-y: auto;
    padding: 10px;
  }
  .content-area { padding: 24px 16px 40px; }
  .login-card, .empresa-card { margin-top: 6vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
