/* 仪表盘专用 — 紧凑布局、与全局 app.css 配合 */

.main-content--dash {
  max-width: 1280px;
  padding-top: 12px;
}

/* 顶栏 */
.dash-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle, #eceef2);
}

.dash-subtitle {
  font-size: 12px;
  color: var(--text-muted, #888);
  margin-top: 2px;
  font-weight: 400;
}

.dash-header__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dash-quick {
  display: inline-flex;
  gap: 6px;
}

/* KPI */
.dash-kpi {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.kpi-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border-subtle, #eceef2);
  border-radius: 10px;
  padding: 10px 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 23, 42, 0.06));
  min-width: 0;
}

.kpi-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 10px 0 0 10px;
  background: var(--kpi-accent, var(--primary-color));
}

.kpi-card:nth-child(1) { --kpi-accent: #4a6fa5; }
.kpi-card:nth-child(2) { --kpi-accent: #c45c26; }
.kpi-card:nth-child(3) { --kpi-accent: #2d8a6e; }
.kpi-card:nth-child(4) { --kpi-accent: #6b5b95; }

.kpi-card__value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-color);
  line-height: 1.2;
}

.kpi-card__label {
  font-size: 12px;
  color: var(--text-muted, #888);
}

/* 分段切换 */
.dash-segment {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2, #eef1f6);
  border-radius: 10px;
  gap: 2px;
  margin-bottom: 12px;
}

.dash-segment button {
  border: none;
  background: transparent;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light, #666);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.dash-segment button:hover {
  color: var(--primary-color);
}

.dash-segment button.active {
  background: var(--surface, #fff);
  color: var(--primary-color);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* 卡片变体 */
.card--dash {
  border: 1px solid var(--border-subtle, #eceef2);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 23, 42, 0.06));
  margin-bottom: 12px;
  border-radius: 10px;
  overflow: hidden;
}

.card--dash .card-header {
  padding: 10px 14px;
  min-height: auto;
}

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

.card--dash .card-body {
  padding: 12px 14px;
}

.card--subtle {
  opacity: 0.98;
}

.card--subtle .card-header {
  background: var(--surface-2, #f8f9fc);
}

/* 祭祀洞察 */
.insight-line {
  font-size: 13px;
  line-height: 1.45;
  color: var(--primary-dark, #3d5c8a);
  margin-bottom: 12px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(74, 111, 165, 0.09) 0%, rgba(74, 111, 165, 0.04) 100%);
  border-radius: 8px;
  border: 1px solid rgba(74, 111, 165, 0.12);
}

.worship-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.worship-toolbar label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #888);
}

.worship-period-select {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid var(--border-subtle, #e0e3ea);
  border-radius: 8px;
  background: var(--surface, #fff);
  min-width: 120px;
  max-width: 100%;
}

.worship-matrix-root {
  min-height: 48px;
}

.worship-scale {
  font-size: 11px;
  color: var(--text-muted, #888);
  margin-bottom: 6px;
}

.worship-bars {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  min-height: 178px;
  padding-top: 4px;
}

.worship-bar-item {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.worship-bar-track {
  width: 100%;
  height: 124px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle, #eceef2);
  background: repeating-linear-gradient(
    to top,
    rgba(31, 157, 115, 0.03) 0,
    rgba(31, 157, 115, 0.03) 19%,
    rgba(31, 157, 115, 0.08) 20%
  );
  display: flex;
  align-items: flex-end;
  padding: 5px;
}

.worship-bar-fill {
  display: block;
  width: 100%;
  min-height: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #57d4aa 0%, #1f9d73 100%);
  box-shadow: 0 4px 10px rgba(31, 157, 115, 0.25);
  transition: height 0.25s ease;
}

.worship-bar-name {
  font-size: 11px;
  color: var(--text-muted, #888);
  line-height: 1;
}

.worship-bar-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-color);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

@media (max-width: 720px) {
  .worship-bars {
    gap: 6px;
    min-height: 150px;
  }
  .worship-bar-track {
    height: 96px;
    padding: 3px;
  }
  .worship-bar-name {
    font-size: 10px;
  }
  .worship-bar-val {
    font-size: 13px;
  }
}

/* 排行工具条 */
.rank-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
  margin-bottom: 10px;
}

.field-inline {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-inline label {
  font-size: 11px;
  color: var(--text-muted, #888);
  font-weight: 500;
}

.rank-toolbar select,
.rank-toolbar input[type="search"] {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 13px;
  border: 1px solid var(--border-subtle, #e0e3ea);
  border-radius: 8px;
  background: var(--surface, #fff);
  min-width: 0;
}

.rank-toolbar input[type="search"] {
  width: min(240px, 100%);
}

/* 表格紧凑 */
.table--compact th,
.table--compact td {
  padding: 7px 10px;
  font-size: 12px;
}

.table--compact th {
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--text-light, #555);
}

/* 兑换柱状图 */
.exchange-scale {
  font-size: 11px;
  color: var(--text-muted, #888);
  margin-bottom: 6px;
}

.exchange-columns {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  min-height: 190px;
}

.exchange-col-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.exchange-col-track {
  width: 100%;
  height: 126px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle, #eceef2);
  background: repeating-linear-gradient(
    to top,
    rgba(74, 111, 165, 0.03) 0,
    rgba(74, 111, 165, 0.03) 19%,
    rgba(74, 111, 165, 0.08) 20%
  );
  display: flex;
  align-items: flex-end;
  padding: 5px;
}

.exchange-col-fill {
  width: 100%;
  min-height: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #8bb3da 0%, #4a6fa5 100%);
  box-shadow: 0 4px 10px rgba(74, 111, 165, 0.25);
  transition: height 0.25s ease;
}

.exchange-col-name {
  font-size: 11px;
  color: var(--text-muted, #666);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
}

.exchange-col-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-color);
  font-variant-numeric: tabular-nums;
}

/* 活动弹层 — 避免与全局 .modal-overlay(display:flex) 冲突 */
.dash-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}

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

.dash-modal-box {
  background: var(--surface, #fff);
  border-radius: 12px;
  max-width: 920px;
  width: 100%;
  max-height: 86vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  border: 1px solid var(--border-subtle, #eceef2);
}

.dash-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle, #eceef2);
  flex-shrink: 0;
}

.dash-modal-head h3 {
  font-size: 15px;
  font-weight: 600;
}

.dash-modal-body {
  padding: 12px 16px 16px;
  overflow: auto;
}

.dash-modal-foot {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle, #eceef2);
}

/* WS 状态徽章 */
.ws-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid transparent;
}

.ws-badge.connected {
  background: rgba(82, 196, 26, 0.12);
  color: #389e0d;
  border-color: rgba(82, 196, 26, 0.25);
}

.ws-badge.disconnected {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-muted, #888);
  border-color: var(--border-subtle, #e0e3ea);
}

.ws-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

/* 主体并排：祭祀次数 + 习惯排行 */
.dash-grid-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

@media (min-width: 1100px) {
  .dash-grid-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: start;
  }
  .dash-grid-main .card--dash { margin-bottom: 0; }
}

/* 兑换页双列 */
.dash-grid-2 {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

@media (min-width: 1100px) {
  .dash-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: start;
  }
  .dash-grid-2 .card--dash { margin-bottom: 0; }
}

@media (max-width: 768px) {
  .dash-header {
    flex-direction: column;
    align-items: stretch;
  }
  .dash-header__actions {
    justify-content: space-between;
  }
  .dash-quick {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .dash-kpi {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }
  .kpi-card {
    padding: 8px 4px 8px 8px;
    border-radius: 8px;
  }
  .kpi-card::before {
    width: 2px;
    border-radius: 8px 0 0 8px;
  }
  .kpi-card__value {
    font-size: 15px;
  }
  .kpi-card__label {
    font-size: 10px;
    line-height: 1.2;
  }
  .dash-segment {
    display: flex;
    width: 100%;
  }
  .dash-segment button {
    flex: 1;
    text-align: center;
    padding: 8px 10px;
    font-size: 12px;
  }
  .rank-toolbar input[type="search"] {
    width: 100%;
  }
  .field-inline[style*="flex:1"] {
    flex-basis: 100% !important;
  }
  .exchange-columns {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    min-height: 156px;
  }
  .exchange-col-track {
    height: 94px;
    padding: 3px;
  }
  .exchange-col-name {
    font-size: 10px;
  }
  .exchange-col-val {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .kpi-card__value {
    font-size: 14px;
  }
  .kpi-card__label {
    font-size: 9px;
  }
}
