:root {
  --c-primary: #1976D2;
  --c-primary-dark: #0D47A1;
  --c-primary-light: #E3F2FD;
  --c-bg: #F5F7FA;
  --c-card: #FFFFFF;
  --c-danger: #D32F2F;
  --c-success: #2E7D32;
  --c-warning: #ED6C02;
  --c-info: #0288D1;
  --c-text: #1F2937;
  --c-text-sub: #6B7280;
  --c-border: #E5E7EB;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .12);
  --gap: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0;
  font-weight: 600;
}

p {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: var(--c-primary);
  text-decoration: none;
}

img {
  max-width: 100%;
  border: 0;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--c-text);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}

.btn:disabled,
.btn.is-busy {
  opacity: .6;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}

.btn--primary:not(:disabled):hover {
  background: var(--c-primary-dark);
  border-color: var(--c-primary-dark);
}

.btn--primary:not(:disabled):active {
  transform: translateY(1px);
}

.btn--danger {
  background: var(--c-danger);
  border-color: var(--c-danger);
  color: #fff;
}

.btn--success {
  background: var(--c-success);
  border-color: var(--c-success);
  color: #fff;
}

.btn--warning {
  background: var(--c-warning);
  border-color: var(--c-warning);
  color: #fff;
}

.btn--ghost {
  background: transparent;
}

.btn--text {
  border-color: transparent;
  background: transparent;
  color: var(--c-primary);
  padding: 0 6px;
}

.btn--text.is-danger {
  color: var(--c-danger);
}

.btn--block {
  width: 100%;
}

.btn--lg {
  min-height: 44px;
  font-size: 15px;
}

/* hidden 属性优先级兜底：.btn 的 display:inline-flex 会覆盖 UA 默认样式 */
.btn[hidden] {
  display: none;
}

.btn--sm {
  min-height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

/* ---------- 表单 ---------- */
.input {
  display: block;
  width: 100%;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--c-text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 2px rgba(25, 118, 210, .12);
}

.input:disabled,
.input[readonly] {
  background: #F3F4F6;
  color: var(--c-text-sub);
}

.input--error {
  border-color: var(--c-danger);
}

.input--textarea {
  min-height: 60px;
  resize: vertical;
}

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

.form-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-item {
  min-width: 0;
}

.form-item--span2 {
  grid-column: span 2;
}

.form-item__label {
  display: block;
  margin-bottom: 4px;
  color: var(--c-text-sub);
  font-size: 12px;
}

.form-item--required .form-item__label::before {
  content: '*';
  margin-right: 3px;
  color: var(--c-danger);
}

.form-item__error {
  min-height: 0;
  color: var(--c-danger);
  font-size: 12px;
}

.form-item--error .form-item__error {
  min-height: 16px;
}

/* ---------- 开关控件（form-render 的 control = 'switch'） ----------
   ⚠️ 这里此前**完全没有样式**，`input[type=checkbox]` 被渲染成浏览器默认小方框，
   老板现场验收时反馈「改收开关……做成开关模式」即指此。移动端与 PC 端共用本样式。
   实现要点：不用伪元素画滑块（`::after` 在 `<input>` 这类替换元素上不可靠），
   改用 `background-image` 画圆点 + `background-position` 平移，兼容性最好。 */
.switch {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
}

.switch__input {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 52px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 999px;
  background-color: var(--c-border, #BDBDBD);
  background-image: radial-gradient(circle closest-side, #fff 100%, rgba(255, 255, 255, 0) 100%);
  background-repeat: no-repeat;
  background-size: 26px 26px;
  background-position: 3px 3px;
  transition: background-color .18s ease, background-position .18s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.switch__input:checked {
  background-color: var(--c-primary);
  /* 52 - 3 - 26 = 23 */
  background-position: 23px 3px;
}

.switch__input:focus-visible {
  outline: 2px solid rgba(25, 118, 210, .45);
  outline-offset: 2px;
}

.switch__input:disabled {
  cursor: not-allowed;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--c-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: var(--gap);
}

.card__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 600;
}

.card__title h3 {
  font-size: 14px;
}

/* ---------- 标签 ---------- */
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 18px;
  white-space: nowrap;
}

.tag--default {
  background: #F1F3F5;
  color: var(--c-text-sub);
}

.tag--muted {
  background: #ECEFF1;
  color: #90A4AE;
  text-decoration: line-through;
}

.tag--info {
  background: #E3F2FD;
  color: var(--c-info);
}

.tag--success {
  background: #E8F5E9;
  color: var(--c-success);
}

.tag--warning {
  background: #FFF3E0;
  color: var(--c-warning);
}

.tag--danger {
  background: #FFEBEE;
  color: var(--c-danger);
}

.tag--primary {
  background: var(--c-primary-light);
  color: var(--c-primary-dark);
}

/* ---------- 通用工具类 ---------- */
.text-danger {
  color: var(--c-danger);
}

.text-success {
  color: var(--c-success);
}

.text-sub {
  color: var(--c-text-sub);
}

.text-warning {
  color: var(--c-warning);
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.font-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.cell-money {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cell-danger {
  text-align: right;
  color: var(--c-danger);
  font-weight: 600;
}

.row--danger {
  background: #FFF5F5 !important;
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mb-8 {
  margin-bottom: 8px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.row-start {
  display: flex;
  align-items: center;
  gap: 8px;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty {
  padding: 32px 12px;
  text-align: center;
  color: var(--c-text-sub);
  font-size: 13px;
}

.empty::before {
  content: '暂无数据';
  display: block;
  margin-bottom: 4px;
  font-size: 15px;
  color: #9CA3AF;
}

.loading {
  padding: 24px 12px;
  text-align: center;
  color: var(--c-text-sub);
  font-size: 13px;
}

.notice {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.notice--danger {
  background: #FFEBEE;
  color: var(--c-danger);
}

.notice--warning {
  background: #FFF8E1;
  color: #8D6E00;
}

.notice--info {
  background: var(--c-primary-light);
  color: var(--c-primary-dark);
}

/* ---------- Toast ---------- */
.toast-host {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: rgba(31, 41, 55, .92);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .18s ease;
}

.toast--success {
  background: #2E7D32;
}

.toast--error {
  background: #D32F2F;
}

.toast--warning {
  background: #ED6C02;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}
