:root {
  color-scheme: light;
  --page-base: #f5f7fb;
  --page-warm: #fff1f2;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --surface-muted: #f8fafc;
  --border: rgba(39, 50, 68, 0.12);
  --border-strong: rgba(39, 50, 68, 0.2);
  --text-primary: #273244;
  --text-secondary: #596579;
  --text-tertiary: #687386;
  --sonic-red: #f21b20;
  --sonic-red-deep: #c9151c;
  --sonic-coral: #ff6b70;
  --sonic-red-soft: #ffe8e9;
  --sonic-red-glow: rgba(242, 27, 32, 0.22);
  --status-good: #14804a;
  --status-warn: #a15c00;
  --status-crit: #c9151c;
  --shadow: 0 24px 70px rgba(44, 54, 70, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI Variable',
    'Segoe UI', Roboto, sans-serif;
  color: var(--text-primary);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.76), transparent 48%),
    linear-gradient(180deg, var(--page-warm) 0%, var(--page-base) 44%, #eef2f7 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.ambient {
  position: fixed;
  width: 620px;
  height: 620px;
  border-radius: 50%;
  filter: blur(115px);
  pointer-events: none;
  z-index: 0;
  will-change: transform;
  animation: drift 20s ease-in-out infinite alternate;
}

.ambient-red {
  top: -300px;
  right: -180px;
  background: rgba(242, 27, 32, 0.18);
}

.ambient-silver {
  bottom: -320px;
  left: -190px;
  background: rgba(127, 145, 171, 0.2);
  animation-delay: -10s;
}

@keyframes drift {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(60px, 40px) scale(1.12);
  }
}

.page {
  flex: 1;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 2.25rem 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.brand {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  align-items: center;
  gap: 2rem;
  margin-bottom: 1.75rem;
}

.logo-frame {
  position: relative;
  width: 100%;
  height: 138px;
  padding: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(135deg, var(--surface-solid), #f9fafb);
  box-shadow:
    0 15px 38px rgba(44, 54, 70, 0.11),
    0 5px 18px var(--sonic-red-glow);
}

.logo-frame::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, var(--sonic-red), var(--sonic-coral));
}

.logo-frame-inner {
  width: 100%;
  height: 100%;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.brand-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.brand-kicker {
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.24em;
  color: var(--sonic-red-deep);
  text-transform: uppercase;
}

.brand-title {
  margin: 0;
  font-size: clamp(2.25rem, 6vw, 3.25rem);
  font-weight: 850;
  line-height: 1;
  letter-spacing: -0.045em;
  color: var(--text-primary);
}

.brand-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.65;
  letter-spacing: 0.13em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.gauge-card {
  position: relative;
  width: 100%;
  overflow: hidden;
  padding: 1.5rem 2rem 1.35rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 30px;
  background: var(--surface);
  box-shadow: var(--shadow), inset 0 0 0 1px var(--border);
  backdrop-filter: blur(24px) saturate(120%);
  -webkit-backdrop-filter: blur(24px) saturate(120%);
}

.gauge-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 2rem;
  right: 2rem;
  height: 3px;
  border-radius: 0 0 999px 999px;
  background: linear-gradient(90deg, transparent, var(--sonic-red), transparent);
  opacity: 0.72;
}

.card-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.17em;
  transition: color 0.4s ease, background 0.4s ease, border-color 0.4s ease;
}

.status-pill.is-good {
  color: var(--status-good);
  border-color: rgba(20, 128, 74, 0.25);
  background: rgba(20, 128, 74, 0.07);
}

.status-pill.is-warn {
  color: var(--status-warn);
  border-color: rgba(161, 92, 0, 0.26);
  background: rgba(245, 158, 11, 0.09);
}

.status-pill.is-crit,
.status-pill.is-error {
  color: var(--status-crit);
  border-color: rgba(201, 21, 28, 0.25);
  background: rgba(242, 27, 32, 0.07);
}

.status-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: dot-pulse 1.8s ease-out infinite;
}

@keyframes dot-pulse {
  0% {
    box-shadow: 0 0 0 0 currentColor;
  }
  70% {
    box-shadow: 0 0 0 10px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

.refresh-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--text-secondary);
  box-shadow: 0 5px 14px rgba(44, 54, 70, 0.08);
  cursor: pointer;
  font: inherit;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease,
    transform 0.15s ease, box-shadow 0.2s ease;
}

.refresh-btn:hover:not(:disabled) {
  color: var(--sonic-red-deep);
  background: var(--sonic-red-soft);
  border-color: rgba(201, 21, 28, 0.3);
  box-shadow: 0 7px 18px var(--sonic-red-glow);
}

.refresh-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.refresh-btn:focus-visible {
  outline: 3px solid rgba(201, 21, 28, 0.28);
  outline-offset: 3px;
}

.refresh-btn:disabled {
  opacity: 0.58;
  cursor: progress;
}

.refresh-btn.is-spinning .refresh-icon {
  animation: refresh-spin 0.9s linear infinite;
}

@keyframes refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

.gauge-wrap {
  position: relative;
  width: 100%;
  max-width: 290px;
  aspect-ratio: 1;
  margin: 0.2rem 0 0.9rem;
}

.gauge {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-track {
  fill: rgba(255, 255, 255, 0.55);
  stroke: #e4e8ef;
  stroke-width: 14;
}

.gauge-fill {
  fill: none;
  stroke: url(#gaugeGradient);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 722.566;
  stroke-dashoffset: 722.566;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.gauge-readout {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-align: center;
  pointer-events: none;
}

.gauge-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.15rem;
  color: var(--text-primary);
  font-size: 4.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.05em;
  line-height: 1;
  transform-origin: center;
  will-change: transform, filter;
}

.gauge-value.is-updating {
  background:
    linear-gradient(
      105deg,
      var(--text-primary) 0%,
      var(--sonic-red-deep) 36%,
      var(--sonic-coral) 50%,
      var(--sonic-red-deep) 64%,
      var(--text-primary) 100%
    );
  background-size: 280% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation:
    value-shimmer 1.1s cubic-bezier(0.22, 1, 0.36, 1) forwards,
    value-pulse 0.9s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}

@keyframes value-shimmer {
  from {
    background-position: 220% 0;
  }
  to {
    background-position: -120% 0;
  }
}

@keyframes value-pulse {
  0% {
    transform: scale(1);
    filter: drop-shadow(0 0 0 transparent);
  }
  40% {
    transform: scale(1.06);
    filter: drop-shadow(0 0 18px var(--sonic-red-glow));
  }
  70% {
    transform: scale(0.985);
    filter: drop-shadow(0 0 10px rgba(242, 27, 32, 0.13));
  }
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 0 transparent);
  }
}

.gauge-unit {
  color: var(--sonic-red-deep);
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: 0;
  -webkit-text-fill-color: initial;
}

.gauge-label {
  margin-top: 0.5rem;
  color: var(--text-tertiary);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.28em;
}

.meta {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.meta-item {
  min-width: 0;
  min-height: 76px;
  padding: 0.75rem 0.55rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-align: center;
  border: 1px solid rgba(39, 50, 68, 0.07);
  border-radius: 15px;
  background: var(--surface-muted);
}

.meta-key {
  color: var(--text-tertiary);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.meta-val {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--text-primary);
  font-size: 0.92rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.analytics-section {
  width: 100%;
  margin-top: 2rem;
}

.analytics-heading {
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.section-kicker {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--sonic-red-deep);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.analytics-heading h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.range-toggle {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 7px 18px rgba(44, 54, 70, 0.07);
}

.range-btn {
  min-height: 34px;
  padding: 0.4rem 0.8rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.range-btn:hover:not(:disabled) {
  color: var(--sonic-red-deep);
}

.range-btn.is-active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--sonic-red-deep), var(--sonic-red));
  box-shadow: 0 5px 14px var(--sonic-red-glow);
}

.range-btn:focus-visible {
  outline: 3px solid rgba(201, 21, 28, 0.24);
  outline-offset: 2px;
}

.range-btn:disabled {
  cursor: progress;
  opacity: 0.7;
}

.analytics-notice {
  margin-bottom: 0.85rem;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(161, 92, 0, 0.2);
  border-radius: 14px;
  background: rgba(245, 158, 11, 0.08);
  color: #7d4b0b;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.5;
}

.analytics-card {
  position: relative;
  width: 100%;
  margin-bottom: 1rem;
  padding: 1.35rem 1.5rem 1.25rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 24px;
  background: var(--surface);
  box-shadow:
    0 18px 48px rgba(44, 54, 70, 0.1),
    inset 0 0 0 1px var(--border);
  backdrop-filter: blur(20px) saturate(120%);
  -webkit-backdrop-filter: blur(20px) saturate(120%);
}

.analytics-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 1.5rem;
  width: 54px;
  height: 3px;
  border-radius: 0 0 999px 999px;
  background: linear-gradient(90deg, var(--sonic-red-deep), var(--sonic-coral));
}

.insight-header {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.insight-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.insight-header p {
  margin: 0.28rem 0 0;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 550;
  line-height: 1.45;
}

.history-stats {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.history-stats span {
  min-width: 72px;
  padding: 0.48rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  border: 1px solid rgba(39, 50, 68, 0.07);
  border-radius: 11px;
  background: var(--surface-muted);
  color: var(--text-tertiary);
  font-size: 0.56rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
}

.history-stats strong {
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: none;
}

.chart-shell {
  position: relative;
  width: 100%;
  height: 255px;
  overflow: hidden;
  border: 1px solid rgba(39, 50, 68, 0.08);
  border-radius: 17px;
  background:
    linear-gradient(180deg, rgba(255, 232, 233, 0.32), transparent 60%),
    var(--surface-muted);
}

.consumption-chart {
  height: 190px;
}

.chart-shell svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-loading,
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
}

.chart-loading::before {
  content: '';
  width: 9px;
  height: 9px;
  margin-right: 0.55rem;
  border-radius: 50%;
  background: var(--sonic-red);
  box-shadow: 0 0 0 0 var(--sonic-red-glow);
  animation: loading-pulse 1.4s ease-out infinite;
}

@keyframes loading-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--sonic-red-glow);
  }
  75%,
  100% {
    box-shadow: 0 0 0 9px transparent;
  }
}

.chart-grid-line {
  stroke: rgba(39, 50, 68, 0.1);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-axis-label {
  fill: var(--text-tertiary);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 10px;
  font-weight: 650;
}

.history-area {
  fill: url(#historyAreaGradient);
}

.history-line {
  fill: none;
  stroke: var(--sonic-red-deep);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
}

.history-end-dot {
  fill: var(--surface-solid);
  stroke: var(--sonic-red);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.consumption-bar {
  fill: var(--sonic-red);
  opacity: 0.86;
}

.consumption-bar.is-zero {
  fill: rgba(39, 50, 68, 0.11);
  opacity: 1;
}

.consumption-metrics {
  margin-bottom: 1rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}

.consumption-metric {
  min-width: 0;
  min-height: 76px;
  padding: 0.72rem 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  border: 1px solid rgba(39, 50, 68, 0.07);
  border-radius: 14px;
  background: var(--surface-muted);
  text-align: center;
}

.metric-label {
  color: var(--text-tertiary);
  font-size: 0.57rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.metric-value {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.insight-note {
  margin: 0.75rem 0 0;
  color: var(--text-secondary);
  font-size: 0.67rem;
  font-weight: 550;
  line-height: 1.45;
  text-align: center;
}

.footer {
  position: relative;
  z-index: 1;
  padding: 0.85rem 1rem 1.2rem;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 550;
  letter-spacing: 0.11em;
  text-align: center;
  text-transform: uppercase;
}

.brand-sonic {
  color: var(--sonic-red-deep);
  font-weight: 800;
  letter-spacing: 0.13em;
}

.footer-divider {
  margin: 0 0.55rem;
  color: var(--text-tertiary);
}

@media (max-width: 620px) {
  .page {
    padding-top: 1.4rem;
  }

  .brand {
    max-width: 440px;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
    text-align: center;
  }

  .logo-frame {
    width: min(100%, 340px);
    height: 132px;
    margin: 0 auto;
  }

  .brand-text {
    align-items: center;
  }

  .brand-title {
    font-size: 2.35rem;
  }

  .insight-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-stats {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .history-stats span {
    min-width: 0;
  }

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

@media (max-width: 520px) {
  .page {
    padding-right: 1rem;
    padding-left: 1rem;
  }

  .gauge-card {
    padding: 1.25rem 1rem 1rem;
    border-radius: 24px;
  }

  .gauge-card::before {
    left: 1.25rem;
    right: 1.25rem;
  }

  .gauge-wrap {
    max-width: 250px;
  }

  .gauge-value {
    font-size: 3.8rem;
  }

  .meta {
    grid-template-columns: 1fr;
  }

  .meta-item {
    min-height: 62px;
  }

  .analytics-section {
    margin-top: 1.5rem;
  }

  .analytics-card {
    padding: 1.2rem 1rem 1rem;
    border-radius: 21px;
  }

  .analytics-card::before {
    left: 1rem;
  }

  .chart-shell {
    height: 230px;
  }

  .consumption-chart {
    height: 175px;
  }

  .footer-divider {
    display: block;
    height: 0.3rem;
    color: transparent;
  }
}

@media (max-width: 410px) {
  .analytics-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .range-toggle {
    width: 100%;
  }

  .range-btn {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ambient,
  .status-dot,
  .refresh-icon,
  .gauge-fill,
  .gauge-value,
  .chart-loading::before {
    animation: none !important;
    transition: none !important;
  }
}

/* Analytical console */
.page {
  max-width: 1240px;
}

.brand,
.gauge-card {
  max-width: 760px;
}

.analytics-console {
  width: 100%;
  margin-top: 2.25rem;
  overflow: hidden;
  border: 1px solid rgba(39, 50, 68, 0.12);
  border-radius: 28px;
  background: rgba(248, 250, 253, 0.94);
  box-shadow: 0 28px 75px rgba(44, 54, 70, 0.14);
  backdrop-filter: blur(18px);
}

.console-header {
  padding: 1.75rem 2rem 1.4rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  background: linear-gradient(135deg, #fff 5%, #fff6f6 100%);
}

.console-header h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: clamp(1.7rem, 3vw, 2.25rem);
  font-weight: 850;
  letter-spacing: -0.045em;
}

.console-header p,
.panel-toolbar p,
.table-header p {
  margin: 0.4rem 0 0;
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.45;
}

.console-freshness {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(20, 128, 74, 0.14);
  border-radius: 999px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.8);
  font-size: 0.7rem;
  font-weight: 650;
}

.freshness-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-good);
  box-shadow: 0 0 0 4px rgba(20, 128, 74, 0.11);
}

.analytics-tabs {
  padding: 0 2rem;
  display: flex;
  gap: 0.35rem;
  border-top: 1px solid rgba(39, 50, 68, 0.06);
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.analytics-tab {
  position: relative;
  padding: 1rem 1.15rem 0.9rem;
  border: 0;
  color: var(--text-tertiary);
  background: transparent;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 750;
  cursor: pointer;
}

.analytics-tab::after {
  content: '';
  position: absolute;
  right: 1rem;
  bottom: -1px;
  left: 1rem;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--sonic-red-deep);
  opacity: 0;
  transform: scaleX(0.35);
  transition: 180ms ease;
}

.analytics-tab:hover,
.analytics-tab.is-active {
  color: var(--sonic-red-deep);
}

.analytics-tab.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

.tab-icon {
  margin-right: 0.35rem;
  font-size: 0.9rem;
}

.analytics-toolbar {
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid rgba(39, 50, 68, 0.08);
  background: #f9fafc;
}

.preset-group {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.24rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.analytics-console .range-btn {
  min-width: 44px;
  padding: 0.52rem 0.68rem;
  border: 0;
  border-radius: 9px;
  color: var(--text-secondary);
  background: transparent;
  font: inherit;
  font-size: 0.69rem;
  font-weight: 750;
  cursor: pointer;
  transition: 160ms ease;
}

.analytics-console .range-btn:hover {
  color: var(--sonic-red-deep);
  background: var(--sonic-red-soft);
}

.analytics-console .range-btn.is-active {
  color: #fff;
  background: var(--sonic-red-deep);
  box-shadow: 0 5px 14px rgba(201, 21, 28, 0.22);
}

.custom-range-btn {
  min-width: 66px !important;
}

.active-period {
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 650;
}

.custom-range-panel {
  padding: 1rem 2rem;
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.custom-range-panel[hidden] {
  display: none;
}

.custom-range-panel label,
.select-control {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: var(--text-tertiary);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.custom-range-panel input,
.select-control select {
  min-height: 38px;
  padding: 0.48rem 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  outline: 0;
  color: var(--text-primary);
  background: #fff;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.custom-range-panel input:focus,
.select-control select:focus {
  border-color: var(--sonic-red-deep);
  box-shadow: 0 0 0 3px rgba(201, 21, 28, 0.1);
}

.date-arrow {
  padding-bottom: 0.65rem;
  color: var(--text-tertiary);
}

.primary-action,
.secondary-action,
.page-btn,
.text-action {
  min-height: 38px;
  padding: 0.55rem 0.82rem;
  border-radius: 10px;
  font: inherit;
  font-size: 0.69rem;
  font-weight: 750;
  cursor: pointer;
  transition: 160ms ease;
}

.primary-action {
  border: 1px solid var(--sonic-red-deep);
  color: #fff;
  background: var(--sonic-red-deep);
  box-shadow: 0 5px 14px rgba(201, 21, 28, 0.16);
}

.primary-action:hover {
  background: #aa1117;
}

.secondary-action,
.page-btn {
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  background: #fff;
}

.secondary-action:hover,
.page-btn:hover:not(:disabled) {
  color: var(--sonic-red-deep);
  border-color: rgba(201, 21, 28, 0.4);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.analytics-notice {
  margin: 1rem 2rem 0;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(161, 92, 0, 0.2);
  border-radius: 12px;
  color: #7e4c05;
  background: #fff8e9;
  font-size: 0.75rem;
  line-height: 1.45;
}

.analytics-notice.is-error {
  border-color: rgba(201, 21, 28, 0.2);
  color: var(--sonic-red-deep);
  background: #fff1f2;
}

.analytics-panel {
  padding: 1.65rem 2rem 2rem;
}

.analytics-panel[hidden] {
  display: none;
}

.metric-grid {
  display: grid;
  gap: 0.7rem;
}

.metric-grid-six {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.metric-card {
  min-width: 0;
  min-height: 124px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.35rem;
  border: 1px solid rgba(39, 50, 68, 0.09);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 25px rgba(44, 54, 70, 0.055);
}

.metric-card.is-primary {
  border-color: rgba(201, 21, 28, 0.2);
  background: linear-gradient(145deg, #fff, #fff3f3);
}

.metric-card > span {
  color: var(--text-tertiary);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-card > strong {
  overflow-wrap: anywhere;
  color: var(--text-primary);
  font-size: clamp(1.15rem, 2vw, 1.48rem);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.045em;
}

.metric-card.is-primary > strong {
  color: var(--sonic-red-deep);
}

.metric-card > small {
  color: var(--text-tertiary);
  font-size: 0.62rem;
  font-weight: 500;
  line-height: 1.35;
}

.overview-grid {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.analytics-console .analytics-card {
  padding: 1.25rem;
  overflow: hidden;
  border: 1px solid rgba(39, 50, 68, 0.1);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 9px 28px rgba(44, 54, 70, 0.065);
}

.analytics-console .analytics-card::before {
  display: none;
}

.panel-title,
.panel-toolbar,
.table-header,
.chart-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.panel-title h3,
.panel-toolbar h3,
.table-header h3 {
  margin: 0.18rem 0 0;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.panel-toolbar h3 {
  font-size: 1.35rem;
}

.eyebrow {
  color: var(--sonic-red-deep);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.text-action {
  min-height: auto;
  padding: 0.25rem;
  border: 0;
  color: var(--sonic-red-deep);
  background: transparent;
}

.canvas-shell {
  position: relative;
  width: 100%;
}

.canvas-shell.compact {
  height: 245px;
  margin-top: 0.8rem;
}

.canvas-shell.large {
  height: 390px;
  margin-top: 0.8rem;
}

.chart-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-tertiary);
  background: rgba(255, 255, 255, 0.82);
  font-size: 0.76rem;
  font-weight: 650;
}

.chart-state[hidden] {
  display: none;
}

.intelligence-card {
  margin-top: 0.85rem;
}

.read-only-badge {
  padding: 0.3rem 0.5rem;
  border: 1px solid rgba(39, 50, 68, 0.12);
  border-radius: 999px;
  color: var(--text-tertiary);
  background: var(--surface-muted);
  font-size: 0.53rem;
  font-weight: 800;
  letter-spacing: 0.11em;
}

.intelligence-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.intelligence-item {
  padding: 0.8rem;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  border-radius: 13px;
  background: var(--surface-muted);
}

.insight-marker {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 0.26rem;
  border-radius: 50%;
  background: var(--sonic-red);
  box-shadow: 0 0 0 4px var(--sonic-red-soft);
}

.intelligence-item strong {
  display: block;
  color: var(--text-primary);
  font-size: 0.72rem;
}

.intelligence-item p {
  margin: 0.3rem 0 0;
  color: var(--text-secondary);
  font-size: 0.67rem;
  line-height: 1.5;
}

.panel-toolbar {
  align-items: flex-end;
  margin-bottom: 1rem;
}

.control-row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.compact-control select {
  min-height: 34px;
  padding-top: 0.38rem;
  padding-bottom: 0.38rem;
}

.large-chart-card,
.table-card {
  margin-top: 0.85rem;
}

.chart-legend-row {
  color: var(--text-tertiary);
  font-size: 0.65rem;
}

.legend-pair {
  display: flex;
  gap: 1rem;
}

.legend-key {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  font-weight: 700;
}

.legend-key span {
  width: 18px;
  height: 3px;
  border-radius: 4px;
  background: var(--sonic-red-deep);
}

.legend-key.average span {
  background: #9299a6;
}

.analysis-strip {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.analysis-strip article {
  padding: 1rem 1.1rem;
  border: 1px solid rgba(39, 50, 68, 0.09);
  border-left: 3px solid var(--sonic-red-deep);
  border-radius: 13px;
  background: #fff;
}

.analysis-strip span {
  display: block;
  color: var(--text-tertiary);
  font-size: 0.59rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.analysis-strip strong {
  display: block;
  margin-top: 0.35rem;
  color: var(--text-primary);
  font-size: 1.15rem;
  font-weight: 850;
}

.analysis-strip p {
  margin: 0.3rem 0 0;
  color: var(--text-tertiary);
  font-size: 0.62rem;
}

.table-header {
  margin-bottom: 0.9rem;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid rgba(39, 50, 68, 0.09);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.71rem;
  white-space: nowrap;
}

th {
  padding: 0.72rem 0.8rem;
  color: var(--text-tertiary);
  background: #f5f7fa;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
}

td {
  padding: 0.72rem 0.8rem;
  border-top: 1px solid rgba(39, 50, 68, 0.07);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

tbody tr:hover td {
  background: #fff8f8;
}

.table-emphasis {
  color: var(--text-primary);
  font-weight: 800;
}

.quality-good,
.quality-limited {
  font-weight: 750;
}

.quality-good {
  color: var(--status-good);
}

.quality-limited {
  color: var(--status-warn);
}

.empty-table {
  height: 90px;
  color: var(--text-tertiary);
  text-align: center;
}

.pagination {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text-tertiary);
  font-size: 0.66rem;
}

.pagination > div {
  display: flex;
  gap: 0.4rem;
}

.page-btn {
  min-height: 32px;
  padding: 0.38rem 0.62rem;
}

@media (max-width: 1040px) {
  .metric-grid-six {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-card {
    min-height: 112px;
  }
}

@media (max-width: 760px) {
  .analytics-console {
    border-radius: 22px;
  }

  .console-header,
  .analytics-toolbar,
  .panel-toolbar,
  .table-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .console-header,
  .analytics-toolbar,
  .custom-range-panel,
  .analytics-panel {
    padding-right: 1.15rem;
    padding-left: 1.15rem;
  }

  .analytics-tabs {
    padding: 0 0.8rem;
    overflow-x: auto;
  }

  .analytics-tab {
    flex: 1 0 auto;
  }

  .analytics-toolbar {
    gap: 0.6rem;
  }

  .preset-group {
    width: 100%;
    overflow-x: auto;
  }

  .analytics-console .range-btn {
    flex: 1 0 auto;
  }

  .custom-range-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .date-arrow {
    display: none;
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }

  .intelligence-grid {
    grid-template-columns: 1fr;
  }

  .control-row {
    width: 100%;
  }

  .chart-instructions {
    display: none;
  }

  .canvas-shell.large {
    height: 330px;
  }
}

@media (max-width: 560px) {
  .metric-grid-six {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card {
    min-height: 108px;
    padding: 0.85rem;
  }

  .analysis-strip {
    grid-template-columns: 1fr;
  }

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

  .canvas-shell.compact {
    height: 215px;
  }

  .canvas-shell.large {
    height: 285px;
  }

  .select-control {
    flex: 1 1 130px;
  }

  .primary-action,
  .secondary-action {
    flex: 1 1 auto;
  }
}
