/* ============ 全局 ============ */
:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --green: #34a853;
  --green-light: #e6f4ea;
  --yellow: #f9ab00;
  --yellow-light: #fef7e0;
  --red: #d93025;
  --red-light: #fce8e6;
  --text: #202124;
  --text2: #5f6368;
  --border: #dadce0;
  --bg: #f8f9fa;
  --card: #ffffff;
  --shadow: 0 1px 3px rgba(60,64,67,.15), 0 1px 2px rgba(60,64,67,.1);
  --shadow-lg: 0 4px 16px rgba(60,64,67,.2);
  --radius: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Google Sans', Roboto, 'Noto Sans SC', -apple-system, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; color: var(--text); }
[hidden] { display: none !important; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: none; border-radius: 8px; padding: 9px 18px; font-size: 14px; font-weight: 500;
  transition: background .15s, box-shadow .15s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--primary-light); color: var(--primary); }
.btn-secondary:hover { background: #d2e3fc; }
.btn-text { background: transparent; color: var(--primary); }
.btn-text:hover { background: var(--primary-light); }
.btn-danger { background: transparent; color: var(--red); }
.btn-danger:hover { background: var(--red-light); }
.btn-block { width: 100%; padding: 12px; font-size: 16px; }
.icon-btn {
  background: transparent; border: none; border-radius: 50%; width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--text2);
}
.icon-btn:hover { background: rgba(60,64,67,.08); }
.chip-btn {
  border: 1px solid var(--border); background: #fff; color: var(--text2);
  border-radius: 16px; padding: 5px 14px; font-size: 13px; font-weight: 500;
}
.chip-btn:hover { background: var(--bg); }
.text-btn { background: none; border: none; color: var(--primary); font-size: 13px; }

/* ============ 登录页 ============ */
#page-login { min-height: 100vh; }
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(135deg, #e8f0fe 0%, #f8f9fa 50%, #e6f4ea 100%);
}
.login-card {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 48px 40px; width: 100%; max-width: 400px; text-align: center;
}
.login-logo { margin-bottom: 12px; }
.login-card h1 { font-size: 24px; font-weight: 500; color: var(--text); }
.login-sub { color: var(--text2); font-size: 14px; margin: 4px 0 28px; }
.login-error {
  background: var(--red-light); color: var(--red); border-radius: 8px;
  padding: 10px 12px; font-size: 13px; margin-bottom: 16px; text-align: left;
}
.login-footer { margin-top: 20px; display: flex; align-items: center; justify-content: center; gap: 24px; flex-wrap: wrap; }
.login-footer .text-btn { font-size: 13px; }

/* ============ 浮动标签输入框 ============ */
.field { position: relative; margin-bottom: 18px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 14px 4px; height: 52px; outline: none; background: transparent;
  transition: border-color .15s; resize: vertical;
}
.field textarea { height: auto; padding-top: 20px; }
.field select.has-label { padding-top: 20px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); border-width: 2px; }
.field label {
  position: absolute; left: 14px; top: 15px; color: var(--text2); font-size: 15px;
  pointer-events: none; transition: all .12s; background: transparent; max-width: calc(100% - 28px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.field input:focus + label, .field input:not(:placeholder-shown) + label,
.field textarea:focus + label, .field textarea:not(:placeholder-shown) + label,
.field select.has-label + label {
  top: 6px; font-size: 11px;
}
/* 下拉框标签恒浮于上方（disabled 下 :valid 不生效，故不依赖伪类） */
.field select.has-label + label { color: var(--text2); }
.field select.has-label:focus + label { color: var(--primary); }
.field input:disabled, .field select:disabled, .field textarea:disabled { background: var(--bg); color: var(--text2); cursor: not-allowed; }
.field-full { width: 100%; }
.input {
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px;
  outline: none; background: #fff; min-width: 0;
}
.input:focus { border-color: var(--primary); }
.form-hint { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* ============ Logo ============ */
.logo-img-lg { width: 72px; height: 72px; object-fit: contain; }
.logo-img-sm { width: 32px; height: 32px; object-fit: contain; cursor: pointer; }
.brand-name { font-size: 16px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-hint { font-size: 13px; color: var(--text2); }

/* ============ 顶栏 ============ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 60px; z-index: 100;
  background: var(--card); display: flex; align-items: center; padding: 0 12px;
  box-shadow: var(--shadow); gap: 8px;
}
.brand { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; cursor: pointer; }
.brand-name { font-size: 19px; font-weight: 500; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; font-size: 15px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center;
}
.user-menu { position: relative; }
.dropdown {
  position: absolute; right: 0; top: 46px; background: var(--card); border-radius: 10px;
  box-shadow: var(--shadow-lg); min-width: 200px; padding: 6px 0; z-index: 200;
  border: 1px solid var(--border);
}
.dropdown-head { padding: 12px 16px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dd-name { font-weight: 500; }
.dd-role { font-size: 12px; color: var(--text2); margin-top: 2px; }
.dropdown-item {
  display: block; width: 100%; text-align: left; padding: 10px 16px;
  background: none; border: none; font-size: 14px; color: var(--text);
}
.dropdown-item:hover { background: var(--bg); }

/* ============ 侧栏 ============ */
.sidebar {
  position: fixed; top: 60px; left: 0; bottom: 0; width: 230px; z-index: 90;
  background: var(--card); padding: 12px 8px; display: flex; flex-direction: column; gap: 2px;
  border-right: 1px solid #ecedef;
}
.nav-item {
  display: flex; align-items: center; gap: 14px; padding: 12px 20px; border: none;
  background: none; border-radius: 0 24px 24px 0; font-size: 14px; color: var(--text2);
  text-align: left; width: 100%;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }
.sidebar-foot {
  margin-top: auto; padding: 14px 20px 6px; border-top: 1px solid #ecedef;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.ver-badge {
  font-size: 12px; color: var(--text2); background: var(--bg);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px;
  font-weight: 500; letter-spacing: .3px;
}
.sidebar-foot-hint { font-size: 11px; color: var(--text2); }
#sidebar-mask {
  position: fixed; inset: 60px 0 0 0; background: rgba(0,0,0,.35); z-index: 85;
}

/* ============ 内容区 ============ */
.content { margin: 60px 0 0 230px; padding: 24px; min-height: calc(100vh - 60px); }
.view-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.view-head h2 { font-size: 22px; font-weight: 500; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 18px;
}

/* ============ 仪表盘 ============ */
.year-picker { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text2); }
.year-picker select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; }
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px;
}
.stat-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 14px;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
}
.stat-total::before { background: var(--primary); }
.stat-unfollowed::before { background: var(--red); }
.stat-followed::before { background: var(--yellow); }
.stat-closed::before { background: var(--green); }
/* Google Material 风格图标（圆形底色 + 实心图标） */
.stat-icon {
  width: 46px; height: 46px; flex: 0 0 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 24px; height: 24px; display: block; }
.stat-total .stat-icon { background: var(--primary-light); }
.stat-total .stat-icon svg { fill: var(--primary); }
.stat-unfollowed .stat-icon { background: var(--red-light); }
.stat-unfollowed .stat-icon svg { fill: var(--red); }
.stat-followed .stat-icon { background: var(--yellow-light); }
.stat-followed .stat-icon svg { fill: #b06000; }
.stat-closed .stat-icon { background: var(--green-light); }
.stat-closed .stat-icon svg { fill: var(--green); }
.stat-body { min-width: 0; }
.stat-num { font-size: 34px; font-weight: 700; margin: 0 0 2px; font-family: 'Google Sans', Roboto, sans-serif; line-height: 1.15; }
.stat-label { color: var(--text2); font-size: 13px; }
.chart-card { padding: 20px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chart-head h3 { font-size: 16px; font-weight: 500; }
.chart-legend { display: flex; gap: 16px; font-size: 13px; color: var(--text2); }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
#trend-chart svg { width: 100%; height: auto; display: block; }
.chart-wrap { position: relative; }
.chart-tip {
  position: absolute; pointer-events: none; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 8px 12px; min-width: 132px;
  font-size: 12px; z-index: 5;
}
.chart-tip .tip-title { font-weight: 500; margin-bottom: 4px; color: var(--text); }
.chart-tip .tip-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; color: var(--text2); }
.chart-tip .tip-row i { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.chart-tip .tip-row span { flex: 1; }
.chart-tip .tip-row b { color: var(--text); font-family: 'Google Sans', Roboto, sans-serif; font-weight: 700; }

/* ============ 筛选栏 ============ */
.filter-bar { padding: 14px 16px; }
.filter-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-row .input[type="text"] { flex: 1; min-width: 200px; }
.filter-sep { color: var(--text2); }
#f-status { min-width: 110px; }

/* ============ 表格 ============ */
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.gtable { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 1120px; }
.gtable th {
  text-align: left; padding: 12px 14px; color: var(--text); font-weight: 700; font-size: 14px;
  border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--bg);
  position: sticky; top: 0;
}
.gtable th.sortable { cursor: pointer; user-select: none; }
.gtable th.sortable:hover { color: var(--text); background: #eef1f4; }
.gtable th.sorted { color: var(--primary); background: var(--primary-light); }
.sort-ind { font-style: normal; font-size: 9px; margin-left: 4px; color: var(--primary); }
.gtable td { padding: 12px 14px; border-bottom: 1px solid #f1f3f4; vertical-align: middle; }
.gtable tbody tr:hover { background: var(--bg); }
.gtable .cell-actions { white-space: nowrap; }
.gtable .desc-col { max-width: 200px; }
.desc-clip { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.table-empty { text-align: center; color: var(--text2); padding: 48px 0; }
.badge {
  display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge-unfollowed { background: var(--red-light); color: var(--red); }
.badge-followed { background: var(--yellow-light); color: #b06000; }
.badge-closed { background: var(--green-light); color: var(--green); }
.badge-role { background: var(--primary-light); color: var(--primary); }

/* 提成发放：绿色√ / 灰色✗（仅超级管理员可点击切换） */
.comm {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
}
.comm svg { fill: currentColor; display: block; }
.comm-ok { background: var(--green); color: #fff; }
.comm-no { background: #eef1f4; color: #9aa0a6; }
.comm-btn { border: none; padding: 0; cursor: pointer; transition: box-shadow .15s, transform .1s; }
.comm-btn:hover { box-shadow: var(--shadow-lg); transform: scale(1.06); }
.comm-btn:active { transform: scale(.95); }
.status-select {
  border: 1px solid var(--border); border-radius: 14px; padding: 4px 8px; font-size: 12px;
  background: #fff; outline: none; cursor: pointer;
}
.status-select.s-unfollowed { color: var(--red); border-color: #f6c9c5; background: var(--red-light); }
.status-select.s-followed { color: #b06000; border-color: #f3ddae; background: var(--yellow-light); }
.status-select.s-closed { color: var(--green); border-color: #bfe3c8; background: var(--green-light); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 16px; font-size: 13px; color: var(--text2); }
.pager button {
  border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 6px 12px; font-size: 13px;
}
.pager button:disabled { opacity: .4; cursor: default; }
.pager button:not(:disabled):hover { background: var(--bg); }

/* ============ 对话框 ============ */
.dialog-mask {
  position: fixed; inset: 0; background: rgba(32,33,36,.5); z-index: 300;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
  overflow-y: auto;
}
.dialog {
  background: var(--card); border-radius: 16px; width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); animation: pop .18s ease;
}
.dialog-sm { max-width: 420px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.dialog-head {
  display: flex; align-items: center; justify-content: space-between; padding: 18px 24px 0;
}
.dialog-head h3 { font-size: 18px; font-weight: 500; flex: 1; min-width: 0; }
.dialog-close { color: var(--text2); flex: 0 0 auto; }
.dialog-close:hover { background: rgba(60,64,67,.1); color: var(--text); }
.dialog-body { padding: 18px 24px; }
.dialog-foot { padding: 0 24px 20px; display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.ai-paste { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 18px; }
.ai-paste textarea {
  flex: 1; border: 1px dashed var(--primary); border-radius: 8px; padding: 10px 12px;
  font-size: 13px; outline: none; resize: vertical; background: #fafcff;
}
.ai-paste textarea:focus { background: #fff; }
.dup-warning {
  background: var(--yellow-light); border: 1px solid #f3ddae; border-radius: 8px;
  padding: 12px 14px; font-size: 13px; color: #7a4d00; margin-top: 14px;
}
.dup-warning .dup-item {
  display: flex; justify-content: space-between; gap: 10px; padding: 6px 0;
  border-bottom: 1px dashed #f0e2bb; flex-wrap: wrap;
}
.dup-warning .dup-item:last-child { border-bottom: none; }
.dup-warning b { color: #b06000; }
.dup-block-note {
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed #f0e2bb;
  font-weight: 500; color: #a3350b;
}
/* 命中重复时保存按钮置灰，禁止重复提交 */
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn-primary:disabled, .btn-primary[disabled] { background: #9aa0a6; }

/* ============ 个人中心 ============ */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.profile-grid h3 { font-size: 16px; font-weight: 500; margin-bottom: 16px; }

/* ============ Toast ============ */
#toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  background: #323639; color: #fff; padding: 12px 24px; border-radius: 10px;
  font-size: 14px; z-index: 500; box-shadow: var(--shadow-lg); max-width: 90vw;
  animation: toastIn .2s ease;
}
#toast.toast-error { background: var(--red); }
#toast.toast-success { background: var(--green); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ 更新日志 ============ */
.view-head-hint { font-size: 13px; color: var(--text2); }
.update-list { display: flex; flex-direction: column; gap: 14px; }
.update-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.update-card-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px;
}
.update-ver {
  font-size: 13px; font-weight: 700; color: #fff; background: var(--primary);
  border-radius: 999px; padding: 3px 12px; letter-spacing: .3px;
}
.update-title { font-size: 15px; font-weight: 600; color: var(--text); flex: 1; min-width: 160px; }
.update-time { font-size: 12px; color: var(--text2); }
.update-items { margin: 0; padding-left: 20px; }
.update-items li { font-size: 14px; color: var(--text); line-height: 1.9; }
.update-items li::marker { color: var(--primary); }
.update-meta { font-size: 12px; color: var(--text2); margin-top: 10px; }
.update-empty { color: var(--text2); font-size: 14px; padding: 28px; text-align: center; }

/* ============ 响应式（移动端） ============ */
/* 桌面端侧栏折叠 */
@media (min-width: 769px) {
  body.sb-collapsed .sidebar { transform: translateX(-100%); }
  body.sb-collapsed .content { margin-left: 0; }
}
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .profile-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .dist-col, .desc-col { display: none; }
}
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%); transition: transform .2s ease; width: 250px;
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .content { margin-left: 0; padding: 16px 12px 90px; }
  .brand-name { font-size: 17px; }
  .view-head h2 { font-size: 19px; }
  .stat-num { font-size: 26px; }
  .filter-row .input[type="text"] { min-width: 100%; }
  #f-from, #f-to { flex: 1; }
  .btn { padding: 9px 14px; }
  .dialog-mask { padding: 16px 10px; align-items: flex-start; }
  .login-card { padding: 36px 24px; }
  .gtable { min-width: 1000px; }
  .status-select { display: block; margin-top: 2px; }
}
