.expenses-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.expenses-tab,
.expenses-mode-tabs button {
  height: 36px;
  padding: 0 14px;
  border: 1px solid #cfe1df;
  border-radius: 8px;
  background: #fff;
  color: #004d4a;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
}

.expenses-tab.active,
.expenses-mode-tabs button.active {
  border-color: rgb(0, 128, 123);
  background: rgb(0, 128, 123);
  color: #fff;
}

.expenses-grid {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.expenses-filter-card,
.expenses-main-card {
  min-width: 0;
  border: 1px solid #d8e6e4;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.06);
}

.expenses-filter-card {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.expenses-filter-card label,
.expenses-inline-filters label,
.expenses-form label {
  display: grid;
  gap: 5px;
  color: #5d6975;
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.28px;
}

.expenses-filter-card input,
.expenses-filter-card select,
.expenses-inline-filters input,
.expenses-inline-filters select,
.expenses-form input {
  width: 100%;
  min-width: 0;
  height: 34px;
  border: 1px solid #d6dde3;
  border-radius: 7px;
  background: #fff;
  color: #212529;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-transform: none;
  letter-spacing: 0;
}

.expenses-filter-card input,
.expenses-inline-filters input,
.expenses-form input {
  padding: 0 10px;
}

.expenses-filter-card select,
.expenses-inline-filters select {
  padding: 0 8px;
}

.expenses-primary-soft,
.expenses-secondary-btn,
.expenses-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #b8dad6;
  border-radius: 8px;
  background: #e9f8f6;
  color: #004d4a;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 950;
}

.expenses-primary-soft,
.expenses-secondary-btn {
  height: 36px;
  padding: 0 12px;
}

.expenses-secondary-btn {
  background: #fff;
}

.expenses-icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
}

.expenses-main-card {
  padding: 12px;
}

.expenses-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.expenses-metric {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 3px 8px;
  align-items: center;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #d8e6e4;
  border-radius: 8px;
  background: #f7fbfb;
}

.expenses-metric i {
  grid-row: span 2;
  color: rgb(0, 128, 123);
  font-size: 17px;
}

.expenses-metric strong {
  min-width: 0;
  color: #111827;
  font-size: 19px;
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expenses-metric span {
  color: #6c757d;
  font-size: 11px;
  font-weight: 850;
}

.expenses-metric-pair strong {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.expenses-metric-pair strong b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expenses-metric-pair strong small {
  flex: 0 0 auto;
  color: #007f78;
  font-size: 12px;
  font-weight: 950;
  line-height: 1;
}

.expenses-metric.good {
  border-color: #badbcc;
  background: #f0fff6;
}

.expenses-metric.danger {
  border-color: #f1aeb5;
  background: #fff5f5;
}

.expenses-inline-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.expenses-inline-filters .wide {
  min-width: 220px;
}

.expenses-table-wrap {
  max-height: calc(100vh - 300px);
  min-height: 280px;
  overflow: auto;
  border: 1px solid #edf2f1;
  border-radius: 8px;
  background: #fff;
}

.expenses-table-wrap.cashflow {
  max-height: calc(100vh - 310px);
}

.expenses-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.expenses-cash-table {
  min-width: 1400px;
}

.expenses-cash-compare-table {
  min-width: 1500px;
}

.expenses-cash-comparison {
  margin-top: 14px;
}

.expenses-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 0 8px;
}

.expenses-section-head h3 {
  margin: 0;
  color: #004d4a;
  font-size: 15px;
  font-weight: 950;
}

.expenses-section-head span {
  color: #6c757d;
  font-size: 11px;
  font-weight: 850;
}

.expenses-table th.cashflow-divider,
.expenses-table td.cashflow-divider {
  border-left: 2px solid #99cfca;
}

.expenses-cash-compare-table .cashflow-metric-head {
  background: #007f78;
  color: #fff;
  text-align: center;
  border-left: 1px solid #99cfca;
}

.expenses-cash-compare-table th,
.expenses-cash-compare-table td {
  padding: 7px 8px;
  text-align: right;
}

.expenses-cash-compare-table .cashflow-sticky-period {
  text-align: left;
}

.expenses-cash-compare-table .cashflow-compare-divider {
  border-left: 2px solid #99cfca;
}

.cashflow-ranked-value {
  display: inline-block;
  min-width: 0;
  color: #111827;
  font-weight: 950;
}

.cashflow-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15px;
  height: 14px;
  margin-left: 3px;
  padding: 0 3px;
  border: 1px solid #b8dad6;
  border-radius: 999px;
  background: #e9f8f6;
  color: #004d4a;
  font-size: 9px;
  font-weight: 950;
  line-height: 1;
  vertical-align: middle;
}

.expenses-cash-compare-table thead tr:nth-child(2) th {
  top: 37px;
  background: #e9f8f6;
  color: #004d4a;
  text-align: center;
}

.expenses-cash-compare-table .cashflow-sticky-period {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #f3f8f7;
}

.expenses-cash-compare-table td.cashflow-sticky-period {
  background: #fff;
}

.expenses-cash-table tr.current-period td,
.expenses-cash-compare-table tr.current-period td {
  background: #fff8df;
  box-shadow: inset 0 1px 0 #ffe69c, inset 0 -1px 0 #ffe69c;
}

.expenses-cash-compare-table tr.current-period td.cashflow-sticky-period {
  background: #fff8df;
}

.expenses-table th,
.expenses-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #edf2f1;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.expenses-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f3f8f7;
  color: #495057;
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.32px;
}

.expenses-table td {
  color: #212529;
  font-weight: 800;
}

.expenses-table td span {
  display: block;
  margin-top: 2px;
  color: #6c757d;
  font-size: 10px;
  font-weight: 800;
  white-space: normal;
}

.expenses-table tr:hover td {
  background: #fbfefe;
}

.expenses-table tr.totals td {
  position: sticky;
  top: 31px;
  z-index: 1;
  background: #e9f8f6;
  color: #004d4a;
  font-weight: 950;
}

.expenses-cash-compare-table tr.totals td {
  top: 62px;
}

.expenses-cash-compare-table th.cashflow-sticky-period,
.expenses-cash-compare-table td.cashflow-sticky-period {
  z-index: 4;
}

.expenses-empty {
  padding: 30px 12px !important;
  color: #6c757d !important;
  text-align: center !important;
}

.expenses-mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.expenses-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.expenses-fuel-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 12px;
}

.expenses-fuel-chart {
  min-width: 0;
  padding: 12px;
  border: 1px solid #d8e6e4;
  border-radius: 8px;
  background: #fbfefe;
}

.expenses-fuel-chart > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.expenses-fuel-chart strong {
  color: #004d4a;
  font-size: 13px;
  font-weight: 950;
}

.expenses-fuel-chart span {
  color: #6c757d;
  font-size: 11px;
  font-weight: 850;
}

.expenses-fuel-chart svg {
  display: block;
  width: 100%;
  height: 140px;
}

.expenses-fuel-chart line {
  stroke: #d8e6e4;
  stroke-width: 2;
}

.expenses-fuel-chart polyline {
  fill: none;
  stroke: #00807b;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.expenses-fuel-chart circle {
  fill: #00807b;
  stroke: #fff;
  stroke-width: 2;
}

.expenses-fuel-card,
.expenses-empty-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid #d8e6e4;
  border-radius: 8px;
  background: #fbfefe;
}

@media (max-width: 900px) {
  .expenses-fuel-chart-grid {
    grid-template-columns: 1fr;
  }
}

.expenses-fuel-card div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.expenses-fuel-card strong {
  color: #004d4a;
  font-size: 16px;
  font-weight: 950;
}

.expenses-fuel-card span,
.expenses-fuel-card small {
  color: #6c757d;
  font-size: 11px;
  font-weight: 800;
}

.expenses-fuel-card p {
  margin: 8px 0 7px;
  color: #111827;
  font-size: 24px;
  font-weight: 950;
}

.expenses-mini-bar {
  display: block;
  height: 7px;
  margin-bottom: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9ecef;
}

.expenses-mini-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: rgb(0, 128, 123);
}

.expenses-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(17, 24, 39, 0.42);
}

.expenses-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(780px, 96vw);
  max-height: 90vh;
  overflow: hidden;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 22px 70px rgba(17, 24, 39, 0.32);
}

.expenses-modal header,
.expenses-modal footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: #f7fbfb;
}

.expenses-modal header {
  border-bottom: 1px solid #dceae8;
}

.expenses-modal footer {
  border-top: 1px solid #dceae8;
  justify-content: flex-end;
}

.expenses-modal h2 {
  margin: 0;
  color: #111827;
  font-size: 17px;
  font-weight: 950;
}

.expenses-modal header button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid #cfd9df;
  border-radius: 8px;
  background: #fff;
  color: #495057;
  cursor: pointer;
}

.expenses-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  min-height: 0;
  padding: 14px;
  overflow: auto;
}

@media (max-width: 980px) {
  .expenses-grid {
    grid-template-columns: 1fr;
  }

  .expenses-filter-card,
  .expenses-inline-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

@media (max-width: 640px) {
  .expenses-tabs,
  .expenses-mode-tabs {
    overflow-x: auto;
  }

  .expenses-filter-card,
  .expenses-inline-filters,
  .expenses-summary-grid,
  .expenses-form {
    grid-template-columns: 1fr;
  }

  .expenses-table-wrap {
    max-height: 62vh;
  }
}
