/* ============================================================
   Groww 通用 UI 构件样式（配合 groww-ui-kit.mjs）
   只放构件本身，不写页面级布局，页面样式留在各自 css。
   ============================================================ */

/* ---------- 卡片 ---------- */
.gk-card {
  background: var(--gw-surface);
  border: 1px solid var(--gw-line);
  border-radius: var(--gw-r-lg);
  padding: 14px 16px;
  margin: 0 0 12px;
}
.gk-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.gk-card-head h3 {
  margin: 0;
  font-size: var(--gw-fs-lg);
  font-weight: 600;
  color: var(--gw-ink);
}
.gk-card-head small {
  display: block;
  margin-top: 3px;
  font-size: var(--gw-fs-xs);
  color: var(--gw-muted);
  line-height: 1.45;
}
.gk-card-head > a {
  flex: 0 0 auto;
  font-size: var(--gw-fs-sm);
  color: var(--gw-green9);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

/* ---------- 环形图 ---------- */
.gk-donut {
  position: relative;
  width: var(--gk-donut-size, 132px);
  height: var(--gk-donut-size, 132px);
  flex: 0 0 auto;
}
.gk-donut svg {
  display: block;
}
.gk-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  pointer-events: none;
  text-align: center;
}
.gk-donut-center b {
  font-size: var(--gw-fs-md);
  font-weight: 700;
  color: var(--gw-ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}
.gk-donut-center small {
  font-size: 11px;
  color: var(--gw-muted);
}
.gk-donut-empty,
.gk-bar-empty {
  padding: 22px 0;
  text-align: center;
  font-size: var(--gw-fs-sm);
  color: var(--gw-muted);
}

.gk-donut-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
}
.gk-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 11px;
}
.gk-legend li {
  display: grid;
  grid-template-columns: 9px 1fr auto;
  align-items: center;
  gap: 9px;
  font-size: var(--gw-fs-sm);
  color: var(--gw-ink);
}
.gk-legend i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: block;
}
.gk-legend span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gk-legend b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--gw-ink);
}

/* ---------- 进度条 ---------- */
.gk-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--gw-green2, #e9faf3);
  overflow: hidden;
}
.gk-progress > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--gw-green9);
  transition: width 0.25s ease;
}
.gk-progress-blue > i {
  background: var(--gw-blue);
}
.gk-progress-red > i {
  background: var(--gw-red9);
}
.gk-progress-muted > i {
  background: var(--gw-muted);
}

/* ---------- 多段占比条 ---------- */
.gk-stacked {
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--gw-line);
}
.gk-stacked > i {
  display: block;
  height: 100%;
}

/* ---------- 时间线 ---------- */
.gk-timeline {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  align-items: flex-start;
}
.gk-tl-step {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 62px;
  text-align: center;
}
.gk-tl-dot {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 2px solid var(--gw-line);
  background: var(--gw-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 1;
  color: #fff;
  font-weight: 700;
}
.gk-tl-step b {
  font-size: 11px;
  font-weight: 500;
  color: var(--gw-muted);
  line-height: 1.2;
}
.gk-tl-step small {
  font-size: 10px;
  color: var(--gw-muted);
  font-variant-numeric: tabular-nums;
}
.gk-tl-done .gk-tl-dot {
  border-color: var(--gw-green9);
  background: var(--gw-green9);
}
.gk-tl-done b {
  color: var(--gw-ink);
}
.gk-tl-active .gk-tl-dot {
  border-color: var(--gw-green9);
  background: var(--gw-surface);
  box-shadow: 0 0 0 3px var(--gw-green3);
}
.gk-tl-active b {
  color: var(--gw-green10);
  font-weight: 600;
}
.gk-tl-line {
  flex: 1 1 auto;
  height: 2px;
  margin-top: 8px;
  background: var(--gw-line);
  border-radius: 2px;
}

/* ---------- 柱状图 ---------- */
.gk-bar {
  position: relative;
  padding-top: 16px;
}
.gk-bar-cols {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border-bottom: 1px solid var(--gw-line);
}
.gk-bar-col {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.gk-bar-val {
  font-size: 10px;
  color: var(--gw-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.gk-bar-fill {
  display: block;
  width: 100%;
  max-width: 34px;
  border-radius: 3px 3px 0 0;
  background: var(--gw-green9);
}
.gk-bar-green {
  background: var(--gw-green9);
}
.gk-bar-blue {
  background: var(--gw-blue);
}
.gk-bar-col small {
  font-size: 10px;
  color: var(--gw-muted);
  padding: 4px 0 6px;
  white-space: nowrap;
}
.gk-bar-unit {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 10px;
  color: var(--gw-muted);
}

/* ---------- 开关 ---------- */
.gk-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  cursor: pointer;
}
.gk-switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.gk-switch i {
  width: 40px;
  height: 23px;
  border-radius: 999px;
  background: #d6dbe3;
  display: block;
  position: relative;
  transition: background 0.18s ease;
}
.gk-switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
  transition: transform 0.18s ease;
}
.gk-switch input:checked + i {
  background: var(--gw-green9);
}
.gk-switch input:checked + i::after {
  transform: translateX(17px);
}
.gk-switch input:focus-visible + i {
  outline: 2px solid var(--gw-blue);
  outline-offset: 2px;
}

/* ---------- 分段控件 ---------- */
.gk-segmented {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: #f1f3f7;
  border-radius: 999px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.gk-segmented::-webkit-scrollbar {
  display: none;
}
.gk-segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: var(--gw-fs-sm);
  font-weight: 500;
  color: var(--gw-muted);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.gk-segmented button.active {
  background: var(--gw-surface);
  color: var(--gw-ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12);
}
.gk-segmented button em {
  font-style: normal;
  font-size: 11px;
  color: var(--gw-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- 统计格 ---------- */
.gk-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 10px;
}
.gk-stats > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.gk-stats span {
  font-size: 11px;
  color: var(--gw-muted);
  line-height: 1.3;
}
.gk-stats b {
  font-size: var(--gw-fs-md);
  font-weight: 600;
  color: var(--gw-ink);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.gk-stats b.up {
  color: var(--gw-green10);
}
.gk-stats b.down {
  color: var(--gw-red9);
}

/* ---------- 行情行 ---------- */
.gk-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--gw-line);
  text-decoration: none;
  color: inherit;
}
.gk-row:last-child {
  border-bottom: 0;
}
a.gk-row:active {
  opacity: 0.65;
}
.gk-row-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f1f3f7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--gw-ink);
  overflow: hidden;
}
.gk-row-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gk-row-main b {
  font-size: var(--gw-fs-md);
  font-weight: 600;
  color: var(--gw-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gk-row-main small {
  font-size: 11px;
  color: var(--gw-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gk-row-right {
  flex: 0 0 auto;
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gk-row-right b {
  font-size: var(--gw-fs-md);
  font-weight: 600;
  color: var(--gw-ink);
  font-variant-numeric: tabular-nums;
}
.gk-row-right small {
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.gk-row-right small.up {
  color: var(--gw-green10);
}
.gk-row-right small.down {
  color: var(--gw-red9);
}

/* ---------- 窄屏收敛 ---------- */
@container groww-app (max-width: 380px){
  .gk-donut-wrap {
    gap: 12px;
  }
  .gk-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .gk-tl-step {
    width: 54px;
  }
}
