/* DM2 INTEGRA · Identidade ERP, primeira rodada (3.0.148).
   Apenas apresentação: navegação, dados e permissões permanecem intactos.
   Separado do estilo legado para permitir evolução controlada. */
html.light {
  --dm2-canvas: #f3f6f5;
  --dm2-surface: #ffffff;
  --dm2-surface-subtle: #eaf1ee;
  --dm2-ink: #203b3d;
  --dm2-muted: #556b6b;
  --dm2-border: #d5e1de;
  --dm2-shadow: 0 10px 32px rgba(33, 63, 61, .055);
  --dm2-primary: #426d68;
  --dm2-primary-ink: #31534f;
}
html.dark {
  --dm2-canvas: #101d21;
  --dm2-surface: #1a292d;
  --dm2-surface-subtle: #25383b;
  --dm2-ink: #eff6f4;
  --dm2-muted: #bdcfca;
  --dm2-border: #32484c;
  --dm2-shadow: 0 12px 30px rgba(0, 0, 0, .13);
  --dm2-primary: #9cc4b9;
  --dm2-primary-ink: #c0ded5;
}
#view-dashboard { background: var(--dm2-canvas); }
#view-dashboard .dm2-erp-topbar {
  background: var(--dm2-surface) !important;
  border-bottom: 1px solid var(--dm2-border);
  box-shadow: 0 2px 16px rgba(25, 60, 58, .035);
  padding-top: 1.45rem;
  padding-bottom: .95rem;
}
#view-dashboard .dm2-erp-topbar .text-gradient-metallic {
  background: none;
  -webkit-text-fill-color: currentColor;
  color: var(--dm2-primary-ink);
  font-size: 12px;
  letter-spacing: .12em;
}
#view-dashboard .dm2-erp-topbar h2 { color: var(--dm2-ink); }
#view-dashboard .dm2-erp-topbar button {
  background: var(--dm2-surface-subtle);
  border-color: var(--dm2-border);
  border-radius: 12px;
  color: var(--dm2-primary-ink);
}
#tab-content-start, #tab-content-modules, #tab-content-contabil {
  background: var(--dm2-canvas) !important;
}
#tab-content-start, #tab-content-modules { padding-top: 1.35rem; }
#view-dashboard .dm2-erp-eyebrow {
  color: var(--dm2-primary-ink);
  font-size: 11px !important;
  letter-spacing: .14em;
}
#view-dashboard .dm2-erp-page-title {
  color: var(--dm2-ink);
  font-size: 24px;
  letter-spacing: -.035em;
  line-height: 1.2;
}
#view-dashboard .dm2-erp-description { color: var(--dm2-muted); }
#view-dashboard .dm2-erp-card,
#accounting-root .dm2-erp-card {
  background: var(--dm2-surface);
  border: 1px solid var(--dm2-border);
  border-radius: 18px;
  box-shadow: var(--dm2-shadow);
}
#view-dashboard .dm2-erp-card { padding: 1.05rem; }
#view-dashboard .dm2-erp-card h3,
#view-dashboard .dm2-erp-card strong { color: var(--dm2-ink); }
#view-dashboard .dm2-erp-card [role="status"] { color: var(--dm2-muted); line-height: 1.6; }
#view-dashboard .dm2-erp-card > div > :is(i,svg):first-child {
  color: var(--dm2-primary-ink);
  background: var(--dm2-surface-subtle);
  border: 1px solid var(--dm2-border);
  border-radius: 12px;
  width: 39px;
  height: 39px;
  padding: 9px;
}
#view-dashboard .dm2-erp-card button:not(.dm2-erp-module),
#view-dashboard .dm2-erp-primary {
  border-radius: 12px;
  min-height: 43px;
}
#view-dashboard .dm2-erp-card button:not(.dm2-erp-module) {
  border: 1px solid var(--dm2-border);
  color: var(--dm2-primary-ink);
  background: var(--dm2-surface-subtle);
}
#view-dashboard .dm2-erp-primary {
  color: #fff;
  background: #426d68;
  border: 1px solid #426d68;
  box-shadow: 0 5px 14px rgba(52, 94, 86, .12);
}
html.dark #view-dashboard .dm2-erp-primary {
  color: #102a27;
  background: #9cc4b9;
  border-color: #9cc4b9;
}
#view-dashboard .dm2-erp-module {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  min-height: 82px;
  align-items: center;
  text-align: left;
  transition: border-color .15s ease, transform .15s ease, background-color .15s ease;
}
#view-dashboard .dm2-erp-module:active { transform: scale(.992); }
#view-dashboard .dm2-erp-module > :is(i,svg):first-child {
  color: var(--dm2-primary-ink);
  background: var(--dm2-surface-subtle);
  border-radius: 13px;
  width: 44px;
  height: 44px;
  padding: 11px;
  flex-shrink: 0;
}
#view-dashboard .dm2-erp-module span span { color: var(--dm2-muted); }
#view-dashboard .dm2-erp-module > :is(i,svg):last-child { color: var(--dm2-primary-ink); }
#accounting-root > div { color: var(--dm2-ink); }
#accounting-root button[onclick^="openAccountingArea"],
#accounting-root button[onclick^="openAccountingSection"] {
  border-color: var(--dm2-border);
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
#accounting-root button[onclick^="openAccountingArea"] {
  background: var(--dm2-surface);
  border-radius: 18px;
  box-shadow: var(--dm2-shadow);
}
#global-navbar.dm2-erp-navbar {
  background: var(--dm2-surface);
  border-top: 1px solid var(--dm2-border);
  box-shadow: 0 -5px 24px rgba(34, 70, 66, .045);
}
#global-navbar.dm2-erp-navbar > div > button {
  background: #426d68;
  background-image: none;
  color: white;
  border-color: var(--dm2-canvas);
  box-shadow: 0 6px 16px rgba(41, 78, 73, .22);
}
html.dark #global-navbar.dm2-erp-navbar > div > button {
  background: #9cc4b9;
  color: #102a27;
}
#global-navbar.dm2-erp-navbar button:focus-visible,
#view-dashboard button:focus-visible,
#accounting-root button:focus-visible {
  outline: 2px solid var(--dm2-primary);
  outline-offset: 3px;
}
@media (hover: hover) {
  #view-dashboard .dm2-erp-module:hover,
  #accounting-root button[onclick^="openAccountingArea"]:hover {
    border-color: var(--dm2-primary);
    background: var(--dm2-surface-subtle);
  }
}
@media (prefers-reduced-motion: reduce) {
  #view-dashboard .dm2-erp-module,
  #accounting-root button[onclick^="openAccountingArea"] { transition: none; }
}

/* Substitui apenas a cor semântica dos textos de marca do tema herdado. */
html.light body .text-brand-light,
html.light body .text-brand-activeLight,
html.light body .text-brand-activeLight\/75 { color: #31534f !important; }
html.dark body .text-brand-dark,
html.dark body .text-brand-dark\/75 { color: #bedbd2 !important; }
html.light #view-dashboard .dm2-erp-eyebrow,
html.dark #view-dashboard .dm2-erp-eyebrow { color: var(--dm2-primary-ink) !important; }
html.light #view-dashboard .dm2-erp-description,
html.dark #view-dashboard .dm2-erp-description { color: var(--dm2-muted) !important; }

/* Início · Identificação empresarial, exclusivamente dados cadastrados pelo titular. */
#tab-content-start .dm2-company-hero {
  position: relative;
  overflow: hidden;
  color: #edf7f3;
  background: linear-gradient(130deg, #294f4b 0%, #396b62 58%, #487b72 100%);
  border: 1px solid rgba(201, 228, 218, .30);
  box-shadow: 0 14px 32px rgba(30, 66, 60, .14);
}
html.dark #tab-content-start .dm2-company-hero {
  background: linear-gradient(130deg, #213b3c 0%, #294d48 100%);
  border-color: #486a62;
}
#tab-content-start .dm2-company-hero::before {
  content: "";
  position: absolute;
  right: -52px;
  top: -74px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(204, 241, 227, .065);
  pointer-events: none;
}
#tab-content-start .dm2-company-hero-top {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .65rem;
}
#tab-content-start .dm2-company-hero-kicker {
  color: #d7ece5;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
}
#tab-content-start .dm2-company-hero-top > svg,
#tab-content-start .dm2-company-hero-top > i { color: #d7ece5; }
#tab-content-start .dm2-company-hero-name {
  position: relative;
  margin-top: 1.15rem;
  font-size: clamp(21px, 5.4vw, 28px);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
  color: #fff !important;
}
#tab-content-start .dm2-company-hero-cnpj {
  position: relative;
  display: inline-block;
  margin-top: .9rem;
  padding: .4rem .75rem;
  border: 1px solid rgba(217, 243, 232, .27);
  border-radius: 9px;
  background: rgba(255, 255, 255, .08);
  color: #e3f5ee;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .015em;
  font-variant-numeric: tabular-nums;
}
#tab-content-start .dm2-company-facts {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .95rem 1.1rem;
  margin-top: 1.4rem;
  padding-top: 1.1rem;
  border-top: 1px solid rgba(220, 244, 232, .22);
}
#tab-content-start .dm2-company-facts > div { min-width: 0; }
#tab-content-start .dm2-company-facts dt {
  color: #cce3d9;
  font-size: 10px;
  letter-spacing: .02em;
  margin-bottom: .24rem;
}
#tab-content-start .dm2-company-facts dd {
  color: #fff;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 650;
  overflow-wrap: anywhere;
}
#tab-content-start .dm2-company-hero-action {
  position: relative;
  background: #e2f0e9 !important;
  color: #23453e !important;
  border: 1px solid #c9e2d6 !important;
}
#tab-content-start .dm2-company-verification [role="status"] {
  color: var(--dm2-muted);
}
#tab-content-start [hidden] { display: none !important; }

/* Início: resumo empresarial em três linhas, sem repetir o cadastro completo. */
#tab-content-start .dm2-company-checklist {
  display: grid;
  gap: .68rem;
  padding: 0;
  margin-bottom: 0;
  list-style: none;
}
#tab-content-start .dm2-company-checklist li {
  display: flex;
  gap: .7rem;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--dm2-border);
  border-radius: 12px;
  background: var(--dm2-surface-subtle);
  padding: .77rem .85rem;
  min-width: 0;
}
#tab-content-start .dm2-company-checklist-label {
  position: relative;
  min-width: 0;
  padding-left: .86rem;
  color: var(--dm2-ink);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}
#tab-content-start .dm2-company-checklist-label::before {
  content: "";
  position: absolute;
  left: 0;
  top: .38em;
  width: .4rem;
  height: .4rem;
  border-radius: 50%;
  background: var(--dm2-primary);
}
#tab-content-start .dm2-company-checklist-value {
  flex-shrink: 0;
  max-width: 56%;
  min-width: 0;
  border-radius: 20px;
  padding: .3rem .52rem;
  background: var(--dm2-surface);
  color: var(--dm2-muted);
  border: 1px solid var(--dm2-border);
  font-size: 10px;
  font-weight: 750;
  line-height: 1.4;
  text-align: right;
}
#tab-content-start .dm2-company-checklist-value[data-state="success"] {
  background: #e5f3ea;
  color: #215c41;
  border-color: #b9dcc6;
}
#tab-content-start .dm2-company-checklist-value[data-state="warning"] {
  background: #fbf0dc;
  color: #785620;
  border-color: #ead8ae;
}
html.dark #tab-content-start .dm2-company-checklist-value[data-state="success"] {
  background: #264a3b;
  color: #d0f2df;
  border-color: #47735b;
}
html.dark #tab-content-start .dm2-company-checklist-value[data-state="warning"] {
  background: #463824;
  color: #f4dca9;
  border-color: #665333;
}
#tab-content-start .dm2-company-checklist-note {
  margin-top: .95rem;
  color: var(--dm2-muted);
  font-size: 10px;
  line-height: 1.55;
}
@media (max-width: 370px) {
  #tab-content-start .dm2-company-checklist li { align-items: flex-start; flex-direction: column; }
  #tab-content-start .dm2-company-checklist-value { max-width: 100%; text-align: left; }
}

/* Prioridade acima do texto de status herdado do cartão ERP. */
html.light #view-dashboard #tab-content-start .dm2-company-checklist-value[data-state="success"] { color: #215c41; }
html.light #view-dashboard #tab-content-start .dm2-company-checklist-value[data-state="warning"] { color: #785620; }
html.dark #view-dashboard #tab-content-start .dm2-company-checklist-value[data-state="success"] { color: #d0f2df; }
html.dark #view-dashboard #tab-content-start .dm2-company-checklist-value[data-state="warning"] { color: #f4dca9; }

/* DM² Financeiro: atualização visual exclusiva do módulo. Não altera dados nem saldos. */
#view-dashboard #tab-content-home.dm2-finance-legacy-view {
  background: var(--dm2-canvas) !important;
  color: var(--dm2-ink);
}
#tab-content-home .dm2-finance-context {
  background: var(--dm2-canvas);
}
#tab-content-home .dm2-finance-context-kicker {
  color: var(--dm2-primary-ink);
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
}
#tab-content-home .dm2-finance-context p {
  margin-top: .45rem;
  padding: .7rem .85rem;
  border: 1px solid var(--dm2-border);
  border-left: 3px solid var(--dm2-primary);
  border-radius: 9px;
  background: var(--dm2-surface);
  color: var(--dm2-muted);
  font-size: 11px;
  line-height: 1.5;
}
#tab-content-home > div:nth-child(2),
#tab-content-home > div:nth-child(3) {
  background: var(--dm2-canvas) !important;
  border-color: var(--dm2-border);
}
#tab-content-home #current-month {
  color: var(--dm2-primary-ink) !important;
  background: var(--dm2-surface-subtle) !important;
  border-color: var(--dm2-border) !important;
}
#tab-content-home #current-month,
#tab-content-home #prev-month,
#tab-content-home #next-month,
#tab-content-home #overall-patrimonio {
  font-variant-numeric: tabular-nums;
}
#tab-content-home .dm2-finance-balance-card {
  background: var(--dm2-surface) !important;
  border: 1px solid var(--dm2-border) !important;
  border-radius: 18px;
  box-shadow: var(--dm2-shadow);
}
#tab-content-home .dm2-finance-balance-card #overall-patrimonio {
  color: var(--dm2-ink) !important;
}
#tab-content-home #groups-container .premium-group-box {
  background: var(--dm2-surface) !important;
  border: 1px solid var(--dm2-border) !important;
  border-radius: 17px;
  box-shadow: var(--dm2-shadow);
}
#tab-content-home #groups-container .premium-group-header {
  background: var(--dm2-surface-subtle) !important;
  color: var(--dm2-primary-ink) !important;
  border-bottom: 1px solid var(--dm2-border);
}
#tab-content-home #groups-container .premium-group-header .text-blue-500,
#tab-content-home #groups-container .text-blue-500 {
  color: #28675b !important;
}
html.dark #tab-content-home #groups-container .premium-group-header .text-blue-500,
html.dark #tab-content-home #groups-container .text-blue-500 {
  color: #a9d8ca !important;
}
#tab-content-home #groups-container .accordion-content > div[onclick^="openAccountView"] {
  background: var(--dm2-surface) !important;
  border: 1px solid var(--dm2-border);
  box-shadow: none;
}
#view-account {
  background: var(--dm2-canvas) !important;
  color: var(--dm2-ink);
}
#view-account > div:first-child,
#view-account #acc-month-navigator,
#view-account #acc-current-month {
  background: var(--dm2-surface-subtle) !important;
  border-color: var(--dm2-border) !important;
}
#view-account #acc-current-month {
  color: var(--dm2-primary-ink) !important;
}
#tab-content-home button:focus-visible,
#view-account button:focus-visible {
  outline: 2px solid var(--dm2-primary);
  outline-offset: 3px;
}

/* DM²: consistência de leitura e navegação entre as três áreas do ERP. */
#tab-content-start, #tab-content-modules {
  padding-bottom: calc(8rem + var(--sab, 0px)) !important;
  overscroll-behavior-y: contain;
}
#tab-content-start .dm2-erp-card,
#tab-content-modules .dm2-erp-card {
  overflow-wrap: anywhere;
}
#view-dashboard .dm2-erp-topbar button {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
}
#global-navbar.dm2-erp-navbar > button {
  min-height: 44px;
  border-radius: 12px;
}
#global-navbar.dm2-erp-navbar > button[aria-current="page"] {
  color: var(--dm2-primary-ink) !important;
  background: var(--dm2-surface-subtle);
  font-weight: 800;
}
#global-navbar.dm2-erp-navbar > button[aria-current="page"] span {
  font-weight: 800;
}

#view-dashboard .dm2-erp-topbar button:focus-visible,
#global-navbar.dm2-erp-navbar button:focus-visible,
#tab-content-start .dm2-company-hero-action:focus-visible {
  outline: 2px solid var(--dm2-primary);
  outline-offset: 2px;
}
#tab-content-modules .dm2-erp-module strong {
  font-size: 14px;
  line-height: 1.35;
}
#tab-content-modules .dm2-erp-module span span {
  font-size: 12px;
  line-height: 1.5;
}
#tab-content-modules #dm2-financial-company-scope {
  display: block;
  margin-top: .65rem;
  padding: .5rem .65rem;
  border: 1px solid var(--dm2-border);
  border-radius: 10px;
  background: var(--dm2-surface-subtle);
  color: var(--dm2-muted);
  font-size: 11px;
}

/* Fatos empresariais e ações legíveis também em celulares compactos. */
@media (max-width: 380px) {
  #tab-content-start .dm2-company-facts { grid-template-columns: 1fr; gap: .7rem; }
  #tab-content-start .dm2-company-hero { padding: 1rem; }
  #tab-content-modules .dm2-erp-module { gap: .7rem; padding: .85rem; }
  #tab-content-modules .dm2-erp-module > :is(i,svg):first-child {
    width: 40px;
    height: 40px;
    padding: 9px;
  }
}
#accounting-root :is(input,select,textarea):focus-visible {
  outline: 2px solid var(--dm2-primary);
  outline-offset: 1px;
}
#tab-content-home .dm2-finance-context p {
  overflow-wrap: anywhere;
}

/* Card de entrada e menus internos Contábil/Fiscal: a mesma superfície ERP. */
#accounting-root button[onclick^="openAccountingArea"] {
  background: var(--dm2-surface) !important;
  color: var(--dm2-ink);
  box-shadow: var(--dm2-shadow);
  height: auto !important;
  min-height: 92px;
}
#accounting-root button[onclick^="openAccountingSection"].dm2-erp-card {
  background: var(--dm2-surface) !important;
  color: var(--dm2-ink);
}
#accounting-root button[onclick^="openAccountingArea"] p,
#accounting-root button[onclick^="openAccountingSection"] p {
  line-height: 1.45;
}
#accounting-root button[onclick^="openAccountingArea"] p.text-zinc-400,
#accounting-root button[onclick^="openAccountingSection"] p.text-zinc-400 {
  color: var(--dm2-muted);
}

/* Desktop ERP: usa a área disponível sem esticar o login e o PIN. */
@media (min-width: 1024px) {
  #phone-wrapper:has(#view-dashboard:not(.hidden)) {
    width: min(1180px, calc(100vw - 48px)) !important;
    max-width: none !important;
    height: min(900px, calc(100vh - 48px)) !important;
    max-height: calc(100vh - 48px) !important;
    border-radius: 22px !important;
    border-width: 1px !important;
  }
  #tab-content-start > :is(p,h2,div),
  #tab-content-modules > :is(p,h2,div) {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
  }
  #tab-content-contabil #accounting-root {
    width: min(100%, 980px);
    margin-inline: auto;
  }

  #tab-content-modules > .space-y-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
  }
  #tab-content-modules > .space-y-3 > * {
    margin-top: 0 !important;
    min-height: 126px;
  }
  #tab-content-modules .dm2-erp-module {
    height: 100%;
    align-items: flex-start;
  }
  #view-dashboard .dm2-erp-topbar > div {
    max-width: 1100px;
    margin-inline: auto;
  }
}
