/* ==========================================================================
   供应商台账 · 基础层：设计变量 / Reset / 排版 / 通用原子
   风格：企业级后台，专业克制，信息密度适中
   ========================================================================== */

:root {
  /* 中性色 */
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --divider: #eef2f6;

  /* 文字 */
  --text: #1f2937;
  --text-2: #5b6675;
  --text-3: #8a94a3;
  --text-inverse: #ffffff;

  /* 主色 / 链接 / 主要操作 */
  --primary: #1d4ed8;
  --primary-hover: #1a44bd;
  --primary-soft: #eaf0fe;
  --primary-border: #c3d3fb;

  /* 状态色 */
  --success: #15803d;
  --success-soft: #e8f6ee;
  --success-border: #b7e2c7;

  --notice: #a16207;         /* 提醒·黄 */
  --notice-soft: #fdf6e3;
  --notice-border: #f2e2ac;

  --warn: #c2410c;           /* 预警·橙 */
  --warn-soft: #fdeee3;
  --warn-border: #f6cdb1;

  --danger: #b91c1c;         /* 严重风险·红 */
  --danger-soft: #fbeaea;
  --danger-border: #f3c2c2;

  --muted: #64748b;          /* 停用·灰 */
  --muted-soft: #eef1f5;
  --muted-border: #d8dfe8;

  /* 尺寸 */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
  --header-h: 92px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
  --shadow-lg: -8px 0 28px rgba(15, 23, 42, .14);

  /* 字体 */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-num: "SF Mono", "JetBrains Mono", Menlo, Consolas, "PingFang SC", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; color: var(--text); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

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

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

button { cursor: pointer; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
::-webkit-scrollbar-track { background: transparent; }

/* 数字统一等宽，金额列对齐 */
.num, .money, td.money, th.money {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* 图标 */
.lucide {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  vertical-align: -3px;
}
.lucide-sm { width: 13px; height: 13px; vertical-align: -2px; }
.lucide-lg { width: 18px; height: 18px; vertical-align: -4px; }
.lucide-xl { width: 22px; height: 22px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-3); color: var(--text); border-color: #b6c2d1; }
.btn:active { background: var(--surface-2); }
.btn:focus-visible { outline: 2px solid var(--primary-border); outline-offset: 1px; }

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

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-3); border-color: var(--border); }

.btn-danger { color: var(--danger); border-color: var(--danger-border); background: var(--danger-soft); }
.btn-danger:hover { background: #f7dcdc; color: var(--danger); border-color: #e8a9a9; }

.btn-icon {
  width: 30px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
}
.btn-icon:hover { background: var(--surface-3); border-color: var(--border); color: var(--text); }

.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; gap: 4px; }
.btn-sm .lucide { width: 13px; height: 13px; }
.btn-lg { height: 34px; padding: 0 14px; }

.btn[disabled], .btn.is-disabled {
  opacity: .5;
  pointer-events: none;
}

.btn.is-active { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary); }

/* ---------- 状态标签 ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 1px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  white-space: nowrap;
  vertical-align: middle;
}
.tag .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}
.tag .lucide { width: 12px; height: 12px; stroke-width: 2.1; vertical-align: 0; }

.tag-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.tag-notice  { background: var(--notice-soft);  border-color: var(--notice-border);  color: var(--notice); }
.tag-warn    { background: var(--warn-soft);    border-color: var(--warn-border);    color: var(--warn); }
.tag-danger  { background: var(--danger-soft);  border-color: var(--danger-border);  color: var(--danger); }
.tag-muted   { background: var(--muted-soft);   border-color: var(--muted-border);   color: var(--muted); }
.tag-primary { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary); }
.tag-plain   { background: var(--surface);      border-color: var(--border);         color: var(--text-2); }

/* ---------- Tooltip ---------- */
.tooltip {
  position: fixed;
  z-index: 4000;
  max-width: 260px;
  padding: 6px 9px;
  border: 1px solid #334155;
  border-radius: var(--radius);
  background: #1e293b;
  color: #f8fafc;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity .12s, transform .12s;
}
.tooltip.is-show { opacity: 1; transform: translateY(0); }
.tooltip b { color: #fff; font-weight: 600; }

/* ---------- Toast ---------- */
.toast-root {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 90vw;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--text);
  animation: toast-in .18s ease-out;
}
.toast-success { border-color: var(--success-border); background: var(--success-soft); color: var(--success); }
.toast-error { border-color: var(--danger-border); background: var(--danger-soft); color: var(--danger); }
.toast-info { border-color: var(--primary-border); background: var(--primary-soft); color: var(--primary); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- 下拉菜单 ---------- */
.menu {
  position: fixed;
  z-index: 3000;
  min-width: 172px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
}
.menu-item:hover { background: var(--surface-3); }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; margin: 4px 2px; background: var(--divider); }
.menu-label { padding: 6px 9px 3px; color: var(--text-3); font-size: 11px; }

/* ---------- 弹窗 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 3500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, .38);
  animation: fade-in .15s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-lg { max-width: 720px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 14px; font-weight: 600; }
.modal-body { padding: 14px; overflow: auto; }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* ---------- 表单 ---------- */
.field { margin-bottom: 12px; }
.field-label {
  display: block;
  margin-bottom: 5px;
  color: var(--text-2);
  font-size: 12px;
}
.field-label .req { color: var(--danger); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.textarea { height: auto; padding: 6px 8px; resize: vertical; min-height: 62px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.select {
  appearance: none;
  padding-right: 24px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235b6675' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 7px center;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-error { margin-top: 4px; color: var(--danger); font-size: 12px; }
.field-error .input, .field-error .select { border-color: var(--danger); }

/* ---------- 通用文本 ---------- */
.t-2 { color: var(--text-2); }
.t-3 { color: var(--text-3); }
.t-danger { color: var(--danger); }
.t-success { color: var(--success); }
.t-warn { color: var(--warn); }
.t-primary { color: var(--primary); }
.t-sm { font-size: 12px; }
.t-xs { font-size: 11px; }
.t-mono { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.t-bold { font-weight: 600; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.hr { height: 1px; background: var(--divider); margin: 12px 0; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 键盘可达焦点 */
[tabindex]:focus-visible, tr:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
