* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  color-scheme: light dark;
  --bg: #071433;
  --bg-2: #081a3f;
  --grad-1: #102657;
  --grad-2: #17346b;
  --grad-3: #0f3b66;
  --grad-4: #1a4f86;
  --grad-opacity: 0.18;
  --panel: rgba(17, 32, 68, 0.65);
  --card: rgba(22, 40, 78, 0.55);
  --text: #e8f0ff;
  --muted: #a9b8d6;
  --accent: #5aa7ff;
  --good: #46c37b;
  --bad: #ff6b6b;
  --border: rgba(90, 140, 220, 0.35);
  --glass-shadow: 0 20px 50px rgba(6, 20, 50, 0.4);
}

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  min-height: 100vh;
  padding: 18px clamp(20px, 4vw, 48px) 60px;
  position: relative;
  overflow-x: hidden;
  zoom: var(--ui-zoom, 1);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grad-opacity);
  background: linear-gradient(120deg, var(--grad-1), var(--grad-2), var(--grad-3), var(--grad-4));
  background-size: 100% 100%;
}

body[data-theme="blue"] {
  background: radial-gradient(1200px 600px at 20% -10%, #132e6d 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 10%, #0d2b5f 0%, transparent 55%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 100%);
}

body[data-theme="dark"] {
  background: radial-gradient(1200px 600px at 20% -10%, #1a1f2b 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 10%, #101723 0%, transparent 55%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 100%);
}

body[data-theme="light"] {
  background: radial-gradient(1200px 600px at 20% -10%, #d9e4ff 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 10%, #dfe7ff 0%, transparent 55%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 100%);
}

h1 {
  font-size: clamp(24px, 3vw, 32px);
  margin-bottom: 6px;
}

h2 {
  font-size: 20px;
  margin-bottom: 6px;
}
.panel-subtitle {
  margin-bottom: 12px;
}

h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.week-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.week-warning {
  margin-top: 6px;
  font-size: 12px;
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.4);
  padding: 6px 10px;
  border-radius: 10px;
  display: inline-block;
}


#week-select {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
}

.page-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.page-title {
  text-align: center;
  min-width: 240px;
  justify-self: center;
}

.header-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  width: 260px;
}

.menu {
  position: relative;
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.menu-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.menu-bars {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
}

.menu-bar {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--glass-shadow);
  z-index: 10;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.menu-panel.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.menu-section {
  display: grid;
  gap: 8px;
}

.menu-section + .menu-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.menu-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.debug-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.debug-summary {
  font-size: 12px;
}

.debug-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.debug-kpi {
  display: grid;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
}

.debug-kpi strong {
  font-size: 12px;
}

.debug-log-section-title {
  margin-top: 2px;
  padding-top: 2px;
  border-top: 1px solid var(--border);
}

.debug-log {
  max-height: 200px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px;
  display: grid;
  gap: 4px;
}

.debug-line {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
}

.debug-line.good {
  color: var(--good);
}

.debug-line.bad {
  color: var(--bad);
}

.logo-wrap {
  display: flex;
  align-items: center;
  margin-right: 12px;
  gap: 12px;
  width: 220px;
}

.logo {
  height: 48px;
  width: auto;
  object-fit: contain;
}


body:not([data-theme="light"]) .logo {
  filter: invert(1);
}

.status {
  background: var(--panel);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  border: 1px solid var(--border);
}

.layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel {
  background: var(--panel);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.card-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.metric {
  font-size: 28px;
  font-weight: 600;
}

.active-locations-missing {
  color: var(--bad);
  font-weight: 600;
}

.split-panel {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.split-panel-stack {
  grid-template-columns: 1fr;
}

.rank-mobile-list {
  display: none;
}

.rank-mobile-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  cursor: pointer;
}

.rank-mobile-card + .rank-mobile-card {
  margin-top: 10px;
}

.rank-mobile-title {
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--text);
  text-transform: none;
  margin-bottom: 8px;
}

.rank-mobile-stats {
  display: grid;
  gap: 6px;
}

.rank-mobile-stats .badge,
.rank-mobile-stats .delta {
  margin-left: 6px;
}

.rank-mobile-empty {
  margin-top: 4px;
}


.search {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: min(280px, 100%);
}

input[type="search"] {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
}

.table-wrap {
  overflow-x: auto;
  max-height: 520px;
  overflow: auto;
}

/* Scrollbar styling (varies by browser/OS) */
body {
  scrollbar-width: thin;
  scrollbar-color: rgba(90, 140, 220, 0.55) transparent;
}

body[data-theme="light"] {
  scrollbar-color: rgba(120, 140, 180, 0.55) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(90, 140, 220, 0.55);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

body[data-theme="light"] *::-webkit-scrollbar-thumb {
  background: rgba(120, 140, 180, 0.55);
}

/* Scrollbar styling (varies by browser/OS) */
body {
  scrollbar-width: thin;
  scrollbar-color: rgba(90, 140, 220, 0.55) transparent;
}

body[data-theme="light"] {
  scrollbar-color: rgba(120, 140, 180, 0.55) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(90, 140, 220, 0.55);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

body[data-theme="light"] *::-webkit-scrollbar-thumb {
  background: rgba(120, 140, 180, 0.55);
}

#kpi-table th:first-child,
#kpi-table td:first-child,
#new-sites-table th:first-child,
#new-sites-table td:first-child,
#worst-yoy-table th:first-child,
#worst-yoy-table td:first-child,
#best-yoy-table th:first-child,
#best-yoy-table td:first-child {
  position: sticky;
  left: 0;
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 3;
  width: 1%;
  white-space: nowrap;
  text-align: left;
}

#kpi-table tbody td:first-child,
#new-sites-table tbody td:first-child,
#worst-yoy-table tbody td:first-child,
#best-yoy-table tbody td:first-child {
  background: var(--panel);
  color: var(--text);
}

#kpi-table th:first-child::after,
#kpi-table td:first-child::after,
#new-sites-table th:first-child::after,
#new-sites-table td:first-child::after,
#worst-yoy-table th:first-child::after,
#worst-yoy-table td:first-child::after,
#best-yoy-table th:first-child::after,
#best-yoy-table td:first-child::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 2px;
  height: 100%;
  background: var(--border);
  pointer-events: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  text-align: left;
  background: var(--panel);
  color: var(--text);
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 0;
  box-shadow: inset 0 -2px 0 var(--border);
  white-space: normal;
  line-height: 1.2;
  vertical-align: middle;
}

#kpi-table th:first-child,
#new-sites-table th:first-child,
#worst-yoy-table th:first-child,
#best-yoy-table th:first-child {
  z-index: 4;
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--border);
}

.table-section td {
  background: rgba(79, 140, 255, 0.12);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

#kpi-table td,
#new-sites-table td,
#worst-yoy-table td,
#best-yoy-table td {
  white-space: nowrap;
}

#kpi-table thead th:not(:first-child),
#new-sites-table thead th:not(:first-child),
#worst-yoy-table thead th:not(:first-child),
#best-yoy-table thead th:not(:first-child) {
  text-align: center;
}

#kpi-table tbody td:not(:first-child),
#new-sites-table tbody td:not(:first-child),
#worst-yoy-table tbody td:not(:first-child),
#best-yoy-table tbody td:not(:first-child) {
  text-align: center;
}

tbody tr:hover {
  background: rgba(79, 140, 255, 0.08);
  cursor: pointer;
}

.badge {
  padding: 4px 8px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 12px;
}

.badge.good {
  color: var(--good);
}

.badge.bad {
  color: var(--bad);
}

.hidden {
  display: none;
}

.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

.ghost.small {
  padding: 6px 10px;
  font-size: 12px;
}

.chart-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  margin-top: 18px;
}

.drilldown-chart-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.range-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.range-toggle-button {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.range-toggle-button.is-active {
  background: var(--card);
  color: var(--accent);
}

.chart-grid.trend-grid {
  grid-template-columns: 3fr 1fr;
}

.chart-grid.trend-grid .chart-card {
  height: 360px;
}

.chart-card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  height: auto;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

#drilldown .chart-card {
  height: 320px;
}

.chart-event-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 6px 0 8px;
  font-size: 11px;
  color: var(--text);
  min-height: 22px;
  align-items: center;
  max-height: 96px;
  overflow: hidden;
}

#drilldown .chart-event-list {
  margin-bottom: 12px;
}

.chart-event-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(8, 14, 24, 0.35);
  color: var(--text);
}

.chart-event-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--event-color, #ff9f43);
  flex: 0 0 auto;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.chart-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.chart-control input[type="range"] {
  width: 120px;
}

.chart-status {
  font-size: 12px;
  margin-top: 4px;
  margin-bottom: 6px;
}

.chart-card.chart-card-wide {
  min-height: 360px;
}

.chart-card canvas {
  width: 100% !important;
  height: 100% !important;
}

#drilldown .chart-canvas-wrap {
  height: 200px;
}

#drilldown .chart-canvas-wrap canvas {
  height: 100% !important;
}

.custom-fields-panel {
  margin-top: 0;
}

.custom-fields-list {
  list-style: none;
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.custom-fields-list--extra {
  margin-top: 10px;
  display: none;
}

.custom-fields-extra {
  margin-top: 10px;
}

.custom-fields-extra.is-hidden {
  display: none;
}

.custom-fields-extra.is-expanded .custom-fields-list--extra {
  display: grid;
}

.custom-fields-toggle {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.custom-fields-toggle-icon {
  display: inline-block;
  transition: transform 0.2s ease;
}

.custom-fields-extra.is-expanded .custom-fields-toggle-icon {
  transform: rotate(180deg);
}

.custom-fields-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.button-pill {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
}

.custom-fields-note {
  margin-top: 6px;
  font-size: 12px;
}

.button-pill:hover {
  text-decoration: none;
}

.custom-field-link {
  color: var(--accent);
  text-decoration: underline;
  word-break: break-all;
}

.region-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--bad);
  vertical-align: middle;
}

.custom-field-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.custom-field-name {
  font-weight: 600;
  font-size: 16px;
  flex: 1 1 55%;
  word-break: break-word;
}

.custom-field-value {
  font-size: 16px;
  color: var(--muted);
  flex: 1 1 45%;
  text-align: right;
  word-break: break-word;
}

.custom-field-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}

.custom-field-image {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
}

#location-picture-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: auto;
  min-height: 260px;
  align-self: start;
}

#drilldown #location-picture-card {
  height: auto;
}

.drilldown-detail-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  margin-top: 18px;
  align-items: start;
}

.drilldown-region {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.drilldown-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drilldown-region-status {
  font-size: 11px;
  color: var(--muted);
}

.drilldown-region select {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
}

.drilldown-region select option {
  color: var(--text);
  background: var(--card);
}

body[data-theme="dark"] .drilldown-region select {
  background: #0f1726;
  border-color: #2d3a52;
}

body[data-theme="dark"] .drilldown-region select option {
  background: #0f1726;
}

body[data-theme="light"] .drilldown-region select {
  background: #ffffff;
  border-color: #d6dbe4;
  color: #1b2330;
}

body[data-theme="light"] .drilldown-region select option {
  background: #ffffff;
  color: #1b2330;
}

body[data-theme="blue"] .drilldown-region select {
  background: #111f3a;
  border-color: #2b3f63;
}

body[data-theme="blue"] .drilldown-region select option {
  background: #111f3a;
}

.picture-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

#location-picture-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: zoom-in;
}

.picture-controls button,
.modal-controls button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.picture-controls button:disabled,
.modal-controls button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.picture-filename {
  font-size: 12px;
  margin: 0;
  text-align: center;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 24, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 24px;
}

.modal-overlay.is-open {
  display: flex;
}

.modal-content {
  width: min(1100px, 94vw);
  max-height: 90vh;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}

.modal-close {
  align-self: flex-end;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}

#picture-modal-image {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.delta {
  font-weight: 600;
}

.delta.good {
  color: var(--good);
}

.delta.bad {
  color: var(--bad);
}

.loading-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.zoom-control {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.zoom-control input[type="range"] {
  width: 120px;
}

.zoom-value {
  min-width: 44px;
  text-align: right;
}

.theme-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.6);
  cursor: pointer;
}

.theme-blue {
  background: linear-gradient(135deg, #1f4fa3, #2a6bd6);
}

.theme-dark {
  background: #0e1117;
}

.theme-light {
  background: #f4f7ff;
  border-color: rgba(0, 0, 0, 0.2);
}

body[data-theme="dark"] {
  --bg: #0a0f16;
  --bg-2: #0b111a;
  --grad-1: #151a26;
  --grad-2: #0f1623;
  --grad-3: #1a2130;
  --grad-4: #101725;
  --grad-opacity: 0.14;
  --panel: rgba(20, 23, 32, 0.75);
  --card: rgba(24, 27, 38, 0.7);
  --text: #eef1f6;
  --muted: #a7b0c1;
  --accent: #5aa7ff;
  --border: rgba(120, 130, 150, 0.35);
  --glass-shadow: 0 20px 50px rgba(2, 6, 16, 0.6);
}

body[data-theme="light"] {
  --bg: #eff2fb;
  --bg-2: #f6f8ff;
  --grad-1: #e8f0ff;
  --grad-2: #eef2ff;
  --grad-3: #e6ebff;
  --grad-4: #f1f4ff;
  --grad-opacity: 0.28;
  --panel: rgba(255, 255, 255, 0.75);
  --card: rgba(255, 255, 255, 0.7);
  --text: #0f1a33;
  --muted: #5b6b8c;
  --accent: #3264ff;
  --border: rgba(120, 140, 180, 0.35);
  --glass-shadow: 0 16px 40px rgba(20, 40, 90, 0.12);
}

body[data-theme="blue"] {
  --bg: #071433;
  --bg-2: #081a3f;
  --grad-1: #102657;
  --grad-2: #17346b;
  --grad-3: #0f3b66;
  --grad-4: #1a4f86;
  --grad-opacity: 0.18;
  --panel: rgba(17, 32, 68, 0.65);
  --card: rgba(22, 40, 78, 0.55);
  --text: #e8f0ff;
  --muted: #a9b8d6;
  --accent: #5aa7ff;
  --border: rgba(90, 140, 220, 0.35);
  --glass-shadow: 0 20px 50px rgba(6, 20, 50, 0.4);
}

.loading-inline.loaded .spinner {
  display: none;
}

.loading-title {
  font-size: 14px;
  font-weight: 600;
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid rgba(232, 234, 242, 0.2);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

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


@media (max-width: 720px) {
  body {
    padding: 20px 16px 40px;
  }

  .page-header {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .logo-wrap {
    justify-content: center;
    width: auto;
  }

  .header-tools {
    justify-content: center;
    width: auto;
  }

  .panel {
    padding: 16px;
  }

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

  .drilldown-detail-grid {
    grid-template-columns: 1fr;
  }

  .panel-actions {
    justify-content: flex-start;
  }

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

  .chart-control input[type="range"] {
    width: 100%;
  }

  .week-select {
    flex-wrap: wrap;
  }

  .chart-grid.trend-grid {
    grid-template-columns: 1fr;
  }

  .range-toggle {
    max-width: 100%;
    overflow-x: auto;
  }

  .rank-table-wrap {
    display: none;
  }

  .rank-mobile-list {
    display: block;
  }

  th,
  td {
    padding: 8px 10px;
  }
}

@media print {
  body {
    background: #ffffff;
    color: #111111;
  }

  .theme-toggle,
  .loading-inline,
  .panel-actions,
  .search,
  .ghost,
  .chart-control,
  #refresh-week,
  #export-pdf,
  #export-csv {
    display: none !important;
  }

  .panel,
  .card,
  .chart-card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
