header.hero {
  background: var(--hero-bg);
  color: var(--hero-text);
  padding: 6px 0;
  position: sticky;
  top: 0;
  z-index: 8;
  overflow: hidden;
  border-bottom: 1px solid var(--hero-bottom-border);
  box-shadow: 0 8px 24px -20px rgba(15, 23, 42, 0.45);
}

header.hero::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: var(--hero-top-accent);
  opacity: 0.92;
  pointer-events: none;
}

.hero__content {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
  grid-template-areas: "identity nav actions";
  align-items: center;
  gap: clamp(8px, 1.5vw, 16px);
  position: relative;
  z-index: 1;
}

.hero__identity {
  grid-area: identity;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.hero__logo {
  display: block;
  flex: 0 0 auto;
  width: clamp(32px, 3vw, 40px);
  height: clamp(32px, 3vw, 40px);
  object-fit: contain;
}

.hero__title {
  font-size: clamp(1.1rem, 0.95rem + 0.5vw, 1.35rem);
  margin: 0;
  letter-spacing: 0.01em;
}

.hero__subtitle {
  margin: 0;
  font-size: 0.82rem;
  color: var(--hero-text-muted);
  max-width: 420px;
}

.hero__nav {
  grid-area: nav;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero__actions {
  grid-area: actions;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-height: 44px;
  flex-wrap: wrap;
}

.demo-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: 0 0 auto;
  max-width: min(100%, 180px);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 243, 199, 0.55);
  background:
    linear-gradient(135deg, rgba(255, 243, 199, 0.24), rgba(245, 158, 11, 0.24)), rgba(120, 53, 15, 0.18);
  color: #fff7ed;
  box-shadow: 0 18px 34px -24px rgba(120, 53, 15, 0.85);
  order: 0;
}

.demo-indicator__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 251, 235, 0.92);
  color: #9a3412;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.demo-indicator__text {
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.hero__status {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 24px;
  min-width: 140px;
  max-width: 320px;
  order: 1;
}

.hero__buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
  order: 2;
}

.hero__actions .status {
  max-width: none;
  width: 100%;
  min-height: 18px;
  text-align: right;
}

.hero__actions .status.status--loading {
  width: 10px;
  min-width: 10px;
  max-width: 10px;
  min-height: 10px;
  height: 10px;
  text-align: left;
}

:is(button.icon-button, .export-icon-btn, .chart-copy-btn, .chart-download-btn) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

button.icon-button {
  border: none;
  border-radius: 10px;
  width: 32px;
  height: 32px;
  transition:
    transform 0.15s ease,
    box-shadow 0.2s ease,
    background 0.25s ease,
    border-color 0.25s ease;
  box-shadow: 0 12px 26px -22px rgba(15, 23, 42, 0.7);
}

button.icon-button svg {
  width: 18px;
  height: 18px;
}

button.icon-button:focus-visible {
  outline: 3px solid var(--nav-focus-ring);
  outline-offset: 3px;
}

button.ed-panel-toggle {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  box-shadow: 0 12px 24px -20px rgba(15, 23, 42, 0.8);
  width: auto;
  height: 36px;
  padding: 0 14px 0 10px;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.ed-panel-toggle__icon {
  width: 22px;
  height: 22px;
}

.ed-panel-toggle__label {
  white-space: nowrap;
}

button.ed-panel-toggle:hover,
button.ed-panel-toggle:focus-visible {
  transform: translateY(-0.5px);
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 0 16px 32px -26px rgba(15, 23, 42, 0.85);
}

button.ed-panel-toggle.is-active {
  background: #fff;
  color: var(--color-accent);
  border-color: rgba(255, 255, 255, 0.6);
}

body[data-theme="dark"] button.ed-panel-toggle {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(148, 163, 184, 0.4);
  color: var(--color-text);
}

body[data-theme="dark"] button.ed-panel-toggle:hover,
body[data-theme="dark"] button.ed-panel-toggle:focus-visible {
  background: rgba(15, 23, 42, 0.85);
  box-shadow: 0 18px 32px -20px rgba(8, 12, 32, 0.85);
}

body[data-theme="dark"] button.ed-panel-toggle.is-active {
  background: rgba(255, 255, 255, 0.92);
  color: var(--color-accent);
}

body[data-theme="dark"] .demo-indicator {
  border-color: rgba(251, 191, 36, 0.44);
  background:
    linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(146, 64, 14, 0.3)), rgba(15, 23, 42, 0.78);
  color: #fef3c7;
  box-shadow: 0 18px 34px -24px rgba(8, 12, 32, 0.9);
}

body[data-theme="dark"] .demo-indicator__badge {
  background: rgba(254, 243, 199, 0.96);
  color: #9a3412;
}

button.settings-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  box-shadow: 0 10px 24px -18px rgba(15, 23, 42, 0.8);
}

button.settings-btn:hover,
button.settings-btn:focus-visible {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.65);
  box-shadow: 0 16px 32px -20px rgba(15, 23, 42, 0.85);
}

button.settings-btn:active {
  transform: translateY(0);
}

.theme-toggle {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
}

.global-search-trigger {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
}

.global-search-trigger:hover,
.global-search-trigger:focus-visible {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.5);
}

body[data-theme="light"] .theme-toggle {
  background: rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(15, 23, 42, 0.24);
  color: #1e293b;
  box-shadow: 0 8px 20px -18px rgba(15, 23, 42, 0.55);
}

body[data-theme="light"] .global-search-trigger {
  background: rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(15, 23, 42, 0.24);
  color: #1e293b;
  box-shadow: 0 8px 20px -18px rgba(15, 23, 42, 0.55);
}

body[data-theme="light"] .theme-toggle:hover,
body[data-theme="light"] .theme-toggle:focus-visible {
  background: rgba(47, 91, 234, 0.14);
  border-color: rgba(47, 91, 234, 0.38);
  color: #12387f;
}

body[data-theme="light"] .global-search-trigger:hover,
body[data-theme="light"] .global-search-trigger:focus-visible {
  background: rgba(47, 91, 234, 0.14);
  border-color: rgba(47, 91, 234, 0.38);
  color: #12387f;
}

body[data-theme="dark"] .theme-toggle {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(148, 163, 184, 0.5);
}

body[data-theme="dark"] .global-search-trigger {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(148, 163, 184, 0.5);
  color: #e2e8f0;
}

.theme-toggle .theme-icon {
  display: none;
}

.theme-toggle[data-theme="light"] .icon--sun,
.theme-toggle:not([data-theme]) .icon--sun {
  display: block;
}

.theme-toggle[data-theme="dark"] .icon--moon {
  display: block;
}

.theme-toggle[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.35);
  color: #0f172a;
}

body[data-theme="dark"] .theme-toggle[aria-pressed="true"] {
  background: rgba(96, 165, 250, 0.3);
  color: #e2e8f0;
}

body[data-fullscreen="true"] header.hero {
  display: none;
}

body[data-fullscreen="true"] main.container {
  padding-top: clamp(16px, 3vw, 40px);
}

.mobile-app-nav,
.mobile-more-sheet,
.mobile-shell-status {
  display: none;
}

body[data-theme="dark"] .kpi-filter span {
  color: var(--color-text);
}

.status {
  margin: 0;
  font-size: 0.8rem;
  color: var(--hero-text-muted);
}

.status:empty:not(.status--loading) {
  display: none;
}

.status--loading {
  position: relative;
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
  border: 0;
  overflow: visible;
  vertical-align: middle;
}

.status--loading::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 0 0 rgba(47, 91, 234, 0.35);
  animation: status-loading 1.2s ease-in-out infinite;
}

.status--loading.status--determinate::before {
  animation: status-loading 1.2s ease-in-out infinite;
  transform: none;
  opacity: 1;
}

.status--loading::after {
  content: none;
}

.status--error {
  color: #b91c1c;
  font-weight: 600;
}

.status[data-tone="warning"] {
  color: #b45309;
}

body[data-theme="dark"] .status--error {
  color: #fecaca;
}

body[data-theme="dark"] .status[data-tone="warning"] {
  color: #f9d977;
}

@keyframes status-loading {
  0% {
    transform: scale(0.86);
    opacity: 0.55;
    box-shadow: 0 0 0 0 rgba(47, 91, 234, 0.26);
  }
  55% {
    transform: scale(1);
    opacity: 1;
    box-shadow: 0 0 0 6px rgba(47, 91, 234, 0);
  }
  100% {
    transform: scale(0.86);
    opacity: 0.55;
    box-shadow: 0 0 0 0 rgba(47, 91, 234, 0);
  }
}

@media (max-width: 1200px) {
  header.hero .section-nav {
    --section-nav-chip-min-height: 44px;
  }

  .hero__content {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "identity actions"
      "nav actions";
  }

  .hero__actions {
    align-items: center;
    justify-self: end;
  }

  .hero__buttons button.icon-button {
    width: 44px;
    height: 44px;
  }

  .hero__nav .section-nav__bar,
  .hero__nav .section-nav__inner {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  header.hero {
    padding: 10px 0;
  }

  .hero__content {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "identity"
      "actions"
      "nav";
    gap: 14px;
  }

  .hero__actions {
    align-items: flex-start;
    gap: 8px;
    justify-content: flex-start;
  }

  .demo-indicator {
    max-width: fit-content;
    justify-content: flex-start;
  }

  .hero__buttons {
    width: 100%;
    justify-content: flex-start;
    gap: 6px;
    flex-wrap: wrap;
  }

  .hero__status {
    min-width: 0;
    width: 100%;
    justify-content: flex-start;
    text-align: left;
  }

  .hero__nav .section-nav__bar,
  .hero__nav .section-nav__inner {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  header.hero {
    padding: calc(8px + env(safe-area-inset-top, 0px)) 0 8px;
  }

  .hero__content {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "identity actions";
    gap: 8px;
  }

  .hero__title {
    font-size: 1rem;
    line-height: 1.15;
  }

  .hero__subtitle {
    font-size: 0.85rem;
    max-width: none;
  }

  .hero__actions {
    width: auto;
    align-items: center;
    gap: 6px;
    margin-top: 0;
  }

  .demo-indicator {
    max-width: fit-content;
    width: auto;
    border-radius: 999px;
  }

  .hero__buttons {
    width: auto;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
  }

  .hero__status,
  .hero__nav {
    display: none;
  }

  .hero__logo {
    width: 32px;
    height: 32px;
  }

  .section-nav--compact .section-nav__bar {
    padding: 0;
  }

  .section-nav--compact .section-nav__inner {
    gap: 6px;
  }

  .section-nav--compact .section-nav__link {
    min-height: 34px;
    padding: 6px 10px;
  }

  .hero__nav .section-nav__bar,
  .hero__nav .section-nav__inner {
    justify-content: flex-start;
  }

  .hero__buttons button.icon-button {
    width: 44px;
    height: 44px;
  }

  .status {
    text-align: left;
    font-size: 0.78rem;
    width: 100%;
  }

  .chart-year-filter {
    padding: 6px 8px;
  }

  .chart-year-filter span {
    display: none;
  }

  .chart-filters {
    margin-left: 0;
    flex: 1 1 100%;
  }

  .chart-filter {
    flex: 1 1 140px;
  }

  .chart-filters__summary {
    order: 5;
  }

  body {
    padding-bottom: calc(var(--component-mobile-bottom-nav-height, 72px) + env(safe-area-inset-bottom, 0px));
    overscroll-behavior-y: auto;
  }

  body[data-mobile-more-open="true"] {
    overflow: hidden;
  }

  .mobile-app-nav {
    --mobile-nav-bg: color-mix(in srgb, var(--color-surface) 92%, transparent);
    position: fixed;
    z-index: 20;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: calc(var(--component-mobile-bottom-nav-height, 72px) + env(safe-area-inset-bottom, 0px));
    padding: 6px max(8px, env(safe-area-inset-left, 0px)) calc(6px + env(safe-area-inset-bottom, 0px))
      max(8px, env(safe-area-inset-right, 0px));
    border-top: 1px solid var(--color-border);
    background: var(--mobile-nav-bg);
    box-shadow: 0 -18px 34px -28px rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .mobile-app-nav__link {
    min-width: 0;
    min-height: 56px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    color: var(--color-text-muted);
    text-decoration: none;
    font: inherit;
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1.1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .mobile-app-nav__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
  }

  .mobile-app-nav__icon svg {
    width: 21px;
    height: 21px;
  }

  .mobile-app-nav__label {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-app-nav__link:focus-visible {
    outline: 3px solid var(--nav-focus-ring);
    outline-offset: 2px;
    color: var(--color-accent);
    background: var(--color-input-bg);
  }

  .mobile-app-nav__link.is-active,
  .mobile-app-nav__link[aria-current="page"],
  .mobile-app-nav__link[aria-expanded="true"] {
    color: var(--color-accent);
    border-color: var(--state-accent-border-38);
    background: var(--nav-chip-active);
    box-shadow: var(--state-accent-inset-16);
  }

  .mobile-more-sheet {
    position: fixed;
    inset: 0;
    z-index: 22;
    display: block;
  }

  .mobile-more-sheet[hidden] {
    display: none;
  }

  .mobile-more-sheet__backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(15, 23, 42, 0.36);
    cursor: pointer;
  }

  .mobile-more-sheet__panel {
    position: absolute;
    left: max(10px, env(safe-area-inset-left, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    bottom: calc(var(--component-mobile-bottom-nav-height, 72px) + env(safe-area-inset-bottom, 0px) + 8px);
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--color-border);
    border-radius: 18px;
    background: var(--color-surface);
    box-shadow: 0 20px 48px -28px rgba(15, 23, 42, 0.72);
  }

  .mobile-more-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-more-sheet__title {
    margin: 0;
    font-size: 1rem;
    line-height: 1.2;
  }

  .mobile-more-sheet__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-input-bg);
    color: var(--color-text);
    cursor: pointer;
  }

  .mobile-more-sheet__close svg {
    width: 20px;
    height: 20px;
  }

  .mobile-more-sheet__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .mobile-more-sheet__item {
    min-width: 0;
    min-height: 76px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 6px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-input-bg);
    color: var(--color-text);
    text-align: center;
    text-decoration: none;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.15;
    cursor: pointer;
    touch-action: manipulation;
  }

  .mobile-more-sheet__icon {
    display: inline-flex;
    width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
    color: var(--color-accent);
  }

  .mobile-more-sheet__icon svg {
    width: 22px;
    height: 22px;
  }

  .mobile-more-sheet__item:focus-visible,
  .mobile-more-sheet__close:focus-visible,
  .mobile-more-sheet__backdrop:focus-visible {
    outline: 3px solid var(--nav-focus-ring);
    outline-offset: 2px;
  }

  .mobile-more-sheet__item.is-active,
  .mobile-more-sheet__item[aria-current="page"] {
    border-color: var(--state-accent-border-42);
    background: var(--nav-chip-active);
    color: var(--color-accent);
    box-shadow: var(--state-accent-inset-18);
  }

  .mobile-shell-status {
    position: fixed;
    left: max(12px, env(safe-area-inset-left, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    bottom: calc(var(--component-mobile-bottom-nav-height, 72px) + env(safe-area-inset-bottom, 0px) + 8px);
    z-index: 21;
    display: block;
    margin: 0;
    padding: 9px 12px;
    border: 1px solid var(--state-accent-border-38);
    border-radius: 12px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.78rem;
    font-weight: 600;
    box-shadow: var(--shadow-popover-soft);
    transform: translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }

  .mobile-shell-status[data-visible="true"] {
    transform: translateY(0);
    opacity: 1;
  }

  .scroll-top-btn {
    bottom: calc(var(--component-mobile-bottom-nav-height, 72px) + env(safe-area-inset-bottom, 0px) + 16px);
  }
}

@media (max-width: 380px) {
  .mobile-app-nav__label {
    font-size: 0.68rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-more-sheet__panel,
  .mobile-shell-status,
  .mobile-app-nav__link {
    transition: none;
  }
}
