/* ============================================================
   KOL Hub — 样式
   设计意图：界面本身尽量安静，把颜色预算全部留给「状态」与
   「停留时长」。老化条是全站唯一的强视觉元素。
   ============================================================ */

:root {
  --paper:      #F5F7F3;
  --surface:    #FFFFFF;
  --surface-2:  #FAFBF9;
  --ink:        #171B19;
  --ink-2:      #545D58;
  --ink-3:      #8A938D;
  --line:       #E3E7E1;
  --line-2:     #EFF2ED;

  --accent:     #2F5D50;
  --accent-2:   #E7EFEA;
  --warn:       #A8791E;
  --warn-2:     #FBF2DE;
  --alert:      #A93D18;
  --alert-2:    #FBEAE3;
  --ok:         #35735A;

  --r:    6px;
  --r-lg: 10px;
  --shadow: 0 1px 2px rgba(23,27,25,.05), 0 8px 24px -12px rgba(23,27,25,.18);

  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;

  --rail: 168px;
  --top:  52px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top); z-index: 40;
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brandmark {
  font-weight: 650; letter-spacing: .1em; font-size: 12px;
  text-transform: uppercase; color: var(--ink);
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
}
.brandmark i {
  width: 9px; height: 9px; border-radius: 2px;
  background: var(--accent); display: inline-block;
}

.segmented { display: flex; gap: 2px; background: var(--line-2); padding: 2px; border-radius: var(--r); }
.segmented button {
  border: 0; background: transparent; padding: 5px 11px; border-radius: 4px;
  font-size: 12.5px; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.segmented button[aria-pressed="true"] {
  background: var(--surface); color: var(--ink); font-weight: 550;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.spacer { flex: 1; }

/* ---------------- 左侧导航 ---------------- */
.rail {
  position: fixed; top: var(--top); left: 0; bottom: 0; width: var(--rail); z-index: 30;
  background: var(--surface-2); border-right: 1px solid var(--line);
  padding: 12px 10px; display: flex; flex-direction: column; gap: 2px;
}
.rail a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: var(--r); color: var(--ink-2);
  font-size: 13.5px; text-decoration: none;
}
.rail a:hover { background: var(--line-2); text-decoration: none; }
.rail a.on { background: var(--accent); color: #fff; font-weight: 550; }
.rail a.on .pill { background: rgba(255,255,255,.24); color: #fff; }
.rail .pill {
  font-family: var(--mono); font-size: 11px; padding: 1px 6px;
  border-radius: 20px; background: var(--line); color: var(--ink-2);
}
.rail .pill.hot { background: var(--alert); color: #fff; }
.rail .sep { height: 1px; background: var(--line); margin: 10px 4px; }

/* ---------------- 主区 ---------------- */
main { margin: var(--top) 0 0 var(--rail); padding: 18px 20px 80px; min-height: calc(100vh - var(--top)); }

.pagehead { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.pagehead h1 { margin: 0; font-size: 19px; font-weight: 620; letter-spacing: -.01em; }
.pagehead .sub { color: var(--ink-3); font-size: 12.5px; }

/* ---------------- 通用控件 ---------------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 6px 12px; border-radius: var(--r); cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--line-2); }
.btn.danger { color: var(--alert); border-color: var(--alert-2); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input[type=text], input[type=number], input[type=date], input[type=email], select, textarea {
  border: 1px solid var(--line); border-radius: var(--r); padding: 6px 9px;
  background: var(--surface); width: 100%; font-size: 13px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
textarea { resize: vertical; min-height: 70px; line-height: 1.55; }
label.f { display: block; margin-bottom: 10px; }
label.f > span, .f > span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 3px; }
.f { margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
.ship-items { display: flex; flex-direction: column; gap: 8px; margin-bottom: 7px; }
.ship-item-row {
  display: grid; grid-template-columns: 1.2fr 1fr .9fr .7fr; gap: 6px;
  border: 1px solid var(--line); border-radius: var(--r); padding: 8px;
  background: var(--paper);
}
.ship-item-row input { min-width: 0; }
.ship-item-row [data-item-f="quantity"],
.ship-item-row [data-item-f="sample_cost"] { text-align: right; }
.ship-item-row [data-item-f="note"] { grid-column: 1 / 4; }
.ship-item-row [data-remove-ship-item] { justify-self: end; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.pad { padding: 14px 16px; }

.tag {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 20px;
  background: var(--line-2); color: var(--ink-2); border: 1px solid var(--line);
}

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink-2); font-size: 14px; margin-bottom: 5px; font-weight: 550; }

/* ---------------- 漏斗概览条 ---------------- */
.funnelbar {
  display: flex; gap: 0; align-items: stretch; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
  background: var(--surface);
}
.funnelbar .step {
  flex: 1; padding: 9px 12px; border-right: 1px solid var(--line-2); min-width: 0;
}
.funnelbar .step:last-child { border-right: 0; }
.funnelbar .k { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.funnelbar .v { font-family: var(--mono); font-size: 18px; font-weight: 550; letter-spacing: -.02em; }
.funnelbar .r { font-size: 11px; color: var(--accent); font-family: var(--mono); }

/* ---------------- 看板 ---------------- */
.board { display: flex; gap: 10px; align-items: flex-start; overflow-x: auto; padding-bottom: 16px; }
.col { flex: 0 0 232px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); }
.col.over { border-color: var(--accent); background: var(--accent-2); }
.col > header {
  padding: 9px 11px 8px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 7px;
}
.col > header .name { font-size: 12.5px; font-weight: 600; }
.col > header .n { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); margin-left: auto; }
.col .body { padding: 8px; display: flex; flex-direction: column; gap: 7px; min-height: 56px; max-height: calc(100vh - 260px); overflow-y: auto; }

.kcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 9px 10px 0; cursor: grab; position: relative;
}
.kcard:hover { border-color: var(--ink-3); }
.kcard.dragging { opacity: .4; }
.kcard .row1 { display: flex; align-items: baseline; gap: 6px; }
.kcard .nm { font-weight: 560; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard .plat { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.kcard .meta { display: flex; gap: 8px; align-items: center; font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.kcard .meta .num { color: var(--ink-2); }

/* —— 签名元素：停留老化条 —— */
.aging { margin: 8px -10px 0; height: 3px; background: var(--line-2); position: relative; border-radius: 0 0 var(--r) var(--r); overflow: hidden; }
.aging i { position: absolute; inset: 0 auto 0 0; background: var(--accent); opacity: .35; transition: width .3s; }
.aging.warn i  { background: var(--warn);  opacity: .8; }
.aging.alert i { background: var(--alert); opacity: 1; }
.kcard.alert { border-color: #E9C0AC; }
.kcard .days { font-family: var(--mono); font-size: 11px; margin-left: auto; color: var(--ink-3); }
.kcard.alert .days { color: var(--alert); font-weight: 600; }
.kcard.warn .days { color: var(--warn); }

/* 列头的整体压力条 */
.pressure { display: flex; height: 2px; gap: 1px; }
.pressure i { flex: 1; background: var(--line); }
.pressure i.ok { background: var(--accent); opacity: .45; }
.pressure i.warn { background: var(--warn); }
.pressure i.alert { background: var(--alert); }

/* ---------------- 表格 ---------------- */
.tablewrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; background: var(--surface-2); z-index: 2;
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--ink-2);
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer;
}
thead th.plain { cursor: default; }
tbody td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.sel { background: var(--accent-2); }
td.r, th.r { text-align: right; }
.linkish { cursor: pointer; font-weight: 550; }
.linkish:hover { color: var(--accent); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[type=text] { width: 190px; }
.filters select { width: auto; min-width: 96px; }

.bulkbar {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 45;
  background: var(--ink); color: #fff; border-radius: 30px; padding: 7px 8px 7px 16px;
  display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow); font-size: 13px;
}
.bulkbar .btn { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; }
.bulkbar .btn:hover { background: rgba(255,255,255,.22); }
.bulkbar select { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; width: auto; }
.bulkbar select option { color: var(--ink); }

/* ---------------- 状态徽标 ---------------- */
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; white-space: nowrap; }

/* ---------------- 抽屉 ---------------- */
.scrim { position: fixed; inset: 0; background: rgba(23,27,25,.32); z-index: 50; opacity: 0; pointer-events: none; transition: opacity .18s; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); z-index: 51;
  background: var(--paper); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .22s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
}
.drawer.on { transform: none; }
.drawer > header { padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--surface); display: flex; align-items: flex-start; gap: 10px; }
.drawer > .scroll { flex: 1; overflow-y: auto; padding: 14px 16px 40px; }
.drawer h2 { margin: 0; font-size: 17px; font-weight: 620; }
.drawer .sect { margin-bottom: 18px; }
.drawer .sect > h3 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-3); margin: 0 0 8px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.drawer .sect > h3::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button {
  border: 0; background: transparent; padding: 7px 11px; cursor: pointer;
  font-size: 13px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 560; }

.kv { display: grid; grid-template-columns: 82px 1fr; gap: 5px 10px; font-size: 13px; }
.kv dt { color: var(--ink-3); font-size: 12px; }
.kv dd { margin: 0; }

/* 时间线 */
.tl { position: relative; padding-left: 16px; }
.tl::before { content: ''; position: absolute; left: 3px; top: 4px; bottom: 4px; width: 1px; background: var(--line); }
.tl .ev { position: relative; padding: 0 0 13px; }
.tl .ev::before {
  content: ''; position: absolute; left: -16px; top: 5px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3);
  border: 2px solid var(--paper);
}
.tl .ev.status::before { background: var(--accent); }
.tl .ev .when { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.tl .ev .what { font-size: 13px; }
.tl .ev .who { font-size: 11.5px; color: var(--ink-3); }

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed; z-index: 60; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: min(560px, calc(100% - 28px)); max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.modal > header { padding: 14px 16px 0; }
.modal > header h3 { margin: 0; font-size: 16px; font-weight: 620; }
.modal > .bd { padding: 14px 16px; }
.modal > footer { padding: 0 16px 14px; display: flex; gap: 8px; justify-content: flex-end; }

/* ---------------- 提醒清单 ---------------- */
.todo { display: flex; flex-direction: column; gap: 7px; }
.todoitem {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 12px; display: flex; align-items: center; gap: 10px;
}
.todoitem.overdue { border-left: 3px solid var(--alert); }
.todoitem.due     { border-left: 3px solid var(--warn); }
.todoitem .t { flex: 1; min-width: 0; }
.todoitem .t .main { font-size: 13.5px; }
.todoitem .t .sub  { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }

/* ---------------- 图表 ---------------- */
.bars { display: flex; flex-direction: column; gap: 6px; }
.barrow { display: grid; grid-template-columns: 130px 1fr 76px; gap: 10px; align-items: center; font-size: 12.5px; }
.barrow .track { background: var(--line-2); border-radius: 3px; height: 16px; overflow: hidden; }
.barrow .fill { height: 100%; background: var(--accent); opacity: .8; border-radius: 3px; }

.spark { display: flex; align-items: flex-end; gap: 4px; height: 92px; }
.spark .b { flex: 1; background: var(--accent); opacity: .75; border-radius: 2px 2px 0 0; min-height: 2px; position: relative; }
.spark .b:hover { opacity: 1; }
.sparkx { display: flex; gap: 4px; margin-top: 5px; }
.sparkx span { flex: 1; text-align: center; font-family: var(--mono); font-size: 10px; color: var(--ink-3); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px,1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; }
.stat .k { font-size: 11.5px; color: var(--ink-3); }
.stat .v { font-family: var(--mono); font-size: 22px; font-weight: 550; letter-spacing: -.03em; margin-top: 2px; }
.stat .n { font-size: 11.5px; color: var(--ink-3); }

/* ---------------- 评论工作台 ---------------- */
.comment-section { margin-bottom: 18px; }
.comment-section__head {
  display: flex; align-items: baseline; gap: 10px; margin: 0 0 8px;
}
.comment-section__head h2 { margin: 0; font-size: 14px; font-weight: 620; }
.comment-section__head span { color: var(--ink-3); font-size: 12.5px; }
.comment-posts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px;
}
.comment-post { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.comment-post__main { display: flex; align-items: flex-start; gap: 10px; }
.comment-post__main > div { min-width: 0; flex: 1; }
.comment-post__name { font-size: 13.5px; font-weight: 600; }
.comment-post__meta { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.comment-post p { margin: 0; color: var(--ink-2); font-size: 12.5px; }
.comment-post__url {
  color: var(--ink-3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.comment-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }

/* ---------------- Toast ---------------- */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 90; display: flex; flex-direction: column; gap: 7px; }
.toast {
  background: var(--ink); color: #fff; padding: 9px 14px; border-radius: var(--r);
  font-size: 13px; box-shadow: var(--shadow); max-width: 340px;
  animation: rise .2s ease-out;
}
.toast.err { background: var(--alert); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 44;
  width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: var(--accent); color: #fff; font-size: 22px; cursor: pointer;
  box-shadow: var(--shadow); display: grid; place-items: center; line-height: 1;
}

.loading { padding: 40px; text-align: center; color: var(--ink-3); font-size: 13px; }

/* ---------------- 移动端 ---------------- */
@media (max-width: 860px) {
  :root { --rail: 0px; }
  .rail {
    top: auto; bottom: 0; left: 0; right: 0; width: auto; height: 54px;
    flex-direction: row; border-right: 0; border-top: 1px solid var(--line);
    padding: 5px 4px; background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
  }
  .rail a { flex: 1; flex-direction: column; justify-content: center; gap: 1px; font-size: 10.5px; padding: 4px 2px; text-align: center; }
  .rail a .ic { font-size: 15px; line-height: 1; }
  .rail a.on { background: transparent; color: var(--accent); }
  .rail a.on .pill { background: var(--alert); }
  .rail .pill { position: absolute; top: 2px; right: 22%; font-size: 9px; padding: 0 4px; }
  .rail .sep, .rail .lbl-desktop { display: none; }
  main { padding: 12px 12px 76px; }
  .fab { bottom: 68px; right: 14px; }
  .toasts { bottom: 68px; right: 12px; left: 12px; }
  .bulkbar { bottom: 66px; left: 12px; right: 12px; transform: none; border-radius: var(--r-lg); }
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar .hide-sm { display: none; }
  .board { gap: 8px; }
  .col { flex: 0 0 78vw; }
  .col .body { max-height: none; }
  .grid2, .grid3, .ship-item-row { grid-template-columns: 1fr; }
  .ship-item-row [data-item-f="note"] { grid-column: auto; }
  .ship-item-row [data-remove-ship-item] { justify-self: stretch; }
  .funnelbar { flex-wrap: wrap; }
  .funnelbar .step { flex: 1 0 33%; border-bottom: 1px solid var(--line-2); }
  .kv { grid-template-columns: 72px 1fr; }
  .barrow { grid-template-columns: 96px 1fr 62px; }
  .drawer { width: 100%; }
}
@media (min-width: 861px) { .rail a .ic { display: none; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
