/* =========================================================================
   components.css — 按钮 · 表单 · 卡片 · 统计砖 · 表格 · 标签 · 分页签 · 弹窗 · 图表 · 空态 · 提示
   ========================================================================= */

/* =========================================================================
   按钮
   ========================================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--r-md);
  font-size: var(--fs-13); font-weight: 550; white-space: nowrap;
  border: 1px solid transparent; color: var(--text);
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.btn:active { transform: translateY(.5px) scale(.99); }
.btn .ic { width: 16px; height: 16px; }
.btn.sm { height: 30px; padding: 0 10px; font-size: var(--fs-12); border-radius: var(--r-sm); }
.btn.lg { height: 42px; padding: 0 20px; font-size: var(--fs-14); }
.btn.block { width: 100%; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }

.btn-primary { background: var(--brand-grad); color: var(--brand-ink); font-weight: 600; box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 6px 18px -8px rgba(84,214,92,.6); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-default { background: var(--surface-2); border-color: var(--line-2); color: var(--text); }
.btn-default:hover { border-color: var(--line-strong); background: var(--surface-hover); }
.btn-ghost { color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-outline { border-color: var(--accent-line); color: var(--accent-text); }
.btn-outline:hover { background: var(--accent-weak); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.06); }
.btn-soft { background: var(--surface-3); border-color: var(--line); color: var(--text-dim); }
.btn-soft:hover { color: var(--text); border-color: var(--line-2); }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* 色系软按钮（工具列多彩按钮） */
.btn-c-info { background: var(--info-weak); color: var(--info); border-color: transparent; }
.btn-c-warn { background: var(--warn-weak); color: var(--warn); }
.btn-c-violet { background: var(--violet-weak); color: var(--violet); }
.btn-c-cyan { background: var(--cyan-weak); color: var(--cyan); }
.btn-c-good { background: var(--good-weak); color: var(--good); }

/* =========================================================================
   表单控件
   ========================================================================= */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: var(--fs-12); color: var(--text-dim); font-weight: 500; }
.field > label .req { color: var(--danger); margin-left: 2px; }

.input, .select, .textarea {
  height: 36px; padding: 0 11px; width: 100%;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-md);
  color: var(--text); font-size: var(--fs-13); outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-weak); }
.textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: var(--lh); }

.select {
  appearance: none; cursor: pointer; padding-right: 32px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b949c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
}
.select.ph { color: var(--text-faint); }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .ic { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--text-faint); pointer-events: none; }
.input-wrap > .input { padding-left: 34px; }

/* 核取 / 单选 */
.check { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: var(--fs-13); }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
  width: 17px; height: 17px; flex: none; border-radius: 5px; border: 1.5px solid var(--line-strong);
  background: var(--surface-2); display: grid; place-items: center; transition: all var(--t-fast);
}
.check input:checked + .box { background: var(--brand-grad); border-color: transparent; }
.check .box svg { width: 12px; height: 12px; color: var(--brand-ink); opacity: 0; transform: scale(.6); transition: all var(--t-fast); }
.check input:checked + .box svg { opacity: 1; transform: none; }
.check input:indeterminate + .box { background: var(--brand); border-color: transparent; }

/* 开关 */
.switch { position: relative; width: 38px; height: 22px; flex: none; border-radius: var(--r-full); background: var(--line-strong); cursor: pointer; transition: background var(--t); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: left var(--t) var(--ease); }
.switch.on { background: var(--brand-grad); }
.switch.on::after { left: 18px; }

/* 分段控制 */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.segmented button { height: 28px; padding: 0 12px; border-radius: var(--r-sm); font-size: var(--fs-12); color: var(--text-dim); font-weight: 500; }
.segmented button:hover { color: var(--text); }
.segmented button.on { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-sm); }

/* 快捷区间 pill 组 */
.pill-row { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.pill {
  height: 30px; padding: 0 12px; border-radius: var(--r-full); font-size: var(--fs-12);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text-dim); font-weight: 500;
  transition: all var(--t-fast);
}
.pill:hover { border-color: var(--accent-line); color: var(--text); }
.pill.on { background: var(--accent-weak); border-color: var(--accent-line); color: var(--accent-text); }

/* 筛选网格 */
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.filter-bar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* =========================================================================
   卡片 / 面板
   ========================================================================= */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card.pad { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head .ct { font-size: var(--fs-14); font-weight: 600; display: flex; align-items: center; gap: 9px; }
.card-head .ct .ic { width: 17px; height: 17px; color: var(--text-dim); }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

.panel { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); }

/* =========================================================================
   统计砖
   ========================================================================= */
.stat-grid { display: grid; gap: 14px; }
.stat {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px;
  transition: border-color var(--t), transform var(--t);
}
.stat:hover { border-color: var(--line-2); }
.stat .st-top { display: flex; align-items: center; justify-content: space-between; }
.stat .st-ic { width: 38px; height: 38px; border-radius: var(--r-md); display: grid; place-items: center; }
.stat .st-ic .ic { width: 19px; height: 19px; }
.stat .st-label { color: var(--text-dim); font-size: var(--fs-12); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.stat .st-val { font-size: var(--fs-28); font-weight: 650; letter-spacing: -0.03em; margin-top: 10px; font-variant-numeric: tabular-nums; }
.stat .st-sub { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: var(--fs-12); color: var(--text-faint); }
.stat .spark { position: absolute; right: 14px; bottom: 12px; width: 92px; height: 34px; opacity: .9; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: var(--fs-12); }
.delta.up { color: var(--good); } .delta.down { color: var(--danger); }
.delta .ic { width: 13px; height: 13px; }

/* 砖的强调左条 */
.stat.accent-info::before,  .stat.accent-good::before, .stat.accent-warn::before,
.stat.accent-danger::before, .stat.accent-violet::before, .stat.accent-cyan::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
}
.stat.accent-info::before { background: var(--info); }
.stat.accent-good::before { background: var(--brand-grad); }
.stat.accent-warn::before { background: var(--warn); }
.stat.accent-danger::before { background: var(--danger); }
.stat.accent-violet::before { background: var(--violet); }
.stat.accent-cyan::before { background: var(--cyan); }
.tint-info { background: var(--info-weak); color: var(--info); }
.tint-good { background: var(--good-weak); color: var(--good); }
.tint-warn { background: var(--warn-weak); color: var(--warn); }
.tint-danger { background: var(--danger-weak); color: var(--danger); }
.tint-violet { background: var(--violet-weak); color: var(--violet); }
.tint-cyan { background: var(--cyan-weak); color: var(--cyan); }
.tint-brand { background: var(--accent-weak); color: var(--brand); }

/* =========================================================================
   标签 / 徽章 / 状态点
   ========================================================================= */
.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px;
  border-radius: var(--r-full); font-size: var(--fs-12); font-weight: 550; white-space: nowrap;
  background: var(--surface-3); color: var(--text-dim); border: 1px solid var(--line);
}
.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.good { background: var(--good-weak); color: var(--good); border-color: transparent; }
.tag.info { background: var(--info-weak); color: var(--info); border-color: transparent; }
.tag.warn { background: var(--warn-weak); color: var(--warn); border-color: transparent; }
.tag.danger { background: var(--danger-weak); color: var(--danger); border-color: transparent; }
.tag.violet { background: var(--violet-weak); color: var(--violet); border-color: transparent; }
.tag.cyan { background: var(--cyan-weak); color: var(--cyan); border-color: transparent; }
.tag.neutral { background: var(--surface-3); color: var(--text-dim); }
.tag.solid-good { background: var(--good); color: #042; border-color: transparent; }

.presence { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.presence.on { background: var(--good); box-shadow: 0 0 0 3px var(--good-weak); }
.presence.off { background: var(--text-faint); }

/* =========================================================================
   表格
   ========================================================================= */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
table.data { font-size: var(--fs-13); }
table.data thead th {
  position: sticky; top: 0; z-index: 2; text-align: left; white-space: nowrap;
  padding: 11px 14px; background: var(--surface-2); color: var(--text-dim); font-weight: 550;
  border-bottom: 1px solid var(--line-2); font-size: var(--fs-12);
}
table.data thead th.sortable { cursor: pointer; user-select: none; }
table.data thead th.sortable:hover { color: var(--text); }
table.data thead th .so { display: inline-flex; margin-left: 4px; width: 13px; height: 13px; opacity: .4; vertical-align: -2px; }
table.data thead th.sorted .so { opacity: 1; color: var(--brand); }
table.data tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr { transition: background var(--t-fast); }
table.data tbody tr:hover td { background: var(--surface-hover); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .two-line { display: flex; flex-direction: column; gap: 2px; line-height: 1.3; }
table.data .two-line .sm { font-size: var(--fs-12); color: var(--text-faint); }
table.data tr.total-row td { background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--line-2); }
.cell-link { color: var(--accent-text); cursor: pointer; }
.cell-link:hover { text-decoration: underline; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.sticky-left { position: sticky; left: 0; z-index: 1; background: var(--surface); }
table.data tbody tr:hover .sticky-left { background: var(--surface-hover); }
.sticky-right { position: sticky; right: 0; z-index: 1; background: var(--surface); }
table.data tbody tr:hover .sticky-right { background: var(--surface-hover); }
thead .sticky-left, thead .sticky-right { background: var(--surface-2); z-index: 3; }

/* 工具列 + 分页 */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px 0; flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 4px; }
.pager .pg { min-width: 32px; height: 32px; padding: 0 8px; border-radius: var(--r-sm); font-size: var(--fs-13); color: var(--text-dim); border: 1px solid transparent; }
.pager .pg:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.pager .pg.on { background: var(--accent-weak); color: var(--accent-text); border-color: var(--accent-line); }
.pager .pg:disabled { opacity: .35; }

/* =========================================================================
   分页签
   ========================================================================= */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs .tab { position: relative; padding: 11px 14px; font-size: var(--fs-13); color: var(--text-dim); font-weight: 500; white-space: nowrap; }
.tabs .tab:hover { color: var(--text); }
.tabs .tab.on { color: var(--text); }
.tabs .tab.on::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--brand-grad); border-radius: 2px; }

/* 描述式栏位（设定页） */
.desc { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.desc .drow { display: grid; grid-template-columns: 220px 1fr; border-bottom: 1px solid var(--line); }
.desc .drow:last-child { border-bottom: none; }
.desc .dk { padding: 14px 16px; background: var(--surface-2); color: var(--text-dim); font-size: var(--fs-13); border-right: 1px solid var(--line); }
.desc .dk .req { color: var(--danger); margin-left: 2px; }
.desc .dv { padding: 12px 16px; min-width: 0; }
.desc .dv .hint { color: var(--text-faint); font-size: var(--fs-12); margin-top: 6px; }

/* 表单网格 */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* =========================================================================
   弹窗
   ========================================================================= */
.modal-scrim { position: fixed; inset: 0; z-index: var(--z-modal); background: rgba(0,0,0,.55); backdrop-filter: blur(4px); display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 40px; overflow: auto; opacity: 0; animation: fade-in var(--t-fast) forwards; }
.modal { width: min(560px, 100%); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); animation: pop-in var(--t) var(--ease-out); }
.modal.wide { width: min(820px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head .mt { font-size: var(--fs-16); font-weight: 600; }
.modal-body { padding: 20px; max-height: 64vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }

/* 详情列表（抽屉/弹窗） */
.kv-list { display: flex; flex-direction: column; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-13); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-faint); }
.kv .v { color: var(--text); word-break: break-word; }

/* =========================================================================
   图表容器
   ========================================================================= */
.chart-box { position: relative; width: 100%; }
.chart-box.h120 { height: 120px; } .chart-box.h200 { height: 200px; }
.chart-box.h240 { height: 240px; } .chart-box.h300 { height: 300px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-12); color: var(--text-dim); }
.legend .lg .sw { width: 10px; height: 10px; border-radius: 3px; }

/* =========================================================================
   空态 / 载入
   ========================================================================= */
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 20px; text-align: center; color: var(--text-faint); }
.empty .ic { width: 38px; height: 38px; opacity: .5; }
.empty .et { color: var(--text-dim); font-size: var(--fs-14); font-weight: 500; }
.empty .es { font-size: var(--fs-12); }

/* =========================================================================
   提示
   ========================================================================= */
.toasts { position: fixed; top: 70px; right: 20px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 11px; min-width: 260px; max-width: 420px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-md); box-shadow: var(--shadow-lg); animation: rise var(--t) var(--ease-out); pointer-events: auto; }
.toast .ti { width: 20px; height: 20px; flex: none; }
.toast.ok .ti { color: var(--good); } .toast.info .ti { color: var(--info); }
.toast.warn .ti { color: var(--warn); } .toast.err .ti { color: var(--danger); }
.toast .tx { font-size: var(--fs-13); flex: 1; }
.toast .tx b { font-weight: 600; }

/* =========================================================================
   杂项
   ========================================================================= */
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.chip-note { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: var(--r-full); background: var(--accent-weak); color: var(--accent-text); font-size: var(--fs-12); font-weight: 500; }
.meter { height: 7px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: var(--r-full); background: var(--brand-grad); }
.avatar-sm { width: 28px; height: 28px; border-radius: var(--r-sm); background: var(--surface-3); display: grid; place-items: center; font-size: var(--fs-12); font-weight: 600; color: var(--text-dim); flex: none; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; } .desc .drow { grid-template-columns: 1fr; } .desc .dk { border-right: none; border-bottom: 1px solid var(--line); } }
