/* ==========================================================================
   团队管理后台 —— 在 wiki(style.css) / frps(panel.css) / 文件站(station.css)
   三套既有样式之上的补充层。只加新组件，不改既有类，避免和那三套打架。
   复用变量：--bg --surface --border --text --primary --grad --radius …
   ========================================================================== */

/* ---------------------------------------------------------------- 骨架 */
/* 侧栏宽度必须跟 style.css 的 --sidebar-w（280px）一致：
   写死 244px 会让 280px 宽的侧栏压住内容区，连页面标题的第一个字都被盖住（踩过） */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w, 280px) minmax(0, 1fr); min-height: 100vh; background: var(--bg); }
.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto;
  padding: 18px 14px 28px; border-right: 1px solid var(--border);
  background: var(--bg-soft);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.sidebar-brand .brand-mark {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: var(--grad); color: #fff; font-weight: 800; font-size: .82rem; letter-spacing: .5px;
  box-shadow: 0 8px 20px -10px rgba(2, 132, 199, .8);
}
.sidebar-brand .brand-text { font-weight: 700; font-size: .98rem; color: var(--text); letter-spacing: -.01em; }
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.side-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 11px;
  color: var(--text-dim); font-size: .92rem; font-weight: 600; text-decoration: none;
  border: 1px solid transparent; transition: background .15s, color .15s, border-color .15s;
}
.side-link svg { flex: 0 0 auto; opacity: .85; }
.side-link:hover { background: var(--surface-strong); color: var(--text); }
.side-link.active { background: var(--grad); color: #fff; box-shadow: 0 10px 24px -14px rgba(2, 132, 199, .9); }
.side-link.active svg { opacity: 1; }
.side-sep { height: 1px; margin: 12px 8px; background: var(--border); }
.sidebar-foot { margin-top: 14px; padding: 0 8px; color: var(--text-faint); font-size: .76rem; line-height: 1.7; }

.app-main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  padding: 14px 22px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px);
}
.topbar .page-title-main { margin: 0; font-size: 1.12rem; font-weight: 700; letter-spacing: -.01em; flex: 1 1 auto; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.nav-toggle { display: none; }
.app-content { flex: 1 1 auto; padding: 22px 0 40px; }
.app-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 24px 26px; color: var(--text-faint); font-size: .8rem;
}

.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text);
  font: inherit; font-size: .86rem;
}
.user-chip:hover { border-color: var(--primary); }
.user-chip .avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--grad); color: #fff; font-size: .78rem; font-weight: 700;
}
.role-tag { padding: 2px 8px; border-radius: 999px; font-size: .72rem; background: var(--surface-strong); color: var(--text-dim); }
.role-tag.superadmin { color: #b45309; background: rgba(217, 119, 6, .12); }
.role-tag.admin { color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }

/* ---------------------------------------------------------------- 提示条 / 吐司 */
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: 14px; margin: 0 24px 12px; border: 1px solid var(--tone-bd, var(--border)); background: var(--tone-bg, var(--surface)); color: var(--text); font-size: .9rem; }
.notice-ok { --tone-bg: rgba(22, 138, 91, .10); --tone-bd: rgba(22, 138, 91, .30); }
.notice-warn { --tone-bg: rgba(169, 104, 0, .10); --tone-bd: rgba(169, 104, 0, .30); }
.notice-err { --tone-bg: rgba(217, 45, 69, .09); --tone-bd: rgba(217, 45, 69, .30); }
.notice-info { --tone-bg: color-mix(in srgb, var(--primary) 10%, transparent); --tone-bd: color-mix(in srgb, var(--primary) 28%, transparent); }

.toast-root { position: fixed; right: 22px; bottom: 22px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.toast-item {
  min-width: 220px; max-width: min(380px, calc(100vw - 40px)); padding: 12px 16px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  box-shadow: 0 18px 50px rgba(2, 8, 23, .28); font-size: .9rem;
  animation: toast-in .18s ease-out;
}
.toast-item strong { display: block; margin-bottom: 2px; }
.toast-item .toast-detail { color: var(--text-dim); font-size: .84rem; }
.toast-item.ok { border-left: 3px solid #16a34a; }
.toast-item.warn { border-left: 3px solid #d97706; }
.toast-item.err { border-left: 3px solid #dc2626; }
.toast-item.info { border-left: 3px solid var(--primary); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- 指标卡 */
/* 6 张指标卡在 1440px 屏幕上要能排成一行：最小宽度压到 172px */
.metric-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(172px, 1fr)); margin-bottom: 18px; }
.metric {
  /* 必须显式 display:block —— panel.css 的 .metric 是 display:flex（frps 站那种「图标 + 文字」
     横排卡片），沿用下来会把这里的标签压成 14px 宽，中文就变成一个字的竖排 */
  display: block;
  padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); position: relative; overflow: hidden;
}
.metric .metric-label { font-size: .82rem; color: var(--text-dim); margin-bottom: 8px; }
.metric .metric-value { font-size: 1.42rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric .metric-foot { margin-top: 6px; font-size: .78rem; color: var(--text-faint); }
.metric.pos .metric-value { color: #168a5b; }
.metric.neg .metric-value { color: #d92d45; }
.metric.tone-primary .metric-value { color: var(--primary); }
.metric::after { content: ''; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: var(--grad); opacity: .07; }

/* ---------------------------------------------------------------- 项目卡片 / 卡片网格 */
.card-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); }
.project-card {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit;
  transition: transform .15s, border-color .15s;
}
.project-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.project-card .pc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.project-card .pc-name { font-weight: 700; font-size: .98rem; }
.project-card .pc-desc { color: var(--text-dim); font-size: .84rem; line-height: 1.6; min-height: 2.4em; }
.project-card .pc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: .8rem; }
.project-card .pc-stats span { display: block; color: var(--text-faint); }
.project-card .pc-stats b { font-size: .95rem; font-variant-numeric: tabular-nums; }

.progress { height: 8px; border-radius: 999px; background: var(--surface-strong); overflow: hidden; box-shadow: inset 0 0 0 1px var(--border); }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--grad); transition: width .3s ease; }
.progress.sm { height: 6px; }
.progress > span.done { background: #16a34a; }
.progress > span.late { background: #dc2626; }

/* ---------------------------------------------------------------- 任务看板 */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; min-height: 180px; }
.kanban-col-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: .9rem; }
.kanban-col-head .count { color: var(--text-faint); font-weight: 600; font-size: .82rem; }
.kanban-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 90px; }
.kanban-body.drop-hint { outline: 2px dashed var(--primary); outline-offset: -6px; border-radius: 12px; }
.task-card {
  border: 1px solid var(--border); border-left-width: 3px; border-radius: 12px; background: var(--bg);
  padding: 11px 13px; cursor: grab; box-shadow: var(--shadow-xs, 0 1px 2px rgba(15, 23, 42, .05));
}
.task-card:active { cursor: grabbing; }
.task-card.dragging { opacity: .5; }
.task-card.pri-高 { border-left-color: #dc2626; }
.task-card.pri-中 { border-left-color: #d97706; }
.task-card.pri-低 { border-left-color: #16a34a; }
.task-card .tc-title { font-weight: 650; font-size: .9rem; line-height: 1.5; }
.task-card .tc-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; color: var(--text-dim); font-size: .78rem; }
/* 卡片里的一排操作按钮收紧一些，否则「移动到 X / 编辑 / 删除」会占掉半张卡 */
.task-card .btn { padding: 5px 11px; font-size: .8rem; border-radius: 9px; }
.task-card .row-actions, .task-card > div:last-child { gap: 6px; }
.task-card.due-soon .tc-due { color: #b45309; font-weight: 700; }
.task-card.overdue .tc-due { color: #d92d45; font-weight: 700; }
.kanban-col.add-col { align-items: stretch; }

/* ---------------------------------------------------------------- 日程月历 */
.cal { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.cal-head h3 { margin: 0; font-size: 1rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow { padding: 8px 10px; font-size: .78rem; color: var(--text-faint); text-align: center; border-bottom: 1px solid var(--border); }
.cal-cell { min-height: 104px; padding: 6px 8px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: .78rem; position: relative; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.out { opacity: .42; }
.cal-cell.today { background: color-mix(in srgb, var(--primary) 7%, transparent); }
.cal-cell.today .cal-day { background: var(--primary); color: #fff; }
.cal-day { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-weight: 700; font-size: .78rem; }
.cal-event { display: block; margin-top: 4px; padding: 3px 6px; border-radius: 7px; font-size: .74rem; color: #fff; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.cal-legend .chip.on { color: #fff; border-color: transparent; }
.sched-list { display: flex; flex-direction: column; gap: 10px; }
.sched-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.sched-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.sched-item .si-name { font-weight: 650; }
.sched-item .si-meta { color: var(--text-dim); font-size: .82rem; }
.sched-item.today-item { border-color: var(--primary); }

/* ---------------------------------------------------------------- 里程碑地铁图 */
.subway-wrap { display: flex; flex-direction: column; gap: 16px; }
.subway { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 18px 20px 22px; }
.subway-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.subway-line { position: relative; display: flex; align-items: flex-start; gap: 0; padding: 6px 4px 0; overflow-x: auto; }
.subway-line::before { content: ''; position: absolute; left: 18px; right: 18px; top: 17px; height: 4px; border-radius: 999px; background: var(--line-color, var(--primary)); opacity: .28; }
.subway-station { position: relative; flex: 1 0 128px; text-align: center; text-decoration: none; color: inherit; padding-top: 2px; }
.subway-station .st-dot { position: relative; z-index: 1; display: block; width: 16px; height: 16px; margin: 6px auto 8px; border-radius: 50%; background: var(--bg); border: 3px solid var(--line-color, var(--primary)); }
.subway-station.done .st-dot { background: #16a34a; border-color: #16a34a; }
.subway-station.doing .st-dot { background: var(--line-color, var(--primary)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
.subway-station.late .st-dot { background: #dc2626; border-color: #dc2626; }
.subway-station .st-name { display: block; font-size: .82rem; font-weight: 650; line-height: 1.4; }
.subway-station .st-date { display: block; margin-top: 3px; font-size: .74rem; color: var(--text-faint); }
.subway-station:hover .st-name { color: var(--primary); }

/* ---------------------------------------------------------------- 图表（纯 SVG，无第三方依赖） */
.chart-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 16px 18px; }
.chart-card h3 { margin: 0 0 12px; font-size: .95rem; }
/* 柱状图：父容器必须 stretch，否则 bar-col 高度塌成内容高度，
   bar-stack 的 height:100% 就无解，柱子全变成 2px 的细线（踩过） */
.chart-bars { display: flex; align-items: stretch; gap: 10px; height: 176px; padding-top: 8px; }
.chart-bars .bar-col { flex: 1 1 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; }
.chart-bars .bar-stack { width: 100%; max-width: 46px; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.chart-bars .bar { border-radius: 6px 6px 0 0; background: var(--grad); min-height: 2px; flex: 0 0 auto; }
.chart-bars .bar.in { background: #16a34a; }
.chart-bars .bar.ex { background: #ef4444; }
.chart-bars .bar-lbl { font-size: .72rem; color: var(--text-faint); white-space: nowrap; }
.chart-legend { display: flex; gap: 14px; margin-top: 10px; font-size: .78rem; color: var(--text-dim); }
.chart-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }
.spark { display: block; width: 100%; height: 46px; }

/* ---------------------------------------------------------------- 列表页通用 */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 auto; }
.toolbar form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.input-inline, .toolbar select, .toolbar input[type="text"], .toolbar input[type="date"] {
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--bg); color: var(--text); font: inherit; font-size: .88rem;
}
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-dim); font-size: .86rem; text-decoration: none; }
.tab.active { background: var(--grad); border-color: transparent; color: #fff; }
.empty { padding: 36px 20px; text-align: center; color: var(--text-faint); border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.empty strong { display: block; color: var(--text-dim); margin-bottom: 6px; font-size: .96rem; }
.money-pos { color: #168a5b; font-variant-numeric: tabular-nums; }
.money-neg { color: #d92d45; font-variant-numeric: tabular-nums; }
/* 窄卡片里的小表：收紧内边距与字号，避免数字被截断（仪表盘的「计划 vs 实际」等） */
.data-table.compact { min-width: 0; font-size: .86rem; }
.data-table.compact th, .data-table.compact td { padding: 8px 9px; }
.num { font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.summary-line { display: flex; flex-wrap: wrap; gap: 18px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); margin-bottom: 14px; font-size: .88rem; }
.summary-line b { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 表单 */
.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid .field.full { grid-column: 1 / -1; }
.modal .field { margin-bottom: 14px; }
.modal .field > span { font-size: .84rem; }
.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-form select, .inline-form input { padding: 7px 10px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); font: inherit; font-size: .86rem; }
.checkline { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--text-dim); }

/* ---------------------------------------------------------------- 文档 / AI / 详情 */
.doc-row .doc-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-strong); font-size: .72rem; font-weight: 700; color: var(--text-dim); }
/* 卡片网格：最小 300px，避免一页塞 4 列把表格挤到截断 */
.detail-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.dl { display: grid; grid-template-columns: 96px 1fr; gap: 8px 14px; font-size: .9rem; }
.dl dt { color: var(--text-faint); }
.dl dd { margin: 0; }
.ai-log { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.ai-bubble { padding: 12px 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); font-size: .9rem; line-height: 1.7; max-width: 880px; }
.ai-bubble.me { align-self: flex-end; background: color-mix(in srgb, var(--primary) 12%, transparent); border-color: color-mix(in srgb, var(--primary) 28%, transparent); }
.ai-preview input, .ai-preview select { width: 100%; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); font: inherit; font-size: .84rem; }
/* 小鲸鱼副驾页面：左右两栏（对话 + 可编辑预览表） */
.ai-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
.ai-grid .section-card { margin-bottom: 0; }
.ai-grid textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); font: inherit; font-size: .92rem; line-height: 1.65; resize: vertical; }
.ai-grid textarea:focus { outline: none; border-color: var(--primary); }
.ai-grid textarea[disabled] { color: var(--text-faint); cursor: not-allowed; }
.ai-log { max-height: 340px; overflow-y: auto; padding: 2px; }
.ai-log .empty { padding: 18px 14px; font-size: .86rem; }
.ai-thinking::after { content: '⋯'; margin-left: 6px; }
.ai-preview .data-table td { vertical-align: top; }
@media (max-width: 1180px) { .ai-grid { grid-template-columns: 1fr; } }
.flow-frame { width: 100%; height: 76vh; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }

/* ---------------------------------------------------------------- 响应式 */
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; width: 250px; transform: translateX(-102%); transition: transform .2s ease; box-shadow: 0 20px 60px rgba(2, 8, 23, .35); }
  .sidebar.open { transform: none; }
  .nav-toggle { display: inline-grid; }
  .notice { margin: 0 16px 12px; }
  .app-content { padding-top: 16px; }
}
@media (max-width: 620px) {
  .topbar { padding: 12px 14px; }
  .metric-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .kanban { grid-auto-columns: minmax(212px, 1fr); }
}
