/* ============================================================
   base.css —— 设计令牌 + 基础组件
   纯 CSS，无任何第三方依赖，也不使用预处理器
   ============================================================ */

:root {
  --bg: #060a12;
  --bg-soft: #0a101c;
  --panel: #0c1322;
  --panel-2: #101a2c;
  --panel-3: #14203a;
  --border: #1b2740;
  --border-soft: #162034;
  --text: #dbe4f3;
  --text-dim: #a7b4c9;
  --muted: #74839d;
  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --teal: #22d3ee;
  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, 0.14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sidebar-w: 236px;
  --header-h: 60px;
}

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

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

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

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: none;
}
/* 按钮型链接与普通按钮保持同一套 hover/focus，不出现下划线 */
a.btn:hover,
a.btn:focus,
a.btn:active {
  text-decoration: none;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.2px;
}

p { margin: 0; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

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

::selection {
  background: rgba(59, 130, 246, 0.35);
}

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #1c2a45;
  border-radius: 8px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #26375a; }

/* ---------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.16s, border-color 0.16s, transform 0.06s, opacity 0.16s;
}
.btn:hover {
  background: var(--panel-3);
  border-color: #26375a;
}
.btn:active { transform: translateY(1px); }
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.btn-primary {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  border-color: #2f6fe0;
  color: #fff;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.28);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #4b8df8, #2b6cf0);
  border-color: #3b82f6;
}
.btn-danger {
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.22);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover {
  background: var(--panel-2);
  color: var(--text);
}
.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: 7px;
}
.btn-block { width: 100%; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* ---------------------------------------------------------- 表单 */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.field > label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}
.input,
.select,
.textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0a1120;
  color: var(--text);
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}
.textarea {
  height: auto;
  min-height: 90px;
  padding: 10px 12px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 13px;
}
.input::placeholder,
.textarea::placeholder { color: #465671; }
.input:hover,
.select:hover { border-color: #253653; }
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
  background: #0b1322;
}
.input:disabled,
.select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #6b7c99 50%),
    linear-gradient(135deg, #6b7c99 50%, transparent 50%);
  background-position: calc(100% - 18px) 17px, calc(100% - 13px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
.field-hint {
  font-size: 12px;
  color: var(--muted);
}
.field-error {
  font-size: 12px;
  color: #fca5a5;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.checkbox input {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid #2a3a58;
  border-radius: 4px;
  background: #0a1120;
  position: relative;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.checkbox input:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox input:checked::after {
  content: "";
  position: absolute;
  left: 4.5px;
  top: 1.5px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}

/* ---------------------------------------------------------- 布局 */
.card {
  background: linear-gradient(180deg, rgba(16, 26, 44, 0.9), rgba(12, 19, 34, 0.9));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.8);
}

.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.dim { color: var(--text-dim); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.small { font-size: 12px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.gap-16 { gap: 16px; }

/* ---------------------------------------------------------- 徽标 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: #86efac; border-color: rgba(34, 197, 94, 0.3); }
.badge-warn { background: var(--warn-soft); color: #fcd34d; border-color: rgba(245, 158, 11, 0.3); }
.badge-danger { background: var(--danger-soft); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }
.badge-info { background: var(--accent-soft); color: #93c5fd; border-color: rgba(59, 130, 246, 0.3); }
.badge-muted { background: #131e33; color: var(--muted); border-color: var(--border); }

/* ---------------------------------------------------------- 表格 */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.table th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.3px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 17, 32, 0.6);
  white-space: nowrap;
}
.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.table tbody tr:hover td { background: rgba(59, 130, 246, 0.05); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* 统一表格列对齐：表头与内容都左对齐，避免同一列有的靠右有的靠左。
   数字列也统左对齐；空态 colspan 单元格保留居中。 */
.table th,
.table td,
.table th.right,
.table td.right {
  text-align: left !important;
}
.table td[colspan] {
  text-align: center !important;
}

/* ---------------------------------------------------------- 空态/加载 */
.empty {
  padding: 44px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.empty svg { width: 34px; height: 34px; opacity: 0.45; margin-bottom: 10px; }

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner-lg {
  width: 26px;
  height: 26px;
  border-width: 2.5px;
  border-color: rgba(59, 130, 246, 0.2);
  border-top-color: var(--accent);
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, #12203a 25%, #182b4a 37%, #12203a 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.loading-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 16px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------------------------------------------------------- 分页 */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 12px;
}
.pagination .page-info { color: var(--muted); font-size: 12px; margin-right: auto; }

/* ---------------------------------------------------------- Toast */
.toast-wrap {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  min-width: 240px;
  max-width: 380px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #101a2c;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
}
.toast.ok { border-color: rgba(34, 197, 94, 0.45); }
.toast.error { border-color: rgba(239, 68, 68, 0.45); }
.toast.info { border-color: rgba(59, 130, 246, 0.45); }
.toast .bar {
  width: 3px;
  align-self: stretch;
  border-radius: 3px;
  background: var(--accent);
}
.toast.ok .bar { background: var(--ok); }
.toast.error .bar { background: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------- Modal */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 12, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9000;
  animation: fade-in 0.15s ease;
}
.modal {
  width: 100%;
  max-width: 460px;
  background: #0d1524;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: modal-in 0.18s ease-out;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}
.modal-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-body { padding: 18px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.modal-close {
  border: none;
  background: transparent;
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
}
.modal-close:hover { background: var(--panel-2); color: var(--text); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------- 提示条 */
.alert {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 9px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  align-items: flex-start;
}
.alert svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.alert-error { border-color: rgba(239, 68, 68, 0.4); background: var(--danger-soft); color: #fecaca; }
.alert-warn { border-color: rgba(245, 158, 11, 0.4); background: var(--warn-soft); color: #fde68a; }
.alert-info { border-color: rgba(59, 130, 246, 0.35); background: var(--accent-soft); color: #bfdbfe; }

/* ---------------------------------------------------------- 页头 */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.page-desc {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
}

.grid {
  display: grid;
  gap: 16px;
}
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
}

/* 描述列表 */
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 10px 14px; font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; color: var(--text); word-break: break-all; }
