.cash-tabs {
  width: fit-content;
  padding: 0.28rem;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: rgba(233, 226, 216, 0.72);
  display: flex;
  gap: 0.25rem;
}

.cash-tabs button {
  min-height: 2.6rem;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: 0.65rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
}

.cash-tabs button[aria-selected="true"] {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 3px 10px rgba(63, 42, 28, 0.1);
}

.cash-tabs button:focus-visible {
  outline: 2px solid rgba(111, 78, 55, 0.35);
  outline-offset: 1px;
}

.cash-analytics,
[data-cash-tab-panel="records"] {
  min-width: 0;
}

.cash-analytics {
  display: grid;
  gap: 1rem;
}

.cash-analytics[hidden],
[data-cash-tab-panel][hidden],
.cash-product-fields[hidden],
[data-cash-custom-size-field][hidden],
.cash-bar-chart[hidden],
.cash-line-chart[hidden],
.cash-donut-layout[hidden] {
  display: none;
}

.cash-period-bar {
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 252, 248, 0.9);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.cash-period-bar > div {
  min-width: 10.5rem;
  margin-right: auto;
  display: grid;
}

.cash-period-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cash-period-bar strong {
  margin-top: 0.1rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.cash-period-filter input,
.cash-list-filters input,
.cash-list-filters select,
.cash-form-grid select {
  width: 100%;
  min-height: 2.8rem;
  padding: 0.56rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.72rem;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.cash-period-filter input {
  min-height: 2.45rem;
}

.cash-period-filter input:focus,
.cash-list-filters input:focus,
.cash-list-filters select:focus,
.cash-form-grid select:focus {
  outline: 2px solid rgba(111, 78, 55, 0.25);
  border-color: var(--line-strong);
}

.cash-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.cash-stats article {
  min-width: 0;
  min-height: 7.5rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-top: 4px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: rgba(255, 252, 248, 0.94);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
}

.cash-stats article.is-sales {
  border-top-color: #52745c;
}

.cash-stats article.is-expenses {
  border-top-color: #a75b52;
}

.cash-stats article.is-balance.is-negative {
  border-top-color: #a75b52;
}

.cash-stats span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cash-stats strong {
  margin: auto 0 0.25rem;
  overflow-wrap: anywhere;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.5vw, 1.85rem);
  line-height: 1.05;
}

.cash-stats .is-sales strong {
  color: #365c43;
}

.cash-stats .is-expenses strong,
.cash-stats .is-balance.is-negative strong {
  color: #8f3932;
}

.cash-stats small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

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

.cash-form-panel form {
  margin-top: 1.1rem;
  display: grid;
  gap: 1rem;
}

.cash-type-switch {
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 0.78rem;
  background: var(--chip);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.25rem;
}

.cash-type-switch label {
  cursor: pointer;
}

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

.cash-type-switch span {
  min-height: 2.5rem;
  border-radius: 0.6rem;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.cash-type-switch input:checked + span {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 3px 10px rgba(63, 42, 28, 0.1);
}

.cash-type-switch input:focus-visible + span {
  outline: 2px solid rgba(111, 78, 55, 0.35);
}

.cash-form-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.7rem;
}

.cash-form-grid > .orders-field {
  grid-column: span 2;
}

.cash-field-description {
  grid-column: span 4 !important;
}

.cash-field-notes {
  grid-column: 1 / -1 !important;
}

.cash-product-fields {
  grid-column: 1 / -1;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(233, 226, 216, 0.42);
  display: grid;
  gap: 0.8rem;
}

.cash-product-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.cash-product-heading > div:first-child {
  display: grid;
}

.cash-product-heading strong {
  color: var(--primary);
  font-size: 0.85rem;
}

.cash-product-heading small {
  margin-top: 0.08rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.cash-product-kind {
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: rgba(255, 255, 255, 0.58);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.2rem;
}

.cash-product-kind label {
  cursor: pointer;
}

.cash-product-kind input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.cash-product-kind span {
  min-height: 2.15rem;
  padding: 0.35rem 0.65rem;
  border-radius: 0.52rem;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.cash-product-kind input:checked + span {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(63, 42, 28, 0.1);
}

.cash-product-kind input:focus-visible + span {
  outline: 2px solid rgba(111, 78, 55, 0.35);
}

.cash-product-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(7rem, 0.34fr);
  gap: 0.7rem;
}

.cash-product-fields.is-weight .cash-product-grid {
  grid-template-columns: minmax(0, 1fr) minmax(7rem, 0.4fr) minmax(7rem, 0.34fr);
}

.cash-custom-size-field {
  width: min(14rem, 100%);
  grid-column: 1 / -1;
}

.cash-unit-input {
  min-height: 2.8rem;
  border: 1px solid var(--line);
  border-radius: 0.72rem;
  background: #fff;
  display: flex;
  align-items: center;
}

.cash-unit-input:focus-within {
  outline: 2px solid rgba(111, 78, 55, 0.25);
  border-color: var(--line-strong);
}

.orders-field .cash-unit-input input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.cash-unit-input > span {
  padding-right: 0.75rem;
  color: var(--muted);
  font-weight: 800;
}

.orders-field small {
  font-size: inherit;
  font-weight: 500;
}

.cash-money-input {
  min-height: 2.8rem;
  border: 1px solid var(--line);
  border-radius: 0.72rem;
  background: #fff;
  display: flex;
  align-items: center;
}

.cash-money-input:focus-within {
  outline: 2px solid rgba(111, 78, 55, 0.25);
  border-color: var(--line-strong);
}

.cash-money-input > span {
  padding-left: 0.7rem;
  color: var(--muted);
}

.orders-field .cash-money-input input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-weight: 800;
}

.cash-list-panel {
  min-width: 0;
}

.cash-list-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.cash-list-filters {
  width: min(22rem, 55%);
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) minmax(9rem, auto);
  gap: 0.5rem;
}

.cash-list-filters input,
.cash-list-filters select {
  min-height: 2.55rem;
  font-size: 0.82rem;
}

.cash-list {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.6rem;
}

.cash-entry {
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-left: 4px solid #52745c;
  border-radius: var(--radius-sm);
  background: #fff;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem 1rem;
}

.cash-entry.is-expense {
  border-left-color: #a75b52;
}

.cash-entry-main {
  min-width: 0;
}

.cash-entry-meta,
.cash-entry-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.cash-insights {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.cash-insights article {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 252, 248, 0.94);
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.cash-insight-icon {
  flex: 0 0 2.65rem;
  width: 2.65rem;
  height: 2.65rem;
  border-radius: 0.8rem;
  background: var(--chip);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
}

.cash-insights article > div {
  min-width: 0;
  display: grid;
}

.cash-insights small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cash-insights strong {
  margin: 0.12rem 0;
  overflow: hidden;
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 1.1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cash-insights article > div > span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.cash-charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 1rem;
  align-items: start;
}

.cash-chart-card {
  min-width: 0;
}

.cash-product-chart-card {
  grid-row: span 2;
}

.cash-chart-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}

.cash-chart-heading h2 {
  font-size: clamp(1.15rem, 2vw, 1.45rem);
}

.cash-chart-heading > span {
  flex: 0 0 auto;
  padding: 0.28rem 0.5rem;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.cash-bar-chart {
  margin-top: 1.15rem;
  display: grid;
  gap: 0.92rem;
}

.cash-bar-row {
  display: grid;
  gap: 0.35rem;
}

.cash-bar-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  font-size: 0.78rem;
}

.cash-bar-label span {
  min-width: 0;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cash-bar-label i,
.cash-donut-legend i {
  display: inline-block;
  width: 0.58rem;
  height: 0.58rem;
  margin-right: 0.4rem;
  border-radius: 50%;
}

.cash-bar-label strong {
  color: var(--primary);
  white-space: nowrap;
}

.cash-bar-track {
  height: 0.62rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--chip);
}

.cash-bar-track span {
  height: 100%;
  border-radius: inherit;
  display: block;
}

.cash-bar-row > small {
  color: var(--muted);
  font-size: 0.68rem;
}

.cash-line-chart {
  margin-top: 0.8rem;
}

.cash-line-chart svg {
  width: 100%;
  height: auto;
  overflow: visible;
  display: block;
}

.cash-chart-grid line {
  stroke: rgba(111, 78, 55, 0.16);
  stroke-width: 1;
}

.cash-chart-grid text,
.cash-chart-labels text {
  fill: var(--muted);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
}

.cash-chart-area {
  fill: rgba(111, 78, 55, 0.11);
}

.cash-chart-line {
  fill: none;
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.cash-chart-points circle {
  fill: #fff;
  stroke: var(--primary);
  stroke-width: 3;
}

.cash-donut-layout {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  align-items: center;
  gap: 1.2rem;
}

.cash-donut {
  width: 9.5rem;
  aspect-ratio: 1;
  padding: 1.35rem;
  border-radius: 50%;
}

.cash-donut > div {
  width: 100%;
  height: 100%;
  padding: 0.4rem;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-content: center;
  text-align: center;
}

.cash-donut strong {
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 1rem;
}

.cash-donut span {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
}

.cash-donut-legend {
  min-width: 0;
  display: grid;
  gap: 0.52rem;
}

.cash-donut-legend > div {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
}

.cash-donut-legend i {
  margin: 0;
}

.cash-donut-legend span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cash-donut-legend strong {
  font-size: 0.7rem;
  white-space: nowrap;
}

.cash-donut-legend small {
  min-width: 2rem;
  color: var(--muted);
  text-align: right;
}

.cash-entry-meta span,
.cash-entry-meta time {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.cash-entry-meta span + span::before,
.cash-entry-meta time + span::before {
  margin-right: 0.35rem;
  content: "•";
  color: var(--line-strong);
}

.cash-entry h3 {
  margin-top: 0.24rem;
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.cash-entry-note {
  margin-top: 0.2rem;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 0.75rem;
}

.cash-entry-value {
  align-self: center;
  color: #365c43;
  font-family: var(--font-display);
  font-size: 1.08rem;
  white-space: nowrap;
}

.cash-entry.is-expense .cash-entry-value {
  color: #8f3932;
}

.cash-entry-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
}

.cash-backup-note {
  padding: 0.85rem 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: rgba(233, 226, 216, 0.5);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.cash-backup-note strong {
  color: var(--primary);
}

@media (max-width: 980px) {
  .cash-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .cash-product-chart-card {
    grid-row: auto;
  }
}

@media (max-width: 700px) {
  .cash-period-bar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .cash-period-bar > div {
    width: 100%;
  }

  .cash-period-filter {
    flex: 1 1 11rem;
  }

  .cash-list-heading {
    flex-direction: column;
  }

  .cash-list-filters {
    width: 100%;
  }

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

  .cash-form-grid > .orders-field {
    grid-column: span 1;
  }

  .cash-field-description {
    grid-column: span 1 !important;
  }

  .cash-field-amount,
  .cash-field-notes,
  .cash-product-fields {
    grid-column: 1 / -1 !important;
  }

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

@media (max-width: 520px) {
  .cash-stats,
  .cash-form-grid,
  .cash-list-filters {
    grid-template-columns: 1fr;
  }

  .cash-field-description,
  .cash-field-notes {
    grid-column: auto !important;
  }

  .cash-product-fields {
    grid-column: auto !important;
  }

  .cash-product-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .cash-product-grid,
  .cash-product-fields.is-weight .cash-product-grid {
    grid-template-columns: 1fr;
  }

  .cash-entry {
    grid-template-columns: 1fr;
  }

  .cash-entry-value {
    justify-self: start;
  }

  .cash-donut-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .cash-donut-legend {
    width: 100%;
  }
}
