/* 各个页面自己的布局 */

/* ---- 登录 ---- */

.login {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
  /* 一束从上方落下来的光 */
  background:
    radial-gradient(
      900px 520px at 50% -140px,
      light-dark(#fff, rgb(255 255 255 / 0.09)),
      transparent 70%
    ),
    var(--bg);
}

.login-card {
  display: grid;
  gap: 28px;
  width: min(380px, 100%);
  animation: page-in 600ms var(--ease-out) both;
}

.login-head {
  display: grid;
  justify-items: center;
  gap: 18px;
  text-align: center;
}

.login-mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(160deg, var(--progress-from), var(--progress-to));
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.45),
    inset 0 -1px 0 rgb(0 0 0 / 0.12),
    0 2px 4px rgb(0 0 0 / 0.1),
    0 18px 36px -10px var(--accent-ring);
}

.login-title {
  font: 700 30px/1.15 var(--font-display);
  letter-spacing: -0.022em;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-submit {
  margin-top: 8px;
}

.login-hint {
  margin-top: -8px;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

/* ---- 看板：几个数 ---- */

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

.kpi {
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 132px;
  padding: 20px 22px 18px;
}

.kpi-label {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}

.kpi-value {
  font: 600 32px/1.15 var(--font-display);
  letter-spacing: -0.02em;
}

.kpi-of {
  color: var(--text-3);
  font-weight: 500;
}

.kpi-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-2);
  font-size: 13px;
}

.kpi-sub-part {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.kpi-sub-bad {
  color: var(--bad);
}

/* Worker 页最上面那一条汇总：五格并排，中间细线隔开；窄屏两三格一行 */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 20px;
  overflow: hidden;
}

.stat {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 16px 20px;
  border-left: 1px solid var(--hairline);
}

.stat:first-child {
  border-left: 0;
}

.stat-label {
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
}

.stat-value {
  font: 600 26px/1.2 var(--font-display);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-value-bad {
  color: var(--bad);
}

.stat-of {
  color: var(--text-3);
  font-size: 17px;
  font-weight: 500;
}

.stat-sub {
  color: var(--text-3);
  font-size: 12px;
}

.stat-sub-bad {
  color: var(--bad);
}

.stat-meter {
  margin-top: 8px;
  background: var(--ok-tint);
}

.stat-meter > .meter-fill {
  background: var(--ok);
}

@media (max-width: 900px) {
  .stat-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stat:nth-child(4) {
    border-left: 0;
  }

  .stat:nth-child(n + 4) {
    border-top: 1px solid var(--hairline);
  }
}

@media (max-width: 560px) {
  .stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat {
    padding: 12px 14px;
    border-left: 0;
  }

  .stat:nth-child(even) {
    border-left: 1px solid var(--hairline);
  }

  .stat:nth-child(n + 3) {
    border-top: 1px solid var(--hairline);
  }

  .stat:nth-child(4) {
    border-left: 1px solid var(--hairline);
  }

  .stat:last-child {
    grid-column: 1 / -1;
    border-left: 0;
  }

  .stat-value {
    font-size: 22px;
  }
}

/* 比例条：没填满的部分是同一个颜色的浅一档 */
.meter {
  align-self: end;
  height: 4px;
  margin-top: 10px;
  border-radius: 2px;
  background: var(--accent-tint);
}

.meter-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  clip-path: inset(0 calc(100% - var(--p, 0%)) 0 0 round 2px);
  transition: clip-path var(--dur-spring-soft) var(--spring-soft);
}

/* ---- 看板：图表 ---- */

.charts {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.chart-card {
  display: flex;
  flex-direction: column;
  padding: 22px 24px 18px;
}

.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 24px;
}

.chart-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.chart-sub {
  margin-top: 2px;
  color: var(--text-2);
  font-size: 13px;
}

/* 这一页上唯一的大数 */
.hero {
  margin-top: 14px;
  font: 600 52px/1 var(--font-display);
  letter-spacing: -0.03em;
}

.hero-unit {
  margin-left: 6px;
  color: var(--text-2);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
}

/* 大数底下一行小的：预计时速 */
.hero-sub {
  margin-top: 8px;
  color: var(--text-2);
  font-size: 13px;
}

.hero-sub > strong {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chart-aside {
  display: grid;
  justify-items: end;
  gap: 2px;
  text-align: right;
}

.chart-aside-value {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.chart-aside-label {
  color: var(--text-2);
  font-size: 12px;
}

.chart {
  position: relative;
  flex: 1;
  min-height: 190px;
  margin: 16px 0 0;
}

.chart-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  border-radius: 8px;
}

.chart-grid {
  stroke: var(--chart-grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart-baseline {
  stroke: var(--chart-axis);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart-tick {
  fill: var(--text-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-line {
  fill: none;
  stroke: var(--chart-series);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area {
  fill: var(--chart-wash);
}

/* 端点和悬停点都带一圈表面色，压在线上也看得清 */
.chart-dot {
  fill: var(--chart-series);
  stroke: var(--surface);
  stroke-width: 2;
}

.chart-cross {
  stroke: var(--chart-axis);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart-bar {
  fill: var(--chart-series);
  transition: opacity var(--dur-fast) ease;
}

.chart-bar-empty {
  fill: var(--chart-grid);
}

.chart-hit {
  fill: transparent;
  cursor: default;
}

.chart-hit:focus-visible {
  outline: none;
}

.chart-svg.is-hovering .chart-bar:not(.is-active) {
  opacity: 0.4;
}

.chart-value {
  fill: var(--text);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chart-value-past {
  fill: var(--text-2);
  font-weight: 500;
}

.chart-empty {
  position: absolute;
  inset: 0 0 24px;
  display: grid;
  place-items: center;
  color: var(--text-3);
  font-size: 13px;
  pointer-events: none;
}

.tip {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  display: grid;
  gap: 2px;
  min-width: 96px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--glass-strong);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow:
    inset 0 0.5px 0 var(--glass-rim),
    var(--shadow-float);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity var(--dur-fast) ease;
}

.tip[hidden] {
  display: grid !important;
  opacity: 0;
}

/* 数值在前，说明在后 */
.tip-value {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.tip-label {
  color: var(--text-2);
}

.tip-rows {
  display: grid;
  grid-template-columns: auto auto;
  gap: 1px 14px;
  margin-top: 4px;
  padding-top: 5px;
  border-top: 1px solid var(--hairline);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.tip-rows > :nth-child(even) {
  color: var(--text);
  text-align: right;
}

/* ---- 看板：任务流转的三列 ---- */

/* 三列等高：只有"最近结束"有内容时，另外两张卡不再缩成一小块、
   底下留一大片空白 */
.flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 14px;
}

.lane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lane-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 18px 20px 10px;
}

.lane-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.lane-count {
  color: var(--text-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* 宽屏上三列并排：列表封顶约六行，多出来的在卡片里滚。不封顶的话"最近结束"
   一长，另外两张空卡也跟着被拉成一大片 */
@media (min-width: 1001px) {
  .lane-list {
    max-height: 384px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }
}

/* 等高之后空的那一列会被拉长：空状态在剩下的地方里居中，不贴在顶上 */
.lane-empty {
  display: grid;
  flex: 1;
  place-items: center;
  min-height: 72px;
  padding: 8px 20px 24px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.5;
}

.lane-more {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  border-top: 1px solid var(--hairline);
  color: var(--accent);
  font-size: 13px;
  transition: background var(--dur-fast) ease;
}

.lane-more:focus-visible {
  outline-offset: -3px;
}

@media (hover: hover) {
  .lane-more:hover {
    background: var(--fill-faint);
  }
}

.item {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  padding: 12px 20px;
}

.item-id {
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-params {
  margin-left: 8px;
  color: var(--text-3);
  font-weight: 400;
}

.item-side {
  color: var(--text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.item-bar {
  grid-column: 1 / -1;
}

.item-meta {
  display: flex;
  grid-column: 1 / -1;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.item-meta > b {
  color: var(--text);
  font-weight: 500;
}

/* ---- 看板：异常的 Worker ---- */

.wrow {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.wrow-name {
  font-weight: 500;
}

.wrow-reason {
  overflow: hidden;
  color: var(--text-2);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-bad {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bad-tint);
  color: var(--bad);
}

/* ---- 新建任务 ---- */

.form {
  display: grid;
  gap: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.parse {
  display: grid;
  gap: 8px;
}

.parse-summary {
  color: var(--text-2);
  font-size: 13px;
}

.parse-summary > b {
  color: var(--text);
  font-weight: 600;
}

.parse-errors {
  display: grid;
  gap: 2px;
  max-height: 96px;
  overflow-y: auto;
  color: var(--bad);
  font-size: 12px;
  line-height: 1.5;
}

/* ---- 详情 ---- */

.detail-progress {
  display: grid;
  gap: 10px;
}

.detail-figure {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.detail-count {
  font: 600 34px/1.1 var(--font-display);
  letter-spacing: -0.02em;
}

.detail-count-of {
  color: var(--text-3);
  font-size: 20px;
  font-weight: 500;
}

.facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px 20px;
  font-size: 14px;
}

.facts > dt {
  color: var(--text-2);
}

.facts > dd {
  overflow-wrap: anywhere;
  text-align: right;
}

/* 详情里的卡片：一组"名字 / 值"，像设置里的分组列表一样一行一条，行间一条细线 */
.detail-card {
  gap: 0 20px;
  padding: 2px 16px;
  border-radius: 16px;
  background: var(--surface-sunken);
}

.detail-card > dt,
.detail-card > dd {
  padding: 11px 0;
  border-bottom: 1px solid var(--hairline);
}

.detail-card > :nth-last-child(-n + 2) {
  border-bottom: 0;
}

.detail-card > dd {
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

/* 进度条右边写百分比；下面一行写读得多快、还要多久 */
.detail-track {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.detail-percent {
  min-width: 3.2em;
  color: var(--text-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.detail-pace {
  color: var(--text-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* 短链接：点了开原文（新标签页），旁边一个复制 */
.detail-out {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.detail-out-link {
  overflow: hidden;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 13px;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 3px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (hover: hover) {
  .detail-out-link:hover {
    text-decoration-color: currentColor;
  }
}

.code {
  max-height: 200px;
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  overflow: auto;
  background: var(--surface-sunken);
  font: 12.5px/1.6 var(--font-mono);
  tab-size: 2;
  white-space: pre;
}

.block-title {
  margin-bottom: 8px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}

.copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: right;
}

.copy > svg {
  color: var(--text-3);
  transition: color var(--dur-fast) ease;
}

@media (hover: hover) {
  .copy:hover > svg {
    color: var(--accent);
  }
}

/* 分配情况：一行一个 worker。不单独滚动，跟着整个对话框一起滚 */
.shares {
  display: grid;
  gap: 2px;
  margin: 0 -8px;
}

.share {
  display: grid;
  grid-template-columns: 8ch minmax(40px, 1fr) 11ch;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.share-count {
  color: var(--text-2);
  text-align: right;
}

/* ---- 设置 ---- */

.settings {
  display: grid;
  gap: 32px;
}

.group-title {
  margin: 0 0 8px 20px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}

.group-note {
  margin: 8px 20px 0;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.5;
}

.setting {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 24px;
  padding: 14px 20px;
}

.setting-label {
  font-weight: 500;
}

.setting-desc {
  grid-column: 1;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.45;
  text-wrap: pretty;
}

.setting-error {
  grid-column: 1 / -1;
  color: var(--bad);
  font-size: 12px;
}

/* 没有说明的那种：控件和名字在同一行，不往下占第二行 */
.setting-plain .setting-control {
  grid-row: 1;
  margin-bottom: 0;
}

.setting-control {
  display: flex;
  grid-row: 1 / span 2;
  grid-column: 2;
  align-items: center;
  align-self: center;
  gap: 8px;
}

.setting-input {
  width: 116px;
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  appearance: textfield;
  background: var(--fill);
  color: var(--text);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  box-shadow: 0 0 0 0 transparent;
  transition:
    background var(--dur-fast) ease,
    box-shadow var(--dur) var(--ease-out);
}

.setting-input::-webkit-inner-spin-button,
.setting-input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.setting-input:focus,
.setting-input:focus-visible {
  outline: none;
  background: var(--surface);
  box-shadow:
    inset 0 0 0 1px var(--accent),
    0 0 0 4px var(--accent-ring);
}

.setting-input[aria-invalid="true"] {
  box-shadow:
    inset 0 0 0 1px var(--bad),
    0 0 0 4px var(--bad-tint);
}

/* 改过还没保存的，左边亮一个点 */
.setting.is-dirty > .setting-label::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 8px 2px -14px;
  border-radius: 50%;
  background: var(--accent);
}

.setting-unit {
  min-width: 3em;
  color: var(--text-2);
  font-size: 13px;
}

.setting-value {
  color: var(--text-2);
  font-size: 14px;
}

/* ---- 窄屏 ---- */

@media (max-width: 1000px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .charts,
  .flow {
    grid-template-columns: minmax(0, 1fr);
  }

  /* 单列时把最要紧的"进行中"提到最前面 */
  .lane-running {
    order: -1;
  }
}

@media (max-width: 720px) {
  .kpis,
  .charts,
  .flow {
    gap: 10px;
  }

  .charts {
    margin-top: 10px;
  }

  .kpi {
    min-height: 116px;
    padding: 16px 16px 14px;
  }

  .kpi-value {
    font-size: 26px;
  }

  .chart-card {
    padding: 18px 18px 14px;
  }

  .hero {
    font-size: 44px;
  }

  .form-row {
    grid-template-columns: minmax(0, 1fr);
  }

  /* 左边的说明是这一行的主角：输入框和单位收窄一点，给它多留一截，
     免得"一个出口 24 小时内绑定几个账号"折成三行 */
  .setting {
    gap: 4px 14px;
    padding: 14px 16px;
  }

  .setting-control {
    gap: 6px;
  }

  /* 放得下七位数（单个任务的数量上限默认就是 1000000） */
  .setting-input {
    width: 92px;
    padding: 0 10px;
  }

  .setting-unit {
    min-width: 1.2em;
  }

  /* 设置页里的分段控件跟着缩一档：四个两字选项按默认内边距要 220px，
     窄屏上会把左边的标签挤没 */
  .setting-seg .seg-item {
    padding: 0 10px;
  }

  .group-title {
    margin-left: 16px;
  }

  .group-note {
    margin: 8px 16px 0;
  }
}

/* ---- 任务详情：小标题后面那一截（"分配给 Worker  25 个 · 都做完了"） ---- */

.block-note {
  color: var(--text-3);
  font-weight: 400;
}

