/* YthLink UI components —— 只含组件层，不含页面布局；依赖 css/tokens.css，须在其后引入 */

/* ===== 卡片 ===== */
.y-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.y-card-hd {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 16px var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.y-card-bd { padding: var(--sp-5); }
.y-card-title {
  font-size: var(--fs-15);
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}
.y-card-sub {
  font-size: var(--fs-12);
  color: var(--text-3);
}
.y-card-act {
  margin-left: auto;
  font-size: var(--fs-12);
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
.y-card-act:hover { color: var(--primary-h); text-decoration: none; }

/* ===== 表格：无外框、无竖线、表头浅底、行 hover 浅底、行高 48、操作列右对齐 ===== */
.y-table {
  width: 100%;
  border-collapse: collapse;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: var(--fs-13);
}
.y-table th {
  height: 40px;
  padding: 0 var(--sp-4);
  background: var(--surface-2);
  border: none;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--text-3);
  text-align: left;
  white-space: nowrap;
}
.y-table td {
  height: 48px;
  padding: 0 var(--sp-4);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
  white-space: nowrap;
}
.y-table tbody tr:last-child td { border-bottom: none; }
.y-table tbody tr:hover { background: var(--surface-2); }
.y-table .y-cell-main {
  font-size: var(--fs-14);
  font-weight: 500;
  line-height: 1.4;
  color: var(--text);
}
.y-cell-sub {
  font-size: var(--fs-12);
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-3);
}
.y-col-act { text-align: right; }
.y-table th.y-col-act,
.y-table td.y-col-act { text-align: right; }
.y-table td.y-col-act .y-row { justify-content: flex-end; }

/* ===== 按钮：只做颜色变化，无位移/缩放 ===== */
.y-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 34px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: var(--sans);
  font-size: var(--fs-13);
  font-weight: 500;
  line-height: 1;
  color: var(--text-2);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.y-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.y-btn:disabled { opacity: .45; cursor: not-allowed; }
.y-btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
.y-btn-primary:hover {
  background: var(--primary-h);
  border-color: var(--primary-h);
}
.y-btn-ghost {
  background: transparent;
  border-color: var(--border-2);
  color: var(--text-2);
}
.y-btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--text);
}
.y-btn-text {
  height: 28px;
  padding: 0 4px;
  border-color: transparent;
  background: transparent;
  font-size: var(--fs-12);
  color: var(--primary);
}
.y-btn-text:hover {
  background: var(--primary-bg);
  color: var(--primary-h);
}
.y-btn-danger {
  background: var(--surface);
  border-color: var(--err);
  color: var(--err);
}
.y-btn-danger:hover {
  background: var(--err);
  border-color: var(--err);
  color: var(--on-primary);
}
.y-btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: var(--fs-12);
}

/* ===== 表单 ===== */
.y-field { display: flex; flex-direction: column; }
.y-label {
  margin: 0 0 6px;
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0;
}
.y-input,
.y-select,
.y-textarea {
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--sans);
  font-size: var(--fs-14);
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.y-input,
.y-select { height: 36px; }
.y-textarea {
  height: auto;
  min-height: 80px;
  padding: 8px 12px;
  line-height: 1.6;
  resize: vertical;
}
.y-input::placeholder,
.y-textarea::placeholder { color: var(--text-3); }
.y-input:focus,
.y-select:focus,
.y-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(180, 85, 47, .12);
}
.y-hint {
  margin: 6px 0 0;
  font-size: var(--fs-12);
  line-height: 1.5;
  color: var(--text-3);
}
/* .y-err 两用：标在控件上 = 错误边框；作为提示元素 = 12px 红字 */
.y-input.y-err,
.y-select.y-err,
.y-textarea.y-err {
  margin-top: 0;
  border-color: var(--err);
}
.y-input.y-err:focus,
.y-select.y-err:focus,
.y-textarea.y-err:focus {
  border-color: var(--err);
  box-shadow: 0 0 0 3px rgba(168, 58, 46, .12);
}
.y-err {
  margin: 6px 0 0;
  font-size: var(--fs-12);
  line-height: 1.5;
  color: var(--err);
}

/* ===== 徽章 ===== */
.y-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: var(--fs-12);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text-2);
}
.y-badge-ok {
  background: var(--ok-wash);
  color: var(--ok);
}
.y-badge-warn {
  background: var(--primary-bg);
  color: var(--primary-h);
}
.y-badge-err {
  background: var(--err-wash);
  color: var(--err);
}
.y-badge-mute {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-3);
}

/* ===== 指标卡 ===== */
.y-stat {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  flex: 1 1 0;
  align-self: stretch;
  min-width: 0;
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.y-stat-label {
  font-size: var(--fs-12);
  color: var(--text-3);
}
.y-stat-value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.01em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.y-stat-foot {
  font-family: var(--mono);
  font-size: var(--fs-12);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ===== 空状态 ===== */
.y-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-10) var(--sp-5);
  text-align: center;
}
.y-empty-ico {
  display: inline-flex;
  width: 32px;
  height: 32px;
  color: var(--text-3);
}
.y-empty-ico svg { width: 32px; height: 32px; }
.y-empty-txt {
  font-size: var(--fs-13);
  color: var(--text-3);
}

/* ===== 工具类 ===== */
.y-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.y-spacer { flex: 1 1 auto; }
.y-mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.y-muted {
  font-size: var(--fs-12);
  color: var(--text-3);
}
.y-divider {
  height: 1px;
  margin: var(--sp-4) 0;
  border: none;
  background: var(--border);
}
/* ---- 图标（配合 /icons.svg 精灵使用） ---- */
.i {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -3px;
}
.i-sm { width: 14px; height: 14px; }
.i-lg { width: 22px; height: 22px; }
.i-xl { width: 32px; height: 32px; }
