/* ==========================================================================
   base.css —— 基础重置与通用控件（系统字体、无外链、离线可用）
   ========================================================================== */

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', 'PingFang SC',
    'Hiragino Sans GB', 'Source Han Sans SC', 'Noto Sans CJK SC', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text, #1f2937);
  background: var(--bg, #f5f6f8);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  line-height: 1.35;
}

p {
  margin: 0;
}

a {
  color: var(--tone, #dc2626);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  filter: brightness(0.92);
}

.btn-ghost {
  background: #fff;
  border-color: #d7dbe2;
  color: #374151;
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--tone, #dc2626);
  color: var(--tone, #dc2626);
}

.btn-danger {
  background: #fff;
  border-color: #f0b4b4;
  color: #b91c1c;
}

.btn-danger:hover:not(:disabled) {
  background: #fef2f2;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.btn.is-active {
  border-color: var(--tone, #dc2626);
  color: var(--tone, #dc2626);
  font-weight: 600;
}

/* ---------- 表单控件 ---------- */
.input,
.select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid #d7dbe2;
  border-radius: 6px;
  background: #fff;
  font-family: inherit;
  font-size: 13px;
  color: inherit;
  outline: none;
  min-width: 0;
}

.input:focus,
.select:focus {
  border-color: var(--tone, #dc2626);
  box-shadow: 0 0 0 3px var(--tone-soft, #fef2f2);
}

.input:disabled,
.select:disabled {
  background: #f3f4f6;
  color: #6b7280;
  cursor: not-allowed;
}

.input::placeholder {
  color: #9ca3af;
}

.textarea {
  height: auto;
  padding: 8px 10px;
  resize: vertical;
  line-height: 1.5;
}

.select-sm {
  height: 28px;
  font-size: 12px;
}

.file-input {
  height: auto;
  padding: 8px;
  width: 100%;
}

.radio-row {
  display: flex;
  gap: 18px;
  margin: 8px 0 4px;
}

.radio,
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

/* ---------- 表格 ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #eef0f3;
}

.data-table th {
  background: #fafbfc;
  font-weight: 600;
  color: #4b5563;
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: #fcfcfd;
}

.cell-empty {
  text-align: center;
  color: #9ca3af;
  padding: 28px 10px !important;
}

.cell-desc {
  max-width: 320px;
  word-break: break-word;
}

.cell-nowrap {
  white-space: nowrap;
}

.cell-time-sub {
  color: #6b7280;
  font-size: 12px;
}

/* ---------- 徽标 ---------- */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-ok {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

.badge-warn {
  background: #fffbeb;
  border-color: #fde68a;
  color: #b45309;
  cursor: help;
}

.badge-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.badge-pending {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.badge-muted {
  background: #f3f4f6;
  border-color: #e5e7eb;
  color: #4b5563;
}

.badge-info {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #4338ca;
}

.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  background: #f3f4f6;
  color: #374151;
  font-size: 13px;
}

/* ---------- 提示 ---------- */
.toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
}

.toast {
  min-width: 220px;
  max-width: 420px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  border-left: 4px solid #6b7280;
  font-size: 13px;
  animation: toast-in 0.18s ease-out;
}

.toast-out {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-success {
  border-left-color: #059669;
}

.toast-error {
  border-left-color: #dc2626;
}

.toast-warn {
  border-left-color: #d97706;
}

.toast-info {
  border-left-color: #2563eb;
}

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

.form-error {
  color: #b91c1c;
  font-size: 12px;
  min-height: 0;
}

.form-error:empty {
  display: none;
}

.hint-text {
  color: #6b7280;
  font-size: 12px;
  margin-top: 6px;
}

.text-ok {
  color: #047857;
}

.text-danger {
  color: #b91c1c;
}

.text-warn {
  color: #b45309;
}

/* ---------- 模态框 ---------- */
.modal-root {
  position: relative;
  z-index: 200;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px 16px;
  overflow-y: auto;
}

.modal {
  width: 460px;
  max-width: 100%;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.24);
  overflow: hidden;
}

.modal-lg {
  width: 720px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #eef0f3;
}

.modal-title {
  font-size: 15px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: #6b7280;
  cursor: pointer;
  padding: 0 4px;
}

.modal-close:hover {
  color: #111827;
}

.modal-body {
  padding: 16px 18px;
  max-height: 66vh;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid #eef0f3;
  background: #fafbfc;
}

/* ---------- 表单布局 ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

.form-grid > .form-error {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.field-label {
  color: #4b5563;
  font-weight: 500;
}

.field-hint {
  color: #9ca3af;
  font-size: 12px;
}

.readonly-value {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  background: #f3f4f6;
  border: 1px dashed #d1d5db;
  color: #374151;
  font-size: 13px;
}

.readonly-value.is-empty {
  color: #9ca3af;
}

/* ---------- 分页 ---------- */
.pager {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.pager-total {
  color: #6b7280;
  font-size: 12px;
  margin-right: 6px;
}

.pager-gap {
  color: #9ca3af;
  padding: 0 2px;
}

/* ---------- 空态 / 加载 ---------- */
.empty-state {
  text-align: center;
  color: #6b7280;
  padding: 32px 16px;
}

.loading {
  color: #9ca3af;
  font-size: 13px;
  padding: 24px 4px;
}

.result-view {
  text-align: center;
  padding: 64px 16px;
  color: #4b5563;
}

.result-icon {
  font-size: 34px;
  margin-bottom: 8px;
}

.result-view h2 {
  font-size: 18px;
  margin-bottom: 6px;
}

.result-view p {
  color: #6b7280;
  margin-bottom: 16px;
}
