/* ==========================================================================
   LiveDesk Design System · base.css
   ========================================================================== */
:root {
  --brand: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --violet: #8b5cf6;
  --cyan: #06b6d4;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --pink: #ec4899;

  --bg: #f5f6fb;
  --bg-2: #eef1f9;
  --surface: #ffffff;
  --surface-2: #fafbff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e6e9f2;
  --line-2: #eef1f7;

  --radius: 14px;
  --radius-lg: 20px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow: 0 8px 24px -12px rgba(15, 23, 42, .18), 0 2px 8px -4px rgba(15, 23, 42, .08);
  --shadow-lg: 0 24px 60px -24px rgba(49, 46, 129, .35), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --ring: 0 0 0 3px rgba(99, 102, 241, .18);
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #a855f7 100%);
  --grad-soft: linear-gradient(135deg, rgba(99, 102, 241, .10), rgba(139, 92, 246, .06));
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); }
img { max-width: 100%; display: block; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; }
p { margin: 0; }
::selection { background: rgba(99, 102, 241, .18); }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d5dae8; border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #c0c7d9; background-clip: content-box; }

/* ---------------------------------------------------------------- 按钮 */
.btn {
  --btn-bg: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--btn-bg); color: var(--ink-2);
  font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  transition: .18s ease; user-select: none;
}
.btn:hover { border-color: #d7dceb; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 8px 20px -10px rgba(99, 102, 241, .8); }
.btn-primary:hover { box-shadow: 0 14px 26px -12px rgba(99, 102, 241, .9); filter: brightness(1.04); }
.btn-soft { background: rgba(99, 102, 241, .09); color: var(--brand-600); border-color: transparent; }
.btn-soft:hover { background: rgba(99, 102, 241, .14); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(15, 23, 42, .05); color: var(--ink); }
.btn-danger { background: rgba(239, 68, 68, .1); color: #dc2626; border-color: transparent; }
.btn-danger:hover { background: rgba(239, 68, 68, .16); }
.btn-dark { background: #0f172a; color: #fff; border-color: transparent; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 9px; }
.btn-lg { height: 48px; padding: 0 26px; font-size: 15px; border-radius: 12px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 10px; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- 表单 */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.label .req { color: var(--red); }
.input, .textarea, .select {
  width: 100%; height: 42px; padding: 0 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); outline: none;
  transition: .16s ease; font-size: 13.5px;
}
.textarea { height: auto; min-height: 92px; padding: 11px 13px; resize: vertical; line-height: 1.65; }
.input:hover, .textarea:hover, .select:hover { border-color: #d7dceb; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--brand); box-shadow: var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8.5 1.8 4.3l.9-.9L6 6.7l3.3-3.3.9.9z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: 40px; }
.input-group .icon { position: absolute; left: 13px; color: var(--muted-2); display: flex; }
.hint { font-size: 12px; color: var(--muted); }
.error-text { font-size: 12px; color: var(--red); }

.switch { position: relative; width: 40px; height: 22px; border-radius: 99px; background: #dbe1ee; border: 0; cursor: pointer; transition: .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: .2s; }
.switch.on { background: var(--brand); }
.switch.on::after { transform: translateX(18px); }

/* ---------------------------------------------------------------- 卡片 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.card-head h3 { font-size: 15px; }
.card-head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------------------------------------------------------------- 徽标 */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 7px; font-size: 11.5px; font-weight: 600; background: #f1f4fa; color: var(--muted); white-space: nowrap; }
.badge-brand { background: rgba(99, 102, 241, .1); color: var(--brand-600); }
.badge-green { background: rgba(16, 185, 129, .12); color: #047857; }
.badge-amber { background: rgba(245, 158, 11, .14); color: #b45309; }
.badge-red { background: rgba(239, 68, 68, .12); color: #b91c1c; }
.badge-cyan { background: rgba(6, 182, 212, .12); color: #0e7490; }
.badge-gray { background: #f1f4fa; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pulse { position: relative; }
.pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid currentColor; opacity: .4; animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { transform: scale(.7); opacity: .6; } 100% { transform: scale(1.6); opacity: 0; } }

/* ---------------------------------------------------------------- 头像 */
.avatar { width: 36px; height: 36px; border-radius: 11px; background: var(--grad); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: none; overflow: hidden; }
.avatar-sm { width: 28px; height: 28px; border-radius: 9px; font-size: 11.5px; }
.avatar-lg { width: 48px; height: 48px; border-radius: 14px; font-size: 17px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------------------------------------------------------------- 表格 */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-2); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:hover { background: #fafbff; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px); display: none; align-items: center; justify-content: center; z-index: 900; padding: 20px; }
.modal-mask.show { display: flex; animation: fade .18s ease; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .22s cubic-bezier(.2, .9, .3, 1.2); overflow: hidden; }
.modal.wide { max-width: 820px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 22px; overflow: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 10px; background: var(--surface-2); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }

/* ---------------------------------------------------------------- 提示 */
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 9px; padding: 11px 18px; border-radius: 11px; background: #0f172a; color: #fff; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); animation: toastIn .26s cubic-bezier(.2, .9, .3, 1.2); }
.toast.ok { background: linear-gradient(135deg, #059669, #10b981); }
.toast.err { background: linear-gradient(135deg, #dc2626, #ef4444); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(.96); } }

/* ---------------------------------------------------------------- 其他 */
.empty { padding: 46px 20px; text-align: center; color: var(--muted); }
.empty .ico { font-size: 30px; opacity: .5; margin-bottom: 8px; }
.divider { height: 1px; background: var(--line-2); margin: 18px 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.tiny { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.gap-8 { gap: 8px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spin { width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, #eef1f7 25%, #f6f8fc 37%, #eef1f7 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@media (max-width: 900px) {
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
