:root {
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --primary-bg: #eff6ff;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
a { color: var(--primary); text-decoration: none; }
ul, ol { list-style: none; }
.no-scroll { overflow: hidden !important; }
.mono { font-family: Consolas, "Courier New", monospace; }
.ico { width: 18px; height: 18px; vertical-align: -3px; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px; padding: 8px 14px; font-size: 14px;
  transition: background .15s, border-color .15s, opacity .15s; white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-2); }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: #f8fafc; }
.btn-danger { background: var(--danger-bg); border-color: #fecaca; color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-flex { flex: 1; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px;
  line-height: 18px; white-space: nowrap;
}
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-blue { background: var(--primary-bg); color: var(--primary); }
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-gray { background: #f1f5f9; color: var(--muted); }

input, select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
input[type="date"] { min-height: 38px; }

.field label, .m-field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border: none; border-radius: 8px; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: #f1f5f9; color: var(--text); }

.link-btn {
  display: inline-flex; align-items: center; gap: 4px; border: none; background: none;
  color: var(--primary); font-size: 13px; padding: 4px 6px; border-radius: 6px;
}
.link-btn:hover { background: var(--primary-bg); }
.link-btn.danger { color: var(--danger); }
.link-btn.danger:hover { background: var(--danger-bg); }
.link-btn .ico { width: 15px; height: 15px; }

.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-item input { display: none; }
.seg-item span {
  display: inline-block; padding: 7px 16px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; font-size: 14px; transition: .15s;
}
.seg-item input:checked + span {
  border-color: var(--primary); background: var(--primary-bg); color: var(--primary); font-weight: 600;
}

.toast-box {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 400;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); animation: toastIn .25s; max-width: 86vw;
}
.toast.err { background: var(--danger); }
.toast.out { opacity: 0; transform: translateY(-8px); transition: .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.empty { color: var(--muted); text-align: center; padding: 30px 12px; font-size: 14px; }
.empty.pad { padding: 42px 12px; }