/* ============================================================
   AI 智能客服 SaaS · 统一设计系统
   Design Read: B2B SaaS for SMB owners & procurement,
   restrained premium business language, cool neutral base
   + single deep-blue accent + precise typography.
   ============================================================ */

/* ---------- 1. Design Tokens ---------- */
:root {
  --bg: #0d1017;
  --bg-soft: #12161f;
  --panel: #161b25;
  --panel-2: #1c222e;
  --panel-3: #232a38;
  --line: #2a3241;
  --line-soft: #1e2531;
  --line-strong: #3a4453;

  --txt: #eef2f7;
  --txt-2: #c3ccd9;
  --dim: #8b97a8;

  --acc: #3b6ef5;
  --acc-2: #2f5fd8;
  --acc-soft: #3b6ef522;
  --acc-line: #3b6ef54d;

  --ok: #2fa86a;
  --ok-soft: #2fa86a1f;
  --warn: #c98a25;
  --warn-soft: #c98a251f;
  --err: #d8524a;
  --err-soft: #d8524a1f;

  --r-xs: 6px;
  --r-sm: 9px;
  --r: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  --sh-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px -2px rgba(0, 0, 0, .25);
  --sh: 0 8px 24px -8px rgba(0, 0, 0, .5);
  --sh-lg: 0 24px 64px -16px rgba(0, 0, 0, .65);

  --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, monospace;

  --ease: cubic-bezier(.16, 1, .3, 1);
  --t-fast: .16s var(--ease);
  --t: .28s var(--ease);
  --t-slow: .5s var(--ease);
}

/* ---------- 2. Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

:focus-visible {
  outline: 2px solid var(--acc-line);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--acc-soft); color: var(--txt); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--r-pill);
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #3a4453; }

/* ---------- 3. Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 .5em;
  font-weight: 650;
  letter-spacing: -.02em;
  line-height: 1.22;
  color: var(--txt);
  text-wrap: balance;
}
h1 { font-size: clamp(1.9rem, 4.2vw, 3rem); letter-spacing: -.03em; line-height: 1.1; }
h2 { font-size: clamp(1.45rem, 2.6vw, 2.1rem); letter-spacing: -.025em; }
h3 { font-size: 1.18rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 1em; color: var(--txt-2); }
p:last-child { margin-bottom: 0; }
a { color: var(--acc); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: #5c86f8; }
small { font-size: .8rem; color: var(--dim); }
strong, b { font-weight: 650; color: var(--txt); }
code, kbd, .mono { font-family: var(--mono); font-size: .88em; }

.eyebrow {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--acc);
  margin-bottom: .75rem;
}

/* ---------- 4. Layout ---------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.wrap-sm { max-width: 860px; margin: 0 auto; padding: 0 24px; }
.stack > * + * { margin-top: 1rem; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* ---------- 5. Panels ---------- */
.panel {
  background: linear-gradient(180deg, #1a202c, var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 22px 24px;
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, var(--sh-sm);
}
.panel-flush { padding: 0; overflow: hidden; }
.panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.panel-hd h3, .panel-hd h4 { margin: 0; font-size: .96rem; }
.panel-bd { padding: 18px 20px; }

.surface-2 { background: var(--panel-2); }
.surface-3 { background: var(--panel-3); }

/* ---------- 6. Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--panel-2);
  color: var(--txt);
  font: inherit;
  font-size: .875rem;
  font-weight: 550;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast),
              transform var(--t-fast), box-shadow var(--t-fast), color var(--t-fast);
}
.btn:hover { background: var(--panel-3); border-color: #3a4453; }
.btn:active { transform: translateY(1px) scale(.995); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn.primary {
  background: linear-gradient(180deg, #4a7cf7, var(--acc));
  border-color: #4a7cf7;
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 4px 14px -4px #3b6ef566;
}
.btn.primary:hover {
  background: linear-gradient(180deg, var(--acc), var(--acc-2));
  border-color: var(--acc);
  box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 8px 22px -6px #3b6ef588;
}

.btn.ghost { background: transparent; border-color: var(--line); color: var(--txt-2); }
.btn.ghost:hover { background: var(--panel-2); color: var(--txt); }

.btn.sm { padding: 5px 11px; min-height: 30px; font-size: .8rem; border-radius: var(--r-xs); }
.btn.lg { padding: 12px 26px; min-height: 46px; font-size: .95rem; border-radius: var(--r); }
.btn.block { width: 100%; }
.btn.danger { color: var(--err); border-color: #d8524a44; }
.btn.danger:hover { background: var(--err-soft); border-color: var(--err); }

/* ---------- 7. Forms ---------- */
label { display: block; font-size: .82rem; font-weight: 550; color: var(--txt-2); margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  min-height: 38px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--txt);
  font: inherit;
  font-size: .875rem;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
input::placeholder, textarea::placeholder { color: var(--dim); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--acc);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--acc-soft);
}
textarea { min-height: 90px; resize: vertical; line-height: 1.6; }
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='%238b97a8' d='M6 8.5L1.5 4h9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.field { margin-bottom: 14px; }
.field-hint { font-size: .76rem; color: var(--dim); margin-top: 5px; }
.field-err { font-size: .78rem; color: var(--err); margin-top: 5px; }

/* ---------- 8. Pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-size: .74rem;
  font-weight: 550;
  line-height: 1.6;
  white-space: nowrap;
  background: var(--panel-3);
  color: var(--txt-2);
  border: 1px solid var(--line);
}
.pill.ok { background: var(--ok-soft); color: #4fd18b; border-color: #2fa86a44; }
.pill.warn { background: var(--warn-soft); color: #e0a84e; border-color: #c98a2544; }
.pill.err { background: var(--err-soft); color: #f0736b; border-color: #d8524a44; }
.pill.info { background: var(--acc-soft); color: #7b9cf8; border-color: var(--acc-line); }

/* ---------- 9. Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: .855rem; }
thead th {
  text-align: left;
  padding: 11px 14px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--dim);
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--txt-2);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: var(--panel-2); }

/* ---------- 10. States ---------- */
.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--dim);
  font-size: .86rem;
  line-height: 1.7;
}
.skel {
  background: linear-gradient(90deg, var(--panel-2) 25%, var(--panel-3) 50%, var(--panel-2) 75%);
  background-size: 200% 100%;
  border-radius: var(--r-xs);
  animation: skel-shift 1.4s ease-in-out infinite;
}
@keyframes skel-shift { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- 11. Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%) translateY(20px);
  padding: 11px 20px;
  background: var(--panel-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--txt);
  font-size: .86rem;
  box-shadow: var(--sh-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t), transform var(--t);
  z-index: 9000;
  max-width: 90vw;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: #d8524a66; color: #f0736b; }
.toast.ok { border-color: #2fa86a66; color: #4fd18b; }

.divider { height: 1px; background: var(--line-soft); border: 0; margin: 20px 0; }
.dot-sep { color: var(--dim); margin: 0 6px; }

/* ---------- 12. Icon helper (phosphor via iconify) ---------- */
/* 内联 SVG 图标容器（icons.js 注入） */
.ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45em;
  height: 1.45em;
  flex: none;
  line-height: 0;
}
.ic > svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* 图标在彩色框内必须是白色，防止被父级 span 规则污染 */
.ic-box .ic,
.ic-box .ic > svg {
  color: #fff !important;
  stroke: #fff;
}
.ic-box {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  color: #fff;
  border: 1px solid transparent;
  background: linear-gradient(160deg, #4a7cf7, #2f5fd8);
  border-color: #5c86f8;
  box-shadow: 0 1px 0 rgba(255,255,255,.22) inset, 0 4px 12px -4px #3b6ef566;
}

/* ---- 多色系：按语义分配 ---- */
.ic-box.c-blue   { background:linear-gradient(160deg,#4a7cf7,#2f5fd8); border-color:#5c86f8; box-shadow:0 1px 0 #ffffff22 inset,0 4px 12px -4px #3b6ef566 }
.ic-box.c-violet { background:linear-gradient(160deg,#8b7cf8,#6349d4); border-color:#a394ff; box-shadow:0 1px 0 #ffffff22 inset,0 4px 12px -4px #7c6cf066 }
.ic-box.c-cyan   { background:linear-gradient(160deg,#22b8d8,#0f7f9c); border-color:#4fd4ee; box-shadow:0 1px 0 #ffffff22 inset,0 4px 12px -4px #22b8d866 }
.ic-box.c-green  { background:linear-gradient(160deg,#34c97e,#1f8a54); border-color:#4fd18b; box-shadow:0 1px 0 #ffffff22 inset,0 4px 12px -4px #2fa86a66 }
.ic-box.c-amber  { background:linear-gradient(160deg,#e8a33a,#b8761a); border-color:#f0bb5c; box-shadow:0 1px 0 #ffffff22 inset,0 4px 12px -4px #c98a2566 }
.ic-box.c-rose   { background:linear-gradient(160deg,#e85c78,#b83352); border-color:#f27d94; box-shadow:0 1px 0 #ffffff22 inset,0 4px 12px -4px #d8524a66 }
.ic-box.c-teal   { background:linear-gradient(160deg,#2fb8a3,#188b78); border-color:#4fd6c1; box-shadow:0 1px 0 #ffffff22 inset,0 4px 12px -4px #2fa89666 }
.ic-box.c-orange { background:linear-gradient(160deg,#e87d3a,#b8551a); border-color:#f2995c; box-shadow:0 1px 0 #ffffff22 inset,0 4px 12px -4px #d9783566 }

/* ---------- 13. Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 14. Responsive ---------- */
@media (max-width: 768px) {
  .wrap, .wrap-sm { padding: 0 18px; }
  .panel { padding: 18px 16px; }
  h1 { font-size: clamp(1.65rem, 7vw, 2.2rem); }
  h2 { font-size: clamp(1.3rem, 5vw, 1.75rem); }
  .grid { gap: 14px; }
  .btn { min-height: 42px; }
}
