:root {
  --chrome-bg: #f6f9fe;
  --chrome-surface: rgba(255, 255, 255, 0.88);
  --chrome-elevated: rgba(255, 255, 255, 0.96);
  --chrome-border: #c7d5e4;
  --chrome-border-strong: #9db4d4;
  --chrome-shell-start: #f8fbff;
  --chrome-shell-end: #eef4ff;
  --chrome-hero-start: rgba(255, 255, 255, 0.98);
  --chrome-hero-end: rgba(240, 246, 255, 0.96);
  --chrome-accent-soft: #dbe7fb;
  --chrome-shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.06);
  --chrome-shadow-md: 0 18px 42px rgba(15, 23, 42, 0.1);
  --chrome-shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.14);
  --chrome-radius-lg: 28px;
  --chrome-radius-md: 20px;
  --chrome-radius-sm: 14px;
}

body {
  background: linear-gradient(180deg, #edf3ff 0%, var(--chrome-bg) 24%, #f5f8fd 100%);
}

.app-shell {
  width: min(100%, calc(100vw - 24px));
  max-width: 100%;
  margin: 0;
  padding: 10px 12px 24px;
}

.app-content {
  display: grid;
  gap: 12px;
  min-width: 0;
}

main {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.hero,
.panel,
.status-card,
.kpi-card {
  border-color: var(--chrome-border);
  box-shadow: var(--chrome-shadow-sm);
}

.panel {
  padding: 22px;
}

/* theme.css es carrega després de styles.css i repeteix aquest padding amb la
   mateixa especificitat, així que la regla de bleed de la matriu anual també
   s'ha de reafirmar aquí o queda sobreescrita. */
.expense-matrix-panel {
  padding-left: 0;
  padding-right: 0;
}

.panel-header {
  align-items: flex-start;
}

.date-shift-button {
  min-width: 140px;
  border-radius: 14px;
}

.date-shift-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.monthly-summary-header {
  gap: 18px;
}

.panel-date-navigation,
.date-navigation-row {
  margin-left: auto;
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.date-current-button {
  border-color: #b7cdee;
  background: #f4f8ff;
  color: #1f4e8c;
}

.panel-header h2,
.monthly-summary-members h3 {
  letter-spacing: -0.02em;
}

.hero {
  position: relative;
  display: block;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--chrome-border);
  border-radius: 24px;
  background: linear-gradient(135deg, var(--chrome-hero-start) 0%, var(--chrome-hero-end) 100%);
  box-shadow: var(--chrome-shadow-sm);
  backdrop-filter: blur(12px);
}

.hero::before {
  content: '';
  position: absolute;
  inset: -24px auto auto -24px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(26, 115, 232, 0.14) 0%, rgba(26, 115, 232, 0) 72%);
  pointer-events: none;
}

.hero-copy {
  max-width: none;
  width: 100%;
  min-width: 0;
  position: relative;
  z-index: 1;
  padding: 16px 22px 18px;
  background: transparent;
}

.hero h1 {
  margin-bottom: 6px;
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  line-height: 1.05;
}

.hero .eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--chrome-accent-soft);
  color: #264f8a;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.subtitle {
  max-width: none;
  line-height: 1.5;
  margin-bottom: 0;
  font-size: 0.96rem;
}

.button,
select,
input,
textarea {
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
}

.button:hover,
.menu-button:hover,
.sidebar-toggle:hover {
  transform: translateY(-1px);
}

.button:focus-visible,
.menu-button:focus-visible,
.sidebar-toggle:focus-visible,
summary:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

select,
input,
textarea {
  border-color: var(--chrome-border);
  background: rgba(255, 255, 255, 0.96);
  min-width: 0;
  font-size: max(16px, 1rem);
}

select:hover,
input:hover {
  border-color: var(--chrome-border-strong);
}

.inline-filters {
  gap: 12px;
}

.inline-filters select {
  min-width: 180px;
  min-height: 44px;
  border-radius: 16px;
}

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

#heroEyebrow,
#filtersSummaryText {
  display: none !important;
}

#filtersPanel.filters-sidebar {
  position: relative;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  z-index: 40;
  display: grid;
  gap: 10px;
}

#filtersPanel.filters-sidebar > .filters-summary {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
}

#filtersPanel .filters-search-shell {
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 0 12px 0 18px;
  border: 1px solid rgba(183, 203, 230, 0.95);
  border-radius: 28px;
  background: linear-gradient(180deg, var(--chrome-shell-start) 0%, var(--chrome-shell-end) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92), 0 8px 24px rgba(123, 152, 191, 0.12);
  cursor: text;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

#filtersPanel:hover .filters-search-shell,
#filtersPanel:focus-within .filters-search-shell,
#filtersPanel[open] .filters-search-shell {
  border-color: var(--chrome-border-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.96), 0 12px 28px rgba(123, 152, 191, 0.16);
}

#filtersPanel .filters-search-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  min-width: 28px;
  height: 28px;
  color: #6e87a5;
  line-height: 1;
  transform: translateY(1px);
}

#filtersPanel .filters-search-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

#filtersPanel .filters-search-copy {
  position: relative;
  min-width: 0;
  display: grid;
  min-height: 100%;
  align-content: center;
  gap: 0;
}

#filtersPanel .filters-search-input {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #19314e;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

#filtersPanel .filters-search-input::placeholder {
  color: #6782a3;
  font-weight: 500;
}

#filtersPanel .filters-search-input:focus {
  outline: none;
}

#filtersPanel .filters-drawer-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(183, 203, 230, 0.9);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(245, 249, 255, 0.98) 0%, rgba(232, 240, 254, 0.96) 100%);
  color: #587495;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.94),
    0 4px 14px rgba(123, 152, 191, 0.08);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

#filtersPanel .filters-drawer-button:hover {
  border-color: #a8c1e3;
  background: linear-gradient(180deg, rgba(250, 252, 255, 1) 0%, rgba(238, 244, 255, 0.98) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    0 8px 20px rgba(123, 152, 191, 0.14);
}

#filtersPanel .filters-drawer-button:focus-visible {
  outline: 0;
  border-color: #9bb8df;
  box-shadow: 0 0 0 3px rgba(155, 184, 223, 0.28);
}

#filtersPanel .filters-drawer-button-icon {
  display: grid;
  gap: 4px;
  width: 18px;
}

#filtersPanel .filters-drawer-button-icon span {
  position: relative;
  display: block;
  height: 2px;
  border-radius: 999px;
  background: rgba(88, 116, 149, 0.48);
}

#filtersPanel .filters-drawer-button-icon span::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  transform: translateY(-50%);
}

#filtersPanel .filters-drawer-button-icon span:nth-child(1)::after {
  left: 0;
}

#filtersPanel .filters-drawer-button-icon span:nth-child(2)::after {
  left: 50%;
  transform: translate(-50%, -50%);
}

#filtersPanel .filters-drawer-button-icon span:nth-child(3)::after {
  right: 0;
}

#filtersPanel .filters-summary-text {
  display: block;
  color: #60758f;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#filtersPanel .active-filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#filtersPanel .active-filter-tags[hidden] {
  display: none;
}

#filtersPanel .active-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid #c9d9ef;
  border-radius: 999px;
  background: #f5f9ff;
  color: #24466f;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
}

#filtersPanel .active-filter-tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(36, 70, 111, 0.08);
  line-height: 1;
}

#filtersPanel .search-suggestions {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  right: 0;
  z-index: 60;
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--chrome-border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(14px);
}

#filtersPanel .search-suggestions[hidden] {
  display: none;
}

#filtersPanel .search-suggestion {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: #f8fbff;
  color: #19314e;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}

#filtersPanel .search-suggestion:hover,
#filtersPanel .search-suggestion.is-active {
  border-color: #bfd2eb;
  background: #eef5ff;
}

#filtersPanel .search-suggestion-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

#filtersPanel .search-suggestion-meta {
  flex: none;
  color: #6782a3;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

#filtersPanel .filters-body {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: min(760px, 100%);
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--chrome-border);
  border-radius: 24px;
  background: var(--chrome-elevated);
  backdrop-filter: blur(14px);
  box-shadow: var(--chrome-shadow-lg);
}

#filtersPanel:not([open]) .filters-body {
  display: none;
}

#filtersPanel .filters-helper-text {
  display: none;
}

#filtersPanel .date-filter-panel {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #d8e4f2;
  border-radius: 18px;
  background: linear-gradient(180deg, #fbfdff 0%, #f4f8ff 100%);
}

#filtersPanel .date-filter-head h3 {
  margin: 0 0 4px;
  font-size: 0.96rem;
  letter-spacing: -0.02em;
  color: #1d3552;
}

#filtersPanel .date-filter-head p {
  margin: 0;
  color: #63758d;
  font-size: 0.88rem;
  line-height: 1.35;
}

#filtersPanel .date-preset-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#filtersPanel .date-preset-button {
  padding: 8px 12px;
  border: 1px solid #d2deef;
  border-radius: 999px;
  background: #ffffff;
  color: #35506e;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: none;
}

#filtersPanel .date-preset-button:hover {
  border-color: #adc4e1;
  background: #f5f9ff;
}

#filtersPanel .date-preset-button.active {
  border-color: #8db0dd;
  background: #eaf2ff;
  color: #1f4e8c;
}

#filtersPanel .date-custom-range {
  display: block;
}

#filtersPanel .date-range-summary-row {
  display: grid;
  gap: 10px;
  justify-items: center;
}

#filtersPanel .date-range-label {
  min-width: 0;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: #29496c;
}

#filtersPanel .filters-section {
  display: grid;
  gap: 10px;
}

#filtersPanel .filters-section-head h3 {
  margin: 0 0 4px;
  font-size: 0.96rem;
  letter-spacing: -0.02em;
  color: #1d3552;
}

#filtersPanel .filters-section-head p {
  margin: 0;
  color: #63758d;
  font-size: 0.88rem;
  line-height: 1.35;
}

#filtersPanel .date-custom-range[hidden] {
  display: none;
}

#filtersPanel .date-custom-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid #dbe5f2;
  border-radius: 18px;
  background: linear-gradient(180deg, #f9fbff 0%, #f3f7ff 100%);
}

#filtersPanel .date-custom-card-copy {
  display: grid;
  gap: 4px;
}

#filtersPanel .date-custom-card-copy strong {
  color: #1d3552;
  font-size: 0.94rem;
}

#filtersPanel .date-custom-card-copy p {
  margin: 0;
  color: #63758d;
  font-size: 0.84rem;
  line-height: 1.35;
}

#filtersPanel .date-month-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid #c8d7ea;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

#filtersPanel .date-month-field:focus-within {
  border-color: #8db0dd;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

#filtersPanel .date-month-icon {
  font-size: 1rem;
  line-height: 1;
}

#filtersPanel .date-month-field input {
  width: 9.5rem;
  min-height: 40px;
  border: 0;
  padding: 0;
  background: transparent;
  color: #1d3552;
  font-size: max(16px, 1rem);
  font-weight: 700;
  box-shadow: none;
}

#filtersPanel .date-month-field input:focus {
  outline: none;
}

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

#filtersPanel .filters-grid label {
  gap: 6px;
}

#filtersPanel .filter-choice-field {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 12px 13px;
  border: 1px solid #d8e4f2;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

#filtersPanel .filters-grid label > span {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #5f728b;
}

#filtersPanel .filter-choice-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#filtersPanel .filter-choice-summary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #24466f;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}

#filtersPanel .filter-choice-summary-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

#filtersPanel .filter-choice-summary-copy strong {
  min-width: 0;
  font-size: 0.98rem;
  color: #24466f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#filtersPanel .filter-choice-summary-copy small {
  color: #70839c;
  font-size: 0.76rem;
  font-weight: 600;
}

#filtersPanel .filter-choice-summary-side {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#filtersPanel .filter-choice-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #edf4ff;
  color: #31567f;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

#filtersPanel .filter-choice-summary.active .filter-choice-summary-icon {
  transform: rotate(180deg);
}

#filtersPanel .filter-choice-summary-icon {
  flex: none;
  color: #6c84a1;
  transition: transform 160ms ease;
}

#filtersPanel .filter-choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 164px;
  overflow: auto;
  padding-top: 4px;
  border-top: 1px solid rgba(216, 228, 242, 0.9);
}

#filtersPanel .filter-choice-group[hidden] {
  display: none;
}

#filtersPanel .filter-choice-button {
  padding: 7px 10px;
  border: 1px solid #d2deef;
  border-radius: 999px;
  background: #ffffff;
  color: #35506e;
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: none;
}

#filtersPanel .filter-choice-button:hover {
  border-color: #adc4e1;
  background: #f5f9ff;
}

#filtersPanel .filter-choice-button.active {
  border-color: #8db0dd;
  background: #eaf2ff;
  color: #1f4e8c;
}

#filtersPanel .filters-footer {
  display: flex;
  justify-content: flex-end;
}

#filtersPanel #resetFiltersButton {
  min-width: 160px;
  border-radius: 14px;
  background: #fff5f5;
  border-color: #f4c4c4;
  color: #c24141;
}

.monthly-flow-strip,
.member-grid,
.grid.two-columns,
.kpi-grid {
  gap: 16px;
}

.saving-summary-panel {
  padding: 16px 18px;
}

.saving-summary-panel .kpi-label,
.saving-summary-panel .kpi-value,
.saving-summary-panel .kpi-meta,
.saving-summary-panel .saving-member-chip-head h3,
.saving-summary-panel .saving-member-chip-badge,
.saving-summary-panel .saving-member-chip-amount,
.saving-summary-panel .saving-member-chip-meta {
  color: var(--text);
}

.saving-summary-panel .kpi-meta,
.saving-summary-panel .saving-member-chip-meta {
  color: var(--muted);
}

.saving-summary-panel .kpi-meta.positive,
.saving-summary-panel .kpi-meta.negative {
  color: var(--text);
}

.saving-summary-panel .kpi-meta.favorable {
  color: var(--success);
}

.saving-summary-panel .panel-header {
  margin-bottom: 14px;
}

.saving-trend-panel {
  margin-top: 20px;
}

.saving-pie-grid {
  align-items: start;
}

.saving-sources-products-grid {
  align-items: start;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
}

.saving-sources-products-grid > .panel {
  display: flex;
  flex-direction: column;
}

.saving-summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.saving-summary-grid .kpi-card {
  padding: 14px 15px;
  border-radius: 16px;
  box-shadow: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, #f8fafc 100%);
}

.saving-summary-grid .kpi-label {
  font-size: 0.8rem;
  line-height: 1.2;
}

.saving-summary-grid .kpi-value {
  margin: 6px 0 2px;
  font-size: 1.5rem;
  line-height: 1.05;
}

.saving-summary-grid .kpi-meta {
  font-size: 0.78rem;
  line-height: 1.2;
}

.saving-summary-grid .kpi-card.clickable {
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.saving-summary-grid .kpi-card.clickable:hover,
.saving-summary-grid .kpi-card.clickable:focus-visible {
  transform: translateY(-1px);
  border-color: var(--primary-soft-border);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  outline: none;
}

.saving-sources-list {
  margin: 16px auto 0;
  max-width: 880px;
  width: 100%;
}

.saving-sources-products-grid .saving-sources-list {
  margin: 0;
  max-width: none;
}

.saving-member-chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.saving-member-chip {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 14px 15px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98) 0%, #f8fafc 100%);
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.saving-member-chip::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 6px;
  background: linear-gradient(90deg, #dfeee2 0%, var(--saving-chip-accent, #4f7a56) 100%);
  transform-origin: left center;
  transform: scaleX(var(--saving-chip-ratio, 0.25));
}

.saving-member-chip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.saving-member-chip-head h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
}

.saving-member-chip-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.saving-member-chip-amount {
  font-size: 1.35rem;
  line-height: 1.1;
  color: var(--text);
}

.saving-member-chip-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.saving-member-chip.clickable {
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.saving-member-chip.clickable:hover,
.saving-member-chip.clickable:focus-visible {
  transform: translateY(-1px);
  border-color: var(--primary-soft-border);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.1);
  outline: none;
}


.table-sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.table-sort-button::after {
  content: '↕';
  font-size: 0.82em;
  opacity: 0.45;
}

.table-sort-button.active::after {
  content: attr(data-sort-direction);
  text-transform: uppercase;
  font-size: 0.68em;
  letter-spacing: 0.04em;
  opacity: 0.72;
}

.member-flow-grid,
.member-grid {
  align-items: stretch;
}

.table-wrapper {
  overflow: auto;
  border-radius: 18px;
}

body .monthly-type-share-panel {
  margin-top: 12px;
}

body .monthly-radar-panel .panel-header p {
  text-align: left;
  max-width: none;
}

body .type-share-chart-host {
  display: flex;
  min-height: 0;
  min-width: 0;
}

body .type-share-chart {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  flex: 1 1 auto;
  gap: 14px;
  min-height: 0;
  min-width: 0;
}

body .type-share-chart-plot {
  position: relative;
  display: flex;
  min-height: 300px;
  padding: 10px 0 0;
  overflow: hidden;
}

body .type-share-chart-grid {
  flex: 1 1 auto;
  position: relative;
  z-index: 1;
  min-height: 0;
  display: grid;
  width: 100%;
  grid-template-columns: repeat(var(--type-share-columns, 3), minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

body .type-share-chart-group {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
  padding: 0 2px;
  transition: transform 120ms ease;
}

body .type-share-chart-group:has(.type-share-chart-bar:hover),
body .type-share-chart-group:focus-visible,
body .type-share-chart-group:focus-within {
  transform: translateY(-1px);
  outline: none;
}

body .type-share-hover-bubble {
  position: absolute;
  bottom: 10px;
  left: 50%;
  min-width: 176px;
  max-width: 220px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(99, 114, 130, 0.14);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.16);
  display: grid;
  gap: 2px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px) scale(0.92);
  transform-origin: center;
  transition: opacity 160ms ease, transform 180ms cubic-bezier(.2,.8,.2,1);
  z-index: 4;
}

body .type-share-hover-bubble strong {
  color: #1f2f46;
  line-height: 1.15;
}

body .type-share-hover-bubble span {
  color: #5a6f88;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.2;
}

body .type-share-hover-bubble small {
  color: #64748b;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.15;
}

body .type-share-chart-group:has(.type-share-chart-bar:hover) .type-share-hover-bubble,
body .type-share-chart-group:focus-visible .type-share-hover-bubble,
body .type-share-chart-group:focus-within .type-share-hover-bubble {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

body .type-share-chart-bars {
  height: 100%;
  min-height: 250px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(4px, 0.8vw, 8px);
  align-items: end;
}

body .type-share-chart-bar.average {
  position: relative;
  min-height: 10px;
  border-radius: 14px 14px 0 0;
  background: linear-gradient(180deg, var(--type-color-soft) 0%, rgba(255, 255, 255, 0.92) 100%);
  border: 1px solid var(--type-color-soft);
  transition: opacity 120ms ease, transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

body .type-share-chart-bar.current {
  position: relative;
  min-height: 10px;
  border-radius: 14px 14px 0 0;
  background: linear-gradient(180deg, var(--type-color) 0%, var(--type-color) 100%);
  border: 1px solid var(--type-color);
  transition: opacity 120ms ease, transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
  cursor: pointer;
}

body .type-share-chart-bar.average {
  cursor: pointer;
}

body .type-share-chart-grid:has(.type-share-chart-bar:hover) .type-share-chart-group:not(:has(.type-share-chart-bar:hover)) .type-share-chart-bar,
body .type-share-chart-grid:has(.type-share-chart-group:focus-within) .type-share-chart-group:not(:focus-within) .type-share-chart-bar {
  opacity: 0.58;
  filter: saturate(0.78);
}

body .type-share-chart-group:has(.type-share-chart-bar:hover) .type-share-chart-bar,
body .type-share-chart-group:focus-visible .type-share-chart-bar,
body .type-share-chart-group:focus-within .type-share-chart-bar {
  filter: brightness(1.04);
  box-shadow: 0 10px 24px rgba(79, 111, 153, 0.12);
}

body .type-share-chart-bar span {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  display: block;
  max-width: calc(100% - 8px);
  padding: 0;
  font-size: clamp(0.62rem, 1.2vw, 0.78rem);
  font-weight: 800;
  color: rgba(255, 255, 255, 0.96);
  line-height: 1;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.18);
  pointer-events: none;
}

body .type-share-chart-bar.average span {
  color: var(--type-color);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.45);
}

body .type-share-chart-bar.current span {
  color: rgba(255, 255, 255, 0.96);
}

body .type-share-chart-delta {
  text-align: center;
}

body .type-share-chart-delta small {
  display: block;
  color: #64748b;
  font-size: clamp(0.74rem, 1vw, 0.92rem);
  line-height: 1.15;
  transition: color 120ms ease, transform 120ms ease;
  overflow-wrap: anywhere;
}

body .type-share-chart-grid:has(.type-share-chart-bar:hover) .type-share-chart-group:not(:has(.type-share-chart-bar:hover)) .type-share-chart-delta small,
body .type-share-chart-grid:has(.type-share-chart-group:focus-within) .type-share-chart-group:not(:focus-within) .type-share-chart-delta small {
  opacity: 0.52;
}

body .type-share-chart-group:has(.type-share-chart-bar:hover) .type-share-chart-delta small,
body .type-share-chart-group:focus-visible .type-share-chart-delta small,
body .type-share-chart-group:focus-within .type-share-chart-delta small {
  color: #4b6488;
  transform: translateY(-1px);
}

body .monthly-highlight-panel {
  margin-top: 12px;
}

body .monthly-highlight-panel .panel-header {
  margin-bottom: 6px;
}

body .monthly-highlight-panel .detail-snapshot-list,
body .monthly-highlight-panel .full-width-snapshot-list {
  gap: 10px;
  margin-top: 8px;
}

body .monthly-highlight-panel .full-width-snapshot-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body .monthly-highlight-panel .snapshot-item {
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
}

body .monthly-highlight-panel .snapshot-item strong {
  line-height: 1.12;
}

body .monthly-highlight-panel .snapshot-item small {
  line-height: 1.15;
}

@media (max-width: 980px) {
  body .monthly-highlight-panel .full-width-snapshot-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-shell {
    width: min(100%, calc(100vw - 20px), 1500px);
    padding-top: 16px;
  }

  .panel {
    padding: 20px;
  }

  .grid.two-columns,
  .monthly-flow-strip,
  .member-grid,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .inline-filters {
    grid-auto-flow: row;
    justify-items: stretch;
  }

  .inline-filters select {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 760px) {
  body .type-share-chart-plot {
    min-height: 260px;
  }

  body .type-share-chart-grid {
    gap: 10px;
  }

  body .type-share-chart-bars {
    min-height: 200px;
    gap: 4px;
  }

  body .type-share-chart-group {
    gap: 8px;
    padding: 0;
  }

  body .type-share-chart-bar span {
    top: 8px;
    max-width: calc(100% - 4px);
    padding: 3px 5px;
  }

  body .monthly-highlight-panel .full-width-snapshot-list {
    grid-template-columns: 1fr;
  }

  #filtersPanel .filters-search-shell {
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 0 14px;
  }

  #filtersPanel .filters-body {
    position: static;
    width: 100%;
    margin-top: 10px;
  }

  #filtersPanel .filters-grid {
    grid-template-columns: 1fr;
  }

  #filtersPanel .date-custom-range {
    display: block;
  }

  #filtersPanel .date-custom-card {
    grid-template-columns: 1fr;
  }

  .panel-date-navigation,
  .date-navigation-row {
    margin-left: 0;
    justify-content: flex-start;
  }
}

/* Canonical shell/sidebar overrides.
   Keep the layout stable even if styles.css contains older duplicated sidebar rules. */
body .app-shell {
  width: 100%;
  padding: 10px 24px 24px;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

body .sidebar-collapsed.app-shell {
  grid-template-columns: 88px minmax(0, 1fr);
}

body .app-content,
body:has(.filters-sidebar[open]) .app-content {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 0;
}

body .hero {
  margin: 0;
  padding: 0;
}

body .hero-copy {
  padding: 16px 22px 18px;
}

body .view-panel {
  margin-top: 0;
}

body #appSidebar {
  position: sticky;
  top: 10px;
  min-height: calc(100dvh - 20px);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  align-content: start;
  gap: 14px;
  padding: 12px 8px;
  border: 1px solid var(--chrome-border);
  border-radius: 24px;
  background: linear-gradient(180deg, var(--chrome-shell-start) 0%, var(--chrome-shell-end) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92), var(--chrome-shadow-sm);
}

body #appSidebar .sidebar-top {
  display: grid;
  gap: 10px;
  padding: 0 6px 8px;
}

body #appSidebar .sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0 4px;
}

body #appSidebar .sidebar-brand-mark {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e8f0fe;
  color: #1a73e8;
  font-size: 16px;
}

body #appSidebar .sidebar-brand-copy {
  min-width: 0;
  color: #203653;
}

body #appSidebar .sidebar-brand-copy strong,
body #appSidebar .sidebar-brand-copy small {
  display: block;
}

body #appSidebar .sidebar-brand-copy small {
  color: #6c7f97;
}

body #appSidebar .sidebar-toggle {
  position: static;
  width: 36px;
  height: 36px;
  margin-left: auto;
  border-radius: 18px;
  border: 1px solid #d7e4fb;
  background: #edf3fe;
  color: #506580;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body #appSidebar .app-menu {
  margin-top: 0;
  padding: 0;
  display: grid;
  gap: 2px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

body #appSidebar .menu-button {
  width: calc(100% - 2px);
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 2px 2px 0;
  padding: 0 14px;
  border: 0;
  border-radius: 0 18px 18px 0;
  background: transparent;
  color: #48617f;
  font-weight: 600;
  text-align: left;
  box-shadow: none;
}

body #appSidebar .menu-button:hover {
  background: #edf3fe;
  color: #16365f;
}

body #appSidebar .menu-button.active {
  background: #d3e3fd;
  color: #0b57d0;
  border-color: transparent;
}

body #appSidebar .menu-icon {
  width: 18px;
  min-width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

body #appSidebar .menu-label {
  font-size: 0.94rem;
  line-height: 1;
  white-space: nowrap;
}

body #appSidebar .sidebar-cache {
  align-self: end;
  width: calc(100% - 12px);
  min-width: 0;
  max-width: none;
  margin: auto 6px 2px;
  padding: 14px 14px 16px;
  border-radius: 22px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92), var(--chrome-shadow-sm);
}

body #appSidebar .sidebar-cache .compact-cache-head {
  gap: 10px;
  align-items: center;
}

body #appSidebar .sidebar-cache .compact-cache-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

body #appSidebar .sidebar-cache .compact-cache-body {
  padding-inline: 0;
}

body #appSidebar .sidebar-cache .compact-cache-tag {
  max-width: none;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-start;
  padding: 7px 12px;
  border: 1px solid rgba(219, 227, 240, 0.95);
  background: rgba(255, 255, 255, 0.78);
  color: #1f3f74;
  font-size: 0.82rem;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

body #appSidebar .sidebar-cache .compact-cache-tag .status-icon {
  color: #d97706;
}

body #appSidebar .sidebar-cache .compact-cache-tag > span:last-child {
  color: inherit;
}

body #appSidebar .sidebar-cache .compact-cache-actions button {
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 13px;
  border: 1px solid #d8e3f3;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: none;
}

body #appSidebar .sidebar-cache .compact-refresh {
  background: #edf3fe;
  border-color: #c9d9f4;
  color: #1f4e8c;
}

body #appSidebar .sidebar-cache .compact-clear {
  background: #fff5f5;
  border: 1px solid #f4c4c4;
  color: #c24141;
}

body .sidebar-collapsed #appSidebar {
  padding: 12px 10px;
  gap: 12px;
  justify-items: center;
}

body .sidebar-collapsed #appSidebar .sidebar-brand-copy,
body .sidebar-collapsed #appSidebar .menu-label {
  display: none;
}

body .sidebar-collapsed #appSidebar .sidebar-top {
  width: 100%;
  gap: 12px;
  padding: 0 0 8px;
}

body .sidebar-collapsed #appSidebar .sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 0;
}

body .sidebar-collapsed #appSidebar .sidebar-brand-mark {
  display: inline-flex;
}

body .sidebar-collapsed #appSidebar .sidebar-toggle {
  position: static;
  margin: 0;
}

body .sidebar-collapsed #appSidebar .app-menu {
  width: 100%;
  justify-items: center;
  gap: 8px;
}

body .sidebar-collapsed #appSidebar .menu-button {
  width: 40px;
  height: 40px;
  min-height: 40px;
  margin: 0;
  padding: 0;
  border-radius: 20px;
  justify-content: center;
}

body .sidebar-collapsed #appSidebar .menu-icon {
  width: 18px;
  min-width: 18px;
}

body .sidebar-collapsed #appSidebar .sidebar-cache {
  display: none;
}

@media (min-width: 981px) {
  body .sidebar-collapsed.app-shell {
    position: relative;
    width: 100%;
    padding: 10px 24px 24px !important;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px !important;
    align-items: start;
  }

  body .sidebar-collapsed #appSidebar {
    position: absolute;
    top: 10px;
    left: 12px;
    width: 56px;
    min-height: 56px;
    height: 56px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    gap: 0;
    grid-template-rows: 56px;
    align-content: start;
    justify-items: stretch;
    overflow: visible;
    z-index: 70;
  }

  body .sidebar-collapsed #appSidebar .sidebar-top {
    width: 56px;
    padding: 0;
    gap: 0;
  }

  body .sidebar-collapsed #appSidebar .sidebar-brand {
    width: 56px;
    height: 56px;
    padding: 0;
    justify-content: center;
    align-items: center;
    gap: 0;
  }

  body .sidebar-collapsed #appSidebar .sidebar-brand-mark,
  body .sidebar-collapsed #appSidebar .app-menu {
    display: none;
  }

  body .sidebar-collapsed #appSidebar .sidebar-toggle {
    width: 56px;
    height: 56px;
    margin: 0;
    border-radius: 20px;
    border: 1px solid rgba(183, 203, 230, 0.95);
    background: linear-gradient(180deg, var(--chrome-shell-start) 0%, var(--chrome-shell-end) 100%);
    color: #264f8a;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.92),
      0 8px 24px rgba(123, 152, 191, 0.12);
  }

  body .sidebar-collapsed .app-content {
    min-width: 0;
    width: 100%;
  }

  body .sidebar-collapsed #filtersPanel.filters-sidebar {
    width: 100%;
    margin-top: 0;
    padding-left: 68px;
  }

  body .sidebar-collapsed #filtersPanel .filters-search-shell {
    min-height: 56px;
    height: 56px;
    border-radius: 20px;
  }
}

/* Sidebar cache refinement for narrower laptop widths */
@media (max-width: 1500px) {
  body #appSidebar .sidebar-cache {
    padding: 12px 12px 13px;
    margin: auto 4px 2px;
    border-radius: 18px;
  }

  body #appSidebar .sidebar-cache .compact-cache-head {
    gap: 8px;
    align-items: center;
  }

  body #appSidebar .sidebar-cache .compact-cache-tag {
    padding: 6px 10px;
    font-size: 0.78rem;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }

  body #appSidebar .sidebar-cache .compact-cache-tag .status-icon {
    width: 0.75em;
    min-width: 0.75em;
    height: 0.75em;
  }

  body #appSidebar .sidebar-cache .compact-cache-actions {
    gap: 6px;
  }

  body #appSidebar .sidebar-cache .compact-cache-actions button {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 12px;
  }

  body #appSidebar .sidebar-cache .compact-refresh,
  body #appSidebar .sidebar-cache .compact-clear {
    box-shadow: none;
  }
}

@media (max-width: 1320px) {
  body #appSidebar .sidebar-cache .compact-cache-head {
    flex-wrap: nowrap;
  }

  body #appSidebar .sidebar-cache .compact-cache-tag {
    max-width: calc(100% - 84px);
  }
}

body #filtersPanel.filters-sidebar,
body #filtersPanel.filters-sidebar[open] {
  position: relative;
  top: auto;
  right: auto;
  left: auto;
  width: 100%;
  max-width: none;
  height: auto;
  margin: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

@media (max-width: 980px) {
  body .app-shell,
  body .sidebar-collapsed.app-shell {
    width: min(100%, calc(100vw - 20px));
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 10px 10px 20px;
  }

  body #appSidebar,
  body .sidebar-collapsed #appSidebar {
    position: static;
    min-height: 0;
    border-radius: 20px;
    padding: 14px;
  }

  body #appSidebar .app-menu {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
  }

  body #appSidebar .menu-button,
  body .sidebar-collapsed #appSidebar .menu-button {
    width: 100%;
    height: auto;
    min-height: 40px;
    margin: 0;
    padding: 0 14px;
    border-radius: 16px;
    justify-content: flex-start;
  }

  body #appSidebar .sidebar-brand-copy,
  body #appSidebar .menu-label {
    display: block;
  }

  .hero {
    padding: 0;
  }

  .hero-copy {
    padding: 22px 22px 24px;
  }
}

/* Normalize spacing between direct children inside each view panel. */
body .view-panel > * + * {
  margin-top: 20px;
}

body .view-panel > :first-child {
  margin-top: 0;
}

/* Final sidebar-cache override: compact, single-line, laptop-friendly */
body #appSidebar .sidebar-cache {
  padding: 11px 12px 12px !important;
  margin: auto 4px 2px !important;
  border-radius: 18px !important;
}

body #appSidebar .sidebar-cache .compact-cache-head {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center !important;
  gap: 8px !important;
}

body #appSidebar .sidebar-cache .compact-cache-tag {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 6px !important;
  padding: 0 !important;
  margin: 0 !important;
  min-width: 0 !important;
  max-width: 100% !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #1f3f74 !important;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

body #appSidebar .sidebar-cache .compact-cache-tag .status-icon {
  width: auto !important;
  min-width: 0 !important;
  height: auto !important;
  font-size: 10px !important;
  line-height: 1 !important;
  flex: 0 0 auto !important;
  color: #1f3f74 !important;
}

body #appSidebar .sidebar-cache.status-card.success .compact-cache-tag,
body #appSidebar .sidebar-cache.status-card.success .compact-cache-tag .status-icon {
  color: var(--success) !important;
}

body #appSidebar .sidebar-cache.status-card.warning .compact-cache-tag,
body #appSidebar .sidebar-cache.status-card.warning .compact-cache-tag .status-icon {
  color: var(--warning) !important;
}

body #appSidebar .sidebar-cache.status-card.error .compact-cache-tag,
body #appSidebar .sidebar-cache.status-card.error .compact-cache-tag .status-icon {
  color: var(--danger) !important;
}

body #appSidebar .sidebar-cache .compact-cache-tag > span:last-child {
  line-height: 1 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

body #appSidebar .sidebar-cache .compact-cache-actions {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex: 0 0 auto !important;
}

body #appSidebar .sidebar-cache .compact-cache-actions button {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  padding: 0 !important;
  border-radius: 11px !important;
  box-shadow: none !important;
}

body #appSidebar .sidebar-cache .compact-refresh,
body #appSidebar .sidebar-cache .compact-clear {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

body #appSidebar .sidebar-cache .compact-refresh {
  background: #edf3fe !important;
  border: 1px solid #c9d9f4 !important;
  color: #1f4e8c !important;
}

body #appSidebar .sidebar-cache .compact-clear {
  background: #fff5f5 !important;
  border: 1px solid #f4c4c4 !important;
  color: #c24141 !important;
}

/* CSS audit hardening */
.inline-filters > *,
#filtersPanel .filters-search-shell,
#filtersPanel .filters-search-copy,
#filtersPanel .date-month-field {
  min-width: 0;
}

@media (max-width: 1024px) {
  body .app-shell,
  body .sidebar-collapsed.app-shell {
    grid-template-columns: 224px minmax(0, 1fr);
    gap: 14px;
  }
}

@media (max-width: 768px) {
  body .app-shell,
  body .sidebar-collapsed.app-shell {
    width: min(100%, calc(100vw - 16px));
    gap: 12px;
    padding: 10px 8px 20px;
  }

  .panel {
    padding: 18px;
  }

  #filtersPanel .filters-search-shell {
    grid-template-columns: 24px minmax(0, 1fr) auto;
    gap: 12px;
    padding: 0 12px;
  }

  #filtersPanel .filters-search-copy {
    min-height: 0;
    align-content: center;
  }

  #filtersPanel .filters-search-input {
    min-height: 28px;
  }

  #filtersPanel .date-month-field {
    width: 100%;
  }

  #filtersPanel .date-month-field input {
    width: 100%;
  }
}

@media (min-width: 1440px) {
  body .app-shell,
  body .sidebar-collapsed.app-shell {
    padding-left: 32px;
    padding-right: 32px;
  }
}

@media (max-width: 440px) {
  body {
    --mobile-safe-top: env(safe-area-inset-top, 0px);
    --mobile-safe-left: env(safe-area-inset-left, 0px);
    --mobile-safe-right: env(safe-area-inset-right, 0px);
    --mobile-header-top: calc(var(--mobile-safe-top) + 14px);
    --mobile-header-left: calc(var(--mobile-safe-left) + 12px);
    --mobile-header-right: calc(var(--mobile-safe-right) + 12px);
    --mobile-header-gap: 12px;
    --mobile-header-control-size: 52px;
    --mobile-search-height: 56px;
    --mobile-search-left: calc(var(--mobile-header-left) + var(--mobile-header-control-size) + var(--mobile-header-gap));
    --mobile-search-top: var(--mobile-header-top);
    --mobile-header-offset: calc(var(--mobile-header-top) + var(--mobile-header-control-size) + 12px);
  }

  body:not(.mobile-chrome-ready) {
    --mobile-safe-top: 44px;
  }

  body:not(.mobile-chrome-ready) .mobile-menu-fab,
  body:not(.mobile-chrome-ready) #filtersPanel.filters-sidebar,
  body:not(.mobile-chrome-ready) #filtersPanel.filters-sidebar[open] {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  body .mobile-menu-fab {
    top: var(--mobile-header-top) !important;
    left: var(--mobile-header-left) !important;
    right: auto !important;
    bottom: auto !important;
    width: var(--mobile-header-control-size) !important;
    height: var(--mobile-header-control-size) !important;
    border-radius: 20px !important;
    border: 1px solid #d8e3f3 !important;
    background: linear-gradient(180deg, #eef5ff 0%, #e8f0fe 100%) !important;
    color: #2563eb !important;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.85),
      0 8px 18px rgba(37, 99, 235, 0.08) !important;
    z-index: 260 !important;
  }

  body .mobile-menu-fab-icon {
    font-size: 1.85rem;
    line-height: 1;
  }

  body.mobile-drawer-open .mobile-nav-overlay {
    z-index: 310 !important;
  }

  body.mobile-drawer-open #filtersPanel.filters-sidebar,
  body.mobile-drawer-open #filtersPanel.filters-sidebar[open] {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  body.mobile-drawer-open #appSidebar,
  body.mobile-drawer-open .sidebar-collapsed #appSidebar,
  body.mobile-drawer-open .app-shell #appSidebar {
    top: 0 !important;
    left: 0 !important;
    width: min(320px, calc(100vw - 40px)) !important;
    max-width: calc(100vw - 40px) !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    padding: calc(var(--mobile-safe-top) + 16px) 14px calc(env(safe-area-inset-bottom, 0px) + 18px) !important;
    border-radius: 0 28px 28px 0 !important;
    z-index: 320 !important;
    box-shadow: 16px 0 36px rgba(15, 23, 42, 0.22) !important;
  }

  body.mobile-drawer-open #appSidebar .sidebar-top {
    padding-top: 0 !important;
  }

  body #filtersPanel.filters-sidebar,
  body #filtersPanel.filters-sidebar[open] {
    position: fixed !important;
    top: var(--mobile-search-top) !important;
    left: var(--mobile-search-left) !important;
    right: var(--mobile-header-right) !important;
    width: auto !important;
    margin: 0 !important;
    z-index: 250 !important;
  }

  body #filtersPanel.filters-sidebar > .filters-summary,
  body #filtersPanel.filters-sidebar[open] > .filters-summary {
    height: var(--mobile-search-height);
  }

  body #filtersPanel .filters-search-shell {
    min-height: var(--mobile-search-height);
    height: var(--mobile-search-height);
    grid-template-columns: 24px minmax(0, 1fr) 44px;
    gap: 10px;
    padding: 0 12px 0 14px;
    border-radius: 22px;
  }

  body #filtersPanel .filters-search-icon {
    width: 24px;
    min-width: 24px;
  }

  body #filtersPanel .filters-search-icon svg {
    width: 24px;
    height: 24px;
  }

  body #filtersPanel .filters-search-copy {
    min-height: 100%;
    align-content: center;
  }

  body #filtersPanel .filters-search-input {
    min-height: 28px;
    font-size: 0.95rem;
  }

  body #filtersPanel .filters-drawer-button {
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }

  body #filtersPanel .filters-body {
    position: fixed !important;
    top: var(--mobile-header-offset) !important;
    left: var(--mobile-header-left) !important;
    right: var(--mobile-header-right) !important;
    width: auto !important;
    max-height: calc(100dvh - var(--mobile-header-offset) - env(safe-area-inset-bottom) - 16px) !important;
  }

  body .app-content,
  body:has(.filters-sidebar) .app-content,
  body:has(.filters-sidebar[open]) .app-content {
    padding-top: calc(var(--mobile-header-offset) + 4px) !important;
  }
}
