/* Dashboard based on the financial overview layout */
.dashboard-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-summary .metric {
  min-height: 116px;
}

.dashboard-reference-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.dashboard-reference-grid > .panel {
  grid-column: span 4;
}

.dashboard-reference-grid > .dashboard-cashflow-panel,
.dashboard-reference-grid > .dashboard-movements-panel {
  grid-column: span 8;
}

.dashboard-panel-heading {
  align-items: end;
}

.dashboard-period-controls {
  display: flex;
  align-items: end;
  gap: 8px;
}

.dashboard-period-controls label {
  min-width: 145px;
}

.dashboard-period-controls input {
  min-height: 36px;
  padding-inline: 9px;
  font-size: 0.78rem;
}

.cashflow-summary-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 40px;
  margin-bottom: 4px;
}

.cashflow-summary-line > div:last-child {
  display: grid;
  gap: 2px;
  text-align: right;
}

.cashflow-summary-line > div:last-child span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.cashflow-summary-line strong {
  font-size: 1.05rem;
}

.cashflow-legend {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.cashflow-legend span::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 2px;
  background: var(--green);
}

.cashflow-legend .expense::before {
  background: var(--red);
}

.dashboard-cashflow-panel .cashflow-chart {
  grid-template-columns: repeat(var(--cashflow-months, 6), minmax(44px, 1fr));
  min-width: calc(var(--cashflow-months, 6) * 54px);
  overflow: visible;
}

.dashboard-cashflow-panel {
  overflow-x: auto;
}

.dashboard-allocation-layout {
  grid-template-columns: 150px minmax(0, 1fr);
}

.dashboard-allocation-layout .allocation-chart {
  width: 150px;
  box-shadow: inset 0 0 0 24px var(--surface);
}

.dashboard-allocation-layout .allocation-chart span {
  width: 96px;
  font-size: 0.78rem;
}

.dashboard-allocation-layout .allocation-legend {
  max-height: 230px;
  overflow-y: auto;
}

.dashboard-allocation-layout.empty {
  grid-template-columns: 1fr;
}

.dashboard-allocation-layout.empty .allocation-chart {
  justify-self: center;
}

.dashboard-allocation-layout .allocation-row {
  min-height: 36px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 7px 2px;
}

.dashboard-movements-table {
  min-width: 700px;
}

.dashboard-movements-table td:first-child,
.dashboard-movements-table th:first-child {
  width: 105px;
}

.dashboard-movements-table td:nth-child(4) {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-portfolio-list {
  display: grid;
}

.portfolio-overview-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 7px 0;
  text-align: left;
}

.portfolio-overview-row:last-child {
  border-bottom: 0;
}

.portfolio-overview-row > span:not(.portfolio-symbol) {
  display: grid;
  gap: 2px;
}

.portfolio-overview-row > span:last-child {
  text-align: right;
}

.portfolio-overview-row small {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
}

.portfolio-symbol {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--green);
  font-size: 0.62rem;
  font-weight: 950;
}

.reports-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 16px;
}

.report-builder,
.report-info-panel {
  display: grid;
  align-content: start;
  gap: 16px;
}

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

.report-actions .primary-button {
  width: 100%;
}

.report-feature-list {
  display: grid;
}

.report-feature-list > div {
  display: grid;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.report-feature-list > div:last-child {
  border-bottom: 0;
}

.report-feature-list span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

@media (max-width: 1100px) {
  .dashboard-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-reference-grid > .panel,
  .dashboard-reference-grid > .dashboard-cashflow-panel,
  .dashboard-reference-grid > .dashboard-movements-panel {
    grid-column: span 12;
  }
}

@media (max-width: 760px) {
  .dashboard-panel-heading,
  .cashflow-summary-line {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-period-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-period-controls label {
    min-width: 0;
  }

  .cashflow-summary-line > div:last-child {
    text-align: left;
  }

  .reports-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .dashboard-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-summary .metric:first-child {
    grid-column: auto;
  }

  .dashboard-summary .metric {
    min-height: 100px;
    padding: 13px;
  }

  .dashboard-allocation-layout,
  .dashboard-period-controls,
  .report-actions {
    grid-template-columns: 1fr;
  }

  .dashboard-allocation-layout .allocation-chart {
    justify-self: center;
  }
}

/* 2026 dashboard shell */
body {
  background: var(--bg);
}

.page-heading {
  display: grid;
  gap: 5px;
}

.page-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
  text-transform: capitalize;
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  box-shadow: 0 0 0 1px var(--line);
  font-size: 0.88rem;
  font-weight: 900;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 30px;
  padding: 4px 6px;
  color: #f8fbfa;
}

.sidebar-brand > span:last-child {
  display: grid;
  gap: 2px;
}

.sidebar-brand strong {
  font-size: 0.96rem;
}

.sidebar-brand small {
  color: #aab8b5;
  font-size: 0.72rem;
  font-weight: 650;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 8px;
  background: #24b47e;
  color: #10261f;
  font-size: 0.78rem;
  font-weight: 950;
}

.sidebar-nav-label {
  margin: 0 8px 8px;
  color: #748580;
  font-size: 0.66rem;
  font-weight: 850;
  text-transform: uppercase;
}

.app-nav-button::before {
  content: attr(data-nav-icon);
  display: grid;
  place-items: center;
  width: 24px;
  flex: 0 0 24px;
  color: currentColor;
  font-size: 1.1rem;
}

.metric,
.panel {
  box-shadow: 0 3px 12px rgba(32, 50, 44, 0.055);
}

.metric {
  border-top: 3px solid var(--line);
}

.metric.accounts,
.simulator-primary {
  border-top-color: var(--blue);
}

.metric.income,
.metric.annual,
.metric.total {
  border-top-color: var(--green);
}

.metric.expense {
  border-top-color: #e07b39;
}

table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.simulator-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.7fr) minmax(0, 1.3fr);
  align-items: start;
  gap: 16px;
}

.simulator-controls,
.simulator-results {
  display: grid;
  gap: 16px;
}

.simulator-field {
  display: grid;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.simulator-field:last-of-type {
  border-bottom: 0;
  padding-bottom: 0;
}

.range-heading,
.range-scale,
.simulator-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.range-heading label {
  color: var(--ink);
}

.range-heading output {
  min-width: 86px;
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 900;
  text-align: right;
}

.range-scale {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.simulator-field input[type="range"] {
  min-height: 22px;
  border: 0;
  background: transparent;
  padding: 0;
  accent-color: var(--green);
  box-shadow: none;
}

.currency-input {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
}

.currency-input span {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 7px 0 0 7px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 900;
}

.currency-input input {
  border-radius: 0 7px 7px 0;
}

.simulator-note {
  margin: 0;
  border-left: 3px solid var(--gold);
  background: var(--gold-soft);
  color: var(--muted);
  padding: 11px 12px;
  font-size: 0.76rem;
  line-height: 1.5;
}

.simulator-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.simulator-kpis .metric {
  min-height: 98px;
  padding: 14px;
}

.simulator-kpis .metric strong {
  font-size: 1.28rem;
}

.simulator-chart-panel canvas {
  display: block;
  width: 100%;
  height: 280px;
}

.simulator-legend {
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.simulator-legend span::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 2px;
  background: var(--blue);
}

.simulator-legend .growth::before {
  background: var(--green);
}

@media (min-width: 921px) {
  .app-shell {
    width: 100%;
    margin: 0;
    padding: 24px 28px 48px 276px;
  }

  .topbar {
    align-items: center;
    min-height: 58px;
    margin-bottom: 18px;
  }

  .topbar h1 {
    font-size: 1.62rem;
  }

  main {
    display: block;
  }

  .app-nav {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    width: 248px;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    margin: 0;
    overflow: hidden auto;
    border: 0;
    border-radius: 0;
    background: #17231f;
    padding: 22px 14px;
    box-shadow: 8px 0 24px rgba(16, 28, 24, 0.11);
    backdrop-filter: none;
  }

  .app-nav-button {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    justify-content: flex-start;
    border-left: 3px solid transparent;
    border-radius: 6px;
    color: #adbbb6;
    padding: 0 11px;
    text-align: left;
  }

  .app-nav-button:hover {
    background: rgba(255, 255, 255, 0.055);
    color: #ffffff;
  }

  .app-nav-button.active {
    border-left-color: #37c48d;
    background: #2b3a35;
    color: #ffffff;
  }

  .control-band,
  .view-section {
    width: 100%;
  }

  .control-band {
    background: var(--surface);
    box-shadow: 0 3px 12px rgba(32, 50, 44, 0.045);
  }

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

  .dashboard-grid > .panel {
    grid-column: span 4;
  }

  .dashboard-grid > .cashflow-panel,
  .dashboard-grid > .panel:nth-child(3) {
    grid-column: span 8;
  }
}

@media (max-width: 1100px) and (min-width: 921px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-grid > .panel,
  .dashboard-grid > .cashflow-panel,
  .dashboard-grid > .panel:nth-child(3) {
    grid-column: span 6;
  }

  .simulator-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .sidebar-brand,
  .sidebar-nav-label {
    display: none;
  }

  .app-nav-button {
    display: inline-flex;
    align-items: center;
  }

  .simulator-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-heading p,
  .user-pill,
  .app-nav-button::before {
    display: none;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .topbar-actions .global-search-shell {
    order: 10;
    flex: 1 0 100%;
    width: 100%;
  }

  .topbar-actions .global-search-shell input {
    width: 100%;
  }

  .app-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    overflow: visible;
    padding: 5px;
  }

  .app-nav > .app-nav-button {
    display: none;
  }

  .app-nav > [data-app-view-tab="dashboard"],
  .app-nav > [data-app-view-tab="banks"],
  .app-nav > [data-app-view-tab="movements"],
  .app-nav > [data-app-view-tab="investments"],
  .app-nav > .mobile-more-nav {
    display: flex;
    min-width: 0;
    min-height: 56px;
    align-items: center;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    overflow: hidden;
    padding: 4px 2px;
    font-size: 0.64rem;
    text-overflow: ellipsis;
  }

  .app-nav > .app-nav-button::before {
    display: block;
    margin: 0;
    content: attr(data-nav-icon);
    font-size: 1rem;
    line-height: 1;
  }

  .mobile-card-table,
  .mobile-card-table tbody {
    display: grid;
    width: 100%;
    min-width: 0 !important;
    gap: 10px;
  }

  .table-wrap:has(.mobile-card-table) {
    overflow: visible;
    border: 0;
  }

  .mobile-card-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .mobile-card-table tbody tr {
    display: grid;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    padding: 5px 12px;
  }

  .mobile-card-table tbody td {
    display: grid;
    grid-template-columns: minmax(88px, 0.42fr) minmax(0, 0.58fr);
    align-items: start;
    gap: 10px;
    min-height: 38px;
    border-bottom: 1px solid var(--line);
    padding: 9px 0;
    text-align: left !important;
    overflow-wrap: anywhere;
  }

  .mobile-card-table tbody td::before {
    content: attr(data-mobile-label);
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 850;
    text-transform: uppercase;
  }

  .mobile-card-table tbody td:last-child {
    border-bottom: 0;
  }

  .mobile-card-table .row-actions {
    justify-content: flex-start;
  }

  .mobile-card-table .mobile-empty-row {
    display: block;
  }

  .mobile-card-table .mobile-empty-row td {
    display: block;
    border: 0;
  }

  .mobile-card-table .mobile-empty-row td::before {
    display: none;
  }

  .topbar-actions .language-inline {
    flex: 0 0 auto;
    min-height: 42px;
    padding: 0 8px;
  }

  .topbar-actions .language-inline > span {
    display: none;
  }

  .topbar-actions .language-inline select {
    width: 54px;
    min-width: 54px;
  }

  .topbar-actions .ghost-button,
  .topbar-actions .user-avatar {
    flex: 0 0 42px;
  }

  #logoutButton {
    width: 42px;
    padding: 0;
  }

  #logoutButton::before {
    content: "↪";
    font-size: 1.1rem;
  }

  #logoutButton span {
    display: none;
  }

  .simulator-kpis {
    grid-template-columns: 1fr;
  }

  .simulator-chart-panel {
    padding: 14px 10px;
  }

  .simulator-chart-panel .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .ledger-filters .search-field,
  .ledger-filters > label:last-child {
    grid-column: 1 / -1;
  }
}
