/**
 * 易诉通 · 数据大屏样式
 * 版权所有 © 上海薯瓜信息科技有限公司
 * Shanghai Shugua Information Technology Co., Ltd.
 */

/* ===== Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #12141c;
  --bg-card: #252833;
  --bg-card-soft: #2e323e;
  --border: rgba(255, 255, 255, 0.06);
  --text: #ffffff;
  --text-muted: #a8b0c0;
  --gold: #c8a26a;
  --purple: #7c5cff;
  --cyan: #4fc3f7;
  --radius: 14px;
  --header-h: 64px;

  /* Design canvas 2763×1557 font tokens (px@design → rem) */
  --fs-title: 2.375rem; /* 38 */
  --fs-main: 3.9375rem; /* 63 */
  --fs-tab: 1.6875rem; /* 27 */
  --fs-badge: 1.5625rem; /* 25 */
  --fs-body: 1.5rem; /* 24 */
  --fs-sm: 1.3125rem; /* 21 */
  --fs-legend: 1.375rem; /* 22 */
  --fs-range: 1.1875rem; /* 19 */
  --fs-donut: 1.25rem; /* 20 */
  --fs-cal-badge: 1rem; /* 16 */
}

html {
  /* Design 2763 wide; scale for common desktops (~14px@1920, up to 17px) */
  font-size: clamp(13px, calc(100vw * 16 / 2200), 17px);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.35;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

ul {
  list-style: none;
}

.dashboard {
  --page-gutter: 1.4vw;
  min-height: 100vh;
  padding: 0.7vh var(--page-gutter) 0.6vh;
  max-width: none;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.7vh;
  box-sizing: border-box;
}

/* ===== Header ===== */
.header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  min-height: var(--header-h);
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

.header-left {
  justify-self: start;
}

.header-center {
  text-align: center;
}

.header-right {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.page-title {
  font-size: var(--fs-title);
  font-weight: 600;
  letter-spacing: 1px;
  line-height: 1.2;
}

.update-time {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: 4px;
}

.link-btn {
  color: #a78bfa;
  font-size: var(--fs-sm);
  transition: color 0.2s;
}

.link-btn:hover {
  color: #c4b5fd;
}

.welcome {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* Project Select */
.project-select {
  position: relative;
}

.project-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0.55em 0.9em;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: var(--fs-body);
  color: var(--text);
  transition: border-color 0.2s, background 0.2s;
}

.project-btn:hover,
.project-select.open .project-btn {
  border-color: rgba(124, 92, 255, 0.5);
  background: var(--bg-card-soft);
}

.grid-icon {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  width: 14px;
  height: 14px;
}

.grid-icon i {
  display: block;
  background: var(--cyan);
  border-radius: 1px;
}

.chevron {
  opacity: 0.7;
  transition: transform 0.2s;
}

.project-select.open .chevron {
  transform: rotate(180deg);
}

.project-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 160px;
  background: rgba(36, 42, 56, 0.98);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  padding: 6px;
  z-index: 200;
}

.project-list > li {
  position: relative;
}

.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  text-align: left;
}

.project-item:hover,
.project-list > li:hover > .project-item {
  background: rgba(255, 255, 255, 0.08);
}

.project-item .arrow {
  opacity: 0.5;
  font-size: 12px;
  margin-left: 16px;
}

.batch-menu {
  display: none;
  position: absolute;
  left: calc(100% + 4px);
  top: 0;
  min-width: 140px;
  background: rgba(36, 42, 56, 0.98);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  padding: 6px;
}

.project-list > li:hover > .batch-menu {
  display: block;
}

.batch-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  text-align: left;
  color: var(--text-muted);
}

.batch-item:hover,
.batch-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

/* ===== Main Grid ===== */
.main-grid {
  /* Design column ratio ≈ 610 : 1370 : 650 */
  display: grid;
  grid-template-columns: 22fr 49.5fr 23.5fr;
  gap: var(--page-gutter);
  flex: 1;
  align-items: stretch;
  min-height: 0;
}

.col-left,
.col-center,
.col-right {
  display: flex;
  flex-direction: column;
  gap: var(--page-gutter);
  min-width: 0;
}

/* ===== Cards ===== */
.card-badge {
  display: inline-block;
  padding: 0.28em 0.9em;
  background: linear-gradient(135deg, #6a4cff, #8b6bff);
  border-radius: 999px;
  font-size: var(--fs-badge);
  font-weight: 500;
  margin: 0 auto 0.7em;
  line-height: 1.3;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85em 1em 1em;
  position: relative;
  text-align: center;
  flex: 1;
  min-height: 0;
}

/* 核心数据：不参与列内压缩，底边距与左右一致 */
.core-card {
  flex: 0 0 auto;
  min-height: auto;
  padding: 1em;
  overflow: visible;
}

.core-card .eq-bars {
  flex-shrink: 0;
}

.core-grid,
.donut-wrap,
.case-type-stats,
.eq-bars,
.rank-list,
.cal-nav,
.cal-weekdays,
.cal-days,
.trend-header,
.trend-chart {
  text-align: left;
}

/* ===== Core Data ===== */
.core-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55em;
}

.core-item {
  background: var(--bg-card-soft);
  border-radius: 8px;
  padding: 0.7em 0.45em;
  text-align: center;
}

.core-label {
  font-size: calc(var(--fs-body) * 0.78);
  font-family: "Times New Roman", "Songti SC", Georgia, serif;
  color: rgba(255, 255, 255, 0.88);
  margin-bottom: 0.25em;
}

.core-value {
  font-family: "Times New Roman", "Songti SC", Georgia, serif;
  font-size: var(--fs-body);
  font-weight: 700;
  color: var(--gold);
  line-height: 1.2;
}

.eq-bars {
  display: flex;
  align-items: flex-end;
  gap: 0;
  height: 3.4em;
  margin-top: 0.85em;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}

.eq-track {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 100%;
  width: max-content;
  animation: track-rtl 10s linear infinite;
}

@keyframes track-rtl {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

.eq-track .bar {
  width: 4px;
  flex-shrink: 0;
  border-radius: 1px 1px 0 0;
  opacity: 0.95;
  height: var(--h, 16px);
  transform-origin: bottom center;
  animation: bar-pulse 1.6s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes bar-pulse {
  0%,
  100% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(0.72);
  }
}

/* ===== Donut ===== */
.donut-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  padding: 4px 2px 8px;
}

.donut-chart {
  flex: 1 1 150px;
  min-width: 0;
  min-height: 0;
  height: auto;
  max-height: 200px;
  aspect-ratio: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.donut-stage {
  position: relative;
  width: min(100%, 180px);
  height: min(100%, 180px);
  max-width: 100%;
  max-height: 100%;
}

.donut-svg {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: block;
  color: transparent;
}

.donut-center {
  position: absolute;
  inset: 28%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
  line-height: 1.15;
}

.donut-name {
  display: block;
  color: #fff;
  fill: none;
  font-size: 13px;
  font-family: "Times New Roman", "Songti SC", Georgia, serif;
}

.donut-pct {
  display: block;
  color: #fff;
  fill: none;
  font-size: 20px;
  font-weight: 700;
  font-family: "Times New Roman", "Songti SC", Georgia, serif;
  margin-top: 2px;
}

.donut-seg:hover {
  opacity: 1 !important;
}

.donut-card .card-badge {
  white-space: nowrap;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 0.75em;
  font-size: var(--fs-body);
  color: rgba(255, 255, 255, 0.88);
  flex-shrink: 0;
  font-family: "Times New Roman", "Songti SC", Georgia, serif;
  cursor: pointer;
  user-select: none;
}

.donut-legend li {
  opacity: 0.65;
  transition: opacity 0.2s, transform 0.2s;
}

.donut-legend li.active,
.donut-legend li:hover {
  opacity: 1;
  transform: translateX(2px);
}

.donut-legend .sq {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 8px;
  vertical-align: middle;
}

/* ===== Case Type ===== */
.case-type-body {
  padding: 4px 4px 2px;
}

.bar-pcts {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-badge);
  color: #fff;
  margin-bottom: 0.35em;
  padding: 0 2px;
}

.stacked-bar {
  display: flex;
  height: 18px;
  border-radius: 999px;
  overflow: hidden;
  margin: 0 0 16px;
}

.seg {
  height: 100%;
  transition: width 1s cubic-bezier(0.22, 1, 0.36, 1);
}

.seg-mediate {
  background: #f5d547;
}

.seg-litigate {
  background: #e53935;
}

.case-type-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  font-size: 13px;
  color: #fff;
}

.ct-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ct-left {
  align-items: flex-start;
  text-align: left;
}

.ct-right {
  align-items: flex-end;
  text-align: right;
}

.ct-col strong {
  color: #fff;
  font-size: var(--fs-body);
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.ct-label {
  font-size: calc(var(--fs-body) * 0.85);
  color: rgba(255, 255, 255, 0.92);
}

.ct-dot {
  display: none;
}

/* ===== Metric Cards ===== */
.metric-card {
  border-radius: 18px;
  padding: 0.9em 1.2em 0.85em;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  flex-shrink: 0;
}

.metric-orange {
  background: linear-gradient(95deg, #e5bd53 0%, #e4b15e 18%, #e09a72 42%, #d87a8e 68%, #c84d8e 100%);
}

.metric-blue {
  background: linear-gradient(95deg, #7ecff5 0%, #78b4f4 28%, #7f8ef0 55%, #8b6cf5 78%, #7a3de8 100%);
}

.metric-tabs {
  display: flex;
  justify-content: center;
  gap: 0.6em;
  margin-bottom: 0.25em;
}

.metric-tab {
  padding: 0.28em 0.95em;
  border-radius: 999px;
  font-size: var(--fs-tab);
  background: rgba(255, 255, 255, 0.32);
  color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(6px);
  transition: background 0.2s, color 0.2s, transform 0.15s;
  line-height: 1.3;
}

.metric-orange .metric-tab.active {
  background: #6a4cff;
  color: #fff;
}

.metric-blue .metric-tab.active {
  background: #e8a35a;
  color: #fff;
}

.metric-tab:not(.active):hover {
  background: rgba(255, 255, 255, 0.45);
}

.metric-main {
  font-family: "Times New Roman", "Songti SC", Georgia, serif;
  font-size: var(--fs-main);
  font-weight: 700;
  letter-spacing: 1px;
  text-align: center;
  line-height: 1.1;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  margin: 0.15em 0 0.4em;
  color: #fff;
}

.metric-subrow {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4em;
  background: transparent;
  border-radius: 0;
  padding: 0.15em 0 0;
}

.metric-sub {
  text-align: center;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2em;
}

.sub-label {
  display: block;
  font-size: calc(var(--fs-body) * 0.78);
  opacity: 0.95;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  color: #fff;
  line-height: 1.25;
}

.sub-value {
  display: block;
  font-size: calc(var(--fs-body) * 1.28);
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.case-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px 8px;
  background: transparent;
  border-radius: 0;
  padding: 4px 0 2px;
}

.case-cell {
  text-align: center;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2em;
}

.case-label {
  font-size: calc(var(--fs-body) * 0.78);
  opacity: 0.95;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  color: #fff;
  line-height: 1.25;
}

.case-num {
  font-size: calc(var(--fs-body) * 1.28);
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ===== Trend ===== */
.trend-card {
  padding-bottom: 8px;
}

.trend-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 4px;
}

.trend-header .card-badge {
  margin-bottom: 0;
}

.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  flex: 1;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-legend);
  color: #fff;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s, opacity 0.2s;
}

.legend-item .legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s;
}

.legend-item.active {
  color: #fff;
  opacity: 1;
}

.legend-item:not(.active) {
  color: #6b7280;
}

.legend-item:not(.active) .legend-dot {
  background: #6b7280 !important;
  box-shadow: none;
}

.legend-item:hover {
  opacity: 0.9;
}

.trend-ranges {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.range-btn {
  padding: 0.25em 0.65em;
  border-radius: 4px;
  font-size: var(--fs-range);
  color: var(--text-muted);
  background: transparent;
  transition: background 0.2s, color 0.2s;
}

.range-btn:hover {
  color: var(--text);
}

.range-btn.active {
  background: rgba(124, 92, 255, 0.35);
  color: var(--text);
}

.trend-chart {
  width: 100%;
  height: clamp(200px, 28vh, 360px);
  flex: 1;
  min-height: 180px;
}

/* ===== Calendar ===== */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cal-title {
  font-size: var(--fs-body);
  font-weight: 500;
}

.cal-nav-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--bg-card-soft);
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s;
}

.cal-nav-btn:hover {
  background: rgba(124, 92, 255, 0.3);
  color: var(--text);
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: calc(var(--fs-body) * 0.75);
  color: var(--text-muted);
  margin-bottom: 6px;
}

.cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 13px;
  border-radius: 6px;
  color: var(--text);
  padding: 2px 0;
  min-height: 42px;
}

.cal-num {
  line-height: 1.1;
  font-weight: 500;
  font-size: calc(var(--fs-body) * 0.85);
}

.cal-sub {
  font-size: calc(var(--fs-cal-badge) * 0.7);
  color: var(--text-muted);
  line-height: 1.1;
  margin-top: 1px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-day.empty {
  visibility: hidden;
}

.cal-day.today {
  background: rgba(124, 92, 255, 0.25);
  color: #c4b5fd;
  font-weight: 600;
}

.cal-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 1.15em;
  height: 1.15em;
  padding: 0 0.2em;
  background: #e53935;
  color: #fff;
  font-size: calc(var(--fs-cal-badge) * 0.65);
  font-weight: 700;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transform: translate(15%, -15%);
  pointer-events: none;
}

/* ===== Rank ===== */
.rank-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rank-row {
  display: grid;
  grid-template-columns: 3.6em 1fr 3em;
  align-items: center;
  gap: 0.5em;
  font-size: var(--fs-legend);
  opacity: 0;
  transform: translateX(12px);
  animation: rank-in 0.45s ease forwards;
}

.rank-idx {
  display: none;
}

.rank-name {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-bar-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
}

.rank-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #4fc3f7, #81d4fa);
  transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes rank-in {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.rank-val {
  text-align: right;
  color: var(--text);
  font-size: calc(var(--fs-legend) * 0.9);
}

.cal-day.has-hearing {
  cursor: pointer;
}

.cal-day.flash {
  animation: cal-flash 0.55s ease;
}

@keyframes cal-flash {
  0%,
  100% {
    background: transparent;
  }
  40% {
    background: rgba(229, 57, 53, 0.35);
  }
}

.cal-badge {
  animation: badge-pop 0.45s ease both;
}

@keyframes badge-pop {
  from {
    transform: translate(15%, -15%) scale(0);
  }
  to {
    transform: translate(15%, -15%) scale(1);
  }
}

/* ===== Entrance / Toast ===== */
.card.enter,
.metric-card.enter {
  animation: card-enter 0.5s ease both;
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  background: rgba(30, 35, 48, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.footer {
  font-size: var(--fs-cal-badge);
  color: var(--text-muted);
  padding: 0.3em 0 0.5em;
}

/* ===== Responsive ===== */
@media (max-width: 1280px) {
  .main-grid {
    grid-template-columns: minmax(240px, 0.95fr) minmax(380px, 2fr) minmax(220px, 0.9fr);
  }

  .metric-subrow {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }

  .case-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .trend-chart {
    height: 220px;
  }

  .donut-chart {
    height: 160px;
    max-height: 160px;
  }

  .sub-value,
  .case-num {
    font-size: calc(var(--fs-body) * 1.28);
  }
}

/* Tablet: keep three columns but ease crowding */
@media (max-width: 1024px) {
  .header {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
  }

  .welcome {
    display: inline;
    font-size: 0.85rem;
  }

  .main-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 12px;
  }

  .col-left,
  .col-center,
  .col-right {
    gap: 12px;
  }

  .metric-tab {
    font-size: calc(var(--fs-tab) * 0.85);
  }

  .metric-main {
    font-size: calc(var(--fs-main) * 0.78);
  }

  .card-badge {
    font-size: calc(var(--fs-badge) * 0.85);
  }
}

/* Phone & small tablet: single column, metrics first */
@media (max-width: 900px) {
  html {
    font-size: 15px;
  }

  .dashboard {
    padding: 12px 16px 16px;
    gap: 12px;
    max-width: 100%;
  }

  .header {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "title actions"
      "select welcome";
    gap: 8px 10px;
    min-height: 0;
    text-align: left;
    align-items: center;
  }

  .header-left {
    grid-area: select;
    justify-self: start;
  }

  .header-center {
    grid-area: title;
    text-align: left;
  }

  .header-right {
    display: contents;
  }

  .welcome {
    grid-area: welcome;
    justify-self: end;
    align-self: center;
    font-size: 0.8rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions {
    grid-area: actions;
    justify-self: end;
    align-self: start;
    gap: 4px;
  }

  .header-actions .link-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 0 4px;
  }

  .page-title {
    font-size: 1.25rem;
    letter-spacing: 0;
  }

  .update-time {
    font-size: 0.8rem;
    margin-top: 2px;
  }

  .project-btn {
    font-size: 0.9rem;
    padding: 0.45em 0.75em;
    gap: 8px;
  }

  .link-btn {
    font-size: 0.9rem;
  }

  .main-grid {
    grid-template-columns: 1fr;
    grid-template-areas: none;
    gap: 12px;
  }

  .col-center {
    order: 1;
  }

  .col-left {
    order: 2;
  }

  .col-right {
    order: 3;
  }

  .col-center,
  .col-left,
  .col-right {
    grid-area: auto;
    grid-column: auto;
    grid-row: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    min-width: 0;
  }

  .card,
  .metric-card {
    flex: none;
    width: 100%;
  }

  .card {
    padding: 0.9em 1em 1.05em;
  }

  .core-card {
    padding: 1em;
  }

  .card-badge {
    font-size: 0.95rem;
    margin-bottom: 0.75em;
  }

  .metric-card {
    padding: 1em 1em 0.95em;
    border-radius: 16px;
  }

  .metric-tabs {
    gap: 0.5em;
    flex-wrap: wrap;
  }

  .metric-tab {
    font-size: 0.95rem;
    padding: 0.35em 0.85em;
  }

  .metric-main {
    font-size: clamp(2rem, 9vw, 2.75rem);
    margin: 0.2em 0 0.65em;
  }

  .metric-subrow {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.55em 0.75em;
  }

  .metric-sub {
    align-items: flex-start;
    text-align: left;
    padding: 0.15em 0;
  }

  .metric-sub:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .sub-label,
  .case-label {
    font-size: 0.75rem;
    white-space: nowrap;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.9;
  }

  .sub-value,
  .case-num {
    font-size: 1.28rem;
    font-weight: 700;
    word-break: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .case-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.55em 0.75em;
  }

  .case-cell {
    align-items: flex-start;
    text-align: left;
    padding: 0.15em 0;
  }

  .core-grid {
    gap: 0.65em;
  }

  .core-item {
    padding: 0.85em 0.55em;
  }

  .core-label {
    font-size: 0.85rem;
  }

  .core-value {
    font-size: 1.15rem;
  }

  .donut-wrap {
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    padding: 2px 0 4px;
  }

  .donut-chart {
    width: min(100%, 180px);
    height: auto;
    max-height: 180px;
    aspect-ratio: 1;
    min-width: 0;
    flex: 0 0 auto;
  }

  .donut-stage {
    width: 100%;
    height: 100%;
  }

  .donut-legend {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.55em 1em;
    font-size: 0.9rem;
    width: 100%;
    padding: 0 4px;
  }

  .donut-legend li:hover,
  .donut-legend li.active {
    transform: none;
  }

  .trend-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .trend-header .card-badge {
    align-self: flex-start;
    margin: 0;
  }

  .trend-legend {
    gap: 8px 12px;
  }

  .legend-item {
    font-size: 0.85rem;
  }

  .trend-ranges {
    margin-left: 0;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .range-btn {
    text-align: center;
    font-size: 0.8rem;
    padding: 0.4em 0.2em;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 6px;
  }

  .trend-chart {
    height: 220px;
    min-height: 200px;
  }

  .cal-day {
    min-height: 44px;
    aspect-ratio: auto;
    padding: 6px 2px 4px;
  }

  .cal-num {
    font-size: 0.9rem;
  }

  .cal-sub {
    font-size: 0.65rem;
  }

  .cal-badge {
    font-size: 0.65rem;
  }

  .rank-name,
  .rank-val {
    font-size: 0.85rem;
  }

  .batch-menu {
    left: 0;
    top: 100%;
    position: relative;
    display: none;
    margin-top: 2px;
    box-shadow: none;
    border: none;
    background: rgba(0, 0, 0, 0.25);
  }

  .project-list > li:hover > .batch-menu,
  .project-list > li.open > .batch-menu {
    display: block;
  }

  .project-menu {
    min-width: min(260px, calc(100vw - 32px));
    max-height: 70vh;
    overflow-y: auto;
  }
}

@media (max-width: 480px) {
  .dashboard {
    padding: 10px 14px 14px;
  }

  .metric-subrow {
    grid-template-columns: repeat(2, 1fr);
  }

  .metric-main {
    font-size: clamp(1.75rem, 10vw, 2.35rem);
  }

  .page-title {
    font-size: 1.1rem;
  }

  .header {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "title actions"
      "select welcome";
  }

  .header-left {
    justify-self: start;
  }

  .welcome {
    justify-self: end;
  }

  .project-btn {
    width: 100%;
    justify-content: center;
  }
}
