/* ============================================================
   coutixy 工作台 Design System v1  (yy / sj / cs 三站共用)
   规范文档: 设计规范.md — 改样式先改规范, 禁止页面内私加颜色/字号
   ============================================================ */

/* ---------- 1. Design Tokens ---------- */
:root {
  /* 侧栏暗底次级文字三档(2026-07-03 登记;cs 邮箱工作台深青侧栏在用) */
  --sb-dim: #7d8f8c;
  --sb-dim2: #9fb3b0;
  --sb-hint: #5d6f6c;

  /* 品牌深青 (Tailwind Teal 标尺) */
  --brand-50:  #f0fdfa;
  --brand-100: #ccfbf1;
  --brand-300: #5eead4;
  --brand-500: #14b8a6;
  --brand-600: #0d9488;   /* 默认品牌色: Primary 按钮/链接/强调 */
  --brand-700: #0f766e;   /* Primary hover */
  --brand-900: #134e4a;
  --sidebar-bg: #0f1f1d;

  /* 中性 (页面 85% 面积) */
  --bg:        #f6f8fa;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --line:      #e8eef2;    /* 结构分隔线(极浅,只用于分区/表格行) */
  --line-ctl:  #cbd5e1;    /* 控件可见边框(按钮/输入框,比 --line 明显,防"隐形按钮") */
  --text:      #0f1f2a;
  --text-2:    #475569;
  --text-3:    #94a3b8;

  /* 状态色 (只许 文字色 + 浅底 两种用法) */
  --success:      #047857;
  --success-bg:   #ecfdf5;
  --warning:      #b45309;
  --warning-bg:   #fffbeb;
  --danger:       #b91c1c;
  --danger-bg:    #fef2f2;
  /* Info：第四组语义色（2026-08-06 补）。此前只有 成功/警告/危险 三组，
     "在途 / 运输中 / 一般信息" 这类状态没有可用 token，各页只好各写各的蓝
     （#1c5fb0 / #1c5aa6 / #1890ff…）。补齐后一律走这一组。 */
  --info:         #1d4ed8;
  --info-bg:      #eff6ff;

  /* 圆角 / 阴影 */
  --radius-sm:   8px;
  --radius:      10px;
  --radius-full: 999px;
  --shadow:     0 1px 3px rgba(15, 23, 42, .07);
  --shadow-pop: 0 8px 24px rgba(15, 23, 42, .12);

  /* 间距 8px 网格 */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --transition: 180ms ease;
}

/* ---------- 2. Base ---------- */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); }

/* ---------- 3. Typography Scale (7 档, 禁止自定义字号) ---------- */
.t-page    { font-size: 20px; font-weight: 650; color: var(--text); margin: 0; }
.t-section { font-size: 15px; font-weight: 600; color: var(--text); margin: 0; }
.t-body    { font-size: 14px; color: var(--text); }
.t-sub     { font-size: 13px; color: var(--text-2); }
.t-cap     { font-size: 12px; color: var(--text-3); }
.t-num     { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 4. Layout ---------- */
.sidebar {
  width: 220px; min-height: 100vh;
  background: var(--sidebar-bg);
  padding: var(--sp-4) var(--sp-2);
}
.sidebar .nav-group-title {
  font-size: 12px; color: rgba(203, 213, 225, .55);
  padding: var(--sp-4) var(--sp-3) var(--sp-1);
  text-transform: uppercase; letter-spacing: .05em;
}
.sidebar .nav-item {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  color: #cbd5e1; font-size: 14px; cursor: pointer;
  border-left: 3px solid transparent;
  transition: background var(--transition), color var(--transition);
}
.sidebar .nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar .nav-item.active {
  background: rgba(94, 234, 212, .08);
  color: var(--brand-300);
  border-left-color: var(--brand-500);
}
.topbar {
  height: 56px; background: var(--surface);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-6);
  border-bottom: 1px solid var(--line);
}
.page-body { padding: var(--sp-6); }

/* ---------- 5. Card (分层靠背景差+留白+一级阴影, 不靠边框) ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--sp-4);
}
.card + .card { margin-top: var(--sp-4); }
.card-lg { padding: var(--sp-6); }
.card-section {                      /* 卡片内分区 */
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: var(--sp-3) var(--sp-4);
}
.card-grid {                         /* Dashboard 统计卡网格 */
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.stat-num { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- 6. Buttons (每屏 1 个 Primary) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; height: 36px; padding: 0 var(--sp-4);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font: 500 14px var(--font); cursor: pointer;
  background: transparent; color: var(--text);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
}
.btn-sm { height: 30px; padding: 0 var(--sp-3); font-size: 13px; }
/* disabled 仍要看得见是个按钮(别淡到隐形), 只是明显不可点 */
.btn:disabled { opacity: .6; cursor: not-allowed; filter: grayscale(.3); }

/* Primary: 实心品牌色 + 阴影抬起, 页面最抓眼的那一个 */
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: 0 2px 8px rgba(13,148,136,.28); }
.btn-primary:hover:not(:disabled) { background: var(--brand-700); box-shadow: 0 3px 12px rgba(13,148,136,.36); }

/* Tonal(品牌调): 与 Primary 同族但更轻——用于"和主动作相关的次动作"(如 定时发送 之于 立即发送) */
.btn-tonal { background: var(--brand-50); border-color: var(--brand-300); color: var(--brand-700); }
.btn-tonal:hover:not(:disabled) { background: var(--brand-100); border-color: var(--brand-500); }

/* Secondary 必须一眼是按钮: 浅灰填充 + 可见边框(--line-ctl), 别在白卡上白底隐形 */
.btn-secondary { background: var(--surface-2); border-color: var(--line-ctl); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #eef2f6; border-color: #b6c2cd; }

/* Ghost 仅用于工具栏里的图标按钮(有上下文可找); 别拿它当白卡上独立动作按钮=会隐形 */
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn-text { color: var(--brand-600); padding: 0 var(--sp-1); height: auto; }
.btn-text:hover:not(:disabled) { color: var(--brand-700); text-decoration: underline; }

.btn-danger { background: var(--surface); border-color: #fecaca; color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); }
.btn-danger-solid { background: var(--danger); color: #fff; }  /* 仅二次确认弹窗内 */

.btn-icon { width: 36px; padding: 0; color: var(--text-2); }
.btn-icon:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn.is-loading { pointer-events: none; opacity: .7; }
.btn.is-loading::before {
  content: ""; width: 14px; height: 14px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: ds-spin .7s linear infinite;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* ---------- 7. Badge (弱化: 浅底深字, 禁饱和实心) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 500;
  background: var(--surface-2); color: var(--text-2);
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-brand   { background: var(--brand-50);   color: var(--brand-700); } /* VIP/PRO */
.badge .dot {   /* 灰 Badge 需要更强区分时: 点带色, 字不带色 */
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3); flex: none;
}
.badge .dot-success { background: var(--success); }
.badge .dot-warning { background: var(--warning); }
.badge .dot-danger  { background: var(--danger); }
.badge .dot-brand   { background: var(--brand-600); }

/* ---------- 8. Table ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface);
  font-size: 12px; font-weight: 500; color: var(--text-3);
  text-align: left; padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none;
}
.table td {
  padding: var(--sp-2) var(--sp-3); height: 40px;
  border-bottom: 1px solid var(--line);
}
.table-compact td { height: 34px; padding-top: var(--sp-1); padding-bottom: var(--sp-1); }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.selected { background: var(--brand-50); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .row-actions { opacity: 0; transition: opacity var(--transition); }
.table tr:hover .row-actions { opacity: 1; }

/* ---------- 9. Forms ---------- */
.field { display: flex; flex-direction: column; gap: var(--sp-1); }
.field label { font-size: 13px; color: var(--text-2); }
.input, select.input, textarea.input {
  height: 36px; padding: 0 var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: 400 14px var(--font); color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
textarea.input { height: auto; padding: var(--sp-2) var(--sp-3); resize: vertical; }
.input:focus {
  border-color: var(--brand-600);
  box-shadow: 0 0 0 2px rgba(13, 148, 136, .12);
  background: var(--surface);
}
.input::placeholder { color: var(--text-3); }
.field .help  { font-size: 12px; color: var(--text-3); }
.field .error { font-size: 12px; color: var(--danger); }

/* ---------- 10. Feedback: Modal / Toast / Loading / Empty ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .4);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  width: min(520px, calc(100vw - 48px));
  padding: var(--sp-6);
}
.modal-footer {
  display: flex; justify-content: flex-end; gap: var(--sp-2);
  margin-top: var(--sp-6);
}

.toast-stack {
  position: fixed; top: var(--sp-4); right: var(--sp-4); z-index: 200;
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.toast {
  background: var(--surface); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
  padding: var(--sp-3) var(--sp-4);
  border-left: 3px solid var(--brand-600);
  font-size: 13px; max-width: 360px;
  animation: ds-slidein 200ms ease;
}
.toast-success { border-left-color: var(--success); }
.toast-warning { border-left-color: var(--warning); }
.toast-danger  { border-left-color: var(--danger); }
@keyframes ds-slidein { from { transform: translateX(16px); opacity: 0; } }

.loading-dots { display: inline-flex; gap: 4px; }
.loading-dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3);
  animation: ds-pulse 1s ease-in-out infinite;
}
.loading-dots i:nth-child(2) { animation-delay: .15s; }
.loading-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ds-pulse { 50% { opacity: .3; transform: translateY(-2px); } }

.empty {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--sp-2); padding: var(--sp-10) var(--sp-4);
  color: var(--text-3); text-align: center;
}
.empty .empty-icon { font-size: 28px; opacity: .6; }
.empty .empty-text { font-size: 13px; color: var(--text-2); }

/* ---------- 11. Misc ---------- */
.divider { height: 1px; background: var(--line); margin: var(--sp-4) 0; border: 0; }
.hidden { display: none !important; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
