:root {
  --blue: #4d76ff;
  --blue-2: #27ccd9;
  --gold: #ffc51b;
  --violet: #8668f6;
  --green: #22c55e;
  --red: #ef4444;
  --ink: #182033;
  --muted: #8a94a8;
  --line: #e6ecf5;
  --panel: #ffffff;
  --page: #f4f7ff;
  --soft-blue: #eaf2ff;
  --shadow: 0 18px 52px rgba(47, 76, 130, 0.1);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 1120px;
  background:
    linear-gradient(120deg, rgba(235, 242, 255, 0.88), rgba(248, 251, 255, 0.92) 42%, rgba(241, 245, 255, 0.92)),
    var(--page);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial,
    sans-serif;
  letter-spacing: 0;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.mobile-app {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: rgba(255, 255, 255, 0.82);
  border-right: 1px solid var(--line);
  padding: 16px 14px;
  backdrop-filter: blur(18px);
  z-index: 3;
}

.brand {
  display: grid;
  place-items: center;
  height: 72px;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(135deg, #111827 0%, #22314a 100%);
  border: 1px solid #eef3fb;
  color: #fff;
  text-decoration: none;
}

.brand-text {
  display: block;
  font-size: 24px;
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1;
}

.side-nav {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 8px;
  color: #717b90;
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
}

.side-link.active,
.side-link:hover {
  background: #e6f0ff;
  color: var(--blue);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f1f5fb;
  font-size: 13px;
  line-height: 1;
}

.side-link.active .nav-icon {
  background: var(--blue);
  color: #fff;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 68px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
}

.top-tabs {
  display: flex;
  align-items: center;
  gap: 14px;
}

.top-tab {
  position: relative;
  border: 0;
  background: transparent;
  color: #5f687a;
  padding: 21px 8px;
  font-size: 16px;
  font-weight: 700;
}

.top-tab.active-under::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 10px;
  height: 4px;
  border-radius: 999px;
  background: var(--blue);
}

.account {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #5d6678;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: #f4f7fb;
  color: #6b7280;
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #b8d8ff, #ffd36b);
  color: #24324b;
  font-weight: 900;
}

.logout-btn {
  min-height: 30px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #fff;
  color: #647084;
  padding: 0 10px;
  font-weight: 800;
}

.page-head,
.filters,
.dashboard-card,
.analysis-card,
.entry-card {
  width: min(1420px, calc(100vw - 268px));
  margin-left: auto;
  margin-right: auto;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 24px;
}

.page-head h1 {
  margin: 0 0 10px;
  font-size: 24px;
  line-height: 1.1;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.sync-status {
  margin-top: 6px !important;
  color: var(--blue) !important;
}

.range-area {
  position: relative;
}

.range-controls {
  display: flex;
  gap: 8px;
}

.range-btn,
.secondary-btn,
.ghost-btn,
.primary-btn {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  background: #fff;
  color: #232a39;
  font-weight: 800;
  font-size: 14px;
}

.range-btn.active {
  background: #dce9ff;
  color: var(--blue);
}

.calendar-popover {
  position: absolute;
  top: 58px;
  right: 0;
  z-index: 8;
  width: min(680px, calc(100vw - 292px));
  border: 1px solid #e7edf6;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(36, 55, 95, 0.16);
  overflow: hidden;
}

.calendar-nav {
  display: grid;
  grid-template-columns: 38px 38px 1fr 38px 38px;
  align-items: center;
  min-height: 48px;
  border-bottom: 1px solid #edf1f7;
}

.calendar-nav button {
  height: 38px;
  border: 0;
  background: transparent;
  color: #6b7280;
  font-size: 19px;
  font-weight: 900;
}

.calendar-nav span {
  text-align: center;
  color: #1f2937;
  font-size: 15px;
  font-weight: 900;
}

.calendar-months {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  padding: 18px 22px 16px;
}

.calendar-month h3 {
  margin: 0 0 14px;
  text-align: center;
  color: #1f2937;
  font-size: 17px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px 4px;
}

.calendar-weekday,
.calendar-day {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #202938;
  font-weight: 800;
  font-size: 13px;
}

.calendar-weekday {
  color: #4b5563;
}

.calendar-day.is-muted {
  color: #b2b8c4;
}

.calendar-day.in-range {
  background: #edf4ff;
  color: var(--blue);
}

.calendar-day.applied-range {
  background: #f3f7ff;
  color: #8a97ae;
}

.calendar-day.applied-boundary {
  background: #dbe7ff;
  color: #4d76ff;
}

.calendar-day.selected {
  background: var(--blue);
  color: #fff;
}

.calendar-day:hover {
  background: #e6f0ff;
  color: var(--blue);
}

.calendar-day.selected:hover {
  color: #fff;
}

.calendar-day.applied-boundary:hover,
.calendar-day.applied-range:hover {
  background: #e6f0ff;
  color: var(--blue);
}

.calendar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid #edf1f7;
}

.secondary-btn {
  border-color: #d9e2ef;
  background: #fff;
  color: #344054;
}

.ghost-btn {
  border-color: #dbe3ee;
  background: #f8fbff;
  color: #647084;
}

.primary-btn {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 10px 24px rgba(77, 118, 255, 0.24);
}

.filters {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  margin-bottom: 20px;
}

.select-like,
.date-field {
  display: flex;
  align-items: center;
  min-height: 42px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #edf2f8;
  overflow: hidden;
}

.select-like span,
.date-field span {
  padding: 0 16px;
  color: #344054;
  border-right: 1px solid var(--line);
  font-weight: 800;
}

.select-like select,
.date-field input {
  min-width: 160px;
  border: 0;
  background: #fff;
  color: #8b94a6;
  padding: 0 18px;
  outline: none;
}

.dashboard-card,
.analysis-card,
.entry-card {
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 22px;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(500px, 0.95fr) minmax(480px, 1.05fr);
  gap: 28px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.section-title.split {
  justify-content: space-between;
  align-items: flex-start;
}

.section-title h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.section-title h3,
.category-layout h3,
.mini-chart h3 {
  margin: 0;
  font-size: 16px;
}

.section-title p {
  margin: 8px 0 0;
  color: #8b94a6;
  font-weight: 650;
}

.hint {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 2px solid #a8b1c2;
  color: #a8b1c2;
  font-size: 11px;
  font-weight: 900;
  cursor: help;
  line-height: 1;
}

.hint:hover,
.hint:focus-visible {
  border-color: var(--blue);
  color: var(--blue);
  outline: none;
}

.hint-tooltip {
  position: fixed;
  z-index: 20;
  max-width: 260px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(24, 32, 51, 0.96);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.22);
  pointer-events: none;
}

.metric-group {
  margin-bottom: 16px;
}

.group-label {
  margin: 0 0 10px;
  font-weight: 900;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  min-height: 104px;
  border: 1px solid #e4eaf3;
  border-radius: 8px;
  padding: 14px 16px;
  background: #fff;
  cursor: pointer;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: #a9bfff;
}

.metric-card.primary,
.metric-card.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(77, 118, 255, 0.18) inset;
  background: #f7faff;
}

.metric-card span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #344054;
  font-weight: 800;
  font-size: 15px;
  min-width: 0;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 23px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.metric-card small {
  display: block;
  margin-top: 10px;
  color: #7a8496;
  font-weight: 750;
}

.metric-card small b {
  color: var(--green);
}

.metric-card small b.down {
  color: var(--red);
}

.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.chart-head h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.chart-head p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.chart-head select {
  min-width: 132px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
  outline: none;
}

.line-chart-wrap {
  position: relative;
  height: 360px;
}

.chart-tooltip {
  position: absolute;
  z-index: 4;
  min-width: 200px;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 45px rgba(31, 41, 55, 0.16);
  color: #243043;
  font-weight: 800;
  font-size: 14px;
  pointer-events: none;
}

.chart-tooltip span {
  display: block;
  margin-bottom: 8px;
  color: #7b8495;
}

.chart-tooltip strong {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.chart-tooltip i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--blue);
}

canvas {
  display: block;
  max-width: 100%;
}

#trendCanvas {
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#categoryCanvas {
  width: min(430px, 100%);
  height: 320px;
}

.mini-chart canvas {
  width: 100%;
  height: 260px;
}

.ai-panel {
  margin-top: 24px;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(110deg, #dffbff 0%, #ddecff 48%, #dceeff 100%);
  border: 1px solid #d6e9ff;
}

.ai-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px 0;
}

.ai-head strong {
  color: #2378ff;
  font-size: 18px;
}

.ai-head span {
  margin-left: auto;
  color: #8190aa;
  font-weight: 750;
  font-size: 13px;
}

.ai-head button {
  border: 0;
  background: transparent;
  color: #647084;
  font-weight: 900;
}

.ai-body {
  padding: 14px 22px 20px;
  color: #2f3a4f;
  font-size: 14px;
  line-height: 1.75;
}

.ai-body p {
  margin: 0 0 8px;
}

.ai-body ul {
  margin: 8px 0 0;
  padding-left: 24px;
}

.ai-body b {
  color: #172033;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 4px;
  padding: 0 4px;
}

.tabs {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
}

.analysis-tab {
  position: relative;
  border: 0;
  background: transparent;
  color: #1d2534;
  padding: 0 0 12px;
  font-size: 18px;
  font-weight: 900;
}

.analysis-tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  border-radius: 999px;
  background: var(--blue);
}

.source-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1.08fr) minmax(400px, 0.92fr);
  gap: 20px;
  margin-top: 18px;
}

.source-table,
.rank-table,
.category-table,
.mini-chart {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.source-table {
  padding: 18px 0 8px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 0 18px 16px;
  color: #657083;
  font-weight: 800;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.source-row {
  display: grid;
  grid-template-columns: 210px 1fr 78px;
  align-items: center;
  gap: 14px;
  min-height: 74px;
  padding: 0 18px;
  border-top: 1px solid #edf1f7;
}

.source-row.featured {
  background: #eef3ff;
  border-top: 0;
}

.source-name {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 850;
}

.bar-stack {
  display: flex;
  width: 100%;
  max-width: 440px;
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

.bar-stack i {
  display: block;
  min-width: 3px;
}

.source-value {
  font-weight: 850;
  color: #2f3849;
}

.table-head,
.rank-row,
.category-row {
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 0.8fr 0.8fr;
  gap: 10px;
  align-items: center;
  min-height: 52px;
  padding: 0 18px;
  font-size: 13px;
}

.table-head {
  background: #f6f8fc;
  color: #5e697c;
  font-weight: 900;
}

.rank-row,
.category-row {
  min-height: 76px;
  border-top: 1px solid #edf1f7;
}

.mini-bar {
  width: 88px;
  height: 10px;
  margin-top: 8px;
  border-radius: 999px;
  background: #e8edf5;
  overflow: hidden;
}

.mini-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.up {
  color: var(--green);
  font-weight: 900;
}

.down {
  color: var(--red);
  font-weight: 900;
}

.category-layout {
  display: grid;
  grid-template-columns: minmax(430px, 0.95fr) minmax(480px, 1.05fr);
  gap: 22px;
  margin-top: 28px;
  align-items: center;
}

.donut-wrap {
  display: grid;
  place-items: center;
  min-height: 290px;
}

.user-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin: 20px 0 28px;
}

.user-stat {
  min-height: 82px;
}

.user-stat span {
  color: #7b8597;
  font-weight: 800;
}

.user-stat strong {
  display: block;
  margin-top: 10px;
  font-size: 21px;
  overflow-wrap: anywhere;
}

.user-stat small {
  display: block;
  margin-top: 8px;
  color: #7b8597;
  font-weight: 750;
}

.guest-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.mini-chart {
  padding: 18px;
  min-height: 320px;
}

.mini-chart h3 {
  margin-bottom: 14px;
}

.upload-panel {
  display: grid;
  grid-template-columns: minmax(400px, 1fr) minmax(260px, 0.5fr);
  gap: 16px;
  margin-bottom: 24px;
}

.upload-drop {
  display: grid;
  grid-template-columns: 52px 1fr;
  grid-template-rows: auto auto;
  column-gap: 16px;
  align-items: center;
  min-height: 96px;
  border: 1px dashed #b7c8e7;
  border-radius: 8px;
  padding: 16px;
  background: linear-gradient(135deg, #f8fbff, #eef5ff);
  cursor: pointer;
}

.upload-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #e1edff;
  color: var(--blue);
  font-size: 24px;
  font-weight: 900;
}

.upload-drop strong {
  align-self: end;
  color: #22304a;
  font-size: 16px;
}

.upload-drop small {
  align-self: start;
  margin-top: 6px;
  color: #7c879b;
  font-weight: 700;
}

.upload-options {
  display: grid;
  align-content: center;
  gap: 14px;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mode-switch label {
  position: relative;
  display: grid;
}

.mode-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-switch span {
  display: grid;
  place-items: center;
  min-height: 40px;
  border: 1px solid #dce4f0;
  border-radius: 8px;
  background: #f8fbff;
  color: #647084;
  font-weight: 850;
}

.mode-switch input:checked + span {
  border-color: var(--blue);
  background: #e9f1ff;
  color: var(--blue);
}

#uploadStatus {
  margin: 0;
  color: #7b8597;
  font-weight: 750;
}

.entry-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.entry-form label {
  display: grid;
  gap: 8px;
  color: #667085;
  font-weight: 800;
}

.entry-form input,
.entry-form select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #dce4f0;
  border-radius: 8px;
  padding: 0 12px;
  color: #253044;
  background: #fff;
  outline: none;
}

.entry-form input:focus,
.entry-form select:focus,
.select-like select:focus,
.date-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(77, 118, 255, 0.12);
}

.data-table-wrap {
  margin-top: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
  padding: 0 18px;
  background: #f7f9fd;
}

.table-toolbar span {
  color: #8a94a8;
  font-weight: 800;
}

.data-table {
  max-height: 400px;
  overflow: auto;
}

.data-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-grid th,
.data-grid td {
  height: 44px;
  border-top: 1px solid #eef2f7;
  padding: 0 12px;
  text-align: left;
  white-space: nowrap;
}

.data-grid th {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
  color: #687386;
}

.delete-row {
  border: 0;
  border-radius: 6px;
  padding: 6px 10px;
  background: #fff1f2;
  color: #dc2626;
  font-weight: 850;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  max-width: 340px;
  padding: 14px 18px;
  border-radius: 8px;
  background: #101828;
  color: #fff;
  box-shadow: 0 18px 40px rgba(16, 24, 40, 0.18);
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.login-page {
  min-width: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(77, 118, 255, 0.16), transparent 28%),
    linear-gradient(135deg, #f7fbff 0%, #eef5ff 52%, #f9fbff 100%);
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(320px, 420px);
  gap: 48px;
  align-items: center;
  width: min(1080px, calc(100vw - 48px));
  min-height: 100vh;
  margin: 0 auto;
}

.login-wordmark {
  display: inline-grid;
  place-items: center;
  min-height: 64px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  padding: 0 24px;
  font-size: 28px;
  font-weight: 950;
  letter-spacing: 0;
}

.login-brand h1 {
  margin: 28px 0 12px;
  color: #182033;
  font-size: 34px;
  line-height: 1.18;
}

.login-brand p {
  margin: 0;
  color: #647084;
  font-size: 16px;
  font-weight: 800;
}

.login-card {
  display: grid;
  gap: 18px;
  border: 1px solid #e4eaf3;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 34px;
  box-shadow: 0 22px 58px rgba(47, 76, 130, 0.13);
}

.login-card h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.login-card p {
  margin: 0;
  color: #7b8597;
  font-weight: 750;
}

.login-card label {
  display: grid;
  gap: 8px;
  color: #344054;
  font-weight: 850;
}

.login-card input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #dce4f0;
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
  color: #182033;
  outline: none;
}

.login-card input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(77, 118, 255, 0.12);
}

.login-card .primary-btn {
  justify-content: center;
  min-height: 46px;
  margin-top: 4px;
}

.login-error {
  min-height: 20px;
  color: var(--red) !important;
}

@media (max-width: 1280px) {
  body {
    min-width: 1040px;
  }

  .app-shell {
    grid-template-columns: 204px minmax(836px, 1fr);
  }

  .page-head,
  .filters,
  .dashboard-card,
  .analysis-card,
  .entry-card {
    width: calc(100vw - 244px);
  }

  .overview-grid,
  .source-layout,
  .category-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  html,
  body {
    min-width: 0;
    overflow-x: hidden;
    background: #f5f7fb;
  }

  body {
    font-size: 13px;
  }

  .login-page {
    min-height: 100vh;
    background:
      linear-gradient(180deg, rgba(232, 246, 255, 0.96) 0%, rgba(247, 250, 255, 0.98) 42%, #f5f7fb 100%);
  }

  .login-shell {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 18px;
    width: 100%;
    min-height: 100vh;
    padding: 34px 18px 28px;
  }

  .login-brand {
    width: 100%;
  }

  .login-wordmark {
    min-height: 48px;
    border-radius: 8px;
    padding: 0 18px;
    font-size: 22px;
  }

  .login-brand h1 {
    margin: 22px 0 8px;
    font-size: 28px;
    line-height: 1.15;
  }

  .login-brand p {
    font-size: 14px;
  }

  .login-card {
    width: 100%;
    gap: 16px;
    border-radius: 18px;
    padding: 22px 18px;
    box-shadow: 0 18px 42px rgba(47, 76, 130, 0.12);
  }

  .login-card h2 {
    font-size: 22px;
  }

  .login-card input {
    min-height: 48px;
    border-radius: 12px;
    font-size: 16px;
  }

  .login-card .primary-btn {
    min-height: 48px;
    border-radius: 12px;
    font-size: 16px;
  }

  .app-shell {
    display: none;
  }

  .mobile-app {
    display: block;
    min-height: 100vh;
    padding: 14px 10px 88px;
    background:
      linear-gradient(180deg, #f9fbff 0%, #f4f7fb 38%, #eef4ff 100%);
  }

  .mobile-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 34px;
    padding: 0 8px;
    color: #111827;
  }

  .mobile-status strong {
    font-size: 15px;
    font-weight: 950;
  }

  .mobile-status span {
    max-width: 50vw;
    overflow: hidden;
    color: #8b95a6;
    font-size: 11px;
    font-weight: 850;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-top-tabs {
    display: flex;
    gap: 28px;
    overflow-x: auto;
    padding: 8px 8px 14px;
    scrollbar-width: none;
  }

  .mobile-top-tabs::-webkit-scrollbar,
  .mobile-source-scroll::-webkit-scrollbar {
    display: none;
  }

  .mobile-top-tabs button {
    position: relative;
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    color: #6d7480;
    padding: 0 0 10px;
    font-size: 18px;
    font-weight: 900;
    line-height: 1.1;
  }

  .mobile-top-tabs button.active {
    color: #111827;
  }

  .mobile-top-tabs button.active::after {
    content: "";
    position: absolute;
    left: 2px;
    right: 2px;
    bottom: 0;
    height: 4px;
    border-radius: 999px;
    background: #4d76ff;
  }

  .mobile-hero-card {
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 24px;
    background:
      linear-gradient(140deg, rgba(174, 245, 255, 0.92) 0%, rgba(232, 245, 255, 0.94) 44%, rgba(239, 226, 255, 0.9) 100%);
    box-shadow: 0 16px 34px rgba(71, 111, 185, 0.13);
    padding: 18px 14px 14px;
  }

  .mobile-card-head,
  .mobile-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-card-head h1,
  .mobile-section-head h2,
  .mobile-source-panel h3,
  .mobile-overview h3 {
    margin: 0;
    color: #111827;
    font-size: 22px;
    font-weight: 950;
    line-height: 1.2;
  }

  .mobile-card-head p {
    margin: 6px 0 0;
    color: #8b95a6;
    font-weight: 850;
  }

  .mobile-hint {
    width: 20px;
    height: 20px;
    margin-left: 3px;
    border-width: 2px;
    border-radius: 6px;
    font-size: 12px;
    vertical-align: 2px;
  }

  .mobile-round-btn {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.64);
    color: #8e97a7;
    font-size: 22px;
    font-weight: 950;
  }

  .mobile-live-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px 10px;
    margin-top: 18px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.88);
    padding: 18px 14px;
  }

  .mobile-live-grid div {
    min-width: 0;
  }

  .mobile-live-grid span,
  .mobile-kpi span,
  .mobile-rank-card span,
  .mobile-source-item span {
    display: block;
    color: #707887;
    font-weight: 850;
  }

  .mobile-live-grid strong {
    display: block;
    margin-top: 7px;
    color: #111827;
    font-size: clamp(19px, 5.2vw, 25px);
    font-weight: 950;
    line-height: 1.1;
    overflow-wrap: anywhere;
  }

  .mobile-live-grid small {
    display: block;
    margin-top: 8px;
    color: #9aa3b2;
    font-size: 12px;
    font-weight: 850;
    line-height: 1.35;
  }

  .mobile-rank-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 44px;
    margin: 14px 0;
    border-radius: 999px;
    background: #eaf2ff;
    color: #6f7888;
    font-weight: 900;
  }

  .mobile-rank-pill strong {
    color: #111827;
    font-size: 16px;
  }

  .mobile-rank-pill b {
    color: #1687ff;
    font-size: 22px;
  }

  .mobile-rank-pill i {
    color: #99a2b1;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
  }

  .mobile-range-panel {
    padding: 2px 0 16px;
  }

  .mobile-range-tabs {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .mobile-range-btn {
    flex: 0 0 auto;
    min-width: 0;
    width: 78px;
    min-height: 42px;
    border: 0;
    border-radius: 999px;
    background: #fff;
    color: #646c7a;
    font-size: 15px;
    font-weight: 900;
    box-shadow: 0 8px 20px rgba(31, 41, 55, 0.04);
  }

  .mobile-range-btn.active {
    background: #e2f4ff;
    color: #1687ff;
  }

  #mobilePeriodText {
    position: relative;
    margin: 14px 0 0;
    color: #9aa3b2;
    font-size: 14px;
    font-weight: 850;
    text-align: center;
  }

  #mobilePeriodText::before,
  #mobilePeriodText::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 22%;
    height: 1px;
    background: #e4e9f2;
  }

  #mobilePeriodText::before {
    left: 0;
  }

  #mobilePeriodText::after {
    right: 0;
  }

  .mobile-panel {
    margin: 0 0 14px;
    border: 1px solid rgba(231, 237, 247, 0.95);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 16px 34px rgba(53, 78, 127, 0.07);
    padding: 18px 14px 20px;
  }

  .mobile-section-head {
    align-items: center;
  }

  .mobile-segments {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
  }

  .mobile-segments button {
    min-width: 50px;
    min-height: 36px;
    border: 0;
    border-radius: 14px;
    background: #f1f3f6;
    color: #687180;
    padding: 0 12px;
    font-size: 14px;
    font-weight: 900;
  }

  .mobile-segments button.active {
    background: #eaf8ff;
    color: #1687ff;
  }

  .mobile-kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 20px;
  }

  .mobile-kpi {
    min-width: 0;
    min-height: 96px;
    border: 1px solid #e7edf5;
    border-radius: 16px;
    background: #fff;
    padding: 12px;
  }

  .mobile-kpi.active {
    border-color: #4d76ff;
    background: #f7fbff;
    box-shadow: inset 0 0 0 1px rgba(77, 118, 255, 0.7);
  }

  .mobile-kpi strong {
    display: block;
    margin-top: 8px;
    color: #111827;
    font-size: clamp(20px, 5vw, 24px);
    font-weight: 950;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  .mobile-kpi small {
    display: block;
    margin-top: 8px;
    color: #9aa3b2;
    font-size: 13px;
    font-weight: 850;
  }

  .mobile-overview h3 {
    margin-top: 26px;
    font-size: 20px;
  }

  .mobile-trend-period {
    margin: 8px 0 0;
    color: #98a2b3;
    font-size: 13px;
    font-weight: 850;
  }

  .mobile-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
    margin: 18px 0 10px;
    color: #1f2937;
    font-size: 14px;
    font-weight: 900;
  }

  .mobile-legend span {
    display: inline-flex;
    align-items: center;
    gap: 9px;
  }

  .mobile-legend i {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
  }

  .mobile-legend .blue {
    background: #4d76ff;
  }

  .mobile-legend .cyan {
    background: #27ccd9;
  }

  .mobile-chart-wrap {
    position: relative;
  }

  #mobileTrendCanvas {
    width: 100%;
    height: 238px;
    touch-action: pan-y;
  }

  .mobile-chart-tooltip {
    position: absolute;
    z-index: 5;
    min-width: 180px;
    max-width: min(250px, calc(100vw - 52px));
    border: 1px solid rgba(226, 232, 240, 0.94);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.14);
    padding: 10px 12px;
    pointer-events: none;
  }

  .mobile-chart-tooltip p {
    margin: 0 0 8px;
    color: #667085;
    font-size: 12px;
    font-weight: 900;
  }

  .mobile-chart-tooltip strong {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    color: #111827;
    font-size: 13px;
    font-weight: 900;
  }

  .mobile-chart-tooltip strong + strong {
    margin-top: 7px;
  }

  .mobile-chart-tooltip span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #667085;
    white-space: nowrap;
  }

  .mobile-chart-tooltip i {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
  }

  .mobile-chart-tooltip b {
    color: #111827;
    white-space: nowrap;
  }

  .mobile-source-panel h3 {
    margin-top: 20px;
    font-size: 18px;
  }

  .mobile-source-stack {
    display: flex;
    gap: 5px;
    height: 13px;
    margin: 18px 0 14px;
  }

  .mobile-source-stack i {
    display: block;
    min-width: 8px;
    border-radius: 999px;
  }

  .mobile-source-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 2px 1px 18px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .mobile-source-item {
    position: relative;
    flex: 0 0 112px;
    min-height: 86px;
    border: 1px solid #e7edf5;
    border-radius: 16px;
    background: #fff;
    padding: 13px 12px;
    scroll-snap-align: start;
  }

  .mobile-source-item.active {
    border-color: #4d76ff;
    background: #f7fbff;
    box-shadow: inset 0 0 0 1px rgba(77, 118, 255, 0.72);
  }

  .mobile-source-item span {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #111827;
    font-size: 15px;
  }

  .mobile-source-item span i {
    width: 10px;
    height: 10px;
    border-radius: 50%;
  }

  .mobile-source-item strong {
    display: block;
    margin-top: 10px;
    color: #111827;
    font-size: 22px;
    font-weight: 950;
  }

  .mobile-rank-card {
    border-radius: 18px;
    background: #f6f8fb;
    padding: 16px 14px;
  }

  .mobile-rank-card > div:first-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
  }

  .mobile-rank-card strong {
    color: #111827;
    font-size: 20px;
    font-weight: 950;
  }

  .mobile-rank-row {
    display: grid;
    grid-template-columns: 46px 54px 1fr auto;
    align-items: center;
    gap: 10px;
  }

  .mobile-rank-row b {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: #ffd25a;
    color: #fff;
    font-size: 12px;
    line-height: 1.1;
  }

  .mobile-rank-row span {
    color: #111827;
    font-size: 17px;
    font-weight: 950;
  }

  .mobile-rank-row i {
    height: 10px;
    border-radius: 999px;
    background: #3f6dff;
  }

  .mobile-date-sheet {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    align-items: end;
    background: rgba(17, 24, 39, 0.28);
    padding: 12px;
  }

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

  .mobile-date-card {
    display: grid;
    gap: 14px;
    border-radius: 24px 24px 18px 18px;
    background: #fff;
    padding: 20px 16px 16px;
    box-shadow: 0 -12px 34px rgba(15, 23, 42, 0.14);
  }

  .mobile-date-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-date-head h2 {
    margin: 0;
    color: #111827;
    font-size: 20px;
    font-weight: 950;
  }

  .mobile-date-head p {
    margin: 6px 0 0;
    color: #98a2b3;
    font-size: 13px;
    font-weight: 850;
  }

  .mobile-date-head button {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: #f2f4f7;
    color: #667085;
    font-size: 24px;
    line-height: 1;
  }

  .mobile-date-shortcuts {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .mobile-date-shortcuts::-webkit-scrollbar,
  .mobile-range-tabs::-webkit-scrollbar {
    display: none;
  }

  .mobile-date-shortcuts button {
    flex: 0 0 auto;
    min-height: 34px;
    border: 0;
    border-radius: 999px;
    background: #f2f4f7;
    color: #667085;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 900;
  }

  .mobile-date-shortcuts button.active {
    background: #eaf8ff;
    color: #1687ff;
  }

  .mobile-date-selected {
    display: grid;
    grid-template-columns: 1fr 28px 1fr;
    align-items: center;
    gap: 8px;
    border-radius: 14px;
    background: #f7f9fc;
    padding: 10px 12px;
  }

  .mobile-date-selected span {
    color: #111827;
    font-size: 14px;
    font-weight: 950;
    text-align: center;
  }

  .mobile-date-selected i {
    height: 1px;
    background: #cbd5e1;
  }

  .mobile-calendar-nav {
    display: grid;
    grid-template-columns: 42px 1fr 42px;
    align-items: center;
  }

  .mobile-calendar-nav button {
    display: grid;
    place-items: center;
    height: 38px;
    border: 0;
    border-radius: 12px;
    background: #f2f4f7;
    color: #344054;
    font-size: 24px;
    font-weight: 950;
  }

  .mobile-calendar-nav strong {
    color: #111827;
    font-size: 17px;
    font-weight: 950;
    text-align: center;
  }

  .mobile-calendar-weekdays,
  .mobile-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 5px;
  }

  .mobile-calendar-weekdays span {
    display: grid;
    place-items: center;
    height: 24px;
    color: #98a2b3;
    font-size: 12px;
    font-weight: 900;
  }

  .mobile-calendar-grid button {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    min-width: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #111827;
    font-size: 14px;
    font-weight: 900;
  }

  .mobile-calendar-grid button.is-muted {
    color: #c4cad5;
  }

  .mobile-calendar-grid button.in-range {
    background: #edf6ff;
    color: #1687ff;
  }

  .mobile-calendar-grid button.selected {
    background: #1687ff;
    color: #fff;
    box-shadow: 0 8px 18px rgba(22, 135, 255, 0.25);
  }

  .mobile-calendar-grid button:disabled {
    color: #d7dce5;
    cursor: not-allowed;
  }

  .mobile-date-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .mobile-bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 22;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: 70px;
    border-top: 1px solid #e7edf5;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -8px 24px rgba(31, 41, 55, 0.06);
    backdrop-filter: blur(18px);
  }

  .mobile-bottom-nav button {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 4px;
    border: 0;
    background: transparent;
    color: #8a93a3;
    font-size: 12px;
    font-weight: 850;
  }

  .mobile-bottom-nav button span {
    color: inherit;
    font-size: 22px;
    line-height: 1;
  }

  .mobile-bottom-nav button.active {
    color: #1687ff;
  }

  .toast {
    right: 12px;
    bottom: 84px;
    left: 12px;
    max-width: none;
    text-align: center;
  }
}
