:root {
  --brand-red: #d11f2f;
  --brand-red-dark: #b91423;
  --ink-950: #29292d;
  --ink-900: #33343a;
  --ink-700: #64666d;
  --ink-500: #8d929c;
  --surface: #ffffff;
  --page: #f4f6f8;
  --line: #dbe2ea;
  --navy: #123f72;
  --blue: #244ab8;
  --green: #1fa552;
  --orange: #e49300;
  --purple: #b92bc7;
  --danger: #d21f30;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.04);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink-900);
  background: var(--page);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(36, 74, 184, 0.25);
  outline-offset: 2px;
}

/* LOGIN */
.login-page {
  display: grid;
  grid-template-columns: minmax(430px, 45.85vw) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  background: #f2f2f2;
}

.login-hero {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(40px, 4.2vw, 86px);
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 22% 48%, rgba(255, 255, 255, 0.025), transparent 30%),
    var(--ink-950);
}

.login-hero__content {
  width: min(670px, 100%);
  transform: translateY(-1.5vh);
}

.eyebrow,
.page-kicker {
  margin: 0 0 14px;
  color: #ee2539;
  font-size: clamp(0.78rem, 0.78vw, 1rem);
  font-weight: 800;
  letter-spacing: 0.035em;
}

.login-hero h1 {
  max-width: 650px;
  margin: 0;
  font-size: clamp(2.3rem, 3vw, 4.25rem);
  line-height: 1.16;
  letter-spacing: -0.035em;
}

.login-hero__description {
  max-width: 690px;
  margin: 18px 0 0;
  color: #9eacc1;
  font-size: clamp(1.05rem, 1.45vw, 1.62rem);
  line-height: 1.34;
}

.hero-pagination {
  position: absolute;
  left: clamp(40px, 4.2vw, 86px);
  bottom: clamp(36px, 7.2vh, 76px);
  display: flex;
  gap: 14px;
}

.hero-pagination span {
  width: 20px;
  height: 3px;
  border-radius: 99px;
  background: #53647c;
}

.hero-pagination .is-active {
  width: 38px;
  background: #f12036;
}

.login-access {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: clamp(24px, 4vw, 72px);
  background: #f5f5f5;
}

.login-stack {
  width: min(590px, 100%);
  display: grid;
  justify-items: center;
  gap: clamp(26px, 4vh, 58px);
}

.login-logo {
  width: clamp(130px, 11vw, 220px);
  height: auto;
  object-fit: contain;
}

.login-card {
  position: relative;
  width: 100%;
  min-height: 548px;
  padding: clamp(32px, 3.2vw, 56px) clamp(28px, 3.4vw, 64px) 62px;
  border: 1px solid #dadde2;
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-card__header h2 {
  margin: 0;
  color: #303238;
  font-size: clamp(1.45rem, 1.4vw, 1.85rem);
  letter-spacing: -0.025em;
}

.login-card__header p {
  margin: 12px 0 30px;
  color: #656971;
  font-size: 0.98rem;
  line-height: 1.4;
}

.field {
  display: grid;
  gap: 9px;
  margin-top: 20px;
  color: #303238;
  font-size: 0.85rem;
}

.field input {
  width: 100%;
  height: 48px;
  padding: 0 17px;
  border: 1px solid #d7dce3;
  border-radius: 8px;
  color: #34363a;
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field input:focus {
  border-color: #8798b2;
  box-shadow: 0 0 0 3px rgba(36, 74, 184, 0.08);
  outline: none;
}

.field input::placeholder {
  color: #b7bec9;
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0;
  font-size: 0.78rem;
}

.remember-access {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #686d75;
  white-space: nowrap;
}

.remember-access input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--brand-red);
}

.link-button {
  padding: 0;
  border: 0;
  color: var(--brand-red);
  background: transparent;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-weight: 750;
  background: var(--brand-red);
  transition: transform 150ms ease, background 150ms ease;
}

.primary-button:hover:not(:disabled) {
  background: var(--brand-red-dark);
  transform: translateY(-1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.75;
}

.form-error {
  margin: -10px 0 14px;
  color: var(--brand-red);
  font-size: 0.78rem;
}

.login-card__footer {
  position: absolute;
  right: 0;
  bottom: 22px;
  left: 0;
  padding-top: 19px;
  border-top: 1px solid #edf0f3;
  color: #c0c8d3;
  font-size: 0.72rem;
  text-align: center;
}


/* DASHBOARD */
.dashboard-shell {
  display: grid;
  grid-template-columns: clamp(236px, 14.2vw, 284px) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--page);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  color: #d8d9dd;
  background: var(--ink-950);
}

.sidebar__brand {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(170px, 18vh, 230px);
  padding: 24px 26px 12px;
  overflow: hidden;
}

.sidebar__brand img {
  width: min(178px, 88%);
  height: auto;
}

.sidebar-close {
  display: none;
}

.sidebar__nav {
  display: grid;
  gap: 10px;
  padding: 8px 16px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 17px;
  width: 100%;
  min-height: 54px;
  padding: 0 18px;
  border: 0;
  border-radius: 7px;
  color: #c3c5ca;
  text-align: left;
  background: transparent;
  transition: background 160ms ease, color 160ms ease;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.is-active {
  color: #fff;
  font-weight: 700;
  background: var(--brand-red);
}

.nav-item__icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 20px;
  width: 20px;
  font-size: 0.9rem;
}

.sidebar__footer {
  display: grid;
  gap: 2px;
  margin-top: auto;
  padding: 18px 16px 34px;
}

.nav-item--footer {
  min-height: 42px;
  font-size: 0.84rem;
}

.nav-item--logout {
  color: #ff7783;
}

.dashboard-main {
  min-width: 0;
}

.mobile-topbar {
  display: none;
}

.dashboard-content {
  width: 100%;
  padding: clamp(20px, 1.55vw, 34px) clamp(18px, 1.6vw, 36px) 42px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.page-kicker {
  display: none;
}

.page-header h1 {
  margin: 0;
  color: #64666b;
  font-size: clamp(1.8rem, 2.15vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 3px;
}

.avatar,
.mobile-avatar {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  background: var(--brand-red);
}

.user-profile__text {
  display: grid;
  gap: 2px;
}

.user-profile__text strong {
  color: #24262a;
  font-size: 0.88rem;
}

.user-profile__text small {
  color: #777d87;
  font-size: 0.68rem;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.05fr) minmax(220px, 1.05fr) minmax(220px, 1.05fr) minmax(220px, 0.95fr);
  gap: 14px;
  margin-bottom: 18px;
}

.filter-control,
.updated-chip {
  min-width: 0;
  min-height: 58px;
  border: 1px solid #d7e0ea;
  border-radius: 8px;
  background: #f8fafc;
}

.filter-control {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
}

.filter-control__icon {
  color: #5d626a;
  font-size: 1rem;
}

.filter-control__content {
  display: grid;
  min-width: 0;
  width: 100%;
}

.filter-control small {
  color: #5d626a;
  font-size: 0.68rem;
  font-weight: 700;
}

.filter-control select {
  width: 100%;
  min-width: 0;
  padding: 4px 24px 2px 0;
  border: 0;
  color: #6d7178;
  font-size: 0.8rem;
  background: transparent;
  outline: 0;
}

.updated-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  align-self: center;
  min-height: 36px;
  margin: 11px 0;
  padding: 0 15px;
  color: #68717d;
  font-size: 0.78rem;
  font-weight: 700;
  background: #e9f1ff;
  border-color: #c7d8f2;
}

.updated-chip span {
  color: #53667f;
  font-size: 1.2rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(132px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi-card {
  min-width: 0;
  min-height: 118px;
  padding: 18px 17px 14px;
  border: 1px solid #d7e0ea;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.02);
}

.kpi-card__top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.kpi-card h2 {
  margin: 0;
  color: #5c6068;
  font-size: clamp(0.68rem, 0.7vw, 0.85rem);
  line-height: 1.15;
}

.kpi-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  color: #fff;
  font-size: 1.2rem;
  background: var(--navy);
}

.kpi-card > strong {
  display: block;
  margin-top: 13px;
  color: #626469;
  font-size: clamp(1.22rem, 1.35vw, 1.8rem);
  line-height: 1;
  white-space: nowrap;
}

.kpi-card > small {
  display: block;
  margin-top: 7px;
  color: var(--green);
  font-size: 0.62rem;
  font-weight: 700;
  text-align: right;
}

.tone-green .kpi-icon,
.tone-green > strong {
  background-color: var(--green);
}

.tone-green > strong,
.tone-red > small {
  background: none;
  color: var(--green);
}

.tone-red .kpi-icon {
  background: #d6353f;
}

.tone-red > small {
  color: #d6353f;
}

.tone-orange .kpi-icon {
  background: var(--orange);
}

.tone-orange > strong {
  color: var(--orange);
}

.tone-purple .kpi-icon {
  background: var(--purple);
}

.tone-purple > strong {
  color: var(--purple);
}

.charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.13fr) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  min-width: 0;
  border: 1px solid #d7e0ea;
  border-radius: 13px;
  background: #fff;
  box-shadow: var(--shadow);
}

.panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 20px 4px;
}

.panel__header h2 {
  margin: 0;
  color: #4d5056;
  font-size: clamp(0.94rem, 0.94vw, 1.18rem);
  line-height: 1.2;
}

.panel__header small {
  color: #9aa0a9;
  font-size: 0.62rem;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px;
  color: #69707a;
  font-size: 0.58rem;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-line {
  display: inline-block;
  width: 18px;
  height: 2px;
  background: #1d2d43;
}

.legend-line--blue { background: var(--blue); }
.legend-line--green { background: var(--green); }

.chart-scroll {
  min-width: 0;
  overflow: hidden;
}

.cash-chart,
.waterfall-chart {
  display: block;
  width: 100%;
  height: auto;
  min-height: 238px;
}

.grid-lines line {
  stroke: #e8edf2;
  stroke-width: 1;
}

.today-line {
  stroke: #b9c1cb;
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.today-label { fill: #20344f; }
.today-text { fill: #fff; font-size: 9px; font-weight: 700; }

.series-line {
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.series-line--ending { stroke: #17283d; }
.series-line--forecast { stroke: #d32232; stroke-dasharray: 7 4; }
.series-line--starting { stroke: var(--blue); }
.series-line--movement { stroke: var(--green); stroke-dasharray: 6 3; }

.point { stroke: #fff; stroke-width: 1.4; }
.point--ending { fill: #17283d; }
.point--forecast { fill: #d32232; }
.point--starting { fill: var(--blue); }
.point--movement { fill: var(--green); }

.point-label {
  font-size: 8.5px;
  font-weight: 700;
}

.point-label--ending { fill: #17283d; }
.point-label--forecast { fill: #d32232; }
.point-label--starting { fill: var(--blue); }
.point-label--movement { fill: var(--green); }
.month-labels text,
.bar-label { fill: #70747b; font-size: 8px; }

.waterfall-bar--positive { fill: #18a84d; }
.waterfall-bar--negative { fill: #d21f30; }
.waterfall-bar--total { fill: #244ab8; }
.bar-value { font-size: 10px; font-weight: 800; }
.bar-value--positive { fill: #11873d; }
.bar-value--negative { fill: #d21f30; }
.bar-value--total { fill: #273348; }

.matrix-panel {
  margin-bottom: 18px;
  transition: border-radius 160ms ease;
}

.matrix-header {
  align-items: center;
  padding-bottom: 10px;
}

.expand-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border: 1px solid #c7d8f2;
  border-radius: 4px;
  color: #4d5968;
  font-size: 0.66rem;
  font-weight: 700;
  background: #f7faff;
}

.matrix-wrapper {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

.matrix-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  color: #61666e;
  font-size: clamp(0.6rem, 0.62vw, 0.76rem);
  font-variant-numeric: tabular-nums;
}

.matrix-table th,
.matrix-table td {
  padding: 6px 10px;
  border-right: 1px solid #e2e7ed;
  text-align: right;
  white-space: nowrap;
}

.matrix-table th:first-child,
.matrix-table td:first-child {
  min-width: 250px;
  text-align: left;
}

.matrix-table th {
  color: #555a62;
  font-weight: 800;
  background: #eff3f7;
}

.matrix-table tr:nth-child(even) td {
  background: #fbfcfd;
}

.matrix-table .row-positive td,
.matrix-table .row-total td {
  background: #eaf3ff;
}

.matrix-table .row-positive-soft td {
  background: #edf8f1;
}

.matrix-table .row-negative td {
  color: #ca1f2e;
  font-weight: 800;
  background: #fff3f4;
}

.matrix-table .row-negative-child td {
  color: #ca1f2e;
  font-weight: 700;
}

.matrix-table .row-child td:first-child,
.matrix-table .row-negative-child td:first-child {
  padding-left: 28px;
}

.matrix-panel--expanded {
  position: fixed;
  inset: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  margin: 0;
  overflow: hidden;
  border-radius: 15px;
  box-shadow: 0 24px 80px rgba(14, 20, 31, 0.32);
}

.matrix-panel--expanded .matrix-wrapper {
  flex: 1;
  overflow: auto;
}

.matrix-panel--expanded .matrix-table {
  min-width: 1240px;
  font-size: 0.8rem;
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(340px, 0.75fr) minmax(0, 1.25fr);
  gap: 18px;
}

.expenses-panel,
.insights-panel {
  min-height: 138px;
}

.expense-list {
  display: grid;
  gap: 10px;
  padding: 12px 20px 18px;
}

.expense-row {
  display: grid;
  grid-template-columns: 22px minmax(92px, 0.72fr) minmax(100px, 1.2fr) auto;
  align-items: center;
  gap: 10px;
  color: #737780;
  font-size: 0.7rem;
}

.expense-rank {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.64rem;
  font-weight: 800;
  background: var(--brand-red);
}

.expense-track {
  height: 12px;
  overflow: hidden;
  border-radius: 99px;
  background: #e9eef3;
}

.expense-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand-red);
}

.expense-value {
  color: var(--brand-red);
  white-space: nowrap;
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
  padding: 12px 20px 18px;
}

.insight-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 74px;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: 9px;
}

.insight-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 900;
}

.insight-card strong,
.insight-card small {
  display: block;
}

.insight-card strong {
  font-size: 0.73rem;
  line-height: 1.25;
}

.insight-card small {
  margin-top: 5px;
  color: #737780;
  font-size: 0.62rem;
  line-height: 1.3;
}

.insight-card--danger { border-color: #f1b9bf; background: #fff1f3; }
.insight-card--danger .insight-icon { background: #dc1d2f; }
.insight-card--danger strong { color: #ca1d2d; }
.insight-card--success { border-color: #b9e7c9; background: #eefaf2; }
.insight-card--success .insight-icon { background: #148d4b; }
.insight-card--success strong { color: #168342; }
.insight-card--warning { border-color: #f0d097; background: #fff8e8; }
.insight-card--warning .insight-icon { color: #fff; background: #e59a00; }
.insight-card--warning strong { color: #bf7900; }

.sidebar-backdrop {
  display: none;
}

/* LARGE DESKTOP / ODYSSEY OLED G9 5120x1440 */
@media (min-width: 2200px) {
  .dashboard-shell {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .dashboard-content {
    padding: 30px 44px 24px;
  }

  .filter-grid,
  .kpi-grid,
  .charts-grid,
  .bottom-grid {
    gap: 20px;
  }

  .kpi-card {
    min-height: 132px;
    padding: 20px;
  }

  .charts-grid {
    grid-template-columns: 1.2fr 1fr;
  }

  .cash-chart,
  .waterfall-chart {
    width: min(100%, 1350px);
    min-height: 0;
    margin-inline: auto;
  }

  .matrix-table {
    min-width: 0;
    font-size: 0.78rem;
  }

  .insight-card {
    min-height: 84px;
  }
}

@media (min-width: 3600px) {
  .dashboard-content {
    padding-inline: 64px;
  }

  .page-header h1 {
    font-size: 3.25rem;
  }

  .kpi-card > strong {
    font-size: 2rem;
  }

  .panel__header h2 {
    font-size: 1.24rem;
  }

  .cash-chart,
  .waterfall-chart {
    width: min(100%, 1480px);
    min-height: 0;
  }
}


/* Compactação vertical para desktops 1080p sem perder legibilidade */
@media (min-width: 1460px) and (max-height: 1150px) {
  .dashboard-content {
    padding-top: 18px;
    padding-bottom: 24px;
  }

  .page-header {
    margin-bottom: 12px;
  }

  .page-header h1 {
    font-size: clamp(1.8rem, 1.95vw, 2.45rem);
  }

  .filter-grid,
  .kpi-grid,
  .charts-grid,
  .matrix-panel {
    margin-bottom: 12px;
  }

  .filter-control,
  .updated-chip {
    min-height: 52px;
  }

  .updated-chip {
    min-height: 34px;
    margin-block: 9px;
  }

  .kpi-card {
    min-height: 102px;
    padding: 13px 14px 11px;
  }

  .kpi-icon {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .kpi-card > strong {
    margin-top: 10px;
  }

  .panel__header {
    padding-top: 12px;
  }

  .cash-chart,
  .waterfall-chart {
    width: min(100%, 760px);
    min-height: 0;
    margin-inline: auto;
  }

  .matrix-table th,
  .matrix-table td {
    padding: 4px 9px;
  }

  .expenses-panel,
  .insights-panel {
    min-height: 112px;
  }

  .expense-list,
  .insights-grid {
    padding-top: 7px;
    padding-bottom: 11px;
  }

  .expense-list {
    gap: 6px;
  }

  .insight-card {
    min-height: 62px;
    padding-block: 8px;
  }
}

/* NOTEBOOK / TABLET LANDSCAPE */
@media (max-width: 1450px) {
  .filter-grid {
    grid-template-columns: repeat(3, minmax(190px, 1fr));
  }

  .updated-chip {
    grid-column: 1 / -1;
    justify-self: end;
    width: max-content;
    margin: 0;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, minmax(160px, 1fr));
  }

  .kpi-card:last-child {
    grid-column: span 2;
  }

  .insights-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1120px) {
  .dashboard-shell {
    grid-template-columns: 218px minmax(0, 1fr);
  }

  .charts-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

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

  .kpi-card:last-child {
    grid-column: auto;
  }

  .insights-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* MOBILE NAVIGATION */
@media (max-width: 899px) {
  .dashboard-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(82vw, 310px);
    transform: translateX(-105%);
    transition: transform 220ms ease;
    box-shadow: 18px 0 50px rgba(18, 21, 29, 0.24);
  }

  .sidebar-is-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(18, 21, 29, 0.48);
  }

  .sidebar-is-open .sidebar-backdrop {
    display: block;
  }

  .sidebar-close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    color: #fff;
    font-size: 1.6rem;
    background: rgba(255, 255, 255, 0.08);
  }

  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: 42px 1fr 42px;
    align-items: center;
    min-height: 64px;
    padding: 8px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
    border-bottom: 1px solid #d9e0e8;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
  }

  .mobile-topbar img {
    justify-self: center;
    width: 82px;
    height: 46px;
    object-fit: contain;
  }

  .menu-button {
    display: grid;
    gap: 5px;
    width: 42px;
    padding: 11px;
    border: 0;
    border-radius: 9px;
    background: #f0f3f6;
  }

  .menu-button span {
    display: block;
    height: 2px;
    border-radius: 9px;
    background: #353941;
  }

  .mobile-avatar {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    justify-self: end;
    font-size: 0.65rem;
  }

  .dashboard-content {
    padding: 18px 16px 34px;
  }

  .page-header {
    align-items: center;
  }

  .page-kicker {
    display: block;
    margin-bottom: 5px;
    font-size: 0.68rem;
  }

  .page-header h1 {
    font-size: clamp(1.55rem, 6vw, 2.2rem);
  }

  .user-profile {
    display: none;
  }

  .filter-grid {
    grid-template-columns: 1fr 1fr;
  }

  .updated-chip {
    grid-column: 1 / -1;
    justify-self: stretch;
    width: 100%;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-card {
    min-height: 126px;
  }

  .kpi-card h2 {
    font-size: 0.72rem;
  }

  .kpi-card > strong {
    font-size: clamp(1.2rem, 4.8vw, 1.55rem);
  }

  .chart-scroll {
    overflow-x: auto;
  }

  .cash-chart,
  .waterfall-chart {
    width: 760px;
    max-width: none;
  }

  .matrix-panel--expanded {
    inset: 0;
    border: 0;
    border-radius: 0;
  }

  .bottom-grid,
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .insights-grid {
    grid-template-columns: 1fr;
  }
}

/* IPHONE 6 / SMALL PHONES */
@media (max-width: 640px) {
  .login-page {
    display: block;
    min-height: 100dvh;
    background: #f5f5f5;
  }

  .login-hero {
    display: none;
  }

  .login-access {
    min-height: 100dvh;
    padding: max(22px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  }

  .login-stack {
    align-content: center;
    gap: 20px;
  }

  .login-logo {
    width: 118px;
  }

  .login-card {
    min-height: 0;
    padding: 28px 20px 58px;
    border-radius: 15px;
  }

  .login-card__header p {
    margin-bottom: 24px;
  }

  .login-options {
    align-items: flex-start;
    font-size: 0.7rem;
  }

  .dashboard-content {
    padding-inline: 12px;
  }

  .filter-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .updated-chip {
    grid-column: auto;
  }

  .kpi-grid {
    gap: 10px;
  }

  .kpi-card {
    min-height: 116px;
    padding: 13px 11px 11px;
  }

  .kpi-card__top {
    align-items: flex-start;
    gap: 7px;
  }

  .kpi-icon {
    width: 31px;
    height: 31px;
    flex-basis: 31px;
    font-size: 1rem;
  }

  .kpi-card h2 {
    font-size: 0.63rem;
  }

  .kpi-card > strong {
    margin-top: 12px;
    font-size: clamp(1.02rem, 4.9vw, 1.25rem);
  }

  .kpi-card > small {
    font-size: 0.52rem;
  }

  .panel__header {
    padding: 14px 14px 5px;
  }

  .chart-legend {
    display: none;
  }

  .matrix-header {
    padding-bottom: 10px;
  }

  .matrix-wrapper {
    overflow: visible;
  }

  .matrix-table,
  .matrix-table tbody,
  .matrix-table tr,
  .matrix-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .matrix-table thead {
    display: none;
  }

  .matrix-table tbody {
    display: grid;
    gap: 8px;
    padding: 4px 10px 12px;
  }

  .matrix-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
    padding: 10px;
    border: 1px solid #e1e7ed;
    border-radius: 9px;
    background: #fff;
  }

  .matrix-table td,
  .matrix-table td:first-child,
  .matrix-table .row-child td:first-child,
  .matrix-table .row-negative-child td:first-child {
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent !important;
    text-align: right;
    white-space: normal;
  }

  .matrix-table td:first-child {
    grid-column: 1 / -1;
    margin-bottom: 5px;
    text-align: left;
    font-size: 0.74rem;
    font-weight: 800;
  }

  .matrix-table td:nth-child(n + 6):nth-child(-n + 9) {
    display: none;
  }

  .matrix-table td:not(:first-child)::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    color: #949aa4;
    font-size: 0.52rem;
    font-weight: 600;
    text-align: right;
  }

  .expense-list {
    padding-inline: 14px;
  }

  .expense-row {
    grid-template-columns: 20px minmax(86px, 1fr) 1.4fr;
  }

  .expense-value {
    grid-column: 2 / -1;
    justify-self: end;
  }

  .insights-grid {
    padding-inline: 14px;
  }
}

@media (max-width: 390px) {
  .page-header h1 {
    font-size: 1.48rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .kpi-card {
    min-height: 102px;
  }

  .kpi-card > strong {
    font-size: 1.35rem;
  }

  .login-options {
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}


/* MATRIZ DFC EXPANDIDA — referência matriz_explodida.svg */
body.matrix-view-is-open {
  overflow: hidden;
}

.matrix-expanded-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: stretch;
  padding: clamp(18px, 4.25vh, 46px) clamp(18px, 2.25vw, 44px);
  background: #f4f6f8;
}

.matrix-expanded-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #d6e0e9;
  border-radius: clamp(14px, 1vw, 20px);
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 32, 56, 0.04);
}

.matrix-expanded-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  flex: 0 0 auto;
  min-height: clamp(78px, 9.5vh, 102px);
  padding: clamp(18px, 2.25vh, 26px) clamp(18px, 1.35vw, 30px) 14px;
}

.matrix-expanded-header h2 {
  margin: 0;
  color: #102c50;
  font-size: clamp(1rem, 1.05vw, 1.32rem);
  line-height: 1.22;
  letter-spacing: -0.015em;
}

.matrix-expanded-header p {
  margin: 12px 0 0;
  color: #8490a1;
  font-size: clamp(0.64rem, 0.62vw, 0.78rem);
}

.matrix-close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  min-width: clamp(124px, 8.1vw, 154px);
  min-height: 48px;
  padding: 10px 18px;
  border: 1.4px solid #1f2937;
  border-radius: 9px;
  color: #cb1f2d;
  background: #fff;
  transition: background 150ms ease, transform 150ms ease;
}

.matrix-close-button:hover {
  background: #fff5f6;
  transform: translateY(-1px);
}

.matrix-close-button strong {
  font-size: clamp(0.92rem, 0.9vw, 1.08rem);
}

.matrix-close-icon {
  position: relative;
  display: inline-block;
  width: 21px;
  height: 21px;
  flex: 0 0 21px;
}

.matrix-close-icon::before,
.matrix-close-icon::after {
  content: '';
  position: absolute;
  top: 9.5px;
  left: 0;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.matrix-close-icon::before { transform: rotate(45deg); }
.matrix-close-icon::after { transform: rotate(-45deg); }

.matrix-expanded-wrapper {
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  margin: 0 clamp(18px, 1.15vw, 26px);
  overflow: auto;
  border-radius: 11px 11px 0 0;
  scrollbar-width: thin;
  scrollbar-color: #bbc8d7 transparent;
}

.matrix-expanded-table {
  width: 100%;
  min-width: 1180px;
  height: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  color: #14335a;
  font-size: clamp(0.66rem, 0.66vw, 0.82rem);
  font-variant-numeric: tabular-nums;
}

.matrix-expanded-table .matrix-account-column {
  width: clamp(280px, 19.5vw, 350px);
}

.matrix-expanded-table th,
.matrix-expanded-table td {
  min-width: 0;
  padding: 10px clamp(9px, 0.8vw, 16px);
  border-right: 1px solid #dbe4ed;
  border-bottom: 1px solid #e9eef3;
  text-align: right;
  white-space: nowrap;
}

.matrix-expanded-table th:last-child,
.matrix-expanded-table td:last-child {
  border-right: 0;
}

.matrix-expanded-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  height: clamp(52px, 6.1vh, 64px);
  color: #0e2c50;
  font-size: clamp(0.59rem, 0.58vw, 0.72rem);
  font-weight: 800;
  background: #edf3f8;
}

.matrix-expanded-table th:first-child,
.matrix-expanded-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  text-align: left;
  box-shadow: 7px 0 10px -10px rgba(15, 45, 78, 0.5);
}

.matrix-expanded-table thead th:first-child {
  z-index: 7;
  border-radius: 11px 0 0 0;
}

.matrix-expanded-table thead th:last-child {
  border-radius: 0 11px 0 0;
}

.matrix-expanded-table tbody tr {
  height: clamp(51px, 6.25vh, 67px);
}

.matrix-expanded-table tbody td {
  font-weight: 520;
  background: #fff;
}

.matrix-expanded-table tbody tr:nth-child(even) td {
  background: #f9fbfd;
}

.matrix-expanded-table .row-neutral td {
  font-weight: 750;
  background: #fbfcfe;
}

.matrix-expanded-table .row-positive td,
.matrix-expanded-table .row-total td {
  color: #102f57;
  font-weight: 800;
  background: #eaf3ff;
}

.matrix-expanded-table .row-positive-soft td {
  color: #087842;
  font-weight: 800;
  background: #f0faf5;
}

.matrix-expanded-table .row-positive-soft td:nth-child(3) {
  color: #c91e2d;
}

.matrix-expanded-table .row-negative td {
  color: #d01b2b;
  font-weight: 800;
  background: #fff1f2;
}

.matrix-expanded-table .row-negative-child td {
  color: #d01b2b;
  font-weight: 740;
}

.matrix-expanded-table .row-child td {
  color: #1b3b62;
}

.matrix-expanded-table .row-neutral td:first-child { background: #fbfcfe; }
.matrix-expanded-table .row-positive td:first-child,
.matrix-expanded-table .row-total td:first-child { background: #eaf3ff; }
.matrix-expanded-table .row-positive-soft td:first-child { background: #f0faf5; }
.matrix-expanded-table .row-negative td:first-child { background: #fff1f2; }
.matrix-expanded-table .row-child td:first-child,
.matrix-expanded-table .row-negative-child td:first-child { background: inherit; }

.sort-arrow {
  float: right;
  margin-right: 38%;
  font-size: 0.64rem;
}

.matrix-account {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.matrix-account strong,
.matrix-account > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-group-toggle {
  display: inline-grid;
  place-items: center;
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  padding: 0;
  border: 1px solid #cad8e7;
  border-radius: 7px;
  color: #7d93ae;
  background: #fff;
}

.matrix-group-toggle span {
  display: block;
  width: 8px;
  height: 8px;
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 160ms ease;
}

.matrix-group-toggle span.is-collapsed {
  transform: translateX(-2px) rotate(-45deg);
}

.matrix-account--child {
  position: relative;
  min-height: 31px;
  padding-left: 42px;
}

.matrix-account--child::before {
  content: '';
  position: absolute;
  top: -28px;
  bottom: -28px;
  left: 15px;
  width: 1px;
  background: #cddbeb;
}

.matrix-hierarchy-dot {
  position: absolute;
  left: 11px;
  width: 8px;
  height: 8px;
  border: 1.5px solid #8ca4bf;
  border-radius: 50%;
  background: #fff;
}

.matrix-expanded-footer {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(260px, 1fr);
  align-items: center;
  gap: 20px;
  flex: 0 0 auto;
  min-height: clamp(58px, 6.7vh, 72px);
  margin: 0 clamp(18px, 1.15vw, 26px);
  border-top: 1px solid #dce5ee;
  color: #65738a;
  font-size: clamp(0.62rem, 0.61vw, 0.75rem);
}

.matrix-lines-status,
.matrix-legend,
.matrix-legend span {
  display: flex;
  align-items: center;
}

.matrix-lines-status {
  gap: 11px;
}

.matrix-lines-status > span {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  border-radius: 50%;
  background: #13864c;
}

.matrix-lines-status strong {
  font-weight: 740;
}

.matrix-legend {
  justify-content: center;
  gap: 22px;
}

.matrix-legend > strong {
  margin-right: -8px;
}

.matrix-legend span {
  gap: 9px;
  white-space: nowrap;
}

.matrix-legend i {
  display: inline-block;
  width: 15px;
  height: 15px;
  border-radius: 3px;
}

.legend-entry { background: #eaf3ff; }
.legend-exit { background: #fff1f2; }
.legend-free { background: #f0faf5; }

.matrix-expanded-footer > small {
  justify-self: end;
  color: #78869a;
  white-space: nowrap;
}

@media (min-width: 2200px) {
  .matrix-expanded-screen {
    padding: 42px 54px;
  }

  .matrix-expanded-header {
    min-height: 112px;
    padding: 30px 36px 18px;
  }

  .matrix-expanded-header h2 {
    font-size: 1.55rem;
  }

  .matrix-expanded-header p,
  .matrix-expanded-table,
  .matrix-expanded-footer {
    font-size: 0.9rem;
  }

  .matrix-expanded-table thead th {
    font-size: 0.82rem;
  }

  .matrix-expanded-table tbody tr {
    height: 72px;
  }

  .matrix-group-toggle {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .matrix-account--child {
    padding-left: 50px;
  }
}

@media (max-width: 899px) {
  .matrix-expanded-screen {
    padding: 0;
  }

  .matrix-expanded-card {
    border: 0;
    border-radius: 0;
  }

  .matrix-expanded-header {
    position: relative;
    z-index: 10;
    align-items: center;
    min-height: 82px;
    padding: max(14px, env(safe-area-inset-top)) 14px 12px;
    border-bottom: 1px solid #dce5ee;
    box-shadow: 0 4px 18px rgba(15, 32, 56, 0.06);
  }

  .matrix-expanded-header h2 {
    max-width: 62vw;
    font-size: 0.98rem;
  }

  .matrix-expanded-header p {
    margin-top: 5px;
    font-size: 0.6rem;
  }

  .matrix-close-button {
    min-width: auto;
    min-height: 42px;
    gap: 8px;
    padding: 8px 11px;
  }

  .matrix-close-button strong {
    font-size: 0.78rem;
  }

  .matrix-close-icon {
    width: 17px;
    height: 17px;
    flex-basis: 17px;
  }

  .matrix-close-icon::before,
  .matrix-close-icon::after {
    top: 8px;
    width: 18px;
  }

  .matrix-expanded-wrapper {
    margin: 0;
    padding: 10px 10px 16px;
    border-radius: 0;
    background: #f4f6f8;
  }

  .matrix-expanded-table,
  .matrix-expanded-table tbody,
  .matrix-expanded-table tr,
  .matrix-expanded-table td {
    display: block;
    width: 100%;
    min-width: 0;
    height: auto;
  }

  .matrix-expanded-table colgroup,
  .matrix-expanded-table thead {
    display: none;
  }

  .matrix-expanded-table tbody {
    display: grid;
    gap: 10px;
  }

  .matrix-expanded-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 12px;
    padding: 12px;
    border: 1px solid #dbe4ed;
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(15, 32, 56, 0.035);
  }

  .matrix-expanded-table th,
  .matrix-expanded-table td,
  .matrix-expanded-table th:first-child,
  .matrix-expanded-table td:first-child {
    position: static;
    padding: 0;
    border: 0;
    background: transparent !important;
    box-shadow: none;
    white-space: normal;
  }

  .matrix-expanded-table td {
    text-align: right;
    font-size: 0.72rem;
  }

  .matrix-expanded-table td:first-child {
    grid-column: 1 / -1;
    padding-bottom: 9px;
    border-bottom: 1px solid rgba(151, 169, 190, 0.28);
    font-size: 0.78rem;
    text-align: left;
  }

  .matrix-expanded-table td:not(:first-child)::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: #8794a7;
    font-size: 0.54rem;
    font-weight: 650;
  }

  .matrix-expanded-table .row-positive,
  .matrix-expanded-table .row-total {
    background: #eaf3ff;
  }

  .matrix-expanded-table .row-negative {
    background: #fff1f2;
  }

  .matrix-expanded-table .row-positive-soft {
    background: #f0faf5;
  }

  .matrix-account {
    gap: 9px;
  }

  .matrix-group-toggle {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }

  .matrix-account--child {
    min-height: 24px;
    padding-left: 31px;
  }

  .matrix-account--child::before {
    top: -17px;
    bottom: -17px;
    left: 11px;
  }

  .matrix-hierarchy-dot {
    left: 7px;
  }

  .matrix-expanded-footer {
    grid-template-columns: 1fr;
    gap: 8px;
    min-height: auto;
    margin: 0;
    padding: 12px 14px max(12px, env(safe-area-inset-bottom));
    background: #fff;
  }

  .matrix-legend {
    display: none;
  }

  .matrix-expanded-footer > small {
    justify-self: start;
  }
}

@media (max-width: 390px) {
  .matrix-expanded-header h2 {
    max-width: 59vw;
    font-size: 0.86rem;
  }

  .matrix-expanded-header p {
    max-width: 58vw;
  }

  .matrix-close-button strong {
    display: none;
  }

  .matrix-close-button {
    width: 42px;
    min-width: 42px;
    padding: 8px;
  }

  .matrix-expanded-table tbody tr {
    padding: 11px 10px;
  }
}

/* DRILL-DOWN DA MATRIZ: FORNECEDORES */
.matrix-expanded-table tbody tr.is-drilldown-row {
  cursor: pointer;
  transition: filter 140ms ease, box-shadow 140ms ease;
}

.matrix-expanded-table tbody tr.is-drilldown-row:hover td {
  filter: brightness(0.985);
  box-shadow: inset 0 1px 0 rgba(208, 27, 43, 0.08), inset 0 -1px 0 rgba(208, 27, 43, 0.08);
}

.matrix-expanded-table tbody tr.is-drilldown-row:focus-visible {
  outline: 3px solid rgba(24, 119, 242, 0.28);
  outline-offset: -3px;
}

.matrix-drill-hint {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  padding-left: 12px;
  color: #b91f2d;
  font-size: 0.58rem;
  font-weight: 800;
  white-space: nowrap;
}

.matrix-drill-hint i {
  display: block;
  width: 7px;
  height: 7px;
  border-top: 1.7px solid currentColor;
  border-right: 1.7px solid currentColor;
  transform: rotate(45deg);
}

/* DETALHAMENTO EXPANDIDO DE FORNECEDORES */
.supplier-detail-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  overflow: hidden;
  color: #12345f;
  background: #f6f8fa;
}

.supplier-detail-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 16px clamp(18px, 1.45vw, 28px) 14px;
}

.supplier-detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 44px;
}

.supplier-export-button,
.supplier-close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px 18px;
  border: 1.4px solid #17345f;
  border-radius: 8px;
  color: #17345f;
  background: #fff;
  transition: background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.supplier-export-button:hover,
.supplier-close-button:hover {
  transform: translateY(-1px);
  background: #f7faff;
  box-shadow: 0 5px 18px rgba(23, 52, 95, 0.08);
}

.supplier-export-button strong,
.supplier-close-button strong {
  font-size: clamp(0.72rem, 0.72vw, 0.88rem);
}

.supplier-close-button {
  border-color: #29323d;
  color: #cf1f2f;
}

.supplier-close-button:hover {
  background: #fff5f6;
}

.supplier-export-icon {
  position: relative;
  display: block;
  width: 18px;
  height: 19px;
  flex: 0 0 18px;
  border-bottom: 1.8px solid currentColor;
}

.supplier-export-icon::before {
  content: '';
  position: absolute;
  top: 0;
  left: 8px;
  width: 2px;
  height: 12px;
  border-radius: 2px;
  background: currentColor;
}

.supplier-export-icon::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 4px;
  width: 8px;
  height: 8px;
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  transform: rotate(45deg);
}

.supplier-close-icon {
  position: relative;
  display: block;
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
}

.supplier-close-icon::before,
.supplier-close-icon::after {
  content: '';
  position: absolute;
  top: 7.5px;
  left: 0;
  width: 18px;
  height: 1.8px;
  border-radius: 2px;
  background: currentColor;
}

.supplier-close-icon::before { transform: rotate(45deg); }
.supplier-close-icon::after { transform: rotate(-45deg); }

.supplier-detail-content {
  display: grid;
  grid-template-rows: minmax(370px, 1.48fr) minmax(235px, 0.92fr);
  gap: 10px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.supplier-summary-card,
.supplier-payments-card,
.supplier-detail-footer {
  border: 1px solid #d1deeb;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 40, 72, 0.035);
}

.supplier-summary-card,
.supplier-payments-card {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 16px;
}

.supplier-summary-card {
  display: flex;
  flex-direction: column;
}

.supplier-summary-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex: 0 0 auto;
  min-height: clamp(70px, 8.1vh, 86px);
  padding: 14px clamp(18px, 1.25vw, 26px) 10px;
}

.supplier-summary-heading h2 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px 13px;
  margin: 0;
  color: #15355e;
  font-size: clamp(0.72rem, 0.73vw, 0.9rem);
  line-height: 1.35;
}

.supplier-summary-heading h2 > span {
  font-weight: 760;
}

.supplier-summary-heading h2 > strong {
  color: #0569d8;
  font-weight: 820;
}

.supplier-summary-heading h2 > i {
  color: #102f56;
  font-size: 1.3em;
  font-style: normal;
  font-weight: 900;
}

.supplier-horizon-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 18px;
  border-radius: 9px;
  color: #536984;
  font-size: clamp(0.65rem, 0.63vw, 0.78rem);
  font-weight: 760;
  white-space: nowrap;
  background: #f0f4f8;
}

.supplier-category-wrapper {
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  margin: 0 clamp(16px, 1vw, 22px) 10px;
  overflow: auto;
  border-radius: 11px 11px 0 0;
  scrollbar-width: thin;
  scrollbar-color: #b9c8d9 transparent;
}

.supplier-category-table {
  width: 100%;
  min-width: 1380px;
  height: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  color: #173a67;
  font-size: clamp(0.64rem, 0.65vw, 0.8rem);
  font-variant-numeric: tabular-nums;
}

.supplier-category-table .supplier-name-column {
  width: clamp(330px, 22.4vw, 430px);
}

.supplier-category-table th,
.supplier-category-table td {
  min-width: 0;
  padding: 9px clamp(9px, 0.75vw, 15px);
  border-right: 1px solid #d9e3ed;
  border-bottom: 1px solid #e9eef3;
  text-align: right;
  white-space: nowrap;
}

.supplier-category-table th:last-child,
.supplier-category-table td:last-child {
  border-right: 0;
}

.supplier-category-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  height: clamp(50px, 5.7vh, 62px);
  border-top: 2px solid #1486ff;
  color: #14345e;
  font-size: clamp(0.58rem, 0.58vw, 0.72rem);
  font-weight: 820;
  background: #eaf2fb;
}

.supplier-category-table thead th:first-child {
  border-left: 2px solid #1486ff;
  border-radius: 11px 0 0 11px;
}

.supplier-category-table thead th:last-child {
  border-right: 2px solid #1486ff;
  border-radius: 0 11px 11px 0;
}

.supplier-category-table th:first-child,
.supplier-category-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  text-align: left;
  box-shadow: 7px 0 10px -10px rgba(15, 45, 78, 0.48);
}

.supplier-category-table thead th:first-child {
  z-index: 7;
}

.supplier-category-table tbody tr {
  height: clamp(48px, 5.45vh, 58px);
}

.supplier-category-table tbody td {
  color: #e21d2d;
  font-weight: 780;
  background: #fff;
}

.supplier-category-table tbody tr:nth-child(even) td {
  background: #fbfcfe;
}

.supplier-category-table .supplier-row-group td {
  color: #e01e2e;
  font-weight: 830;
  background: #fff0f1;
}

.supplier-category-table .supplier-row-group td:first-child {
  color: #14345e;
  background: #fff0f1;
}

.supplier-category-table .supplier-row-category td:first-child {
  color: #173a67;
  font-weight: 530;
  background: inherit;
}

.supplier-category-name {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.supplier-category-name > strong,
.supplier-category-name > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.supplier-category-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  padding: 0;
  border: 1px solid #c3d4e6;
  border-radius: 8px;
  color: #31577f;
  background: #fff;
}

.supplier-category-toggle span {
  display: block;
  width: 10px;
  height: 10px;
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 150ms ease;
}

.supplier-category-toggle span.is-collapsed {
  transform: translateX(-2px) rotate(-45deg);
}

.supplier-category-toggle.is-category {
  cursor: default;
}

.supplier-category-name--child {
  position: relative;
  min-height: 34px;
  padding-left: 34px;
}

.supplier-category-name--child::before {
  content: '';
  position: absolute;
  top: -24px;
  bottom: -24px;
  left: 9px;
  width: 1px;
  background: #c7d7e8;
}

.supplier-tree-dot {
  position: absolute;
  left: 5px;
  width: 8px;
  height: 8px;
  border: 1.4px solid #87a5c4;
  border-radius: 50%;
  background: #fff;
}

.supplier-payments-card {
  display: flex;
  flex-direction: column;
}

.supplier-payments-card h3 {
  flex: 0 0 auto;
  margin: 0;
  padding: clamp(14px, 1.75vh, 20px) clamp(18px, 1.25vw, 26px) 10px;
  color: #15355e;
  font-size: clamp(0.82rem, 0.82vw, 1rem);
  letter-spacing: -0.01em;
}

.supplier-payments-wrapper {
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  margin: 0 clamp(16px, 1vw, 22px) 6px;
  overflow: auto;
  border-radius: 8px 8px 0 0;
}

.supplier-payments-table {
  width: 100%;
  min-width: 880px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  color: #536b8a;
  font-size: clamp(0.63rem, 0.63vw, 0.77rem);
  font-variant-numeric: tabular-nums;
}

.supplier-payments-table th,
.supplier-payments-table td {
  height: clamp(31px, 3.65vh, 39px);
  padding: 7px clamp(15px, 1.6vw, 30px);
  border-right: 1px solid #dbe5ef;
  border-bottom: 1px solid #e9eef3;
  text-align: left;
  white-space: nowrap;
}

.supplier-payments-table th:last-child,
.supplier-payments-table td:last-child {
  border-right: 0;
  text-align: right;
}

.supplier-payments-table thead th {
  color: #173860;
  font-weight: 820;
  text-align: center;
  background: #eaf2fb;
}

.supplier-payments-table thead th:first-child {
  border: 1px solid #a8cff7;
  border-right-color: #dbe5ef;
  border-radius: 8px 0 0 8px;
  text-align: left;
}

.supplier-payments-table thead th:last-child {
  border: 1px solid #a8cff7;
  border-left: 0;
  border-radius: 0 8px 8px 0;
}

.supplier-payments-table tbody td:last-child {
  color: #e21d2d;
  font-weight: 820;
}

.calendar-icon {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 6px;
  border: 1.5px solid #31577f;
  border-radius: 2px;
  vertical-align: -2px;
}

.calendar-icon::before {
  content: '';
  position: absolute;
  top: 3px;
  right: 0;
  left: 0;
  height: 1px;
  background: #31577f;
}

.calendar-icon::after {
  content: '';
  position: absolute;
  top: -3px;
  left: 3px;
  width: 6px;
  height: 4px;
  border-right: 1.5px solid #31577f;
  border-left: 1.5px solid #31577f;
}

.supplier-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 108px;
  min-height: 24px;
  padding: 4px 14px;
  border-radius: 7px;
  font-size: clamp(0.56rem, 0.56vw, 0.69rem);
  font-weight: 820;
}

.supplier-status--open {
  color: #e0202f;
  background: #ffe7e8;
}

.supplier-status--scheduled {
  color: #1169d4;
  background: #e8f1ff;
}

.supplier-detail-footer {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) auto minmax(300px, 1fr);
  align-items: center;
  gap: 20px;
  min-height: 54px;
  padding: 9px clamp(18px, 1.45vw, 28px);
  border-radius: 13px;
  color: #647894;
  font-size: clamp(0.6rem, 0.59vw, 0.73rem);
}

.supplier-lines-status,
.supplier-detail-legend,
.supplier-detail-legend span {
  display: flex;
  align-items: center;
}

.supplier-lines-status {
  gap: 12px;
}

.supplier-lines-status > span {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border-radius: 50%;
  background: #159553;
}

.supplier-lines-status strong {
  font-weight: 780;
}

.supplier-detail-legend {
  justify-content: center;
  gap: 25px;
}

.supplier-detail-legend span {
  gap: 10px;
  white-space: nowrap;
}

.supplier-detail-legend i {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 4px;
}

.supplier-legend-category { background: #eaf2fb; }
.supplier-legend-exit { background: #fff0f1; }
.supplier-legend-scheduled { background: #e8f1ff; }

.supplier-detail-footer > small {
  justify-self: end;
  white-space: nowrap;
}

@media (min-width: 2200px) {
  .supplier-detail-shell {
    gap: 14px;
    padding: 22px 38px 20px;
  }

  .supplier-detail-toolbar {
    min-height: 54px;
  }

  .supplier-export-button,
  .supplier-close-button {
    min-height: 50px;
    padding-inline: 22px;
  }

  .supplier-detail-content {
    gap: 14px;
    grid-template-rows: minmax(450px, 1.5fr) minmax(280px, 0.9fr);
  }

  .supplier-summary-heading {
    min-height: 98px;
    padding-inline: 34px;
  }

  .supplier-summary-heading h2,
  .supplier-category-table,
  .supplier-payments-table {
    font-size: 0.9rem;
  }

  .supplier-category-table thead th,
  .supplier-payments-table thead th {
    font-size: 0.8rem;
  }

  .supplier-category-table tbody tr {
    height: 68px;
  }

  .supplier-payments-table th,
  .supplier-payments-table td {
    height: 46px;
  }

  .supplier-detail-footer {
    min-height: 66px;
    font-size: 0.82rem;
  }
}

@media (max-width: 899px) {
  .matrix-drill-hint {
    margin-left: auto;
    font-size: 0;
  }

  .supplier-detail-screen {
    overflow: auto;
    overscroll-behavior: contain;
  }

  .supplier-detail-shell {
    display: block;
    height: auto;
    min-height: 100%;
    padding: 0 10px 10px;
  }

  .supplier-detail-toolbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 66px;
    margin: 0 -10px 10px;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
    border-bottom: 1px solid #d5e0eb;
    background: rgba(246, 248, 250, 0.96);
    backdrop-filter: blur(12px);
  }

  .supplier-export-button,
  .supplier-close-button {
    min-height: 42px;
    gap: 8px;
    padding: 8px 12px;
  }

  .supplier-export-button strong,
  .supplier-close-button strong {
    font-size: 0.72rem;
  }

  .supplier-detail-content {
    display: grid;
    grid-template-rows: auto auto;
    gap: 10px;
    overflow: visible;
  }

  .supplier-summary-card,
  .supplier-payments-card {
    overflow: visible;
    border-radius: 12px;
  }

  .supplier-summary-heading {
    align-items: flex-start;
    min-height: 0;
    padding: 16px 13px 12px;
  }

  .supplier-summary-heading h2 {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 7px;
    max-width: calc(100% - 104px);
    font-size: 0.68rem;
  }

  .supplier-summary-heading h2 > i {
    display: none;
  }

  .supplier-summary-heading h2 > strong:last-child {
    grid-column: 2;
  }

  .supplier-horizon-chip {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 0.56rem;
  }

  .supplier-category-wrapper,
  .supplier-payments-wrapper {
    margin: 0;
    padding: 0 9px 11px;
    overflow: visible;
    border-radius: 0;
  }

  .supplier-category-table,
  .supplier-category-table tbody,
  .supplier-category-table tr,
  .supplier-category-table td,
  .supplier-payments-table,
  .supplier-payments-table tbody,
  .supplier-payments-table tr,
  .supplier-payments-table td {
    display: block;
    width: 100%;
    min-width: 0;
    height: auto;
  }

  .supplier-category-table colgroup,
  .supplier-category-table thead,
  .supplier-payments-table thead {
    display: none;
  }

  .supplier-category-table tbody,
  .supplier-payments-table tbody {
    display: grid;
    gap: 9px;
  }

  .supplier-category-table tbody tr,
  .supplier-payments-table tbody tr {
    display: grid;
    height: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 12px;
    padding: 12px;
    border: 1px solid #d8e3ed;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 2px 9px rgba(15, 40, 72, 0.035);
  }

  .supplier-category-table tbody tr.supplier-row-group {
    background: #fff0f1;
  }

  .supplier-category-table th,
  .supplier-category-table td,
  .supplier-category-table th:first-child,
  .supplier-category-table td:first-child,
  .supplier-payments-table th,
  .supplier-payments-table td,
  .supplier-payments-table th:last-child,
  .supplier-payments-table td:last-child {
    position: static;
    padding: 0;
    border: 0;
    color: #e21d2d;
    background: transparent !important;
    box-shadow: none;
    text-align: right;
    white-space: normal;
  }

  .supplier-category-table td:first-child,
  .supplier-payments-table td:first-child {
    grid-column: 1 / -1;
    padding-bottom: 9px;
    border-bottom: 1px solid rgba(151, 169, 190, 0.28);
    color: #173a67;
    text-align: left;
  }

  .supplier-category-table td:not(:first-child)::before,
  .supplier-payments-table td:not(:first-child)::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: #8796aa;
    font-size: 0.52rem;
    font-weight: 680;
  }

  .supplier-category-table td,
  .supplier-payments-table td {
    font-size: 0.7rem;
  }

  .supplier-category-name--child {
    padding-left: 27px;
  }

  .supplier-category-name--child::before {
    top: -18px;
    bottom: -18px;
    left: 8px;
  }

  .supplier-tree-dot {
    left: 4px;
  }

  .supplier-category-toggle {
    width: 29px;
    height: 29px;
    flex-basis: 29px;
  }

  .supplier-payments-card h3 {
    padding: 15px 13px 11px;
    font-size: 0.84rem;
  }

  .supplier-payments-table tbody tr {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .supplier-payments-table td:nth-child(2) {
    grid-column: 1 / -1;
    text-align: left;
  }

  .supplier-payments-table td:nth-child(2)::before {
    text-align: left;
  }

  .supplier-payments-table td:last-child {
    color: #e21d2d;
  }

  .supplier-status {
    min-width: 90px;
    min-height: 23px;
    padding: 4px 9px;
    font-size: 0.58rem;
  }

  .supplier-detail-footer {
    grid-template-columns: 1fr;
    gap: 8px;
    min-height: 0;
    margin-top: 10px;
    padding: 13px 14px max(13px, env(safe-area-inset-bottom));
    border-radius: 11px;
  }

  .supplier-detail-legend {
    display: none;
  }

  .supplier-detail-footer > small {
    justify-self: start;
  }
}

@media (max-width: 390px) {
  .supplier-export-button strong,
  .supplier-close-button strong {
    display: none;
  }

  .supplier-export-button,
  .supplier-close-button {
    width: 43px;
    min-width: 43px;
    padding: 8px;
  }

  .supplier-summary-heading h2 {
    max-width: calc(100% - 93px);
    font-size: 0.61rem;
  }

  .supplier-horizon-chip {
    max-width: 88px;
    white-space: normal;
    text-align: center;
  }

  .supplier-category-table tbody tr,
  .supplier-payments-table tbody tr {
    padding: 11px 10px;
  }
}


/* ========================================================================== 
   RESPONSIVIDADE REFORÇADA — mobile real, incluindo Safari do iPhone 6
   ========================================================================== */
html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body,
#app-root,
.login-page,
.dashboard-shell,
.dashboard-main,
.dashboard-content {
  max-width: 100%;
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

input,
select,
button {
  max-width: 100%;
}

/* Fallbacks para navegadores antigos que não interpretam clamp()/min()/max(). */
.login-hero { padding: 64px; }
.login-hero__content { width: 100%; max-width: 670px; }
.login-hero h1 { font-size: 3.4rem; }
.login-hero__description { font-size: 1.32rem; }
.login-access { padding: 48px; }
.login-stack { width: 100%; max-width: 590px; }
.login-logo { width: 180px; }
.login-card { padding: 46px 52px 62px; }
.dashboard-shell { grid-template-columns: 264px minmax(0, 1fr); }
.dashboard-content { padding: 28px 30px 42px; }
.page-header h1 { font-size: 2.25rem; }
.kpi-card h2 { font-size: 0.78rem; }
.kpi-card > strong { font-size: 1.55rem; }
.panel__header h2 { font-size: 1.05rem; }

/* Tablets, celulares e modo responsivo do navegador. */
@media (max-width: 899px) {
  html,
  body,
  #app-root {
    width: 100%;
    min-width: 0;
  }

  body {
    overflow-x: hidden;
  }

  .dashboard-shell,
  .dashboard-main,
  .dashboard-content,
  .page-header,
  .filter-grid,
  .kpi-grid,
  .charts-grid,
  .bottom-grid,
  .panel,
  .matrix-panel {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .sidebar {
    width: 310px;
    max-width: 86vw;
  }

  .mobile-topbar {
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    padding: 8px 14px;
  }

  @supports (padding: max(0px)) {
    .mobile-topbar {
      padding-right: max(14px, env(safe-area-inset-right));
      padding-left: max(14px, env(safe-area-inset-left));
    }
  }

  .dashboard-content {
    padding: 18px 16px 34px;
    overflow: hidden;
  }

  .page-header {
    gap: 12px;
    margin-bottom: 16px;
  }

  .page-header h1 {
    font-size: 2rem;
    line-height: 1.12;
    overflow-wrap: anywhere;
  }

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

  .filter-control,
  .updated-chip {
    width: 100%;
    min-width: 0;
  }

  .filter-control {
    padding: 8px 12px;
  }

  .filter-control__content,
  .filter-control select {
    min-width: 0;
  }

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

  .kpi-card,
  .kpi-card:last-child {
    grid-column: auto;
    min-width: 0;
  }

  .kpi-card h2,
  .kpi-card > strong,
  .kpi-card > small {
    overflow-wrap: anywhere;
  }

  .kpi-card > strong {
    white-space: normal;
  }

  .charts-grid,
  .bottom-grid,
  .insights-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel__header {
    min-width: 0;
  }

  .panel__header > div,
  .panel__header h2 {
    min-width: 0;
  }

  .chart-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .cash-chart,
  .waterfall-chart {
    width: 680px;
    min-width: 680px;
    max-width: none;
    min-height: 210px;
  }

  .matrix-wrapper {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .expense-row {
    min-width: 0;
  }

  .expense-label,
  .expense-value,
  .insight-card strong,
  .insight-card small {
    overflow-wrap: anywhere;
  }

  /* Matriz expandida */
  .matrix-expanded-screen,
  .matrix-expanded-card {
    width: 100%;
    max-width: 100%;
  }

  .matrix-expanded-header {
    padding: 14px 14px 12px;
  }

  @supports (padding: max(0px)) {
    .matrix-expanded-header {
      padding-top: max(14px, env(safe-area-inset-top));
    }
  }

  .matrix-expanded-header > div {
    min-width: 0;
    flex: 1 1 auto;
  }

  .matrix-expanded-header h2,
  .matrix-expanded-header p {
    max-width: none;
    overflow-wrap: anywhere;
  }

  .matrix-close-button {
    flex: 0 0 auto;
  }

  .matrix-expanded-wrapper {
    width: 100%;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .matrix-expanded-table tbody tr {
    min-width: 0;
  }

  .matrix-expanded-table td {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .matrix-expanded-table td:last-child {
    grid-column: 1 / -1;
    padding-top: 8px;
    border-top: 1px dashed rgba(135, 148, 167, 0.35);
  }

  .matrix-expanded-footer {
    padding: 12px 14px;
  }

  @supports (padding: max(0px)) {
    .matrix-expanded-footer {
      padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
  }

  /* Fornecedores */
  .supplier-detail-screen,
  .supplier-detail-shell,
  .supplier-detail-content,
  .supplier-summary-card,
  .supplier-payments-card,
  .supplier-category-wrapper,
  .supplier-payments-wrapper {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .supplier-detail-shell {
    padding: 0 10px 10px;
  }

  .supplier-detail-toolbar {
    padding: 10px 12px;
  }

  @supports (padding: max(0px)) {
    .supplier-detail-toolbar {
      padding-top: max(10px, env(safe-area-inset-top));
    }
  }

  .supplier-summary-heading {
    gap: 10px;
  }

  .supplier-summary-heading h2 {
    min-width: 0;
    max-width: none;
    flex: 1 1 auto;
    overflow-wrap: anywhere;
  }

  .supplier-horizon-chip {
    flex: 0 0 auto;
  }

  .supplier-category-table tbody tr,
  .supplier-payments-table tbody tr {
    min-width: 0;
  }

  .supplier-category-table td,
  .supplier-payments-table td {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .supplier-category-table td:last-child,
  .supplier-payments-table td:last-child {
    grid-column: 1 / -1;
    padding-top: 8px;
    border-top: 1px dashed rgba(135, 148, 167, 0.35);
  }

  .supplier-detail-footer {
    padding: 13px 14px;
  }

  @supports (padding: max(0px)) {
    .supplier-detail-footer {
      padding-bottom: max(13px, env(safe-area-inset-bottom));
    }
  }
}

/* Celulares em modo retrato, incluindo 375 × 667 do iPhone 6. */
@media (max-width: 640px) {
  .login-page,
  .login-access,
  .login-stack,
  .login-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .login-access {
    min-height: 100vh;
    padding: 22px 16px 24px;
  }

  @supports (padding: max(0px)) {
    .login-access {
      padding-top: max(22px, env(safe-area-inset-top));
      padding-bottom: max(24px, env(safe-area-inset-bottom));
    }
  }

  .login-stack {
    gap: 20px;
  }

  .login-logo {
    width: 118px;
  }

  .login-card {
    padding: 28px 20px 58px;
  }

  .login-options {
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  /* Fallback para Safari antigo, que não possui gap em flexbox. */
  .login-options > * {
    margin-bottom: 4px;
  }

  .remember-access {
    white-space: normal;
  }

  .mobile-topbar {
    min-height: 58px;
  }

  .dashboard-content {
    padding: 14px 12px 28px;
  }

  .page-header {
    display: block;
    margin-bottom: 14px;
  }

  .page-header h1 {
    font-size: 1.62rem;
  }

  .filter-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .filter-control,
  .updated-chip {
    min-height: 54px;
  }

  .updated-chip {
    margin: 0;
  }

  .panel {
    border-radius: 11px;
  }

  .panel__header {
    display: block;
    padding: 14px 14px 8px;
  }

  .panel__header > * + * {
    margin-top: 8px;
  }

  .chart-legend {
    justify-content: flex-start;
  }

  .cash-chart,
  .waterfall-chart {
    width: 620px;
    min-width: 620px;
    min-height: 192px;
  }

  .matrix-header {
    display: flex;
    align-items: center;
  }

  .matrix-header > * + * {
    margin-top: 0;
  }

  .expand-button {
    flex: 0 0 auto;
    margin-left: 10px;
  }

  .expense-list,
  .insights-grid {
    padding-right: 12px;
    padding-left: 12px;
  }

  .expense-row {
    grid-template-columns: 22px minmax(0, 1fr) auto;
    gap: 7px 9px;
  }

  .expense-track {
    grid-column: 2 / -1;
    width: 100%;
  }

  .expense-value {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    font-size: 0.67rem;
  }

  .insight-card {
    grid-template-columns: 34px minmax(0, 1fr);
    padding: 11px 12px;
  }

  .insight-icon {
    width: 32px;
    height: 32px;
  }

  .matrix-expanded-header {
    min-height: 76px;
    gap: 10px;
  }

  .matrix-expanded-header h2 {
    font-size: 0.9rem;
  }

  .matrix-expanded-header p {
    font-size: 0.58rem;
  }

  .matrix-close-button {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 8px;
  }

  .matrix-close-button strong {
    display: none;
  }

  .matrix-expanded-table tbody tr,
  .supplier-category-table tbody tr,
  .supplier-payments-table tbody tr {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 10px;
    padding: 11px 10px;
  }

  .matrix-expanded-table td,
  .supplier-category-table td,
  .supplier-payments-table td {
    font-size: 0.69rem;
  }

  .matrix-expanded-table td:not(:first-child)::before,
  .supplier-category-table td:not(:first-child)::before,
  .supplier-payments-table td:not(:first-child)::before {
    font-size: 0.5rem;
  }

  .supplier-detail-toolbar {
    min-height: 62px;
  }

  .supplier-summary-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    padding: 14px 11px 11px;
  }

  .supplier-summary-heading h2 {
    display: block;
    font-size: 0.65rem;
    line-height: 1.55;
  }

  .supplier-summary-heading h2 > span,
  .supplier-summary-heading h2 > strong {
    display: block;
  }

  .supplier-summary-heading h2 > i {
    display: none;
  }

  .supplier-horizon-chip {
    max-width: 92px;
    min-height: 34px;
    padding: 7px 9px;
    font-size: 0.55rem;
    white-space: normal;
    text-align: center;
  }

  .supplier-export-button,
  .supplier-close-button {
    min-width: 43px;
    min-height: 43px;
  }

  .supplier-category-name {
    min-width: 0;
  }

  .supplier-category-name > strong,
  .supplier-category-name > span:last-child {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* Telefones estreitos e zoom de acessibilidade. */
@media (max-width: 430px) {
  .kpi-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .kpi-card {
    min-height: 100px;
  }

  .kpi-card > strong {
    font-size: 1.35rem;
  }

  .chart-legend {
    display: none;
  }

  .matrix-expanded-table tbody tr,
  .supplier-category-table tbody tr,
  .supplier-payments-table tbody tr {
    gap: 8px;
  }

  .supplier-export-button strong,
  .supplier-close-button strong {
    display: none;
  }

  .supplier-export-button,
  .supplier-close-button {
    width: 43px;
    padding: 8px;
  }
}

@media (max-width: 350px) {
  .dashboard-content {
    padding-right: 8px;
    padding-left: 8px;
  }

  .page-header h1 {
    font-size: 1.45rem;
  }

  .matrix-expanded-table tbody tr,
  .supplier-category-table tbody tr,
  .supplier-payments-table tbody tr {
    grid-template-columns: minmax(0, 1fr);
  }

  .matrix-expanded-table td,
  .supplier-category-table td,
  .supplier-payments-table td,
  .matrix-expanded-table td:not(:first-child)::before,
  .supplier-category-table td:not(:first-child)::before,
  .supplier-payments-table td:not(:first-child)::before {
    text-align: left;
  }

  .matrix-expanded-table td:last-child,
  .supplier-category-table td:last-child,
  .supplier-payments-table td:last-child {
    grid-column: auto;
  }
}

/* Modo paisagem em celulares: preserva conteúdo e evita cabeçalhos gigantes. */
@media (max-width: 899px) and (orientation: landscape) and (max-height: 500px) {
  .mobile-topbar {
    min-height: 52px;
  }

  .mobile-topbar img {
    width: 72px;
    height: 38px;
  }

  .dashboard-content {
    padding-top: 12px;
  }

  .filter-grid,
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .matrix-expanded-header,
  .supplier-detail-toolbar {
    min-height: 58px;
  }

  .matrix-expanded-header {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .matrix-expanded-footer,
  .supplier-detail-footer {
    display: none;
  }
}

/* Ajustes finais de composição mobile. */
@media (max-width: 899px) {
  .cash-chart,
  .waterfall-chart {
    display: block;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 0;
  }

  .chart-scroll {
    overflow-x: hidden;
  }

  .point-label,
  .today-text {
    font-size: 13px;
  }

  .month-labels text,
  .bar-label {
    font-size: 11px;
  }

  .bar-value {
    font-size: 13px;
  }

  .matrix-expanded-table tbody tr {
    height: auto !important;
    min-height: 0;
    align-content: start;
    overflow: hidden;
  }
}



/* ========================================================================== 
   CORREÇÃO v1.3.1 — sidebar desktop fixa e estabilidade ao alternar breakpoints
   Evita o recorte da navegação quando a página é rolada até o final.
   ========================================================================== */
:root {
  --dashboard-sidebar-width: 264px;
}

@supports (width: clamp(236px, 14.2vw, 284px)) {
  :root {
    --dashboard-sidebar-width: clamp(236px, 14.2vw, 284px);
  }
}

@media (min-width: 900px) {
  .dashboard-shell {
    display: block;
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--dashboard-sidebar-width);
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .dashboard-main {
    width: calc(100% - var(--dashboard-sidebar-width));
    min-width: 0;
    margin-left: var(--dashboard-sidebar-width);
  }
}

@media (min-width: 900px) and (max-width: 1120px) {
  :root {
    --dashboard-sidebar-width: 218px;
  }
}

@media (min-width: 2200px) {
  :root {
    --dashboard-sidebar-width: 300px;
  }
}

@media (max-width: 899px) {
  .dashboard-main {
    width: 100%;
    margin-left: 0;
  }

  .sidebar {
    overflow-y: auto;
  }
}

/* ========================================================================== 
   TELAS DE PERFIL, CONFIGURAÇÕES E SIDEBAR RECOLHÍVEL — v1.4.0
   ========================================================================== */
:root {
  --dashboard-sidebar-collapsed-width: 92px;
  --workspace-gap: clamp(16px, 1.35vw, 28px);
  --workspace-radius: 16px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.sidebar,
.dashboard-main,
.sidebar__brand,
.nav-item,
.nav-item__label {
  transition: width 220ms ease, margin 220ms ease, padding 220ms ease, gap 220ms ease, opacity 150ms ease;
}

.sidebar-brand-toggle {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 190px;
  padding: 4px;
  border: 0;
  border-radius: 14px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.sidebar-brand-toggle:hover {
  background: rgba(255, 255, 255, 0.055);
}

.sidebar-brand-toggle:active {
  transform: scale(0.98);
}

.sidebar-brand-toggle:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 4px;
}

.sidebar__logo {
  display: block;
}

.sidebar__monogram {
  display: none;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 2px solid rgba(255, 255, 255, 0.76);
  border-radius: 13px;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: -0.08em;
}


.user-profile {
  min-width: 188px;
  min-height: 54px;
  padding: 7px 12px;
  border: 0;
  border-radius: 12px;
  text-align: left;
  background: #fff;
}

.user-profile:hover {
  box-shadow: 0 8px 26px rgba(16, 24, 40, 0.07);
}

.user-profile__chevron {
  margin-left: auto;
  color: #9ba8b9;
  font-size: 0.9rem;
}

.mobile-avatar {
  border: 0;
  padding: 0;
}

@media (min-width: 900px) {
  .dashboard-shell.sidebar-is-collapsed {
    --dashboard-sidebar-width: var(--dashboard-sidebar-collapsed-width);
  }

  .sidebar-is-collapsed .sidebar__brand {
    min-height: 112px;
    padding: 20px 12px 12px;
  }

  .sidebar-is-collapsed .sidebar__logo {
    display: none;
  }

  .sidebar-is-collapsed .sidebar__monogram {
    display: grid;
  }

  .sidebar-is-collapsed .sidebar__nav,
  .sidebar-is-collapsed .sidebar__footer {
    padding-inline: 10px;
  }

  .sidebar-is-collapsed .nav-item {
    justify-content: center;
    gap: 0;
    padding-inline: 0;
  }

  .sidebar-is-collapsed .nav-item__icon {
    flex-basis: 24px;
    width: 24px;
    font-size: 1rem;
  }

  .sidebar-is-collapsed .nav-item__label {
    width: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
  }

  .sidebar-is-collapsed .nav-item.is-active {
    border-radius: 8px;
  }

  .sidebar-is-collapsed .sidebar__footer {
    padding-bottom: 26px;
  }
}

/* Common workspace shell */
.workspace-main {
  min-height: 100vh;
  min-height: 100dvh;
  background: #f6f7f9;
}

.workspace-content {
  width: 100%;
  padding: clamp(24px, 2.2vw, 46px) clamp(22px, 2.45vw, 52px) 50px;
}

.workspace-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.workspace-header h1 {
  margin: 0;
  color: #33363d;
  font-size: clamp(1.3rem, 1.45vw, 2rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.workspace-header p {
  margin: 10px 0 0;
  color: #7c8798;
  font-size: clamp(0.78rem, 0.7vw, 0.94rem);
  line-height: 1.45;
}

.user-profile--compact {
  flex: 0 0 auto;
  min-width: 214px;
  box-shadow: none;
}

.workspace-card {
  min-width: 0;
  border: 1px solid #edf0f3;
  border-radius: var(--workspace-radius);
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.015);
}

.card-heading h2,
.system-behavior h3,
.settings-tab-content h2,
.role-card h3,
.integration-card h3 {
  margin: 0;
  color: #3f434b;
  font-size: 0.88rem;
  font-weight: 650;
}

.card-heading p,
.tab-content-heading p,
.role-card p,
.integration-card p {
  margin: 10px 0 0;
  color: #8290a4;
  font-size: 0.72rem;
  line-height: 1.45;
}

.card-heading--compact {
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  gap: 24px 28px;
}

.form-grid--two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.workspace-field {
  display: grid;
  gap: 10px;
  min-width: 0;
  color: #677386;
  font-size: 0.72rem;
}

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

.workspace-field input,
.workspace-field select,
.workspace-field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #d7dee8;
  border-radius: 9px;
  color: #4c5868;
  background: #fafbfc;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.workspace-field input,
.workspace-field select {
  min-height: 50px;
  padding: 0 16px;
}

.workspace-field textarea {
  min-height: 70px;
  padding: 14px 16px;
  resize: vertical;
}

.workspace-field input:focus,
.workspace-field select:focus,
.workspace-field textarea:focus {
  border-color: #9cacc0;
  outline: 0;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(36, 74, 184, 0.08);
}

.form-divider {
  height: 1px;
  margin: 34px 0;
  background: #edf0f3;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  margin-top: 10px;
}

.form-status {
  min-height: 18px;
  color: #148b4b;
  font-size: 0.72rem;
}

.primary-action-button {
  min-width: 156px;
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 9px;
  color: #fff;
  font-size: 0.74rem;
  font-weight: 750;
  background: var(--brand-red);
}

.primary-action-button:hover {
  background: var(--brand-red-dark);
}

.primary-action-button--compact {
  min-width: auto;
  min-height: 40px;
}

.outline-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 145px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid #ced8e5;
  border-radius: 9px;
  color: #4d5968;
  font-size: 0.72rem;
  font-weight: 600;
  background: #fff;
}

.outline-button:hover {
  border-color: #aebbd0;
  background: #fafbfc;
}

.outline-button--full {
  width: 100%;
}

.muted-note {
  display: block;
  margin-top: 16px;
  color: #a0adbe;
  font-size: 0.68rem;
  line-height: 1.4;
}

.switch-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: center;
  gap: 16px;
  min-height: 44px;
  color: #677386;
  font-size: 0.72rem;
  cursor: pointer;
}

.switch-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-row i {
  position: relative;
  display: block;
  width: 39px;
  height: 22px;
  border-radius: 999px;
  background: #e3e8ef;
  transition: background 150ms ease;
}

.switch-row i::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.18);
  transition: transform 150ms ease;
}

.switch-row input:checked + i {
  background: var(--brand-red);
}

.switch-row input:checked + i::after {
  transform: translateX(17px);
}

.switch-row--static {
  cursor: default;
}

.switch-row--static strong {
  color: var(--brand-red);
  font-size: 0.7rem;
  text-align: right;
}

/* Profile */
.profile-summary-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 26px;
  min-height: 126px;
  margin-bottom: var(--workspace-gap);
  padding: 22px 30px;
}

.profile-summary__avatar {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  color: var(--brand-red);
  font-size: 1.45rem;
  font-weight: 800;
  background: #fde7ea;
}

.profile-summary__identity {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.profile-summary__identity strong {
  color: #343840;
  font-size: 0.88rem;
}

.profile-summary__identity span,
.profile-summary__identity small {
  color: #7f8ca0;
  font-size: 0.72rem;
}

.profile-summary__identity i {
  margin: 0 4px;
  font-style: normal;
}

.profile-summary__identity small {
  color: #a1adbc;
}

.profile-photo-button {
  cursor: pointer;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.95fr);
  gap: var(--workspace-gap);
  align-items: start;
}

.profile-information-card {
  padding: 30px;
}

.profile-information-card .card-heading {
  margin-bottom: 34px;
}

.profile-side-column,
.settings-side-column {
  display: grid;
  gap: var(--workspace-gap);
  min-width: 0;
}

.security-card,
.quick-preferences-card {
  padding: 30px;
}

.security-item {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 24px 0;
}

.security-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--brand-red);
  font-size: 1rem;
  background: #fde7ea;
}

.security-item > span:last-child {
  display: grid;
  gap: 5px;
}

.security-item strong {
  color: #5c6675;
  font-size: 0.72rem;
}

.security-item small {
  color: #a0adbe;
  font-size: 0.66rem;
}

.quick-preferences-card {
  min-height: 270px;
}

/* Settings */
.settings-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  margin-bottom: var(--workspace-gap);
  padding: 10px 12px;
  overflow-x: auto;
  border: 1px solid #edf0f3;
  border-radius: 14px;
  background: #fff;
  scrollbar-width: thin;
}

.settings-tabs button {
  flex: 0 0 auto;
  min-width: 148px;
  min-height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 9px;
  color: #5f6978;
  font-size: 0.72rem;
  background: transparent;
}

.settings-tabs button.is-active {
  color: var(--brand-red);
  background: #fde8eb;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
  gap: var(--workspace-gap);
  align-items: start;
}

.settings-general-card {
  padding: 30px;
}

.settings-general-card > .card-heading {
  margin-bottom: 34px;
}

.system-behavior h3 {
  margin-bottom: 18px;
}

.settings-info-card {
  padding: 30px;
}

.settings-info-card .card-heading {
  margin-bottom: 24px;
}

.integration-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 42px;
  color: #697587;
  font-size: 0.72rem;
}

.integration-status-row > span {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.status-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
}

.status-dot--active {
  background: #0caf62;
}

.status-dot--pending {
  background: #f18a00;
}

.status-active {
  color: #0b9d56;
}

.status-pending {
  color: #e47d00;
}

.button-row {
  display: flex;
  gap: 14px;
}

.button-row .outline-button {
  flex: 1;
  min-width: 0;
}

.settings-tab-content {
  min-width: 0;
}

.tab-content-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.responsive-data-list {
  display: grid;
  gap: 12px;
}

.data-user-card {
  display: grid;
  grid-template-columns: 44px minmax(180px, 1.4fr) minmax(130px, 0.8fr) auto 42px;
  align-items: center;
  gap: 16px;
  min-height: 76px;
  padding: 14px 18px;
  border: 1px solid #e8edf2;
  border-radius: 13px;
  background: #fff;
}

.data-user-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--brand-red);
  font-size: 0.72rem;
  font-weight: 800;
  background: #fde7ea;
}

.data-user-identity {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.data-user-identity strong {
  color: #414751;
  font-size: 0.78rem;
}

.data-user-identity small,
.data-user-role {
  overflow: hidden;
  color: #8692a4;
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  min-height: 27px;
  padding: 0 11px;
  border-radius: 99px;
  font-size: 0.64rem;
  font-weight: 750;
}

.status-pill--active {
  color: #0c8c4c;
  background: #e9f8f0;
}

.status-pill--pending {
  color: #ce7600;
  background: #fff3dd;
}

.icon-action-button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  color: #7d899b;
  background: #f5f7fa;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--workspace-gap);
}

.role-card {
  padding: 26px;
}

.role-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 20px;
  border-radius: 12px;
  color: var(--brand-red);
  background: #fde7ea;
}

.role-card footer {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid #edf0f3;
  color: #8692a4;
  font-size: 0.68rem;
}

.role-card footer button {
  margin-left: auto;
  border: 0;
  color: var(--brand-red);
  font-size: 0.68rem;
  background: transparent;
}

.integration-grid {
  display: grid;
  gap: 14px;
}

.integration-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  padding: 22px;
}

.integration-logo {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 13px;
  color: #fff;
  font-weight: 900;
  background: #164a7f;
}

.integration-logo--powerbi {
  color: #624100;
  background: #f7c331;
}

.logs-wrapper {
  overflow-x: auto;
}

.logs-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  color: #687486;
  font-size: 0.72rem;
}

.logs-table th,
.logs-table td {
  padding: 16px 18px;
  border-bottom: 1px solid #edf0f3;
  text-align: left;
}

.logs-table th {
  color: #515b69;
  background: #f7f9fb;
}

/* Ultrawide */
@media (min-width: 2200px) {
  .workspace-content {
    padding: 44px 64px 64px;
  }

  .workspace-header h1 {
    font-size: 2.25rem;
  }

  .workspace-header p,
  .card-heading p,
  .workspace-field,
  .switch-row,
  .integration-status-row {
    font-size: 0.86rem;
  }

  .card-heading h2,
  .system-behavior h3 {
    font-size: 1rem;
  }

  .profile-layout,
  .settings-layout {
    grid-template-columns: minmax(0, 1.8fr) minmax(420px, 1fr);
  }
}

/* Tablet */
@media (max-width: 1180px) and (min-width: 900px) {
  .profile-layout,
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .profile-side-column,
  .settings-side-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-side-column .audit-card {
    grid-column: 1 / -1;
  }

  .role-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Mobile */
@media (max-width: 899px) {
  .sidebar__monogram {
    display: none !important;
  }

  .sidebar__logo {
    display: block !important;
  }

  .sidebar-is-collapsed .sidebar__brand {
    min-height: clamp(170px, 18vh, 230px);
    padding: 24px 26px 12px;
  }

  .sidebar-is-collapsed .sidebar__nav,
  .sidebar-is-collapsed .sidebar__footer {
    padding-inline: 16px;
  }

  .sidebar-is-collapsed .nav-item {
    justify-content: flex-start;
    gap: 17px;
    padding-inline: 18px;
  }

  .sidebar-is-collapsed .nav-item__label {
    width: auto;
    opacity: 1;
    overflow: visible;
  }

  .workspace-content {
    padding: 20px 14px 34px;
  }

  .workspace-header {
    margin-bottom: 18px;
  }

  .workspace-header h1 {
    font-size: 1.45rem;
  }

  .workspace-header p {
    margin-top: 7px;
    font-size: 0.74rem;
  }

  .workspace-header .user-profile {
    display: none;
  }

  .profile-summary-card {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 14px;
    min-height: 0;
    padding: 18px;
  }

  .profile-summary__avatar {
    width: 58px;
    height: 58px;
    font-size: 1.05rem;
  }

  .profile-photo-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .profile-layout,
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .profile-information-card,
  .security-card,
  .quick-preferences-card,
  .settings-general-card,
  .settings-info-card {
    padding: 20px 17px;
  }

  .profile-information-card .card-heading,
  .settings-general-card > .card-heading {
    margin-bottom: 24px;
  }

  .form-grid--two-columns {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .workspace-field--full {
    grid-column: auto;
  }

  .workspace-field input,
  .workspace-field select {
    min-height: 48px;
    font-size: 16px;
  }

  .workspace-field textarea {
    font-size: 16px;
  }

  .form-divider {
    margin: 26px 0;
  }

  .form-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .primary-action-button,
  .form-actions .primary-action-button {
    width: 100%;
  }

  .form-status {
    text-align: center;
  }

  .profile-side-column,
  .settings-side-column {
    grid-template-columns: 1fr;
  }

  .settings-tabs {
    gap: 6px;
    min-height: 54px;
    padding: 8px;
  }

  .settings-tabs button {
    min-width: 112px;
  }

  .button-row {
    flex-direction: column;
  }

  .role-grid {
    grid-template-columns: 1fr;
  }

  .tab-content-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .data-user-card {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 12px;
  }

  .data-user-role {
    grid-column: 2 / -1;
  }

  .status-pill {
    grid-column: 2;
  }

  .data-user-card .icon-action-button {
    grid-column: 3;
    grid-row: 1;
  }

  .integration-card {
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 13px;
  }

  .integration-logo {
    width: 44px;
    height: 44px;
  }

  .integration-card .status-pill,
  .integration-card .outline-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .logs-wrapper {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .logs-table,
  .logs-table tbody,
  .logs-table tr,
  .logs-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .logs-table thead {
    display: none;
  }

  .logs-table tbody {
    display: grid;
    gap: 12px;
  }

  .logs-table tr {
    padding: 14px;
    border: 1px solid #e6ecf2;
    border-radius: 12px;
    background: #fff;
  }

  .logs-table td {
    display: grid;
    grid-template-columns: minmax(90px, 0.7fr) minmax(0, 1fr);
    gap: 12px;
    padding: 7px 0;
    border: 0;
  }

  .logs-table td::before {
    content: attr(data-label);
    color: #909caf;
    font-size: 0.65rem;
    font-weight: 700;
  }
}

@media (max-width: 390px) {
  .workspace-content {
    padding-inline: 11px;
  }

  .profile-summary-card {
    padding: 15px;
  }

  .profile-summary__identity span,
  .profile-summary__identity small {
    font-size: 0.65rem;
  }

  .switch-row {
    font-size: 0.68rem;
  }
}


/* ========================================================================== 
   USUÁRIOS E PERMISSÕES — telas integradas do Figma — v1.5.0
   ========================================================================== */
.access-content {
  --access-card-padding: clamp(20px, 1.65vw, 34px);
}

.access-page-header {
  margin-bottom: 20px;
}

.access-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  min-height: 66px;
  margin-bottom: var(--workspace-gap);
  padding: 10px 14px;
  border: 1px solid #edf0f3;
  border-radius: 14px;
  background: #fff;
}

.access-tabs button {
  position: relative;
  min-width: 0;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 9px;
  color: #5e6877;
  font-size: 0.72rem;
  font-weight: 650;
  background: transparent;
  transition: color 150ms ease, background 150ms ease, transform 150ms ease;
}

.access-tabs button:hover {
  background: #f8f9fb;
}

.access-tabs button.is-active {
  color: var(--brand-red);
  background: #fde8eb;
}

.access-tabs button span {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 8px;
  padding: 0 6px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.6rem;
  background: var(--brand-red);
}

.access-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(300px, 0.72fr);
  gap: var(--workspace-gap);
  align-items: start;
}

.access-layout--profiles,
.access-layout--permissions {
  grid-template-columns: minmax(0, 1.7fr) minmax(310px, 0.72fr);
}

.access-layout--invitations {
  grid-template-columns: minmax(0, 2.05fr) minmax(280px, 0.55fr);
}

.access-primary-card {
  min-width: 0;
  min-height: 620px;
  padding: var(--access-card-padding);
}

.access-side-column {
  display: grid;
  gap: var(--workspace-gap);
  min-width: 0;
}

.access-side-card {
  min-width: 0;
  padding: clamp(20px, 1.5vw, 30px);
}

.access-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

.access-card-heading--compact {
  margin-bottom: 20px;
}

.access-card-heading h2 {
  margin: 0;
  color: #444852;
  font-size: 0.88rem;
  font-weight: 700;
}

.access-card-heading p {
  margin: 9px 0 0;
  color: #8995a7;
  font-size: 0.69rem;
  line-height: 1.45;
}

.access-toolbar {
  display: grid;
  gap: 12px;
  margin-bottom: 22px;
}

.access-toolbar--users {
  grid-template-columns: minmax(220px, 1.55fr) minmax(130px, 0.72fr) minmax(120px, 0.68fr) auto auto;
}

.access-toolbar--profiles {
  grid-template-columns: minmax(220px, 1.35fr) minmax(170px, 0.8fr) auto auto;
}

.access-toolbar--permissions {
  grid-template-columns: minmax(190px, 1.1fr) minmax(150px, 0.65fr) minmax(140px, 0.65fr) auto auto;
}

.access-toolbar--invitations {
  grid-template-columns: minmax(220px, 1.55fr) minmax(150px, 0.72fr) auto auto;
}

.access-toolbar select,
.access-search {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid #d9e0e9;
  border-radius: 9px;
  color: #697486;
  background: #fff;
}

.access-toolbar select {
  padding: 0 34px 0 13px;
  font-size: 0.68rem;
}

.access-search {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  overflow: hidden;
}

.access-search > span {
  display: grid;
  place-items: center;
  height: 100%;
  color: #8ea0b5;
  font-size: 1.05rem;
}

.access-search input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 12px 0 0;
  border: 0;
  outline: 0;
  color: #4e5968;
  font-size: 0.68rem;
  background: transparent;
}

.access-search input::placeholder {
  color: #a4afbd;
}

.access-toolbar .outline-button,
.access-toolbar .primary-action-button {
  min-width: 118px;
  min-height: 44px;
  white-space: nowrap;
}

.access-table-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  border: 1px solid #edf0f3;
  border-radius: 10px;
  scrollbar-width: thin;
}

.access-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
  color: #6e7989;
  font-size: 0.67rem;
}

.access-table--users {
  min-width: 920px;
}

.access-table--profiles {
  min-width: 760px;
}

.access-table--permissions {
  min-width: 900px;
}

.access-table--invitations {
  min-width: 1080px;
}

.access-table th,
.access-table td {
  min-width: 0;
  padding: 15px 14px;
  border-bottom: 1px solid #edf0f3;
  text-align: left;
  vertical-align: middle;
}

.access-table th {
  color: #8b96a7;
  font-size: 0.59rem;
  font-weight: 750;
  letter-spacing: 0.015em;
  text-transform: uppercase;
  background: #f8fafc;
}

.access-table tbody tr {
  cursor: pointer;
  transition: background 120ms ease, box-shadow 120ms ease;
}

.access-table tbody tr:hover {
  background: #fcfcfd;
}

.access-table tbody tr.is-selected {
  background: #fff7f8;
  box-shadow: inset 3px 0 var(--brand-red);
}

.access-table tbody tr:last-child td {
  border-bottom: 0;
}

.access-table td strong {
  color: #4a515d;
  font-weight: 650;
}

.access-table--users th:nth-child(1) { width: 27%; }
.access-table--users th:nth-child(2) { width: 12%; }
.access-table--users th:nth-child(3) { width: 18%; }
.access-table--users th:nth-child(4) { width: 16%; }
.access-table--users th:nth-child(5) { width: 12%; }
.access-table--users th:nth-child(6) { width: 10%; }

.access-table--profiles th:nth-child(1) { width: 24%; }
.access-table--profiles th:nth-child(2) { width: 34%; }
.access-table--profiles th:nth-child(3) { width: 14%; }
.access-table--profiles th:nth-child(4) { width: 12%; }
.access-table--profiles th:nth-child(5) { width: 16%; }

.access-table--permissions th:first-child { width: 22%; }
.access-table--permissions th:not(:first-child) { width: 19.5%; }

.access-user-cell,
.profile-name-cell,
.access-profile-detail__identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.access-user-cell > span:last-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.access-user-cell strong,
.access-user-cell small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.access-user-cell small {
  color: #9aa5b4;
  font-size: 0.61rem;
}

.data-user-avatar.avatar-tone-blue { color: #3559c7; background: #eaf0ff; }
.data-user-avatar.avatar-tone-orange { color: #d86d1d; background: #fff0e5; }
.data-user-avatar.avatar-tone-cyan { color: #168aa0; background: #e6f8fb; }
.data-user-avatar.avatar-tone-purple { color: #8b44c4; background: #f2eafb; }
.data-user-avatar.avatar-tone-green { color: #168a4e; background: #e8f8ef; }

.status-pill--inactive {
  color: #697586;
  background: #eef1f5;
}

.status-pill--danger {
  color: #c83240;
  background: #fde9eb;
}

.access-link-button {
  padding: 5px 3px;
  border: 0;
  color: #657184;
  font-size: 0.64rem;
  background: transparent;
}

.access-link-button:hover {
  color: var(--brand-red);
}

.access-link-button--danger {
  color: #c92d3d;
}

.access-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.access-empty-row td {
  padding: 34px 18px;
  color: #9aa5b4;
  text-align: center;
}

.access-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 62px;
  color: #919cad;
  font-size: 0.63rem;
}

.access-pagination {
  display: inline-flex;
  gap: 7px;
}

.access-pagination button {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  color: #758195;
  font-size: 0.62rem;
  background: #fff;
}

.access-pagination button.is-active {
  border-color: #ed5060;
  color: var(--brand-red);
}

.access-profile-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 66px;
  padding: 12px 0;
  border: 0;
  border-bottom: 1px solid #edf0f3;
  text-align: left;
  background: transparent;
}

.access-profile-summary:last-child {
  border-bottom: 0;
}

.access-profile-summary > span:first-child {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.access-profile-summary strong,
.access-profile-summary small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.access-profile-summary strong {
  color: #535d6c;
  font-size: 0.7rem;
}

.access-profile-summary small {
  color: #9ba6b5;
  font-size: 0.61rem;
}

.access-profile-summary > span:last-child {
  color: #8b96a6;
  font-size: 0.64rem;
}

.access-profile-summary:hover strong {
  color: var(--brand-red);
}

.access-permission-summary {
  margin: 0;
}

.access-permission-summary > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 47px;
  border-bottom: 1px solid #edf0f3;
}

.access-permission-summary > div:last-child {
  border-bottom: 0;
}

.access-permission-summary dt,
.access-permission-summary dd {
  margin: 0;
}

.access-permission-summary dt {
  color: #6f7a8a;
  font-size: 0.66rem;
}

.access-permission-summary dd {
  color: #596476;
  font-size: 0.62rem;
  text-align: right;
}

.access-profile-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--brand-red);
  font-size: 0.9rem;
  background: #fde9eb;
}

.access-profile-detail__identity {
  margin-bottom: 18px;
}

.access-profile-detail__identity > span:last-child {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.access-profile-detail__identity strong {
  color: #525d6c;
  font-size: 0.72rem;
}

.access-profile-detail__identity small {
  color: #9aa5b5;
  font-size: 0.62rem;
  line-height: 1.35;
}

.profile-usage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 16px;
  min-height: 57px;
}

.profile-usage-row > span {
  display: grid;
  gap: 9px;
}

.profile-usage-row strong {
  color: #606b7b;
  font-size: 0.65rem;
}

.profile-usage-row i {
  display: block;
  height: 2px;
  max-width: 100%;
  border-radius: 99px;
  background: var(--brand-red);
}

.profile-usage-row small {
  color: #8e99a9;
  font-size: 0.6rem;
}

.profile-usage-total {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #edf0f3;
  color: #8f9aaa;
  font-size: 0.62rem;
}

.profile-usage-total strong {
  color: #5a6574;
}

.permission-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  min-height: 25px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  font-size: 0.57rem;
  font-weight: 700;
  white-space: nowrap;
}

.permission-badge--button {
  cursor: pointer;
}

.permission-badge--total {
  color: #0b9853;
  background: #e5f8ed;
}

.permission-badge--edit {
  color: #8552ca;
  background: #f0e8fb;
}

.permission-badge--view-export {
  color: #4f63d4;
  background: #e9edff;
}

.permission-badge--view {
  color: #4965c3;
  background: #edf1ff;
}

.permission-badge--none {
  color: #7e8998;
  background: #eef1f5;
}

.access-permissions-note {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  min-height: 54px;
  padding-top: 18px;
  color: #9aa5b4;
  font-size: 0.61rem;
}

.access-permissions-note span {
  color: #16884d;
  font-weight: 700;
}

.permission-legend-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 13px;
  margin-bottom: 19px;
}

.permission-legend-dot {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.permission-legend-dot--total { background: #e5f8ed; }
.permission-legend-dot--edit { background: #f0e8fb; }
.permission-legend-dot--view { background: #edf1ff; }
.permission-legend-dot--none { background: #eef1f5; }

.permission-legend-item > span:last-child {
  display: grid;
  gap: 5px;
}

.permission-legend-item strong {
  color: #5e6877;
  font-size: 0.66rem;
}

.permission-legend-item small {
  color: #9aa5b5;
  font-size: 0.6rem;
  line-height: 1.45;
}

.permission-summary-stat {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin-top: 10px;
  padding: 10px 13px;
  border: 1px solid #edf0f3;
  border-radius: 9px;
  background: #fbfcfd;
}

.permission-summary-stat strong {
  color: var(--brand-red);
  font-size: 0.76rem;
}

.permission-summary-stat span {
  color: #7d8999;
  font-size: 0.61rem;
}

.invitation-metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 54px;
  border-bottom: 1px solid #edf0f3;
}

.invitation-metric:last-child {
  border-bottom: 0;
}

.invitation-metric strong {
  color: #4d5766;
  font-size: 0.92rem;
}

.invitation-help-card p {
  margin: 0 0 20px;
  color: #8793a4;
  font-size: 0.66rem;
  line-height: 1.55;
}

.access-modal-is-open {
  overflow: hidden !important;
}

.access-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(18, 22, 31, 0.52);
  backdrop-filter: blur(2px);
}

.access-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 2001;
  width: min(560px, calc(100vw - 30px));
  max-height: min(780px, calc(100dvh - 30px));
  overflow-y: auto;
  padding: 28px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(16, 24, 40, 0.28);
  transform: translate(-50%, -50%);
}

.access-modal > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.access-modal > header h2 {
  margin: 0;
  color: #3d424b;
  font-size: 1.05rem;
}

.access-modal > header p {
  margin: 7px 0 0;
  color: #8894a5;
  font-size: 0.69rem;
  line-height: 1.4;
}

.access-modal > header > button {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  color: #6f7b8c;
  font-size: 1.25rem;
  background: #f2f4f7;
}

.access-modal form {
  display: grid;
  gap: 18px;
}

.access-modal form > footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid #edf0f3;
}

@media (min-width: 2200px) {
  .access-layout {
    grid-template-columns: minmax(0, 2.25fr) minmax(390px, 0.72fr);
  }

  .access-primary-card {
    min-height: 720px;
  }

  .access-card-heading h2 {
    font-size: 1rem;
  }

  .access-card-heading p,
  .access-table,
  .access-toolbar select,
  .access-search input {
    font-size: 0.78rem;
  }

  .access-table th {
    font-size: 0.67rem;
  }
}

@media (max-width: 1360px) and (min-width: 900px) {
  .access-layout,
  .access-layout--profiles,
  .access-layout--permissions,
  .access-layout--invitations {
    grid-template-columns: 1fr;
  }

  .access-side-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .access-toolbar--users,
  .access-toolbar--permissions {
    grid-template-columns: minmax(200px, 1.4fr) repeat(2, minmax(130px, 0.65fr));
  }

  .access-toolbar--users .access-export-button,
  .access-toolbar--permissions .outline-button {
    grid-column: 2;
  }

  .access-toolbar--users .access-create-button,
  .access-toolbar--permissions .primary-action-button {
    grid-column: 3;
  }

  .access-toolbar--invitations {
    grid-template-columns: minmax(220px, 1fr) minmax(160px, 0.65fr) auto auto;
  }
}

@media (max-width: 899px) {
  .access-content {
    --access-card-padding: 18px 14px;
  }

  .access-tabs {
    display: flex;
    gap: 7px;
    min-height: 58px;
    padding: 8px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .access-tabs::-webkit-scrollbar {
    display: none;
  }

  .access-tabs button {
    flex: 0 0 auto;
    min-width: 128px;
    min-height: 40px;
    padding-inline: 14px;
    scroll-snap-align: start;
  }

  .access-layout,
  .access-layout--profiles,
  .access-layout--permissions,
  .access-layout--invitations {
    grid-template-columns: 1fr;
  }

  .access-primary-card {
    min-height: 0;
    padding: var(--access-card-padding);
  }

  .access-side-card {
    padding: 19px 16px;
  }

  .access-card-heading {
    margin-bottom: 20px;
  }

  .access-toolbar,
  .access-toolbar--users,
  .access-toolbar--profiles,
  .access-toolbar--permissions,
  .access-toolbar--invitations {
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }

  .access-toolbar .access-search {
    grid-column: 1 / -1;
  }

  .access-toolbar select,
  .access-search,
  .access-toolbar .outline-button,
  .access-toolbar .primary-action-button {
    min-height: 46px;
  }

  .access-toolbar select,
  .access-search input {
    font-size: 16px;
  }

  .access-toolbar .outline-button,
  .access-toolbar .primary-action-button {
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
  }

  .access-table-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  .access-table,
  .access-table tbody,
  .access-table tr,
  .access-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .access-table {
    table-layout: auto;
  }

  .access-table thead {
    display: none;
  }

  .access-table tbody {
    display: grid;
    gap: 12px;
  }

  .access-table tbody tr {
    padding: 14px;
    overflow: hidden;
    border: 1px solid #e6ebf1;
    border-radius: 12px;
    background: #fff;
  }

  .access-table tbody tr.is-selected {
    border-color: #f5c7cd;
    box-shadow: inset 3px 0 var(--brand-red);
  }

  .access-table td {
    display: grid;
    grid-template-columns: minmax(105px, 0.72fr) minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    min-height: 38px;
    padding: 7px 0;
    border: 0;
    text-align: right;
    overflow-wrap: anywhere;
  }

  .access-table td::before {
    content: attr(data-label);
    color: #929dad;
    font-size: 0.6rem;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
  }

  .access-table--users td:first-child,
  .access-table--profiles td:first-child {
    grid-template-columns: 1fr;
    padding-bottom: 12px;
    border-bottom: 1px solid #edf0f3;
    text-align: left;
  }

  .access-table--users td:first-child::before,
  .access-table--profiles td:first-child::before {
    display: none;
  }

  .access-user-cell,
  .profile-name-cell {
    justify-self: stretch;
    text-align: left;
  }

  .access-table td .status-pill,
  .access-table td .permission-badge,
  .access-table td .access-actions {
    justify-self: end;
  }

  .access-table--permissions tbody tr {
    padding-top: 10px;
  }

  .access-table--permissions td:first-child {
    display: block;
    min-height: 0;
    margin-bottom: 7px;
    padding-bottom: 12px;
    border-bottom: 1px solid #edf0f3;
    text-align: left;
  }

  .access-table--permissions td:first-child::before {
    display: none;
  }

  .access-empty-row {
    display: block !important;
  }

  .access-empty-row td {
    display: block !important;
    text-align: center !important;
  }

  .access-empty-row td::before {
    display: none;
  }

  .access-table-footer {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px 0 3px;
  }

  .access-pagination {
    width: 100%;
  }

  .access-pagination button {
    flex: 1;
  }

  .access-side-column {
    grid-template-columns: 1fr;
  }

  .access-permissions-note {
    align-items: flex-start;
    flex-direction: column;
  }

  .access-modal {
    width: calc(100vw - 22px);
    max-height: calc(100dvh - 22px);
    padding: 20px 16px;
    border-radius: 14px;
  }

  .access-modal .form-grid--two-columns {
    grid-template-columns: 1fr;
  }

  .access-modal form > footer {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .access-modal form > footer .outline-button,
  .access-modal form > footer .primary-action-button {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .access-toolbar,
  .access-toolbar--users,
  .access-toolbar--profiles,
  .access-toolbar--permissions,
  .access-toolbar--invitations {
    grid-template-columns: 1fr;
  }

  .access-toolbar .access-search,
  .access-toolbar > * {
    grid-column: 1;
  }

  .access-table td {
    grid-template-columns: minmax(86px, 0.62fr) minmax(0, 1fr);
  }

  .access-table-footer {
    font-size: 0.6rem;
  }
}


/* Sidebar acionada pela marca — v1.5.1 */
@media (min-width: 900px) {
  .sidebar-is-collapsed .sidebar-brand-toggle {
    width: 58px;
    min-height: 58px;
    padding: 5px;
  }
}

@media (max-width: 899px) {
  .sidebar-brand-toggle {
    min-height: 92px;
  }
}


/* ==========================================================================
   AJUSTES v1.5.2 — sidebar sem seta e retorno da gestão de acessos
   ========================================================================== */
.access-page-header__main {
  min-width: 0;
}

.access-back-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  margin: 0 0 14px;
  padding: 0 13px;
  border: 1px solid #d7dee8;
  border-radius: 9px;
  color: #4d5968;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  background: #fff;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, transform 150ms ease;
}

.access-back-button:hover {
  border-color: #bdc8d6;
  color: #202832;
  background: #fafbfc;
}

.access-back-button:active {
  transform: translateY(1px);
}

.access-back-button:focus-visible {
  outline: 3px solid rgba(225, 29, 52, 0.16);
  outline-offset: 2px;
}

.access-back-button__icon {
  font-size: 1.05rem;
  line-height: 1;
}

@media (max-width: 899px) {
  .access-page-header__main {
    width: 100%;
  }

  .access-back-button {
    min-height: 42px;
    margin-bottom: 16px;
    padding-inline: 14px;
    font-size: 0.75rem;
  }
}

@media (max-width: 390px) {
  .access-back-button {
    width: 100%;
    justify-content: center;
  }
}

/* ========================================================================== 
   RESPONSIVIDADE DAS NOVAS TELAS + MODO ESCURO — v1.6.0
   ========================================================================== */


/* API-backed access management */
.access-api-status {
  margin: 0 0 14px;
  padding: 11px 14px;
  border: 1px solid rgba(39, 174, 96, .28);
  border-radius: 10px;
  background: rgba(39, 174, 96, .08);
  font-size: .86rem;
}
.access-api-status.is-error {
  border-color: rgba(224, 31, 53, .32);
  background: rgba(224, 31, 53, .08);
  color: #b2142a;
}
.invitation-link-box {
  display: grid;
  grid-template-columns: minmax(220px, .7fr) minmax(280px, 1.4fr) auto;
  gap: 12px;
  align-items: center;
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid rgba(33, 104, 179, .25);
  border-radius: 12px;
  background: rgba(33, 104, 179, .07);
}
.invitation-link-box div { display: grid; gap: 4px; }
.invitation-link-box small { color: var(--muted-text, #6f7885); line-height: 1.35; }
.invitation-link-box input {
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border-color, #d6dce4);
  border-radius: 9px;
  background: var(--surface-color, #fff);
  color: inherit;
}
.access-security-note {
  margin: 18px 0 0;
  padding: 13px;
  border-radius: 10px;
  background: rgba(33, 104, 179, .08);
  line-height: 1.5;
}
.invite-login-link {
  display: block;
  margin: 14px auto 0;
}
.workspace-field small,
.field small {
  display: block;
  margin-top: 5px;
  color: var(--muted-text, #77808d);
  font-size: .76rem;
}
@media (max-width: 900px) {
  .invitation-link-box { grid-template-columns: 1fr; }
  .invitation-link-box .outline-button { width: 100%; }
}

/* ========================================================================== 
   AJUSTES DE LAYOUT — Usuários e acessos — v1.6.1
   ========================================================================== */
.access-page-header {
  align-items: center;
}

.access-tabs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 8px;
}

.access-tabs button {
  min-height: 48px;
  padding: 0 18px;
  font-size: 0.82rem;
  font-weight: 700;
}

.access-tabs button.is-active {
  box-shadow: inset 0 0 0 1px rgba(225, 29, 52, 0.14);
}

.access-layout--profiles {
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.82fr);
}

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

.access-profile-card {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 22px;
  border: 1px solid rgba(121, 132, 154, 0.22);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.access-profile-card:hover {
  transform: translateY(-1px);
  border-color: rgba(225, 29, 52, 0.28);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.access-profile-card.is-selected {
  border-color: rgba(225, 29, 52, 0.42);
  box-shadow: 0 14px 30px rgba(225, 29, 52, 0.12);
  background: rgba(225, 29, 52, 0.05);
}

.access-profile-card__header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.access-profile-card__header > span:nth-child(2) {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.access-profile-card__header strong,
.access-profile-detail .access-card-heading h2 {
  color: var(--title-color, #eef2f8);
  font-size: 1.04rem;
  line-height: 1.15;
}

.access-profile-card__header small {
  color: var(--muted-text, #99a5b6);
  font-size: 0.76rem;
  line-height: 1.35;
}

.access-profile-card > p {
  margin: 0;
  color: var(--muted-text, #b9c2cf);
  font-size: 0.93rem;
  line-height: 1.55;
}

.access-profile-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(121, 132, 154, 0.16);
  color: var(--muted-text, #99a5b6);
  font-size: 0.78rem;
}

.access-profile-card__meta > span:last-child {
  font-weight: 600;
}

.access-profile-detail {
  position: sticky;
  top: 24px;
}

.access-profile-detail .access-card-heading {
  margin-bottom: 24px;
}

.access-profile-detail .access-card-heading p {
  margin-top: 8px;
  font-size: 0.8rem;
  line-height: 1.5;
}

.access-permission-summary > div {
  min-height: 54px;
}

.access-permission-summary dt {
  color: var(--title-color, #e9edf4);
  font-size: 0.8rem;
}

.access-permission-summary dd {
  color: var(--muted-text, #c0c8d4);
  font-size: 0.75rem;
  font-weight: 700;
}

.access-security-note {
  margin-top: 20px;
  font-size: 0.8rem;
}

@media (max-width: 1360px) {
  .access-profile-grid {
    grid-template-columns: 1fr;
  }

  .access-layout--profiles {
    grid-template-columns: 1fr;
  }

  .access-profile-detail {
    position: static;
  }
}

@media (max-width: 899px) {
  .access-page-header {
    align-items: stretch;
  }

  .access-tabs button {
    min-width: 164px;
    font-size: 0.78rem;
  }

  .access-profile-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .access-profile-card {
    padding: 18px;
  }

  .access-profile-card__header {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .access-profile-card__header .status-pill {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .access-profile-card__meta {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* Seletor visual do tema nas Configurações */
.appearance-card {
  overflow: hidden;
}

.theme-choice {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-width: 0;
  min-height: 82px;
  padding: 14px;
  border: 1px solid #e4e9f0;
  border-radius: 12px;
  background: #fafbfc;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.theme-choice:hover {
  border-color: #cbd4df;
  transform: translateY(-1px);
}

.theme-choice__preview {
  position: relative;
  display: grid;
  grid-template-columns: 16px 1fr;
  grid-template-rows: 13px 1fr;
  gap: 4px;
  width: 70px;
  height: 50px;
  padding: 5px;
  overflow: hidden;
  border: 1px solid #d7dee8;
  border-radius: 8px;
  background: #eef2f6;
}

.theme-choice__preview i {
  display: block;
  border-radius: 3px;
  background: #ffffff;
}

.theme-choice__preview i:first-child {
  grid-row: 1 / -1;
  background: #29292d;
}

.theme-choice__preview i:nth-child(2) {
  background: #d11f2f;
}

.theme-choice.is-dark .theme-choice__preview {
  border-color: #394454;
  background: #0f141b;
}

.theme-choice.is-dark .theme-choice__preview i {
  background: #202833;
}

.theme-choice.is-dark .theme-choice__preview i:first-child {
  background: #25272d;
}

.theme-choice.is-dark .theme-choice__preview i:nth-child(2) {
  background: #e02a3c;
}

.theme-choice__text {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.theme-choice__text strong {
  color: #4c5665;
  font-size: 0.74rem;
}

.theme-choice__text small {
  color: #8793a4;
  font-size: 0.64rem;
  line-height: 1.45;
}

.theme-choice__switch {
  position: relative;
  display: block;
  width: 42px;
  height: 24px;
}

.theme-choice__switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.theme-choice__switch i {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #dce2ea;
  transition: background 160ms ease;
}

.theme-choice__switch i::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.22);
  transition: transform 160ms ease;
}

.theme-choice__switch input:checked + i {
  background: var(--brand-red);
}

.theme-choice__switch input:checked + i::after {
  transform: translateX(18px);
}

/* Garantias contra estouro nas telas adicionadas */
.workspace-content,
.workspace-header,
.profile-layout,
.settings-layout,
.access-layout,
.access-primary-card,
.access-side-column,
.access-side-card,
.access-card-heading,
.access-toolbar,
.access-table-wrap,
.settings-side-column,
.profile-side-column,
.tab-content-heading {
  min-width: 0;
  max-width: 100%;
}

.workspace-content img,
.access-content img,
.profile-layout img,
.settings-layout img {
  max-width: 100%;
}

.access-card-heading > div,
.tab-content-heading > div,
.workspace-header > div,
.profile-summary__identity,
.access-profile-detail__identity > span:last-child {
  min-width: 0;
}

.access-card-heading h2,
.access-card-heading p,
.workspace-header h1,
.workspace-header p,
.profile-summary__identity strong,
.profile-summary__identity span,
.profile-summary__identity small,
.access-profile-detail__identity strong,
.access-profile-detail__identity small {
  overflow-wrap: anywhere;
}

.access-actions {
  max-width: 100%;
  flex-wrap: wrap;
}

/* Tablet: mantém os painéis laterais legíveis sem apertar tabelas e formulários */
@media (max-width: 1360px) and (min-width: 900px) {
  .workspace-content {
    padding-inline: clamp(22px, 2.6vw, 36px);
  }

  .settings-side-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-side-column .appearance-card,
  .settings-side-column .audit-card {
    grid-column: 1 / -1;
  }

  .access-primary-card {
    min-height: 0;
  }

  .access-table-wrap {
    max-width: calc(100vw - var(--dashboard-sidebar-width) - 54px);
  }
}

/* Celulares e tablets em modo retrato */
@media (max-width: 899px) {
  .workspace-main,
  .dashboard-main {
    width: 100%;
    min-width: 0;
  }

  .workspace-content,
  .access-content {
    width: 100%;
    padding:
      18px
      max(14px, env(safe-area-inset-right))
      max(34px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }

  .workspace-header,
  .access-page-header {
    width: 100%;
  }

  .profile-summary__identity span {
    white-space: normal;
  }

  .settings-side-column,
  .profile-side-column,
  .access-side-column {
    width: 100%;
  }

  .theme-choice {
    grid-template-columns: 62px minmax(0, 1fr) auto;
    gap: 12px;
  }

  .theme-choice__preview {
    width: 60px;
    height: 45px;
  }

  .access-primary-card,
  .access-side-card,
  .profile-information-card,
  .security-card,
  .quick-preferences-card,
  .settings-general-card,
  .settings-info-card {
    width: 100%;
  }

  .access-table tbody tr,
  .logs-table tr {
    width: 100%;
    min-width: 0;
  }

  .access-table td,
  .logs-table td {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .access-table td > *,
  .logs-table td > * {
    min-width: 0;
    max-width: 100%;
  }

  .access-table td .access-actions {
    justify-content: flex-end;
  }

  .access-search {
    overflow: hidden;
  }

  .access-modal {
    top: auto;
    bottom: 0;
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 10px);
    padding: 22px max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    border-radius: 18px 18px 0 0;
    transform: translateX(-50%);
  }

  .access-modal > header {
    position: sticky;
    top: -22px;
    z-index: 2;
    margin: -22px -16px 22px;
    padding: 20px 16px 14px;
    background: inherit;
  }
}

@media (max-width: 640px) {
  .workspace-content,
  .access-content {
    padding-inline: max(11px, env(safe-area-inset-left));
  }

  .workspace-header h1 {
    font-size: clamp(1.25rem, 6.2vw, 1.55rem);
  }

  .settings-tabs {
    display: grid;
    grid-template-columns: 0.78fr 1.44fr 0.78fr;
    gap: 5px;
    overflow: visible;
    padding: 6px;
  }

  .settings-tabs button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 5px 7px;
    line-height: 1.2;
    white-space: normal;
  }

  .access-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    overflow: visible;
    scroll-snap-type: none;
  }

  .access-tabs button {
    width: 100%;
    min-width: 0;
    padding-inline: 7px;
    white-space: normal;
  }

  .access-toolbar,
  .access-toolbar--users,
  .access-toolbar--profiles,
  .access-toolbar--permissions,
  .access-toolbar--invitations {
    grid-template-columns: 1fr;
  }

  .access-toolbar .access-search,
  .access-toolbar > * {
    grid-column: 1;
  }

  .access-table td {
    grid-template-columns: minmax(88px, 0.65fr) minmax(0, 1fr);
    gap: 10px;
    text-align: right;
  }

  .access-table td:first-child {
    text-align: left;
  }

  .access-user-cell small,
  .access-user-cell strong {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .access-table-footer,
  .access-permissions-note {
    gap: 10px;
  }

  .profile-summary-card {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .profile-summary__avatar {
    width: 52px;
    height: 52px;
  }

  .theme-choice {
    grid-template-columns: 1fr auto;
  }

  .theme-choice__preview {
    display: none;
  }

  .theme-choice__text small {
    font-size: 0.66rem;
  }

  .button-row,
  .form-actions,
  .access-modal form > footer {
    width: 100%;
  }

  .button-row .outline-button,
  .form-actions .primary-action-button,
  .access-modal form > footer button {
    min-height: 48px;
  }
}

@media (max-width: 390px) {
  .workspace-content,
  .access-content {
    padding-inline: max(9px, env(safe-area-inset-left));
  }

  .workspace-card,
  .settings-tabs,
  .access-tabs {
    border-radius: 12px;
  }

  .profile-information-card,
  .security-card,
  .quick-preferences-card,
  .settings-general-card,
  .settings-info-card,
  .access-primary-card,
  .access-side-card {
    padding-inline: 14px;
  }

  .access-table tbody tr {
    padding: 12px;
  }

  .access-table td {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 8px;
  }

  .access-table td::before {
    font-size: 0.56rem;
  }

  .access-actions {
    gap: 8px;
  }

  .permission-badge {
    max-width: 100%;
    min-height: 28px;
    padding-inline: 9px;
    white-space: normal;
    text-align: center;
  }
}

/* --------------------------------------------------------------------------
   MODO ESCURO GLOBAL
   -------------------------------------------------------------------------- */
html[data-theme='dark'] {
  --ink-950: #f4f7fb;
  --ink-900: #e7edf4;
  --ink-700: #b3becb;
  --ink-500: #8391a3;
  --surface: #171d25;
  --page: #0f141b;
  --line: #2a3441;
  --navy: #77a9df;
  --blue: #7397ff;
  --green: #46cf7e;
  --orange: #ffb52e;
  --purple: #dc66e9;
  --danger: #ff5c6c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.34), 0 14px 34px rgba(0, 0, 0, 0.2);
  background: #0f141b;
  color: #e7edf4;
}

html[data-theme='dark'],
html[data-theme='dark'] body,
html[data-theme='dark'] #app-root,
html[data-theme='dark'] .dashboard-shell,
html[data-theme='dark'] .dashboard-main,
html[data-theme='dark'] .workspace-main,
html[data-theme='dark'] .dashboard-content,
html[data-theme='dark'] .workspace-content {
  background: #0f141b;
  color: #e7edf4;
}

html[data-theme='dark'] .sidebar {
  border-right: 1px solid #303640;
  background: #202228;
}

html[data-theme='dark'] .mobile-topbar {
  border-bottom-color: #2a3441;
  background: rgba(23, 29, 37, 0.96);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.22);
}

html[data-theme='dark'] .mobile-topbar img,
html[data-theme='dark'] .login-logo {
  filter: brightness(0) invert(1) grayscale(1);
}

html[data-theme='dark'] .panel,
html[data-theme='dark'] .kpi-card,
html[data-theme='dark'] .filter-control,
html[data-theme='dark'] .updated-chip,
html[data-theme='dark'] .workspace-card,
html[data-theme='dark'] .settings-tabs,
html[data-theme='dark'] .access-tabs,
html[data-theme='dark'] .user-profile,
html[data-theme='dark'] .login-card,
html[data-theme='dark'] .data-user-card,
html[data-theme='dark'] .access-modal,
html[data-theme='dark'] .supplier-summary-card,
html[data-theme='dark'] .supplier-payments-card,
html[data-theme='dark'] .supplier-detail-footer,
html[data-theme='dark'] .matrix-expanded-card {
  border-color: #2b3542;
  background: #171d25;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 14px 34px rgba(0, 0, 0, 0.1);
}

html[data-theme='dark'] .page-header h1,
html[data-theme='dark'] .panel__header h2,
html[data-theme='dark'] .workspace-header h1,
html[data-theme='dark'] .card-heading h2,
html[data-theme='dark'] .system-behavior h3,
html[data-theme='dark'] .settings-tab-content h2,
html[data-theme='dark'] .role-card h3,
html[data-theme='dark'] .access-card-heading h2,
html[data-theme='dark'] .access-modal > header h2,
html[data-theme='dark'] .profile-summary__identity strong,
html[data-theme='dark'] .access-profile-detail__identity strong,
html[data-theme='dark'] .data-user-identity strong,
html[data-theme='dark'] .access-table td strong,
html[data-theme='dark'] .theme-choice__text strong,
html[data-theme='dark'] .security-item strong,
html[data-theme='dark'] .invitation-metric strong,
html[data-theme='dark'] .permission-legend-item strong,
html[data-theme='dark'] .matrix-expanded-header h2,
html[data-theme='dark'] .supplier-summary-heading h2,
html[data-theme='dark'] .supplier-payments-card h3 {
  color: #edf3f8;
}

html[data-theme='dark'] .page-header p,
html[data-theme='dark'] .workspace-header p,
html[data-theme='dark'] .panel__header small,
html[data-theme='dark'] .card-heading p,
html[data-theme='dark'] .tab-content-heading p,
html[data-theme='dark'] .access-card-heading p,
html[data-theme='dark'] .access-modal > header p,
html[data-theme='dark'] .muted-note,
html[data-theme='dark'] .profile-summary__identity span,
html[data-theme='dark'] .profile-summary__identity small,
html[data-theme='dark'] .access-profile-detail__identity small,
html[data-theme='dark'] .data-user-identity small,
html[data-theme='dark'] .data-user-role,
html[data-theme='dark'] .theme-choice__text small,
html[data-theme='dark'] .security-item small,
html[data-theme='dark'] .access-table-footer,
html[data-theme='dark'] .access-permissions-note,
html[data-theme='dark'] .invitation-help-card p {
  color: #93a2b5;
}

html[data-theme='dark'] .filter-control small,
html[data-theme='dark'] .filter-control select,
html[data-theme='dark'] .updated-chip,
html[data-theme='dark'] .chart-legend,
html[data-theme='dark'] .expense-label,
html[data-theme='dark'] .expense-value,
html[data-theme='dark'] .user-profile__text small,
html[data-theme='dark'] .switch-row,
html[data-theme='dark'] .workspace-field,
html[data-theme='dark'] .access-table,
html[data-theme='dark'] .logs-table,
html[data-theme='dark'] .access-profile-summary,
html[data-theme='dark'] .access-permission-summary dt,
html[data-theme='dark'] .access-permission-summary dd,
html[data-theme='dark'] .profile-usage-row strong,
html[data-theme='dark'] .profile-usage-total,
html[data-theme='dark'] .permission-summary-stat span {
  color: #aab6c4;
}

html[data-theme='dark'] .workspace-field input,
html[data-theme='dark'] .workspace-field select,
html[data-theme='dark'] .workspace-field textarea,
html[data-theme='dark'] .access-toolbar select,
html[data-theme='dark'] .access-search,
html[data-theme='dark'] .login-card input {
  border-color: #34404e;
  color: #e5ebf2;
  background: #11171f;
}

html[data-theme='dark'] .workspace-field input:focus,
html[data-theme='dark'] .workspace-field select:focus,
html[data-theme='dark'] .workspace-field textarea:focus,
html[data-theme='dark'] .access-search:focus-within,
html[data-theme='dark'] .access-toolbar select:focus {
  border-color: #697b91;
  background: #151c25;
  box-shadow: 0 0 0 3px rgba(115, 151, 255, 0.14);
}

html[data-theme='dark'] input::placeholder,
html[data-theme='dark'] textarea::placeholder,
html[data-theme='dark'] .access-search input::placeholder {
  color: #657386;
}

html[data-theme='dark'] .outline-button,
html[data-theme='dark'] .access-back-button,
html[data-theme='dark'] .access-pagination button,
html[data-theme='dark'] .icon-action-button,
html[data-theme='dark'] .access-modal > header > button,
html[data-theme='dark'] .expand-button,
html[data-theme='dark'] .matrix-close-button,
html[data-theme='dark'] .supplier-close-button,
html[data-theme='dark'] .supplier-export-button {
  border-color: #3a4655;
  color: #c5cfdb;
  background: #151b23;
}

html[data-theme='dark'] .outline-button:hover,
html[data-theme='dark'] .access-back-button:hover,
html[data-theme='dark'] .access-pagination button:hover,
html[data-theme='dark'] .icon-action-button:hover {
  border-color: #56667a;
  color: #f2f6fa;
  background: #1d2530;
}

html[data-theme='dark'] .settings-tabs button,
html[data-theme='dark'] .access-tabs button {
  color: #aab6c4;
}

html[data-theme='dark'] .settings-tabs button:hover,
html[data-theme='dark'] .access-tabs button:hover {
  background: #202833;
}

html[data-theme='dark'] .settings-tabs button.is-active,
html[data-theme='dark'] .access-tabs button.is-active {
  color: #ff7180;
  background: #3a2027;
}

html[data-theme='dark'] .theme-choice {
  border-color: #303b48;
  background: #121820;
}

html[data-theme='dark'] .theme-choice:hover {
  border-color: #4b5a6c;
  background: #151c25;
}

html[data-theme='dark'] .theme-choice__switch i,
html[data-theme='dark'] .switch-row i {
  background: #3b4654;
}

html[data-theme='dark'] .theme-choice__switch i::after,
html[data-theme='dark'] .switch-row i::after {
  background: #eef3f8;
}

html[data-theme='dark'] .form-divider,
html[data-theme='dark'] .role-card footer,
html[data-theme='dark'] .access-table th,
html[data-theme='dark'] .access-table td,
html[data-theme='dark'] .access-profile-summary,
html[data-theme='dark'] .access-permission-summary > div,
html[data-theme='dark'] .profile-usage-total,
html[data-theme='dark'] .invitation-metric,
html[data-theme='dark'] .access-modal form > footer,
html[data-theme='dark'] .logs-table th,
html[data-theme='dark'] .logs-table td {
  border-color: #2b3542;
}

html[data-theme='dark'] .access-table-wrap,
html[data-theme='dark'] .logs-wrapper {
  border-color: #2b3542;
}

html[data-theme='dark'] .access-table th,
html[data-theme='dark'] .logs-table th {
  color: #94a3b5;
  background: #11171f;
}

html[data-theme='dark'] .access-table tbody tr:hover {
  background: #1b222c;
}

html[data-theme='dark'] .access-table tbody tr.is-selected {
  background: #2b1b21;
}

html[data-theme='dark'] .permission-summary-stat {
  border-color: #2e3946;
  background: #121820;
}

html[data-theme='dark'] .status-pill--inactive,
html[data-theme='dark'] .permission-badge--none {
  color: #aeb9c6;
  background: #2b333e;
}

html[data-theme='dark'] .status-pill--active,
html[data-theme='dark'] .permission-badge--total {
  color: #65dfa0;
  background: #173a2b;
}

html[data-theme='dark'] .status-pill--pending {
  color: #ffc15c;
  background: #3a2d18;
}

html[data-theme='dark'] .status-pill--danger {
  color: #ff8b98;
  background: #402027;
}

html[data-theme='dark'] .permission-badge--edit {
  color: #c99cff;
  background: #302540;
}

html[data-theme='dark'] .permission-badge--view,
html[data-theme='dark'] .permission-badge--view-export {
  color: #9eb4ff;
  background: #202d50;
}

html[data-theme='dark'] .data-user-avatar,
html[data-theme='dark'] .profile-summary__avatar,
html[data-theme='dark'] .security-icon,
html[data-theme='dark'] .role-icon,
html[data-theme='dark'] .access-profile-icon {
  background: #3b2027;
}

html[data-theme='dark'] .access-table tbody tr,
html[data-theme='dark'] .logs-table tr {
  border-color: #2b3542;
  background: #171d25;
}

html[data-theme='dark'] .access-modal-backdrop,
html[data-theme='dark'] .matrix-expanded-screen,
html[data-theme='dark'] .supplier-detail-screen {
  background: rgba(5, 8, 12, 0.82);
}

/* Dashboard no tema escuro */
html[data-theme='dark'] .kpi-card h2,
html[data-theme='dark'] .kpi-card > strong,
html[data-theme='dark'] .kpi-card > small {
  color: #e7edf4;
}

html[data-theme='dark'] .grid-lines line {
  stroke: #2a3441;
}

html[data-theme='dark'] .month-labels text,
html[data-theme='dark'] .bar-label {
  fill: #8998aa;
}

html[data-theme='dark'] .matrix-wrapper,
html[data-theme='dark'] .matrix-expanded-wrapper,
html[data-theme='dark'] .supplier-category-wrapper,
html[data-theme='dark'] .supplier-payments-wrapper {
  border-color: #2b3542;
}

html[data-theme='dark'] .matrix-table,
html[data-theme='dark'] .matrix-expanded-table,
html[data-theme='dark'] .supplier-category-table,
html[data-theme='dark'] .supplier-payments-table {
  color: #b8c3d0;
  background: #171d25;
}

html[data-theme='dark'] .matrix-table th,
html[data-theme='dark'] .matrix-expanded-table th,
html[data-theme='dark'] .supplier-category-table th,
html[data-theme='dark'] .supplier-payments-table th {
  border-color: #2b3542;
  color: #a9b6c5;
  background: #11171f;
}

html[data-theme='dark'] .matrix-table td,
html[data-theme='dark'] .matrix-expanded-table td,
html[data-theme='dark'] .supplier-category-table td,
html[data-theme='dark'] .supplier-payments-table td {
  border-color: #2b3542;
  background: #171d25;
}

html[data-theme='dark'] .matrix-table tr:nth-child(even) td,
html[data-theme='dark'] .supplier-category-table tbody tr:nth-child(even) td {
  background: #151b23;
}

html[data-theme='dark'] .matrix-table .row-positive td,
html[data-theme='dark'] .matrix-table .row-total td,
html[data-theme='dark'] .matrix-expanded-table .row-positive td,
html[data-theme='dark'] .matrix-expanded-table .row-total td {
  background: #142438;
}

html[data-theme='dark'] .matrix-table .row-positive-soft td,
html[data-theme='dark'] .matrix-expanded-table .row-positive-soft td {
  background: #142a21;
}

html[data-theme='dark'] .matrix-table .row-negative td,
html[data-theme='dark'] .matrix-expanded-table .row-negative td {
  background: #351c22;
}

html[data-theme='dark'] .matrix-expanded-table .row-neutral td:first-child,
html[data-theme='dark'] .matrix-expanded-table .row-positive td:first-child,
html[data-theme='dark'] .matrix-expanded-table .row-total td:first-child,
html[data-theme='dark'] .matrix-expanded-table .row-positive-soft td:first-child,
html[data-theme='dark'] .matrix-expanded-table .row-negative td:first-child {
  background: inherit;
}

html[data-theme='dark'] .insight-card--danger {
  border-color: #5d2a32;
  background: #2a171c;
}

html[data-theme='dark'] .insight-card--success {
  border-color: #28573c;
  background: #14251c;
}

html[data-theme='dark'] .insight-card--warning {
  border-color: #634a1f;
  background: #2a2111;
}

html[data-theme='dark'] .insight-card small {
  color: #b8c3d0;
}

html[data-theme='dark'] .login-page,
html[data-theme='dark'] .login-access {
  background: #0f141b;
}

html[data-theme='dark'] .login-card__header h2,
html[data-theme='dark'] .login-card label {
  color: #e9eff6;
}

html[data-theme='dark'] .login-card__header p,
html[data-theme='dark'] .remember-access {
  color: #96a5b7;
}

html[data-theme='dark'] .login-card__footer {
  border-color: #2b3542;
  color: #667588;
}

@media (max-width: 899px) {
  html[data-theme='dark'] .access-table tbody tr,
  html[data-theme='dark'] .logs-table tr,
  html[data-theme='dark'] .matrix-table tr,
  html[data-theme='dark'] .matrix-expanded-table tr,
  html[data-theme='dark'] .supplier-category-table tr,
  html[data-theme='dark'] .supplier-payments-table tr {
    border-color: #2b3542;
    background: #171d25;
  }

  html[data-theme='dark'] .access-table td:first-child,
  html[data-theme='dark'] .access-table--permissions td:first-child,
  html[data-theme='dark'] .logs-table td,
  html[data-theme='dark'] .matrix-table td {
    border-color: #2b3542;
  }
}

/* Refinamentos finais de legibilidade mobile e estados dos controles */
html[data-theme='dark'] .switch-row input:checked + i,
html[data-theme='dark'] .theme-choice__switch input:checked + i {
  background: var(--brand-red);
}

@media (max-width: 899px) {
  .access-card-heading h2 {
    font-size: 0.92rem;
  }

  .access-card-heading p {
    font-size: 0.74rem;
  }

  .access-table {
    font-size: 0.76rem;
  }

  .access-table td::before {
    font-size: 0.61rem;
  }

  .access-user-cell strong,
  .profile-name-cell strong,
  .access-profile-summary strong,
  .access-profile-detail__identity strong {
    font-size: 0.75rem;
  }

  .access-user-cell small,
  .access-profile-summary small,
  .access-profile-detail__identity small,
  .permission-legend-item small {
    font-size: 0.64rem;
  }

  .access-link-button,
  .access-profile-summary > span:last-child,
  .access-permission-summary dt,
  .access-permission-summary dd,
  .profile-usage-row strong,
  .profile-usage-row small,
  .invitation-help-card p {
    font-size: 0.68rem;
  }

  .permission-badge,
  .status-pill {
    font-size: 0.62rem;
  }
}

@media (max-width: 640px) {
  .switch-row--static {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .switch-row--static strong {
    width: auto;
    max-width: 125px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* ========================================================================== 
   AUDITORIA COMPLETA DO MODO ESCURO — v1.6.1
   Revisão de contraste, superfícies, tabelas, menus, overlays e mobile.
   ========================================================================== */

/* Login: mantém o painel institucional realmente escuro quando as variáveis
   semânticas do tema são invertidas. */
html[data-theme='dark'] .login-hero {
  color: #f7f9fc;
  background:
    radial-gradient(circle at 22% 48%, rgba(255, 255, 255, 0.035), transparent 31%),
    #202228;
}

html[data-theme='dark'] .login-hero h1 {
  color: #f7f9fc;
}

html[data-theme='dark'] .login-hero__description {
  color: #b7c3d1;
}

html[data-theme='dark'] .eyebrow,
html[data-theme='dark'] .page-kicker,
html[data-theme='dark'] .link-button {
  color: #ff7a88;
}

html[data-theme='dark'] .login-card__footer {
  color: #91a0b3;
}

/* Cabeçalhos, navegação móvel e controles globais. */
html[data-theme='dark'] .user-profile__text strong {
  color: #edf3f8;
}

html[data-theme='dark'] .user-profile__chevron {
  color: #9eacbd;
}

html[data-theme='dark'] .filter-control__icon {
  color: #bdc9d6;
}

html[data-theme='dark'] .menu-button {
  border: 1px solid #3a4655;
  background: #202833;
  box-shadow: none;
}

html[data-theme='dark'] .menu-button:hover {
  background: #27313d;
}

html[data-theme='dark'] .menu-button span {
  background: #edf3f8;
}

html[data-theme='dark'] .sidebar-close {
  border-color: #4a5564;
  color: #ffffff;
  background: #303640;
}

html[data-theme='dark'] .sidebar-close:hover {
  border-color: #657286;
  background: #3a424e;
}

html[data-theme='dark'] select option {
  color: #e8eef5;
  background: #11171f;
}

html[data-theme='dark'] * {
  scrollbar-color: #4b5a6d #11171f;
}

/* Os ícones dos KPIs usam fundos mais escuros para garantir contraste do
   glifo branco, sem perder a codificação cromática original. */
html[data-theme='dark'] .kpi-icon {
  color: #ffffff;
  background: #28577f;
}

html[data-theme='dark'] .tone-green .kpi-icon {
  background: #17683d;
}

html[data-theme='dark'] .tone-red .kpi-icon {
  background: #8b2934;
}

html[data-theme='dark'] .tone-orange .kpi-icon {
  background: #7b5100;
}

html[data-theme='dark'] .tone-purple .kpi-icon {
  background: #713077;
}

/* Matriz DFC principal e expandida. */
html[data-theme='dark'] .matrix-table .row-negative td,
html[data-theme='dark'] .matrix-table .row-negative-child td {
  color: #ff8b98;
}

html[data-theme='dark'] .matrix-table .row-positive td,
html[data-theme='dark'] .matrix-table .row-total td {
  color: #9ecbff;
}

html[data-theme='dark'] .matrix-table .row-positive-soft td {
  color: #71e3a8;
}

html[data-theme='dark'] .matrix-expanded-screen {
  background: #0b1016;
}

html[data-theme='dark'] .matrix-expanded-header {
  border-color: #2b3542;
  background: #171d25;
}

html[data-theme='dark'] .matrix-expanded-header p {
  color: #96a5b7;
}

html[data-theme='dark'] .matrix-close-button:hover,
html[data-theme='dark'] .supplier-close-button:hover,
html[data-theme='dark'] .supplier-export-button:hover {
  border-color: #596a7f;
  color: #ffffff;
  background: #202833;
  box-shadow: none;
}

html[data-theme='dark'] .matrix-expanded-wrapper {
  background: #0f141b;
}

html[data-theme='dark'] .matrix-expanded-table tbody tr:nth-child(even) td {
  background: #151b23;
}

html[data-theme='dark'] .matrix-expanded-table .row-neutral td {
  color: #d6e0ea;
  background: #171d25;
}

html[data-theme='dark'] .matrix-expanded-table .row-child td {
  color: #c7d3df;
}

html[data-theme='dark'] .matrix-expanded-table .row-positive td,
html[data-theme='dark'] .matrix-expanded-table .row-total td {
  color: #a9d2ff;
  background: #142438;
}

html[data-theme='dark'] .matrix-expanded-table .row-positive-soft td {
  color: #71e3a8;
  background: #142a21;
}

html[data-theme='dark'] .matrix-expanded-table .row-positive-soft td:nth-child(3) {
  color: #ff8b98;
}

html[data-theme='dark'] .matrix-expanded-table .row-negative td {
  color: #ff8b98;
  background: #351c22;
}

html[data-theme='dark'] .matrix-expanded-table .row-negative-child td {
  color: #ff8b98;
}

html[data-theme='dark'] .matrix-expanded-table .row-neutral td:first-child,
html[data-theme='dark'] .matrix-expanded-table .row-child td:first-child,
html[data-theme='dark'] .matrix-expanded-table .row-negative-child td:first-child {
  color: inherit;
  background: inherit;
}

html[data-theme='dark'] .matrix-group-toggle,
html[data-theme='dark'] .supplier-category-toggle {
  border-color: #4c5b6d;
  color: #c5d1de;
  background: #202833;
}

html[data-theme='dark'] .matrix-group-toggle:hover,
html[data-theme='dark'] .supplier-category-toggle:hover {
  border-color: #68798e;
  color: #ffffff;
  background: #27313d;
}

html[data-theme='dark'] .matrix-hierarchy-dot,
html[data-theme='dark'] .supplier-tree-dot {
  border-color: #7f91a6;
  background: #171d25;
}

html[data-theme='dark'] .matrix-account--child::before,
html[data-theme='dark'] .supplier-category-name--child::before {
  background: #3c4a5b;
}

html[data-theme='dark'] .matrix-expanded-footer {
  border-color: #2b3542;
  color: #a8b5c4;
  background: #171d25;
}

html[data-theme='dark'] .matrix-expanded-footer > small {
  color: #95a4b6;
}

html[data-theme='dark'] .legend-entry {
  background: #24486d;
}

html[data-theme='dark'] .legend-exit {
  background: #6a2933;
}

html[data-theme='dark'] .legend-free {
  background: #24583a;
}

/* Detalhamento de fornecedores. */
html[data-theme='dark'] .supplier-detail-screen {
  color: #dce6f1;
  background: #0b1016;
}

html[data-theme='dark'] .supplier-detail-toolbar {
  border-color: #2b3542;
  background: rgba(15, 20, 27, 0.97);
}

html[data-theme='dark'] .supplier-summary-heading h2,
html[data-theme='dark'] .supplier-summary-heading h2 > i {
  color: #e3ebf4;
}

html[data-theme='dark'] .supplier-summary-heading h2 > strong {
  color: #78b7ff;
}

html[data-theme='dark'] .supplier-horizon-chip {
  color: #dce8f5;
  background: #263445;
}

html[data-theme='dark'] .supplier-category-table tbody tr:nth-child(even) td {
  background: #151b23;
}

html[data-theme='dark'] .supplier-category-table .supplier-row-group td {
  color: #ff8b98;
  background: #351c22;
}

html[data-theme='dark'] .supplier-category-table .supplier-row-group td:first-child {
  color: #e4edf6;
  background: #351c22;
}

html[data-theme='dark'] .supplier-category-table .supplier-row-category td {
  color: #ff8b98;
}

html[data-theme='dark'] .supplier-category-table .supplier-row-category td:first-child {
  color: #cfdae6;
}

html[data-theme='dark'] .supplier-payments-table tbody td {
  color: #c5d0dc;
  background: #171d25;
}

html[data-theme='dark'] .supplier-payments-table tbody tr:nth-child(even) td {
  background: #151b23;
}

html[data-theme='dark'] .supplier-payments-table tbody td:last-child {
  color: #ff8b98;
}

html[data-theme='dark'] .calendar-icon {
  border-color: #9bb0c7;
}

html[data-theme='dark'] .calendar-icon::before,
html[data-theme='dark'] .calendar-icon::after {
  border-color: #9bb0c7;
  background: #9bb0c7;
}

html[data-theme='dark'] .supplier-status--open {
  color: #ff9aa5;
  background: #442129;
}

html[data-theme='dark'] .supplier-status--scheduled {
  color: #abc2ff;
  background: #23325a;
}

html[data-theme='dark'] .supplier-detail-footer {
  border-color: #2b3542;
  color: #a5b3c3;
  background: #171d25;
}

html[data-theme='dark'] .supplier-legend-category {
  background: #24486d;
}

html[data-theme='dark'] .supplier-legend-exit {
  background: #6a2933;
}

html[data-theme='dark'] .supplier-legend-scheduled {
  background: #2d4173;
}

/* Perfil, usuários, perfis, permissões e convites. */
.switch-row--static {
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto);
}

.switch-row--static > span {
  min-width: 0;
}

.switch-row--static strong {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

html[data-theme='dark'] .security-icon,
html[data-theme='dark'] .role-icon,
html[data-theme='dark'] .access-profile-icon {
  border: 1px solid #59303a;
  color: #ff8b98;
  background: #3b2027;
}

html[data-theme='dark'] .access-link-button {
  color: #bdc9d6;
}

html[data-theme='dark'] .access-link-button:hover {
  color: #ff8b98;
}

html[data-theme='dark'] .access-link-button--danger {
  color: #ff929e;
}

html[data-theme='dark'] .access-profile-summary strong,
html[data-theme='dark'] .access-profile-detail__identity strong,
html[data-theme='dark'] .profile-usage-total strong,
html[data-theme='dark'] .permission-legend-item strong,
html[data-theme='dark'] .permission-summary-stat strong {
  color: #e0e8f1;
}

html[data-theme='dark'] .data-user-avatar.avatar-tone-red {
  color: #ffd0d5;
  background: #5a2630;
}

html[data-theme='dark'] .data-user-avatar.avatar-tone-blue {
  color: #c4d1ff;
  background: #293a63;
}

html[data-theme='dark'] .data-user-avatar.avatar-tone-orange {
  color: #ffd39a;
  background: #553819;
}

html[data-theme='dark'] .data-user-avatar.avatar-tone-cyan {
  color: #aeeaf4;
  background: #1f4b54;
}

html[data-theme='dark'] .data-user-avatar.avatar-tone-purple {
  color: #e1c3ff;
  background: #49305f;
}

html[data-theme='dark'] .data-user-avatar.avatar-tone-green {
  color: #acebc8;
  background: #254d39;
}

html[data-theme='dark'] .permission-legend-dot--total {
  background: #20523a;
}

html[data-theme='dark'] .permission-legend-dot--edit {
  background: #4a335f;
}

html[data-theme='dark'] .permission-legend-dot--view {
  background: #2c3f70;
}

html[data-theme='dark'] .permission-legend-dot--none {
  background: #343e4b;
}

html[data-theme='dark'] .permission-summary-stat strong {
  color: #f1f5f9;
}

/* A coluna de e-mail dos convites não invade as colunas vizinhas. */
.access-table--invitations td:nth-child(2) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Modal aberto: foco visual e rodapé coerentes no escuro. */
html[data-theme='dark'] .access-modal > header,
html[data-theme='dark'] .access-modal form > footer {
  background: #171d25;
}

html[data-theme='dark'] .access-modal > header > button:hover {
  color: #ffffff;
  background: #27313d;
}

@media (max-width: 899px) {
  /* Cards da matriz expandida no mobile. */
  html[data-theme='dark'] .matrix-expanded-header {
    border-color: #2b3542;
    background: #171d25;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
  }

  html[data-theme='dark'] .matrix-expanded-wrapper {
    background: #0f141b;
  }

  html[data-theme='dark'] .matrix-expanded-table tbody tr {
    border-color: #334050;
    color: #d4dee8;
    background: #171d25;
    box-shadow: none;
  }

  html[data-theme='dark'] .matrix-expanded-table tbody tr:nth-child(even) {
    background: #151b23;
  }

  html[data-theme='dark'] .matrix-expanded-table tbody tr.row-positive,
  html[data-theme='dark'] .matrix-expanded-table tbody tr.row-total {
    color: #a9d2ff;
    background: #142438;
  }

  html[data-theme='dark'] .matrix-expanded-table tbody tr.row-negative {
    color: #ff8b98;
    background: #351c22;
  }

  html[data-theme='dark'] .matrix-expanded-table tbody tr.row-positive-soft {
    color: #71e3a8;
    background: #142a21;
  }

  html[data-theme='dark'] .matrix-expanded-table td:first-child {
    border-color: #3a4757;
  }

  html[data-theme='dark'] .matrix-expanded-table td:not(:first-child)::before {
    color: #94a4b6;
  }

  html[data-theme='dark'] .matrix-expanded-footer {
    border-top: 1px solid #2b3542;
    background: #171d25;
  }

  /* Cards de fornecedores no mobile. */
  html[data-theme='dark'] .supplier-detail-toolbar {
    border-color: #2b3542;
    background: rgba(15, 20, 27, 0.97);
  }

  html[data-theme='dark'] .supplier-category-table tbody tr,
  html[data-theme='dark'] .supplier-payments-table tbody tr {
    border-color: #334050;
    color: #d1dbe6;
    background: #171d25;
    box-shadow: none;
  }

  html[data-theme='dark'] .supplier-category-table tbody tr:nth-child(even),
  html[data-theme='dark'] .supplier-payments-table tbody tr:nth-child(even) {
    background: #151b23;
  }

  html[data-theme='dark'] .supplier-category-table tbody tr.supplier-row-group {
    background: #351c22;
  }

  html[data-theme='dark'] .supplier-category-table td,
  html[data-theme='dark'] .supplier-payments-table td {
    color: #cbd6e1;
  }

  html[data-theme='dark'] .supplier-category-table .supplier-row-group td,
  html[data-theme='dark'] .supplier-category-table .supplier-row-category td,
  html[data-theme='dark'] .supplier-payments-table td:last-child {
    color: #ff8b98;
  }

  html[data-theme='dark'] .supplier-category-table td:first-child,
  html[data-theme='dark'] .supplier-payments-table td:first-child {
    border-color: #3a4757;
    color: #e1e9f1;
  }

  html[data-theme='dark'] .supplier-category-table td:not(:first-child)::before,
  html[data-theme='dark'] .supplier-payments-table td:not(:first-child)::before {
    color: #94a4b6;
  }

  html[data-theme='dark'] .supplier-detail-footer {
    border-color: #2b3542;
    background: #171d25;
  }

  /* Convites e textos longos em cartões mobile. */
  .access-table--invitations td:nth-child(2) {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .switch-row--static {
    grid-template-columns: minmax(0, 1fr) minmax(0, 42%);
  }

  .switch-row--static strong {
    max-width: none;
  }
}

/* Complemento da auditoria: contrastes residuais e conteúdo sem truncamento. */
html[data-theme='dark'] .insight-card--danger strong {
  color: #ff9aa5;
}

html[data-theme='dark'] .insight-card--danger .insight-icon {
  color: #ffffff;
  background: #8b2934;
}

html[data-theme='dark'] .insight-card--success strong {
  color: #71e3a8;
}

html[data-theme='dark'] .insight-card--success .insight-icon {
  color: #ffffff;
  background: #17683d;
}

html[data-theme='dark'] .insight-card--warning strong {
  color: #ffd071;
}

html[data-theme='dark'] .insight-card--warning .insight-icon {
  color: #ffffff;
  background: #795000;
}

html[data-theme='dark'] .profile-summary__avatar {
  border: 1px solid #6a3440;
  color: #ffd0d5;
  background: #5a2630;
}

html[data-theme='dark'] .switch-row--static strong {
  color: #ff9aa5;
}

.access-table--invitations td:nth-child(2) {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

html[data-theme='dark'] .sidebar-is-collapsed .nav-item__icon {
  color: #cbd5df;
}

html[data-theme='dark'] .sidebar-is-collapsed .nav-item.is-active .nav-item__icon {
  color: #ffffff;
}

/* ========================================================================== 
   CORREÇÃO MOBILE EPLAST — v1.6.2
   Unifica o comportamento entre 320 px e 899 px, inclusive modo paisagem.
   ========================================================================== */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (max-width: 899px) {
  html,
  body,
  #app-root {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  body {
    overflow-x: clip;
  }

  /* Evita o zoom automático do Safari/iOS ao focar campos menores que 16 px. */
  input,
  select,
  textarea {
    max-width: 100%;
    font-size: 16px !important;
  }

  button {
    min-width: 0;
    max-width: 100%;
  }

  /* Login: abaixo de 900 px usa sempre uma composição própria para touch.
     O layout anterior mantinha as duas colunas desktop entre 641 e 899 px. */
  .login-page {
    display: block;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    background: #f5f5f5;
  }

  .login-hero {
    display: none;
  }

  .login-access {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(22px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  }

  .login-stack {
    width: min(520px, 100%);
    max-width: 100%;
    gap: 20px;
  }

  .login-logo {
    width: clamp(112px, 24vw, 154px);
  }

  .login-card {
    width: 100%;
    min-width: 0;
    min-height: 0;
    padding: 28px 26px 0;
    overflow: hidden;
    border-radius: 16px;
  }

  .login-card__header h2 {
    font-size: clamp(1.45rem, 5vw, 1.8rem);
  }

  .login-card__header p {
    margin: 10px 0 22px;
  }

  .field {
    margin-top: 17px;
  }

  .field input {
    min-height: 50px;
  }

  .login-options {
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin: 20px 0;
  }

  .remember-access {
    min-width: 0;
    white-space: normal;
  }

  .login-card__footer {
    position: static;
    width: auto;
    margin: 26px -26px 0;
    padding: 18px 20px 20px;
  }

  /* Mantém o documento imóvel enquanto o menu lateral estiver aberto. */
  .dashboard-shell.sidebar-is-open {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .sidebar {
    max-width: min(88vw, 320px);
  }

  .sidebar__brand {
    min-height: 142px;
    padding-top: max(22px, env(safe-area-inset-top));
  }

  .sidebar__footer {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

  .mobile-topbar {
    width: 100%;
  }

  .dashboard-content,
  .workspace-content,
  .access-content {
    overflow: visible;
  }

  /* A Matriz DFC principal também vira cartões até 899 px. Antes disso só
     acontecia abaixo de 640 px, cortando a tabela em celulares paisagem. */
  .matrix-wrapper {
    width: 100%;
    max-width: 100%;
    overflow: visible;
  }

  .matrix-table,
  .matrix-table tbody,
  .matrix-table tr,
  .matrix-table td {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .matrix-table {
    table-layout: auto;
  }

  .matrix-table thead {
    display: none;
  }

  .matrix-table tbody {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 5px 12px 14px;
  }

  .matrix-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 8px 12px;
    padding: 12px;
    overflow: hidden;
    border: 1px solid #e1e7ed;
    border-radius: 10px;
    background: #fff;
  }

  .matrix-table td,
  .matrix-table td:first-child,
  .matrix-table .row-child td:first-child,
  .matrix-table .row-negative-child td:first-child {
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent !important;
    text-align: right;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .matrix-table td:first-child {
    grid-column: 1 / -1;
    margin-bottom: 3px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e4e9ef;
    text-align: left;
    font-size: 0.76rem;
    font-weight: 800;
  }

  .matrix-table td:nth-child(n + 6):nth-child(-n + 9) {
    display: none;
  }

  .matrix-table td:not(:first-child)::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: #8d98a7;
    font-size: 0.56rem;
    font-weight: 700;
    line-height: 1.25;
    text-align: right;
    text-transform: uppercase;
  }

  .matrix-table .row-negative,
  .matrix-table .row-negative-child {
    border-color: rgba(210, 31, 48, 0.25);
  }

  /* Formulários e barras de ação não podem manter larguras desktop. */
  .form-actions,
  .button-row,
  .access-modal form > footer {
    width: 100%;
  }

  .workspace-field,
  .filter-control__content,
  .access-search,
  .access-toolbar > *,
  .access-actions,
  .access-card-heading > * {
    min-width: 0;
  }

  .workspace-field textarea {
    min-height: 130px;
  }

  .settings-tabs,
  .access-tabs {
    width: 100%;
    max-width: 100%;
  }

  .access-modal {
    overscroll-behavior: contain;
  }
}

@media (max-width: 640px) {
  .matrix-table tbody {
    grid-template-columns: minmax(0, 1fr);
  }

  .login-card {
    padding-right: 20px;
    padding-left: 20px;
  }

  .login-card__footer {
    margin-right: -20px;
    margin-left: -20px;
  }
}

@media (max-width: 899px) and (orientation: landscape) and (max-height: 500px) {
  .login-access {
    align-items: flex-start;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .login-stack {
    gap: 10px;
  }

  .login-logo {
    width: 92px;
  }

  .login-card {
    width: min(560px, 100%);
    padding-top: 20px;
  }

  .login-card__header p {
    margin-bottom: 16px;
  }

  .field {
    margin-top: 12px;
  }

  .login-options {
    margin: 14px 0;
  }

  .login-card__footer {
    margin-top: 18px;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .matrix-table tbody {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

html[data-theme='dark'] .login-page,
html[data-theme='dark'] .login-access {
  background: #0f141b;
}

@media (max-width: 899px) {
  html[data-theme='dark'] .matrix-table tr {
    border-color: #2f3a48;
    background: #171d25;
  }

  html[data-theme='dark'] .matrix-table td:first-child {
    border-color: #344150;
  }

  html[data-theme='dark'] .matrix-table td:not(:first-child)::before {
    color: #91a0b2;
  }

  html[data-theme='dark'] .matrix-table .row-negative,
  html[data-theme='dark'] .matrix-table .row-negative-child {
    border-color: #71303a;
    background: #28191e;
  }

  html[data-theme='dark'] .matrix-table .row-positive,
  html[data-theme='dark'] .matrix-table .row-total {
    border-color: #294967;
    background: #142438;
  }

  html[data-theme='dark'] .matrix-table .row-positive-soft {
    border-color: #28533c;
    background: #142a21;
  }
}


/* v1.6.4 — a Curva de Caixa acompanha integralmente a largura do card.
   Esta regra final sobrescreve os limites de largura usados em breakpoints ultrawide. */
.panel--cash-chart .chart-scroll {
  width: 100%;
  max-width: none;
}

.panel--cash-chart .cash-chart {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: none;
  height: auto;
  min-height: 0;
  margin-inline: 0;
}

/* ===================================================================== */
/* Matriz DFC — visão mensal (Orçado / Realizado / Projetado)            */
/* ===================================================================== */

.matrix-header__actions,
.matrix-expanded-header__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.matrix-projected-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border: 1px solid #c7d8f2;
  border-radius: 4px;
  background: #f7faff;
  color: #4d5968;
  font-size: 0.66rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.matrix-projected-toggle input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: #1f6fd6;
  cursor: pointer;
}

.matrix-hint {
  margin: -2px 0 12px;
  font-size: 0.68rem;
  color: #7a828d;
}

.matrix-hint strong {
  color: #3b5673;
}

/* --- estrutura de cabeçalho em dois níveis --- */
.matrix-table--months .matrix-head-groups th {
  text-align: center;
  font-weight: 800;
  border-bottom: 1px solid #dfe6ee;
}

.matrix-table--months .matrix-head-leaves th {
  text-align: right;
  font-weight: 700;
  position: relative;
}

.matrix-table--months .matrix-head-leaves th:first-child {
  min-width: 64px;
  text-align: right;
}

.matrix-table--months .matrix-col-account {
  min-width: 230px;
  text-align: left;
}

/* --- coluna de respiro entre acumulado e meses futuros --- */
.matrix-table--months .matrix-col-gap,
.matrix-table--months .matrix-grp-gap {
  min-width: 18px;
  width: 18px;
  padding: 0 !important;
  background: transparent !important;
  border-left: 0 !important;
  border-right: 0 !important;
  box-shadow: none !important;
}

/* --- separadores entre meses --- */
.matrix-table--months .group-start {
  border-left: 1px solid #d5dee8;
}

/* --- cabeçalhos clicáveis + seta de expansão --- */
.matrix-table--months .is-clickable {
  cursor: pointer;
  user-select: none;
}

.matrix-table--months .is-clickable:hover {
  background: #e2edfb;
}

.matrix-caret {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg);
  opacity: 0.5;
  vertical-align: middle;
  transition: transform 150ms ease;
}

.matrix-caret.is-open {
  transform: rotate(45deg);
  opacity: 0.9;
}

/* --- realces por tipo de coluna --- */
.matrix-table--months .matrix-grp-current {
  background: #e5eeff;
  color: #123a74;
}

.matrix-table--months td.is-current,
.matrix-table--months .matrix-head-leaves th.is-current {
  background: #eef4ff;
}

.matrix-table--months .matrix-grp-acum {
  background: #dcefe4;
  color: #0b5f38;
}

.matrix-table--months td.is-acum,
.matrix-table--months .matrix-head-leaves th.is-acum {
  background: #ecf6f0;
  font-weight: 700;
}

.matrix-table--months .matrix-grp-future {
  background: #fbf4e6;
  color: #7a5c1e;
}

.matrix-table--months td.is-orcado {
  font-style: italic;
}

.matrix-table--months .matrix-head-leaves th.is-orcado {
  font-style: italic;
  color: #8a94a1;
}

.matrix-table--months td.is-week,
.matrix-table--months .matrix-head-leaves th.is-week {
  background: #f2f7ff;
}

.matrix-table--months td.is-day,
.matrix-table--months .matrix-head-leaves th.is-day {
  background: #eaf1fb;
  font-size: 0.92em;
}

.matrix-table--months .is-muted {
  opacity: 0.4;
  text-decoration: line-through;
}

/* --- variação expandida (modal): layout automático e cabeçalho fixo --- */
.matrix-expanded-table.matrix-table--months {
  table-layout: auto;
  min-width: 1600px;
}

.matrix-expanded-table.matrix-table--months th,
.matrix-expanded-table.matrix-table--months td {
  min-width: 66px;
}

.matrix-expanded-table.matrix-table--months .matrix-col-account {
  min-width: 250px;
}

.matrix-expanded-table.matrix-table--months .matrix-head-groups th {
  top: 0;
  height: 34px;
}

.matrix-expanded-table.matrix-table--months .matrix-head-leaves th {
  top: 34px;
  height: 46px;
}

.matrix-expanded-table.matrix-table--months .matrix-head-leaves th:first-child {
  position: sticky;
  top: 34px;
  left: auto;
  text-align: right;
  box-shadow: none;
  border-radius: 0;
  z-index: 5;
}

/* ---------- modo escuro ---------- */
html[data-theme='dark'] .matrix-projected-toggle {
  border-color: #33405a;
  background: #141b26;
  color: #c5d2e4;
}

html[data-theme='dark'] .matrix-hint {
  color: #8b97a8;
}

html[data-theme='dark'] .matrix-hint strong {
  color: #b9c8dd;
}

html[data-theme='dark'] .matrix-table--months .matrix-head-groups th {
  border-bottom-color: #2b3648;
}

html[data-theme='dark'] .matrix-table--months .group-start {
  border-left-color: #2c3648;
}

html[data-theme='dark'] .matrix-table--months .is-clickable:hover {
  background: #1c2635;
}

html[data-theme='dark'] .matrix-table--months .matrix-grp-current {
  background: #1a2740;
  color: #bcd4ff;
}

html[data-theme='dark'] .matrix-table--months td.is-current,
html[data-theme='dark'] .matrix-table--months .matrix-head-leaves th.is-current {
  background: #15202f;
}

html[data-theme='dark'] .matrix-table--months .matrix-grp-acum {
  background: #14301f;
  color: #9fe6bd;
}

html[data-theme='dark'] .matrix-table--months td.is-acum,
html[data-theme='dark'] .matrix-table--months .matrix-head-leaves th.is-acum {
  background: #122519;
}

html[data-theme='dark'] .matrix-table--months .matrix-grp-future {
  background: #2a2413;
  color: #e2c98a;
}

html[data-theme='dark'] .matrix-table--months .matrix-head-leaves th.is-orcado {
  color: #7f8b9d;
}

html[data-theme='dark'] .matrix-table--months td.is-week,
html[data-theme='dark'] .matrix-table--months .matrix-head-leaves th.is-week {
  background: #141f2e;
}

html[data-theme='dark'] .matrix-table--months td.is-day,
html[data-theme='dark'] .matrix-table--months .matrix-head-leaves th.is-day {
  background: #101a27;
}

/* ---------- responsivo: mantém tabela rolável (não vira cartões) ---------- */
@media (max-width: 899px) {
  .matrix-table.matrix-table--months,
  .matrix-expanded-table.matrix-table--months {
    display: table;
    width: auto;
  }

  .matrix-table.matrix-table--months thead,
  .matrix-expanded-table.matrix-table--months thead {
    display: table-header-group;
  }

  .matrix-table.matrix-table--months tbody,
  .matrix-expanded-table.matrix-table--months tbody {
    display: table-row-group;
    gap: 0;
  }

  .matrix-table.matrix-table--months tbody tr,
  .matrix-expanded-table.matrix-table--months tbody tr {
    display: table-row;
    grid-template-columns: none;
    gap: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    height: auto;
  }

  .matrix-table.matrix-table--months th,
  .matrix-table.matrix-table--months td,
  .matrix-expanded-table.matrix-table--months th,
  .matrix-expanded-table.matrix-table--months td {
    display: table-cell;
    width: auto;
    grid-column: auto;
    padding: 8px 10px;
    border-right: 1px solid #e2e7ed;
    border-bottom: 1px solid #e9eef3;
    white-space: nowrap;
    text-align: right;
  }

  .matrix-table.matrix-table--months .matrix-col-account,
  .matrix-expanded-table.matrix-table--months .matrix-col-account {
    text-align: left;
  }

  .matrix-table--months td::before {
    content: none !important;
  }
}


/* ===================================================================== */
/* v1.6.6 — scroll estável + drill-down mês → semana → dia               */
/* ===================================================================== */

.matrix-table--months .matrix-head-groups th.is-clickable {
  cursor: pointer;
  user-select: none;
  transition: filter 140ms ease, box-shadow 140ms ease;
}

.matrix-table--months .matrix-head-groups th.is-clickable:hover {
  filter: brightness(0.975);
  box-shadow: inset 0 -2px 0 rgba(31, 111, 214, 0.42);
}

.matrix-table--months .matrix-head-groups th.is-clickable:focus-visible,
.matrix-table--months .matrix-head-leaves th.is-clickable:focus-visible {
  outline: 3px solid rgba(31, 111, 214, 0.34);
  outline-offset: -3px;
}

.matrix-caret--month {
  margin-left: 9px;
  transform: translateY(-1px) rotate(-45deg);
}

.matrix-caret--month.is-open {
  transform: translateY(-3px) rotate(45deg);
}

/* O wrapper é o único elemento que rola. A tabela nunca invade o modal. */
.matrix-expanded-wrapper {
  position: relative;
  isolation: isolate;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.matrix-expanded-table.matrix-table--months {
  width: max-content;
  min-width: 100%;
  height: auto;
  table-layout: auto;
}

.matrix-expanded-table.matrix-table--months th,
.matrix-expanded-table.matrix-table--months td {
  box-sizing: border-box;
  background-clip: padding-box;
}

/* A primeira coluna tem largura fixa e fundo opaco para não deixar os dados
   das demais colunas aparecerem por baixo durante o scroll horizontal. */
.matrix-expanded-table.matrix-table--months .matrix-col-account {
  width: 300px;
  min-width: 300px;
  max-width: 300px;
}

.matrix-expanded-table.matrix-table--months thead th.matrix-col-account {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 40;
  background: #edf3f8;
  box-shadow: 8px 0 12px -10px rgba(15, 45, 78, 0.72);
}

.matrix-expanded-table.matrix-table--months tbody td.matrix-col-account {
  position: sticky;
  left: 0;
  z-index: 20;
  overflow: hidden;
  background: #fff;
  box-shadow: 8px 0 12px -10px rgba(15, 45, 78, 0.72);
}

.matrix-expanded-table.matrix-table--months tbody tr:nth-child(even) td.matrix-col-account {
  background: #f9fbfd;
}

.matrix-expanded-table.matrix-table--months tbody tr.row-neutral td.matrix-col-account {
  background: #fbfcfe;
}

.matrix-expanded-table.matrix-table--months tbody tr.row-positive td.matrix-col-account,
.matrix-expanded-table.matrix-table--months tbody tr.row-total td.matrix-col-account {
  background: #eaf3ff;
}

.matrix-expanded-table.matrix-table--months tbody tr.row-positive-soft td.matrix-col-account {
  background: #f0faf5;
}

.matrix-expanded-table.matrix-table--months tbody tr.row-negative td.matrix-col-account {
  background: #fff1f2;
}

.matrix-expanded-table.matrix-table--months tbody tr.row-child:nth-child(odd) td.matrix-col-account,
.matrix-expanded-table.matrix-table--months tbody tr.row-negative-child:nth-child(odd) td.matrix-col-account {
  background: #fff;
}

.matrix-expanded-table.matrix-table--months tbody tr.row-child:nth-child(even) td.matrix-col-account,
.matrix-expanded-table.matrix-table--months tbody tr.row-negative-child:nth-child(even) td.matrix-col-account {
  background: #f9fbfd;
}

.matrix-expanded-table.matrix-table--months .matrix-account {
  width: 100%;
  min-width: 0;
}

.matrix-expanded-table.matrix-table--months .matrix-account strong,
.matrix-expanded-table.matrix-table--months .matrix-account > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* O primeiro cabeçalho da segunda linha não é a coluna Grupo e nunca deve
   ficar preso à esquerda. */
.matrix-expanded-table.matrix-table--months .matrix-head-leaves th:first-child {
  left: auto;
  z-index: 8;
  box-shadow: none;
}

html[data-theme='dark'] .matrix-expanded-wrapper {
  background: #0f141b;
}

html[data-theme='dark'] .matrix-expanded-table.matrix-table--months thead th.matrix-col-account {
  background: #1b2531;
  box-shadow: 8px 0 12px -10px rgba(0, 0, 0, 0.92);
}

html[data-theme='dark'] .matrix-expanded-table.matrix-table--months tbody td.matrix-col-account {
  background: #171d25;
  box-shadow: 8px 0 12px -10px rgba(0, 0, 0, 0.92);
}

html[data-theme='dark'] .matrix-expanded-table.matrix-table--months tbody tr:nth-child(even) td.matrix-col-account,
html[data-theme='dark'] .matrix-expanded-table.matrix-table--months tbody tr.row-child:nth-child(even) td.matrix-col-account,
html[data-theme='dark'] .matrix-expanded-table.matrix-table--months tbody tr.row-negative-child:nth-child(even) td.matrix-col-account {
  background: #151b23;
}

html[data-theme='dark'] .matrix-expanded-table.matrix-table--months tbody tr.row-neutral td.matrix-col-account,
html[data-theme='dark'] .matrix-expanded-table.matrix-table--months tbody tr.row-child:nth-child(odd) td.matrix-col-account,
html[data-theme='dark'] .matrix-expanded-table.matrix-table--months tbody tr.row-negative-child:nth-child(odd) td.matrix-col-account {
  background: #171d25;
}

html[data-theme='dark'] .matrix-expanded-table.matrix-table--months tbody tr.row-positive td.matrix-col-account,
html[data-theme='dark'] .matrix-expanded-table.matrix-table--months tbody tr.row-total td.matrix-col-account {
  background: #14253a;
}

html[data-theme='dark'] .matrix-expanded-table.matrix-table--months tbody tr.row-positive-soft td.matrix-col-account {
  background: #12251b;
}

html[data-theme='dark'] .matrix-expanded-table.matrix-table--months tbody tr.row-negative td.matrix-col-account {
  background: #2b181d;
}

@media (max-width: 899px) {
  .matrix-expanded-table.matrix-table--months .matrix-col-account {
    width: 230px;
    min-width: 230px;
    max-width: 230px;
  }

  .matrix-expanded-table.matrix-table--months {
    min-width: max-content;
  }
}

.matrix-expanded-table.matrix-table--months .matrix-account > span:not(.matrix-hierarchy-dot):not(.matrix-drill-hint) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matrix-expanded-table.matrix-table--months .matrix-drill-hint {
  flex: 0 0 auto;
}

/* ===================================================================== */
/* v1.7.0 — melhorias executivas integradas do projeto de referência     */
/* ===================================================================== */

.updated-chip--button {
  width: 100%;
  cursor: pointer;
  font: inherit;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.updated-chip--button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #9ebbe3;
  box-shadow: 0 5px 14px rgba(28, 74, 128, 0.1);
}

.updated-chip--button:disabled {
  cursor: wait;
  opacity: 0.8;
}

.updated-chip__icon.is-spinning {
  animation: dashboard-spin 760ms linear infinite;
}

@keyframes dashboard-spin {
  to { transform: rotate(360deg); }
}

.kpi-card > small.note-success { color: var(--green); }
.kpi-card > small.note-danger { color: #d6353f; }

.executive-indicators {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: -4px 0 18px;
}

.executive-indicator {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  min-height: 66px;
  padding: 11px 14px;
  border: 1px solid #dbe3ec;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}

.executive-indicator__icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 9px;
  color: #315372;
  font-size: 1rem;
  font-weight: 850;
  background: #edf3f9;
}

.executive-indicator > span:last-child {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.executive-indicator small {
  color: #77818e;
  font-size: 0.65rem;
  font-weight: 700;
}

.executive-indicator strong {
  overflow: hidden;
  color: #39424d;
  font-size: 0.88rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.executive-indicator--success .executive-indicator__icon { color: #0a8840; background: #e6f7ed; }
.executive-indicator--warning .executive-indicator__icon { color: #b26d00; background: #fff4db; }
.executive-indicator--danger .executive-indicator__icon { color: #c72535; background: #fdebed; }
.executive-indicator--info .executive-indicator__icon { color: #2459a8; background: #eaf1ff; }

.dashboard-feedback {
  margin: -6px 0 12px;
  color: #536477;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: right;
}

.matrix-tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid #c9d8ea;
  border-radius: 6px;
  color: #42546a;
  font-size: 0.68rem;
  font-weight: 800;
  background: #f8fbff;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.matrix-tool-button:hover:not(:disabled),
.expand-button:hover {
  transform: translateY(-1px);
  border-color: #9fb9da;
  background: #eef5ff;
}

.matrix-tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.matrix-account--nested {
  padding-left: 76px;
}

.matrix-account--nested::before {
  left: 48px;
}

.matrix-account--nested .matrix-hierarchy-dot {
  left: 44px;
}

.matrix-table--months .is-drilldown-row {
  cursor: pointer;
}

.matrix-table--months .is-drilldown-row:hover td {
  filter: brightness(0.985);
}

.legend-line--projected {
  height: 0;
  border-top: 2px dashed #7d8896;
  background: transparent;
}

/* Curva de caixa com três faixas independentes. */
.cash-chart--bands {
  min-height: 320px;
}

.band-separator {
  stroke: #e3e9ef;
  stroke-width: 1;
}

.band-label {
  fill: #6a7078;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.band-baseline {
  stroke: #d7dee6;
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.cash-chart--bands .series-line--solid { stroke-dasharray: none; }
.cash-chart--bands .series-line--dashed { stroke-dasharray: 7 4; opacity: 0.85; }
.series-line--saldoInicial { stroke: var(--blue); }
.series-line--movimentacao { stroke: var(--green); }
.series-line--saldoFinal { stroke: #17283d; }
.point--saldoInicial { fill: var(--blue); }
.point--movimentacao { fill: var(--green); }
.point--saldoFinal { fill: #17283d; }
.point--projected { fill: #fff; stroke-width: 1.8; }
.point--projected.point--saldoInicial { stroke: var(--blue); }
.point--projected.point--movimentacao { stroke: var(--green); }
.point--projected.point--saldoFinal { stroke: #17283d; }
.cash-chart--bands .point-label { fill: #5b616b; font-size: 8.5px; }

.waterfall-connector {
  stroke: #97a3b2;
  stroke-width: 1;
  stroke-dasharray: 4 3;
  stroke-linecap: butt;
  vector-effect: non-scaling-stroke;
}

html[data-theme='dark'] .updated-chip--button:hover:not(:disabled) {
  border-color: #4c6380;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.28);
}

html[data-theme='dark'] .executive-indicator {
  border-color: #2f3a48;
  background: #171d25;
}

html[data-theme='dark'] .executive-indicator small { color: #94a0af; }
html[data-theme='dark'] .executive-indicator strong { color: #e1e7ef; }
html[data-theme='dark'] .executive-indicator__icon { color: #a9bfd9; background: #202c3a; }
html[data-theme='dark'] .executive-indicator--success .executive-indicator__icon { color: #78d99e; background: #153122; }
html[data-theme='dark'] .executive-indicator--warning .executive-indicator__icon { color: #e5bd67; background: #372c13; }
html[data-theme='dark'] .executive-indicator--danger .executive-indicator__icon { color: #ff8894; background: #3a1c23; }
html[data-theme='dark'] .executive-indicator--info .executive-indicator__icon { color: #8fb7ff; background: #172a49; }
html[data-theme='dark'] .dashboard-feedback { color: #9ba9ba; }

html[data-theme='dark'] .matrix-tool-button {
  border-color: #344357;
  color: #c8d5e5;
  background: #151e29;
}

html[data-theme='dark'] .matrix-tool-button:hover:not(:disabled) {
  border-color: #516782;
  background: #1d2a39;
}

html[data-theme='dark'] .band-separator { stroke: #2b3440; }
html[data-theme='dark'] .band-label { fill: #9aa4b2; }
html[data-theme='dark'] .band-baseline { stroke: #39434f; }
html[data-theme='dark'] .series-line--saldoFinal { stroke: #cdd7e4; }
html[data-theme='dark'] .point--saldoFinal { fill: #cdd7e4; }
html[data-theme='dark'] .point--projected { fill: #1b2430; }
html[data-theme='dark'] .point--projected.point--saldoFinal { stroke: #cdd7e4; }
html[data-theme='dark'] .cash-chart--bands .point-label { fill: #aeb6c2; }
html[data-theme='dark'] .waterfall-connector { stroke: #6b7787; }

@media (max-width: 1100px) {
  .executive-indicators {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 899px) {
  .matrix-header__actions,
  .matrix-expanded-header__actions {
    width: 100%;
    justify-content: flex-start;
  }

  .matrix-projected-toggle {
    flex: 1 1 100%;
    justify-content: center;
  }

  .matrix-tool-button,
  .expand-button {
    flex: 1 1 auto;
    min-height: 40px;
  }

  .cash-chart--bands {
    min-height: 260px;
  }

  .matrix-account--nested {
    padding-left: 58px;
  }

  .matrix-account--nested::before { left: 34px; }
  .matrix-account--nested .matrix-hierarchy-dot { left: 30px; }
}

@media (max-width: 540px) {
  .executive-indicators {
    grid-template-columns: 1fr;
  }

  .executive-indicator {
    min-height: 58px;
  }

  .matrix-header__actions .button-label,
  .matrix-expanded-header__actions .button-label {
    display: none;
  }

  .matrix-tool-button,
  .expand-button {
    flex: 0 1 48px;
    min-width: 44px;
    padding-inline: 10px;
  }

  .matrix-expanded-header__actions .matrix-close-button {
    flex: 1 1 92px;
  }

  .cash-chart--bands {
    min-height: 220px;
  }
}

/* Ultrawide: aumenta a densidade útil da matriz e limita a altura dos gráficos. */
@media (min-width: 1600px) {
  .matrix-table,
  .matrix-table--months {
    font-size: 0.9rem;
    line-height: 1.35;
  }

  .matrix-table th,
  .matrix-table td,
  .matrix-table--months th,
  .matrix-table--months td {
    padding: 10px 13px;
  }

  .panel--cash-chart .cash-chart,
  .panel--waterfall .waterfall-chart {
    max-height: 340px;
    margin-inline: auto;
  }
}

@media (min-width: 2200px) {
  .matrix-table,
  .matrix-table--months {
    font-size: 1rem;
    line-height: 1.4;
  }

  .matrix-table th,
  .matrix-table td,
  .matrix-table--months th,
  .matrix-table--months td {
    padding: 13px 17px;
  }

  .matrix-table th:first-child,
  .matrix-table td:first-child,
  .matrix-table--months th:first-child,
  .matrix-table--months td:first-child {
    min-width: 320px;
  }
}

@media (min-width: 3600px) {
  .matrix-table,
  .matrix-table--months {
    font-size: 1.14rem;
  }

  .matrix-table th,
  .matrix-table td,
  .matrix-table--months th,
  .matrix-table--months td {
    padding: 17px 21px;
  }
}

/* v1.7.0 — correção de contenção da Matriz DFC em celulares. A tabela
   continua legível em formato tabular, mas o scroll fica restrito ao card. */
@media (max-width: 899px) {
  .dashboard-main,
  .dashboard-content,
  .matrix-panel {
    min-width: 0;
    max-width: 100%;
  }

  .matrix-panel {
    overflow: hidden;
  }

  .matrix-panel .matrix-wrapper {
    position: relative;
    isolation: isolate;
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .matrix-panel .matrix-table.matrix-table--months {
    width: max-content;
    min-width: 100%;
    max-width: none;
  }
}

.matrix-mobile-summary {
  display: none;
}

@media (max-width: 899px) {
  .matrix-panel > .matrix-wrapper {
    display: none;
  }

  .matrix-mobile-summary {
    display: grid;
    gap: 9px;
    padding: 0 12px 14px;
  }

  .matrix-mobile-row {
    min-width: 0;
    overflow: hidden;
    border: 1px solid #dbe4ee;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(18, 34, 51, 0.04);
  }

  .matrix-mobile-row__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 46px;
    padding: 9px 10px;
    border-bottom: 1px solid #e6ecf2;
  }

  .matrix-mobile-row__header .matrix-account {
    flex: 1 1 auto;
    min-width: 0;
  }

  .matrix-mobile-row__header .matrix-account strong,
  .matrix-mobile-row__header .matrix-account > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .matrix-mobile-row__detail {
    flex: 0 0 auto;
    color: #315d91;
    font-size: 0.65rem;
    font-weight: 800;
  }

  .matrix-mobile-row__metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
  }

  .matrix-mobile-row__metrics > div {
    min-width: 0;
    padding: 8px 10px;
    border-right: 1px solid #edf1f5;
    border-bottom: 1px solid #edf1f5;
  }

  .matrix-mobile-row__metrics > div:nth-child(2n) { border-right: 0; }
  .matrix-mobile-row__metrics > div:nth-last-child(-n + 2) { border-bottom: 0; }

  .matrix-mobile-row__metrics dt {
    margin-bottom: 3px;
    color: #7a8592;
    font-size: 0.58rem;
    font-weight: 750;
    text-transform: uppercase;
  }

  .matrix-mobile-row__metrics dd {
    margin: 0;
    overflow: hidden;
    color: #3d4855;
    font-size: 0.74rem;
    font-weight: 820;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }

  .matrix-mobile-row.row-negative,
  .matrix-mobile-row.row-negative-child { border-color: #f0d6da; }
  .matrix-mobile-row.row-negative .matrix-mobile-row__header { background: #fff3f4; }
  .matrix-mobile-row.row-positive,
  .matrix-mobile-row.row-total { border-color: #d7e6f7; }
  .matrix-mobile-row.row-positive .matrix-mobile-row__header,
  .matrix-mobile-row.row-total .matrix-mobile-row__header { background: #eef6ff; }
  .matrix-mobile-row.row-positive-soft { border-color: #d5eadf; }
  .matrix-mobile-row.row-positive-soft .matrix-mobile-row__header { background: #effaf4; }

  html[data-theme='dark'] .matrix-mobile-row {
    border-color: #2d3947;
    background: #171d25;
    box-shadow: none;
  }

  html[data-theme='dark'] .matrix-mobile-row__header {
    border-bottom-color: #2b3541;
  }

  html[data-theme='dark'] .matrix-mobile-row__metrics > div {
    border-color: #28323e;
  }

  html[data-theme='dark'] .matrix-mobile-row__metrics dt { color: #8e9aaa; }
  html[data-theme='dark'] .matrix-mobile-row__metrics dd { color: #dce4ee; }
  html[data-theme='dark'] .matrix-mobile-row__detail { color: #91b9ed; }
  html[data-theme='dark'] .matrix-mobile-row.row-negative,
  html[data-theme='dark'] .matrix-mobile-row.row-negative-child { border-color: #513039; }
  html[data-theme='dark'] .matrix-mobile-row.row-negative .matrix-mobile-row__header { background: #2a181d; }
  html[data-theme='dark'] .matrix-mobile-row.row-positive,
  html[data-theme='dark'] .matrix-mobile-row.row-total { border-color: #274563; }
  html[data-theme='dark'] .matrix-mobile-row.row-positive .matrix-mobile-row__header,
  html[data-theme='dark'] .matrix-mobile-row.row-total .matrix-mobile-row__header { background: #14263a; }
  html[data-theme='dark'] .matrix-mobile-row.row-positive-soft { border-color: #24523a; }
  html[data-theme='dark'] .matrix-mobile-row.row-positive-soft .matrix-mobile-row__header { background: #12271b; }
}


/* ===================================================================== */
/* v1.7.1 — limpeza executiva, matriz compacta e overlays sem scroll geral */
/* ===================================================================== */

html.matrix-view-is-open,
body.matrix-view-is-open {
  width: 100%;
  height: 100%;
  overflow: hidden !important;
  overscroll-behavior: none;
}

.matrix-expanded-screen {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
  box-sizing: border-box;
  overscroll-behavior: none;
}

.matrix-expanded-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  max-height: 100%;
}

.matrix-expanded-wrapper {
  width: auto;
  height: 100%;
  max-height: 100%;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.matrix-title-block {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  min-width: 0;
}

.matrix-title-block h2 { margin: 0; }

.matrix-summary-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 9px;
  border: 1px solid #cfe0f4;
  border-radius: 999px;
  color: #315b86;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  background: #edf5ff;
}

.matrix-panel.is-collapsed-view {
  border-color: #cbd9e8;
  box-shadow: 0 8px 24px rgba(24, 61, 101, 0.07);
}

.matrix-panel.is-collapsed-view .matrix-header {
  border-bottom: 1px solid #e0e8f1;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.matrix-panel.is-collapsed-view .matrix-hint {
  margin: 0;
  padding: 9px 16px;
  border-bottom: 1px solid #e5ebf2;
  color: #708096;
  background: #fbfdff;
}

.matrix-panel.is-collapsed-view .matrix-wrapper {
  padding: 8px 10px 10px;
  background: #f5f8fc;
}

.matrix-panel.is-collapsed-view .matrix-table {
  overflow: hidden;
  border: 1px solid #dce5ee;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(24, 61, 101, 0.04);
}

.matrix-panel.is-collapsed-view .matrix-table tbody tr { height: 44px; }

.matrix-panel.is-collapsed-view .matrix-table tbody td {
  border-bottom: 1px solid #e8edf3;
  background-clip: padding-box;
}

.matrix-panel.is-collapsed-view .matrix-table tbody tr:last-child td { border-bottom: 0; }

.matrix-panel.is-collapsed-view .matrix-table tbody td:first-child {
  position: relative;
  color: #34485f;
  font-weight: 760;
}

.matrix-panel.is-collapsed-view .matrix-table tbody tr.row-positive td:first-child,
.matrix-panel.is-collapsed-view .matrix-table tbody tr.row-total td:first-child { box-shadow: inset 4px 0 #3978c8; }

.matrix-panel.is-collapsed-view .matrix-table tbody tr.row-negative td:first-child { box-shadow: inset 4px 0 #d92536; }

.matrix-panel.is-collapsed-view .matrix-table tbody tr.row-positive-soft td:first-child { box-shadow: inset 4px 0 #1c9a59; }

.matrix-panel.is-collapsed-view .matrix-group-toggle {
  border-color: #bdd0e4;
  background: #fff;
  box-shadow: 0 2px 6px rgba(28, 73, 119, 0.08);
}

.matrix-expanded-card.is-collapsed-view .matrix-expanded-wrapper { background: #f5f8fc; }
.matrix-expanded-card.is-collapsed-view .matrix-expanded-table tbody tr { height: 48px; }
.matrix-expanded-card.is-collapsed-view .matrix-expanded-table tbody td:first-child { font-weight: 760; }

@media (min-width: 900px) {
  .supplier-detail-shell {
    gap: 6px;
    padding-top: 10px;
  }

  .supplier-detail-toolbar { min-height: 40px; }
  .supplier-detail-content { gap: 7px; }

  .supplier-summary-heading {
    min-height: 54px;
    padding-top: 8px;
    padding-bottom: 5px;
  }

  .supplier-category-wrapper { margin-top: -2px; }
}

html[data-theme='dark'] .matrix-summary-chip {
  border-color: #35506d;
  color: #a9c8ea;
  background: #18283a;
}

html[data-theme='dark'] .matrix-panel.is-collapsed-view {
  border-color: #334253;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

html[data-theme='dark'] .matrix-panel.is-collapsed-view .matrix-header {
  border-color: #2f3a48;
  background: linear-gradient(180deg, #171d25 0%, #151b23 100%);
}

html[data-theme='dark'] .matrix-panel.is-collapsed-view .matrix-hint {
  border-color: #2c3744;
  color: #9ba9ba;
  background: #151b23;
}

html[data-theme='dark'] .matrix-panel.is-collapsed-view .matrix-wrapper,
html[data-theme='dark'] .matrix-expanded-card.is-collapsed-view .matrix-expanded-wrapper { background: #10161e; }

html[data-theme='dark'] .matrix-panel.is-collapsed-view .matrix-table {
  border-color: #303b49;
  background: #171d25;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.24);
}

html[data-theme='dark'] .matrix-panel.is-collapsed-view .matrix-table tbody td { border-bottom-color: #293440; }
html[data-theme='dark'] .matrix-panel.is-collapsed-view .matrix-table tbody td:first-child { color: #d5deea; }

html[data-theme='dark'] .matrix-panel.is-collapsed-view .matrix-group-toggle {
  border-color: #435369;
  background: #1c2632;
  box-shadow: none;
}

@media (max-width: 899px) {
  .matrix-expanded-card { grid-template-rows: auto minmax(0, 1fr) auto; }
  .matrix-title-block--expanded { display: block; }
  .matrix-title-block--expanded .matrix-summary-chip { display: none; }

  .matrix-panel.is-collapsed-view .matrix-wrapper {
    padding: 0;
    background: transparent;
  }
}

/* ===================================================================== */
/* v1.7.2 — continuidade dos saldos, colunas alinhadas e fornecedores    */
/* ===================================================================== */

/* A tabela não deve usar altura forçada: ela fazia a segunda linha do
   cabeçalho disputar espaço com a primeira linha de dados em alguns
   tamanhos de viewport. As duas faixas agora têm alturas explícitas. */
.matrix-table--months,
.matrix-expanded-table.matrix-table--months {
  height: auto !important;
}

.matrix-expanded-table.matrix-table--months thead {
  position: relative;
  z-index: 30;
}

.matrix-expanded-table.matrix-table--months .matrix-head-groups {
  height: 40px;
}

.matrix-expanded-table.matrix-table--months .matrix-head-leaves {
  height: 42px;
}

.matrix-expanded-table.matrix-table--months .matrix-head-groups th {
  top: 0 !important;
  height: 40px !important;
  min-height: 40px;
  padding-top: 8px;
  padding-bottom: 8px;
  vertical-align: middle;
}

.matrix-expanded-table.matrix-table--months .matrix-head-leaves th,
.matrix-expanded-table.matrix-table--months .matrix-head-leaves th:first-child {
  top: 40px !important;
  height: 42px !important;
  min-height: 42px;
  padding-top: 8px;
  padding-bottom: 8px;
  vertical-align: middle;
}

.matrix-expanded-table.matrix-table--months thead th.matrix-col-account {
  top: 0 !important;
  height: 82px !important;
  min-height: 82px;
  vertical-align: middle;
}

.matrix-expanded-table.matrix-table--months tbody tr:first-child td {
  border-top: 0;
}

/* O quadro do detalhamento de fornecedores passa a ser a única caixa azul.
   A borda deixa de pertencer às células, evitando que ultrapasse o cartão,
   alcance a barra de rolagem ou pareça invadir o contêiner seguinte. */
.supplier-summary-card {
  isolation: isolate;
  contain: paint;
}

.supplier-category-wrapper {
  box-sizing: border-box;
  width: auto;
  max-width: calc(100% - clamp(32px, 2vw, 44px));
  margin-inline: clamp(16px, 1vw, 22px);
  margin-bottom: 12px;
  border: 2px solid #1486ff;
  border-radius: 12px;
  background: #fff;
  overflow: auto;
  scrollbar-gutter: stable;
}

.supplier-category-table {
  width: max(100%, 1380px);
  min-width: 1380px;
  height: auto;
  min-height: 100%;
}

.supplier-category-table thead th {
  border-top: 0;
}

.supplier-category-table thead th:first-child,
.supplier-category-table thead th:last-child {
  border-left: 0;
  border-right: 0;
  border-radius: 0;
}

.supplier-category-table thead th:first-child {
  box-shadow: 8px 0 12px -10px rgba(15, 45, 78, 0.55);
}

html[data-theme='dark'] .supplier-category-wrapper {
  border-color: #2f8fff;
  background: #111821;
}

@media (max-width: 899px) {
  .matrix-expanded-table.matrix-table--months .matrix-head-groups th {
    height: 38px !important;
    min-height: 38px;
  }

  .matrix-expanded-table.matrix-table--months .matrix-head-leaves th,
  .matrix-expanded-table.matrix-table--months .matrix-head-leaves th:first-child {
    top: 38px !important;
    height: 40px !important;
    min-height: 40px;
  }

  .matrix-expanded-table.matrix-table--months thead th.matrix-col-account {
    height: 78px !important;
    min-height: 78px;
  }

  .supplier-category-wrapper {
    max-width: calc(100% - 20px);
    margin-inline: 10px;
    border-width: 1.5px;
  }
}

/* A regra base dos cabeçalhos mensais usa position: relative. No modal,
   todos os cabeçalhos de segundo nível precisam ser sticky; caso contrário,
   o valor de top desloca as células e cria uma falsa terceira linha. */
.matrix-expanded-table.matrix-table--months .matrix-head-leaves th,
.matrix-expanded-table.matrix-table--months .matrix-head-leaves th:first-child {
  position: sticky !important;
}

/* Mantém o cabeçalho do modal utilizável em celulares sem cortar o controle
   de projeção ou empurrar ações para fora da viewport. */
@media (max-width: 540px) {
  .matrix-expanded-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .matrix-expanded-header__actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    min-width: 0;
  }

  .matrix-expanded-header__actions .matrix-projected-toggle {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
  }

  .matrix-expanded-header__actions .matrix-tool-button {
    width: 100%;
    min-width: 0;
  }

  .matrix-expanded-header__actions .matrix-close-button {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

  .matrix-expanded-header__actions .matrix-close-button strong {
    display: inline;
  }
}


/* v1.8.1 — gráficos com tamanho original e crescimento progressivo. */
.panel--cash-chart .chart-scroll,
.panel--waterfall .chart-scroll {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
}

.panel--cash-chart .cash-chart,
.panel--waterfall .waterfall-chart {
  display: block;
  width: 100%;
  height: auto;
  min-height: 0;
  margin-inline: auto;
}

.panel--cash-chart .cash-chart {
  max-width: 900px;
}

.panel--waterfall .waterfall-chart {
  max-width: 790px;
}

.cash-chart--bands {
  min-height: 0;
}

.panel__header small {
  font-size: clamp(0.68rem, 0.38vw, 0.82rem);
}

.chart-legend {
  gap: 14px;
  font-size: clamp(0.64rem, 0.34vw, 0.76rem);
}

.today-text { font-size: 10px; }
.band-label { font-size: 11px; }
.cash-chart--bands .point-label { font-size: 9.5px; font-weight: 800; }
.month-labels text,
.bar-label { font-size: 9px; }
.bar-value { font-size: 10.5px; }

/* Em telas realmente amplas, os gráficos crescem junto com o espaço útil. */
@media (min-width: 2200px) {
  .panel--cash-chart .cash-chart { max-width: 1120px; max-height: 400px; }
  .panel--waterfall .waterfall-chart { max-width: 980px; max-height: 360px; }
  .cash-chart--bands .point-label { font-size: 10.5px; }
  .month-labels text,
  .bar-label { font-size: 10px; }
  .bar-value { font-size: 11.5px; }
}

@media (min-width: 3600px) {
  .panel--cash-chart .cash-chart { max-width: 1480px; max-height: 500px; }
  .panel--waterfall .waterfall-chart { max-width: 1280px; max-height: 430px; }
  .panel__header small { font-size: 0.9rem; }
  .chart-legend { font-size: 0.82rem; }
  .cash-chart--bands .point-label { font-size: 11.5px; }
  .month-labels text,
  .bar-label { font-size: 10.75px; }
  .bar-value { font-size: 12px; }
}

@media (max-width: 899px) {
  .panel--cash-chart .cash-chart,
  .panel--waterfall .waterfall-chart {
    max-width: none;
  }

  .panel__header small { font-size: 0.76rem; }
  .chart-legend { font-size: 0.7rem; gap: 10px; }
}

/* v1.8.0 — estados explícitos para recursos de demonstração. */
.form-message {
  margin: 0;
  color: #315f9e;
  font-size: 0.78rem;
  line-height: 1.45;
}

.feature-status {
  display: block;
  margin-top: 3px;
  color: #8a94a2;
  font-size: 0.68rem;
  font-weight: 600;
}

.switch-row input:disabled + i {
  cursor: not-allowed;
  opacity: 0.55;
}

html[data-theme='dark'] .form-message { color: #8ab7f5; }
html[data-theme='dark'] .feature-status { color: #8f9dad; }

.demo-auth-notice {
  display: block;
  margin-top: 8px;
  color: #7d8795;
  font-size: 0.72rem;
  line-height: 1.4;
}
html[data-theme='dark'] .demo-auth-notice { color: #93a0b0; }

/* v1.8.1 — expansão temporal disponível em todas as contas da Matriz DFC. */
.matrix-period-detail-row > td,
.matrix-expanded-table.matrix-table--months .matrix-period-detail-row > td,
.matrix-table.matrix-table--months .matrix-period-detail-row > td {
  position: static !important;
  left: auto !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  padding: 0 !important;
  border-left: 0;
  border-right: 0;
  background: #f7faff !important;
  box-shadow: inset 0 1px 0 #dce7f3, inset 0 -1px 0 #dce7f3 !important;
}

.matrix-period-detail {
  display: grid;
  gap: 12px;
  padding: 14px 18px 16px;
  color: #26384f;
  background: linear-gradient(180deg, #f8fbff 0%, #f2f7fd 100%);
}

.matrix-period-detail > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.matrix-period-detail > header strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

.matrix-period-detail > header span {
  flex: 0 0 auto;
  color: #607792;
  font-size: 0.7rem;
  font-weight: 700;
}

.matrix-period-detail__summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
}

.matrix-period-detail__summary > div,
.matrix-period-detail__weeks > div {
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid #d8e4f1;
  border-radius: 8px;
  background: #fff;
}

.matrix-period-detail__summary small,
.matrix-period-detail__summary strong,
.matrix-period-detail__weeks strong,
.matrix-period-detail__weeks span {
  display: block;
}

.matrix-period-detail__summary small {
  margin-bottom: 3px;
  color: #708197;
  font-size: 0.66rem;
}

.matrix-period-detail__summary strong {
  overflow: hidden;
  color: #213853;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matrix-period-detail__weeks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.matrix-period-detail__weeks strong {
  margin-bottom: 5px;
  color: #243a55;
  font-size: 0.7rem;
}

.matrix-period-detail__weeks span {
  color: #64778e;
  font-size: 0.66rem;
  line-height: 1.45;
}

.matrix-period-detail > p {
  margin: 0;
  color: #667b93;
  font-size: 0.68rem;
}

.matrix-period-detail--mobile {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #d8e4f1;
  border-radius: 10px;
}

html[data-theme='dark'] .matrix-period-detail-row > td,
html[data-theme='dark'] .matrix-expanded-table.matrix-table--months .matrix-period-detail-row > td,
html[data-theme='dark'] .matrix-table.matrix-table--months .matrix-period-detail-row > td {
  background: #111923 !important;
  box-shadow: inset 0 1px 0 #2c3948, inset 0 -1px 0 #2c3948 !important;
}

html[data-theme='dark'] .matrix-period-detail {
  color: #d7e2ef;
  background: linear-gradient(180deg, #151f2a 0%, #111923 100%);
}

html[data-theme='dark'] .matrix-period-detail__summary > div,
html[data-theme='dark'] .matrix-period-detail__weeks > div,
html[data-theme='dark'] .matrix-period-detail--mobile {
  border-color: #304052;
  background: #18232f;
}

html[data-theme='dark'] .matrix-period-detail > header span,
html[data-theme='dark'] .matrix-period-detail__summary small,
html[data-theme='dark'] .matrix-period-detail__weeks span,
html[data-theme='dark'] .matrix-period-detail > p {
  color: #97a8bc;
}

html[data-theme='dark'] .matrix-period-detail__summary strong,
html[data-theme='dark'] .matrix-period-detail__weeks strong,
html[data-theme='dark'] .matrix-period-detail > header strong {
  color: #e0e8f2;
}

@media (max-width: 899px) {
  .matrix-period-detail__summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .matrix-period-detail__weeks {
    grid-template-columns: 1fr;
  }

  .matrix-period-detail > header {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }
}


/* v1.8.9 — Ponte do fluxo dimensionada para preencher o card sem espaço vazio excessivo. */
.panel--waterfall {
  display: flex;
  flex-direction: column;
}

.panel--waterfall .chart-scroll {
  flex: 1 1 auto;
  align-items: center;
  padding: 2px 12px 12px;
}

.panel--waterfall .waterfall-chart {
  width: 100%;
  max-width: 790px;
  height: auto;
  aspect-ratio: 790 / 350;
}

@media (min-width: 2200px) {
  .panel--waterfall .waterfall-chart {
    max-width: 980px;
  }
}

@media (min-width: 3600px) {
  .panel--waterfall .waterfall-chart {
    max-width: 1280px;
  }
}

@media (max-width: 899px) {
  .panel--waterfall .chart-scroll {
    padding-inline: 6px;
  }

  .panel--waterfall .waterfall-chart {
    max-width: none;
    aspect-ratio: 790 / 350;
  }
}


/* v1.9.1 — fixa a coluna Grupo durante o scroll horizontal da matriz principal */
@media (min-width: 900px) {
  .matrix-panel .matrix-wrapper {
    position: relative;
    isolation: isolate;
  }

  .matrix-table.matrix-table--months {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
  }

  .matrix-table.matrix-table--months .matrix-col-account {
    width: 300px;
    min-width: 300px;
    max-width: 300px;
  }

  .matrix-table.matrix-table--months thead th.matrix-col-account {
    position: sticky;
    left: 0;
    top: 0;
    z-index: 26;
    background: #edf3f8;
    box-shadow: 8px 0 12px -10px rgba(15, 45, 78, 0.72);
  }

  .matrix-table.matrix-table--months tbody td.matrix-col-account {
    position: sticky;
    left: 0;
    z-index: 14;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 8px 0 12px -10px rgba(15, 45, 78, 0.72);
    background-clip: padding-box;
  }

  .matrix-table.matrix-table--months tbody tr:nth-child(even) td.matrix-col-account {
    background: #f9fbfd;
  }

  .matrix-table.matrix-table--months tbody tr.row-neutral td.matrix-col-account {
    background: #fbfcfe;
  }

  .matrix-table.matrix-table--months tbody tr.row-positive td.matrix-col-account,
  .matrix-table.matrix-table--months tbody tr.row-total td.matrix-col-account {
    background: #eaf3ff;
  }

  .matrix-table.matrix-table--months tbody tr.row-positive-soft td.matrix-col-account {
    background: #f0faf5;
  }

  .matrix-table.matrix-table--months tbody tr.row-negative td.matrix-col-account {
    background: #fff1f2;
  }

  .matrix-table.matrix-table--months tbody tr.row-child:nth-child(odd) td.matrix-col-account,
  .matrix-table.matrix-table--months tbody tr.row-negative-child:nth-child(odd) td.matrix-col-account {
    background: #fff;
  }

  .matrix-table.matrix-table--months tbody tr.row-child:nth-child(even) td.matrix-col-account,
  .matrix-table.matrix-table--months tbody tr.row-negative-child:nth-child(even) td.matrix-col-account {
    background: #f9fbfd;
  }

  html[data-theme='dark'] .matrix-table.matrix-table--months thead th.matrix-col-account {
    background: #1b2431;
    box-shadow: 8px 0 12px -10px rgba(0, 0, 0, 0.58);
  }

  html[data-theme='dark'] .matrix-table.matrix-table--months tbody td.matrix-col-account {
    background: #121926;
    box-shadow: 8px 0 12px -10px rgba(0, 0, 0, 0.58);
  }

  html[data-theme='dark'] .matrix-table.matrix-table--months tbody tr:nth-child(even) td.matrix-col-account,
  html[data-theme='dark'] .matrix-table.matrix-table--months tbody tr.row-child:nth-child(even) td.matrix-col-account,
  html[data-theme='dark'] .matrix-table.matrix-table--months tbody tr.row-negative-child:nth-child(even) td.matrix-col-account {
    background: #101723;
  }

  html[data-theme='dark'] .matrix-table.matrix-table--months tbody tr.row-neutral td.matrix-col-account,
  html[data-theme='dark'] .matrix-table.matrix-table--months tbody tr.row-child:nth-child(odd) td.matrix-col-account,
  html[data-theme='dark'] .matrix-table.matrix-table--months tbody tr.row-negative-child:nth-child(odd) td.matrix-col-account {
    background: #121926;
  }

  html[data-theme='dark'] .matrix-table.matrix-table--months tbody tr.row-positive td.matrix-col-account,
  html[data-theme='dark'] .matrix-table.matrix-table--months tbody tr.row-total td.matrix-col-account {
    background: rgba(57, 120, 200, 0.18);
  }

  html[data-theme='dark'] .matrix-table.matrix-table--months tbody tr.row-positive-soft td.matrix-col-account {
    background: rgba(28, 154, 89, 0.16);
  }

  html[data-theme='dark'] .matrix-table.matrix-table--months tbody tr.row-negative td.matrix-col-account {
    background: rgba(217, 37, 54, 0.16);
  }
}


/* v1.9.2 — coluna Grupo completamente opaca durante o scroll horizontal. */
@media (min-width: 900px) {
  .matrix-panel .matrix-table.matrix-table--months {
    border-collapse: separate !important;
    border-spacing: 0;
  }

  .matrix-panel .matrix-table.matrix-table--months .matrix-col-account {
    position: sticky;
    left: 0;
    opacity: 1 !important;
    background-clip: border-box !important;
    isolation: isolate;
  }

  .matrix-panel .matrix-table.matrix-table--months thead th.matrix-col-account {
    z-index: 60 !important;
    background-color: #edf3f8 !important;
  }

  .matrix-panel .matrix-table.matrix-table--months tbody td.matrix-col-account {
    z-index: 40 !important;
    background-color: #ffffff !important;
  }

  .matrix-panel .matrix-table.matrix-table--months tbody tr:nth-child(even) td.matrix-col-account {
    background-color: #f9fbfd !important;
  }

  .matrix-panel .matrix-table.matrix-table--months tbody tr.row-neutral td.matrix-col-account {
    background-color: #fbfcfe !important;
  }

  .matrix-panel .matrix-table.matrix-table--months tbody tr.row-positive td.matrix-col-account,
  .matrix-panel .matrix-table.matrix-table--months tbody tr.row-total td.matrix-col-account {
    background-color: #eaf3ff !important;
  }

  .matrix-panel .matrix-table.matrix-table--months tbody tr.row-positive-soft td.matrix-col-account {
    background-color: #f0faf5 !important;
  }

  .matrix-panel .matrix-table.matrix-table--months tbody tr.row-negative td.matrix-col-account {
    background-color: #fff1f2 !important;
  }

  .matrix-panel .matrix-table.matrix-table--months tbody tr.row-child:nth-child(odd) td.matrix-col-account,
  .matrix-panel .matrix-table.matrix-table--months tbody tr.row-negative-child:nth-child(odd) td.matrix-col-account {
    background-color: #ffffff !important;
  }

  .matrix-panel .matrix-table.matrix-table--months tbody tr.row-child:nth-child(even) td.matrix-col-account,
  .matrix-panel .matrix-table.matrix-table--months tbody tr.row-negative-child:nth-child(even) td.matrix-col-account {
    background-color: #f9fbfd !important;
  }

  .matrix-panel .matrix-table.matrix-table--months .matrix-col-account::after {
    content: '';
    position: absolute;
    top: 0;
    right: -1px;
    bottom: 0;
    width: 1px;
    background: #d5dee8;
    box-shadow: 8px 0 12px -8px rgba(15, 45, 78, 0.55);
    pointer-events: none;
  }

  .matrix-panel .matrix-table.matrix-table--months .matrix-account {
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .matrix-panel .matrix-table.matrix-table--months .matrix-account strong,
  .matrix-panel .matrix-table.matrix-table--months .matrix-account > span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html[data-theme='dark'] .matrix-panel .matrix-table.matrix-table--months thead th.matrix-col-account {
    background-color: #11171f !important;
  }

  html[data-theme='dark'] .matrix-panel .matrix-table.matrix-table--months tbody td.matrix-col-account {
    background-color: #171d25 !important;
  }

  html[data-theme='dark'] .matrix-panel .matrix-table.matrix-table--months tbody tr:nth-child(even) td.matrix-col-account,
  html[data-theme='dark'] .matrix-panel .matrix-table.matrix-table--months tbody tr.row-child:nth-child(even) td.matrix-col-account,
  html[data-theme='dark'] .matrix-panel .matrix-table.matrix-table--months tbody tr.row-negative-child:nth-child(even) td.matrix-col-account {
    background-color: #151b23 !important;
  }

  html[data-theme='dark'] .matrix-panel .matrix-table.matrix-table--months tbody tr.row-neutral td.matrix-col-account,
  html[data-theme='dark'] .matrix-panel .matrix-table.matrix-table--months tbody tr.row-child:nth-child(odd) td.matrix-col-account,
  html[data-theme='dark'] .matrix-panel .matrix-table.matrix-table--months tbody tr.row-negative-child:nth-child(odd) td.matrix-col-account {
    background-color: #171d25 !important;
  }

  html[data-theme='dark'] .matrix-panel .matrix-table.matrix-table--months tbody tr.row-positive td.matrix-col-account,
  html[data-theme='dark'] .matrix-panel .matrix-table.matrix-table--months tbody tr.row-total td.matrix-col-account {
    background-color: #142438 !important;
  }

  html[data-theme='dark'] .matrix-panel .matrix-table.matrix-table--months tbody tr.row-positive-soft td.matrix-col-account {
    background-color: #142a21 !important;
  }

  html[data-theme='dark'] .matrix-panel .matrix-table.matrix-table--months tbody tr.row-negative td.matrix-col-account {
    background-color: #351c22 !important;
  }

  html[data-theme='dark'] .matrix-panel .matrix-table.matrix-table--months .matrix-col-account::after {
    background: #2b3542;
    box-shadow: 8px 0 12px -8px rgba(0, 0, 0, 0.72);
  }
}

/* =====================================================================
   v1.9.4 — auditoria tipográfica e prevenção de textos fora do layout
   ===================================================================== */

:root {
  --type-xs: 0.72rem;
  --type-sm: 0.8rem;
  --type-md: 0.9rem;
  --type-lg: 1.05rem;
  --type-leading-tight: 1.18;
  --type-leading-normal: 1.4;
}

body,
button,
input,
select,
textarea {
  line-height: var(--type-leading-normal);
}

button,
input,
select,
textarea {
  min-width: 0;
}

.page-header h1,
.workspace-header h1,
.access-page-header h1,
.login-card__header h2,
.panel__header h2,
.matrix-title-block h2,
.matrix-expanded-header h2,
.supplier-payments-card h3,
.card-heading h2,
.access-card-heading h2,
.access-modal > header h2 {
  max-width: 100%;
  line-height: var(--type-leading-tight);
  overflow-wrap: break-word;
  text-wrap: balance;
}

.page-header p,
.workspace-header p,
.access-page-header p,
.login-card__header p,
.matrix-hint,
.matrix-expanded-header p,
.muted-note,
.form-message,
.form-status,
.dashboard-feedback {
  line-height: 1.45;
  overflow-wrap: break-word;
}

/* KPIs: títulos, valores e comparativos ocupam faixas previsíveis. */
.kpi-grid {
  align-items: stretch;
}

.kpi-card {
  display: grid;
  grid-template-rows: minmax(46px, auto) auto minmax(28px, auto);
  align-content: start;
  min-height: 136px;
  overflow: hidden;
}

.kpi-card__top {
  align-items: flex-start;
  min-width: 0;
  min-height: 46px;
}

.kpi-card h2 {
  display: -webkit-box;
  min-width: 0;
  max-width: 100%;
  margin-top: 2px;
  color: inherit;
  font-size: clamp(0.76rem, 0.72vw, 0.9rem);
  font-weight: 760;
  line-height: 1.08;
  letter-spacing: -0.01em;
  overflow: hidden;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.kpi-card.has-long-label h2 {
  font-size: clamp(0.71rem, 0.64vw, 0.82rem);
}

.kpi-card > strong {
  align-self: center;
  min-width: 0;
  max-width: 100%;
  margin-top: 8px;
  color: inherit;
  font-size: clamp(1.22rem, 1.45vw, 1.72rem);
  font-weight: 780;
  line-height: 1.05;
  letter-spacing: -0.035em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.kpi-card.has-long-value > strong {
  font-size: clamp(1.08rem, 1.25vw, 1.48rem);
  letter-spacing: -0.04em;
}

.kpi-card > small {
  align-self: end;
  min-width: 0;
  min-height: 2.35em;
  margin-top: 7px;
  font-size: clamp(0.58rem, 0.5vw, 0.69rem);
  font-weight: 760;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  overflow-wrap: normal;
}

.kpi-card__spacer {
  visibility: hidden;
}

.kpi-card > small.note-success {
  color: #16894a;
}

.kpi-card > small.note-danger {
  color: #c92939;
}

html[data-theme='dark'] .kpi-card > small.note-success {
  color: #69d89a;
}

html[data-theme='dark'] .kpi-card > small.note-danger {
  color: #ff8791;
}

/* Filtros e identificação do usuário. */
.filter-control,
.filter-control__content,
.user-profile,
.user-profile__text,
.data-user-identity,
.access-user-cell,
.access-profile-detail__identity {
  min-width: 0;
}

.filter-control__content small {
  font-size: clamp(0.72rem, 0.62vw, 0.82rem);
  font-weight: 760;
  line-height: 1.2;
}

.filter-control__content select {
  width: 100%;
  max-width: 100%;
  font-size: clamp(0.82rem, 0.72vw, 0.94rem);
  line-height: 1.3;
  text-overflow: ellipsis;
}

.updated-chip span:last-child {
  min-width: 0;
  font-size: clamp(0.76rem, 0.68vw, 0.9rem);
  font-weight: 650;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: break-word;
}

.user-profile__text strong,
.user-profile__text small,
.data-user-identity strong,
.data-user-identity small,
.access-user-cell strong,
.access-user-cell small {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Títulos, legendas e textos dos painéis. */
.panel__header {
  min-width: 0;
}

.panel__header > div {
  min-width: 0;
}

.panel__header h2 {
  font-size: clamp(0.98rem, 0.9vw, 1.18rem);
  font-weight: 760;
}

.panel__header small,
.matrix-hint,
.chart-legend,
.matrix-expanded-header p,
.matrix-expanded-footer,
.supplier-detail-footer {
  font-size: clamp(0.7rem, 0.58vw, 0.82rem);
}

.chart-legend {
  line-height: 1.3;
}

.insight-card strong,
.expense-label,
.expense-value {
  line-height: 1.25;
}

.insight-card small {
  line-height: 1.35;
  overflow-wrap: break-word;
}

/* Matriz DFC: legibilidade sem retirar o scroll necessário. */
.matrix-table,
.matrix-expanded-table {
  font-size: clamp(0.7rem, 0.62vw, 0.82rem);
  line-height: 1.35;
}

.matrix-table th,
.matrix-expanded-table th {
  font-weight: 780;
}

.matrix-account,
.matrix-detail-name,
.supplier-category-name {
  min-width: 0;
  line-height: 1.28;
}

.matrix-account strong,
.matrix-account > span:last-child,
.matrix-detail-name strong,
.matrix-detail-name span,
.supplier-category-name strong,
.supplier-category-name > span:last-child {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matrix-mobile-row__header,
.matrix-mobile-row__metrics,
.matrix-period-detail,
.matrix-period-detail__summary,
.matrix-period-detail__weeks {
  line-height: 1.35;
}

.supplier-category-table,
.supplier-payments-table,
.access-table,
.logs-table {
  font-size: clamp(0.72rem, 0.62vw, 0.84rem);
  line-height: 1.35;
}

.supplier-summary-heading h2,
.supplier-summary-heading strong,
.supplier-horizon-chip,
.supplier-status,
.permission-badge,
.feature-status {
  line-height: 1.25;
}

/* Configurações, perfil, permissões e modais. */
.workspace-header h1,
.access-page-header h1 {
  font-size: clamp(1.5rem, 1.55vw, 2.15rem);
  letter-spacing: -0.025em;
}

.workspace-header p,
.access-page-header p {
  font-size: clamp(0.78rem, 0.7vw, 0.92rem);
}

.card-heading h2,
.access-card-heading h2,
.system-behavior h3,
.integration-card h3,
.appearance-card h3,
.audit-card h3 {
  font-size: clamp(0.92rem, 0.82vw, 1.08rem);
  line-height: 1.25;
}

.field,
.form-grid label,
.settings-tabs,
.access-tabs,
.nav-item,
.outline-button,
.primary-action-button,
.access-create-button,
.access-export-button,
.access-back-button,
.matrix-tool-button,
.expand-button,
.matrix-close-button,
.supplier-export-button,
.supplier-close-button {
  line-height: 1.25;
}

.field,
.form-grid label {
  font-size: clamp(0.78rem, 0.7vw, 0.9rem);
}

.field small,
.form-grid small,
.muted-note,
.access-permissions-note,
.invitation-help-card p,
.audit-card p,
.appearance-card p,
.system-behavior p {
  font-size: clamp(0.72rem, 0.64vw, 0.82rem);
  line-height: 1.45;
}

button,
.nav-item,
.settings-tabs button,
.access-tabs button {
  font-weight: 650;
}

/* Tablets e desktops médios: reduz somente o necessário, sem comprimir. */
@media (min-width: 900px) and (max-width: 1599px) {
  .kpi-grid {
    gap: 10px;
  }

  .kpi-card {
    min-height: 132px;
    padding: 14px 13px 12px;
  }

  .kpi-card__top {
    gap: 8px;
  }

  .kpi-icon {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .kpi-card > strong {
    font-size: clamp(1.16rem, 1.45vw, 1.48rem);
  }

  .kpi-card.has-long-value > strong {
    font-size: clamp(1.02rem, 1.24vw, 1.3rem);
  }
}

/* Ultrawide: o texto cresce junto com o espaço, sem estourar os cards. */
@media (min-width: 2200px) {
  .kpi-card {
    min-height: 150px;
  }

  .kpi-card h2 {
    font-size: clamp(0.86rem, 0.54vw, 1rem);
  }

  .kpi-card.has-long-label h2 {
    font-size: clamp(0.8rem, 0.48vw, 0.94rem);
  }

  .kpi-card > strong {
    font-size: clamp(1.6rem, 1vw, 2rem);
  }

  .kpi-card.has-long-value > strong {
    font-size: clamp(1.42rem, 0.9vw, 1.82rem);
  }

  .kpi-card > small {
    font-size: clamp(0.68rem, 0.38vw, 0.78rem);
  }
}

/* Mobile: nenhum texto sai do card e os controles permanecem legíveis. */
@media (max-width: 899px) {
  .page-header h1,
  .workspace-header h1,
  .access-page-header h1 {
    text-wrap: wrap;
  }

  .kpi-card {
    min-height: 126px;
    padding: 13px 12px 11px;
  }

  .kpi-card h2,
  .kpi-card.has-long-label h2 {
    font-size: 0.74rem;
    -webkit-line-clamp: 3;
  }

  .kpi-card > strong,
  .kpi-card.has-long-value > strong {
    font-size: clamp(1.08rem, 4.7vw, 1.38rem);
  }

  .kpi-card > small {
    font-size: 0.62rem;
  }

  .filter-control__content small {
    font-size: 0.78rem;
  }

  .filter-control__content select,
  .field input,
  .field select,
  .form-grid input,
  .form-grid select,
  .form-grid textarea {
    font-size: 16px;
  }

  .panel__header h2 {
    font-size: 1rem;
  }

  .matrix-table,
  .matrix-expanded-table,
  .supplier-category-table,
  .supplier-payments-table,
  .access-table,
  .logs-table {
    font-size: 0.76rem;
  }
}

@media (max-width: 390px) {
  .kpi-card {
    min-height: 112px;
  }

  .kpi-card__top {
    min-height: 38px;
  }

  .kpi-card h2,
  .kpi-card.has-long-label h2 {
    font-size: 0.78rem;
  }

  .kpi-card > strong,
  .kpi-card.has-long-value > strong {
    font-size: 1.42rem;
  }
}

/* Elementos compactos que ainda estavam abaixo do limite confortável. */
.access-table th {
  font-size: clamp(0.66rem, 0.56vw, 0.76rem);
  line-height: 1.25;
}

.permission-badge,
.supplier-status,
.supplier-horizon-chip,
.feature-status {
  font-size: clamp(0.64rem, 0.54vw, 0.74rem);
}

.matrix-mobile-row__metrics dt {
  font-size: 0.65rem;
  line-height: 1.25;
}

.band-label {
  font-size: 11px;
}

.cash-chart--bands .point-label,
.point-label {
  font-size: 10.5px;
}

.month-labels text,
.bar-label {
  font-size: 10px;
}

.bar-value {
  font-size: 11px;
}

.today-text {
  font-size: 10px;
}

@media (max-width: 899px) {
  .matrix-expanded-header p,
  .supplier-horizon-chip,
  .matrix-table td:not(:first-child)::before,
  .matrix-expanded-table td:not(:first-child)::before,
  .supplier-category-table td:not(:first-child)::before,
  .supplier-payments-table td:not(:first-child)::before,
  .access-table td::before {
    font-size: 0.66rem;
    line-height: 1.3;
  }

  .permission-badge,
  .supplier-status,
  .feature-status {
    font-size: 0.68rem;
  }
}



/* v1.8.5 — detalhamento em tela ampliada para todas as expansões */
.supplier-detail-toolbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.supplier-category-table tbody tr[role="button"] {
  cursor: pointer;
}

.supplier-category-table tbody tr[role="button"]:hover {
  filter: brightness(0.985);
}

.supplier-category-table tbody tr[role="button"]:focus-visible {
  outline: 2px solid rgba(17, 120, 255, 0.45);
  outline-offset: -2px;
}

@media (max-width: 767px) {
  .supplier-detail-toolbar__actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

/* v1.8.6 — toda expansão abre exclusivamente em tela ampliada. */
.matrix-period-detail-row,
.matrix-period-detail--mobile {
  display: none !important;
}

.supplier-detail-screen {
  display: block;
  width: 100vw;
  height: 100dvh;
  min-height: 100vh;
}

/* v1.8.8 — separa o botão de hierarquia do botão de detalhamento. */
.matrix-detail-name {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.matrix-detail-name strong,
.matrix-detail-name span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matrix-detail-name:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.matrix-detail-name:focus-visible {
  border-radius: 4px;
  outline: 2px solid rgba(34, 105, 190, 0.45);
  outline-offset: 3px;
}

/* v1.9.5 — os gráficos acompanham a largura da própria caixa.
   O viewBox passa a ser recalculado em JS com a largura medida do painel
   (mesma proporção do container), então aqui basta liberar os limites de
   largura que travavam o desenho em 760/1120/1350/1480px e impediam o
   gráfico de crescer junto com o painel em telas ultrawide.
   Abaixo de 900px nada muda: segue a rolagem horizontal do mobile. */
@media (min-width: 900px) {
  .panel--cash-chart .cash-chart,
  .panel--waterfall .waterfall-chart {
    width: 100%;
    max-width: none;
    min-width: 0;
    height: auto;
    min-height: 0;
    max-height: none;
    margin-inline: 0;
    /* A proporção agora vem do viewBox calculado; um aspect-ratio fixo
       brigaria com ele e encolheria o desenho dentro do card. */
    aspect-ratio: auto;
  }

  .panel--cash-chart .chart-scroll,
  .panel--waterfall .chart-scroll {
    overflow-x: hidden;
  }
}
