/* 方传公益 OA — 基于 finance-ui 设计令牌(Apple 风格) */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--background-100);
  color: var(--foreground);
  font-size: 14.5px;
  line-height: 1.55;
  letter-spacing: var(--tracking-normal);
}
a { color: var(--primary); text-decoration: none; }
h2 { margin: 14px 0 12px; font-size: 21px; font-weight: 700; }
h3 { margin: 0 0 10px; font-size: 15.5px; font-weight: 700; }
code { background: var(--secondary); padding: 1px 6px; border-radius: 6px; font-family: var(--font-mono); font-size: 12px; }

/* ── 顶栏(移动端)── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--background-50) 82%, transparent);
  backdrop-filter: blur(14px);
  color: var(--foreground); padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 700; font-size: 16px; }
.topbar-user { margin-left: auto; font-size: 12px; color: var(--muted-foreground); }
.menu-btn {
  background: var(--secondary); border: none; color: var(--foreground);
  font-size: 16px; cursor: pointer; width: 32px; height: 32px; border-radius: 999px;
}
.nav-close-row { display: flex; justify-content: space-between; align-items: center; }

/* ── 侧边导航 ── */
.sidenav {
  position: fixed; z-index: 60; top: 0; left: -280px; width: 250px; height: 100vh;
  background: var(--sidebar); color: var(--sidebar-foreground);
  padding: 14px 10px; transition: left .22s ease; overflow-y: auto;
  border-right: 1px solid var(--sidebar-border);
  box-shadow: var(--shadow-lg);
}
.sidenav.open { left: 0; }
.sidenav a {
  display: block; padding: 9px 14px; margin-bottom: 2px;
  color: var(--sidebar-foreground); font-size: 14px; font-weight: 500;
  border-radius: 999px; transition: background-color .15s ease;
}
.sidenav a.active, .sidenav a:hover { background: var(--card); box-shadow: var(--shadow-sm); }
.sidenav a.active { color: var(--sidebar-primary); font-weight: 600; }
.nav-close-row { padding: 4px 14px 10px; color: var(--muted-foreground); font-size: 12px; }
.nav-close-row button { background: none; border: none; color: var(--muted-foreground); font-size: 15px; cursor: pointer; }
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.28); z-index: 55; }
.overlay.show { display: block; }

/* ── 主区 ── */
.main { padding: 12px; max-width: 1120px; margin: 0 auto; }
.card {
  background: var(--card); color: var(--card-foreground);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.card.narrow { max-width: 660px; }

/* ── 统计块 ── */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 12px; text-align: center; box-shadow: var(--shadow-sm);
}
.stat b { display: block; font-size: 25px; font-weight: 700; color: var(--foreground); letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--muted-foreground); }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0; }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.kv-grid span { color: var(--muted-foreground); font-size: 11px; display: block; letter-spacing: .06em; }
.kv-grid b { font-weight: 600; font-size: 14px; }

/* ── 表单 ── */
label { display: block; margin-bottom: 10px; font-size: 13.5px; color: var(--text-600); }
input, select, textarea {
  width: 100%; padding: 8px 12px; margin-top: 4px;
  border: 1px solid var(--input); border-radius: calc(var(--radius-sm) + 2px);
  font-size: 14px; font-family: var(--font-sans); background: var(--card); color: var(--foreground);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 22%, transparent);
}
label.check { display: flex; align-items: center; gap: 7px; }
label.check input { width: auto; margin: 0; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: 1fr; }
.form-grid .full { grid-column: 1 / -1; }
.approver-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 4px; }

/* ── 按钮 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px; border: none; border-radius: 999px;
  background: var(--secondary); color: var(--secondary-foreground);
  font-size: 13.5px; font-weight: 600; font-family: var(--font-sans);
  cursor: pointer; text-align: center; white-space: nowrap; box-shadow: var(--shadow-2xs);
  transition: filter .15s ease, background-color .15s ease, color .15s ease;
}
.btn:hover { background: var(--muted); color: var(--secondary-foreground); }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: var(--primary); filter: brightness(.94); color: var(--primary-foreground); }
.btn-danger { background: var(--state-error-surface); color: var(--state-error); }
.btn-danger:hover { background: var(--state-error-surface); filter: brightness(.96); color: var(--state-error); }
.btn-warn { background: #fff4e0; color: #b26300; }
.btn-sm { padding: 4px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
button.btn { font-family: var(--font-sans); }

/* ── 表格 ── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 9px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { color: var(--muted-foreground); font-weight: 600; white-space: nowrap; font-size: 12px; }
.table tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; }
.row-yellow td { background: color-mix(in srgb, #ff9500 8%, var(--card)); }
.row-red td { background: var(--state-error-surface); }
.warn-red { color: var(--state-error); }
.warn-yellow { color: #b26300; }
.small { font-size: 12px; }

/* ── 标签 ── */
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--secondary); color: var(--text-600); white-space: nowrap;
}
.tag-ok { background: var(--state-success-surface); color: #1e7d38; }
.tag-warn { background: #fff4e0; color: #b26300; }
.tag-err { background: var(--state-error-surface); color: var(--state-error); }
.tag-muted { background: var(--secondary); color: var(--text-400); }

/* ── 列表 / 待办 ── */
.list { list-style: none; }
.list li {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  padding: 11px 2px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.list li:last-child { border-bottom: none; }
.list-main { flex: 1; min-width: 0; color: var(--foreground); display: block; }
.list-side { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.todo-list { list-style: none; }
.todo-list li { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.todo-list li:last-child { border-bottom: none; }
.steps { list-style: none; }
.steps li { padding: 8px 0 8px 16px; border-left: 2px solid var(--border); }
.steps li.approved { border-left-color: var(--state-success); }
.steps li.rejected { border-left-color: var(--state-error); }
.steps li.pending { border-left-color: #ff9500; }

/* ── 筛选 / tab / 分页 ── */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filter-bar input, .filter-bar select { width: auto; min-width: 130px; flex: 1; margin: 0; }
.filter-bar .btn { flex: 0; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.tab {
  padding: 6px 16px; border-radius: 999px; background: transparent;
  color: var(--muted-foreground); font-size: 13.5px; font-weight: 500;
  transition: background-color .15s ease;
}
.tab:hover { background: var(--secondary); }
.tab.active { background: var(--primary); color: var(--primary-foreground); font-weight: 600; }
.pager { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; }

/* ── 其他 ── */
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.flash {
  padding: 10px 14px; border-radius: calc(var(--radius-sm) + 2px); margin-bottom: 12px;
  font-size: 13.5px; cursor: pointer; box-shadow: var(--shadow-2xs);
}
.flash-ok { background: var(--state-success-surface); color: #1e7d38; border: 1px solid color-mix(in srgb, var(--state-success) 35%, transparent); }
.flash-err { background: var(--state-error-surface); color: #c0271d; border: 1px solid color-mix(in srgb, var(--state-error) 35%, transparent); }
.muted { color: var(--muted-foreground); font-size: 13px; }
.actions { white-space: nowrap; }
.actions details { display: inline-block; position: relative; }
.actions summary { list-style: none; }
.actions summary::-webkit-details-marker { display: none; }
.card-edit {
  position: absolute; right: 0; top: 110%; z-index: 30; min-width: 240px;
  background: var(--popover); border: 1px solid var(--border);
  box-shadow: var(--shadow-xl); padding: 14px; border-radius: var(--radius);
}
.inline-form { display: inline-block; margin: 0 2px 2px 0; }
.article { margin: 8px 0; white-space: normal; }
.record-img { max-width: 180px; max-height: 130px; border-radius: calc(var(--radius) - 4px); display: block; margin-top: 6px; border: 1px solid var(--border); }
.bar { background: var(--secondary); border-radius: 999px; height: 10px; overflow: hidden; }
.bar-fill { background: var(--primary); height: 100%; }
.mt-xs { margin-top: 4px; }

/* ── 登录页 ── */
.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 92vh; padding: 16px; }
.login-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 32px 26px; width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
}
.login-card h1 { font-size: 20px; text-align: center; font-weight: 700; }
.login-sub { text-align: center; color: var(--muted-foreground); font-size: 13px; margin: 6px 0 20px; }
.login-card .btn-block { height: 44px; font-size: 15px; }

/* ── 桌面端 ── */
@media (min-width: 860px) {
  .topbar { display: none; }
  .main.with-nav { margin-left: 220px; max-width: none; padding: 22px 30px; }
  .sidenav { left: 0; width: 220px; box-shadow: none; }
  .nav-close-row { display: none; }
  .grid-2 { grid-template-columns: 1fr 1fr; gap: 14px; }
  .stat-grid { grid-template-columns: repeat(5, 1fr); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .card.narrow { max-width: 760px; }
  .table th, .table td { padding: 10px 12px; }
}

/* ── 图标 ── */
.ic { width: 16px; height: 16px; flex: none; stroke-width: 1.8; }
.sidenav a { display: flex; align-items: center; gap: 10px; }
.card-title { display: flex; align-items: center; gap: 8px; }
.todo-link { display: flex; align-items: flex-start; gap: 8px; }
.todo-link .ic { margin-top: 4px; }
.edit-row td { background: var(--background-100); }
.edit-btn { cursor: pointer; }

/* 搜索选择组件 */
.search-select { display: block; position: relative; }
.vol-results {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--popover); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-xl); max-height: 220px; overflow-y: auto; padding: 4px;
}
.vol-item {
  display: block; width: 100%; text-align: left; padding: 8px 10px; margin: 0;
  border: none; background: none; border-radius: 8px; cursor: pointer;
  font-size: 13.5px; font-family: var(--font-sans); color: var(--foreground);
}
.vol-item:hover { background: var(--secondary); }
.vol-empty { display: block; padding: 8px 10px; color: var(--muted-foreground); font-size: 13px; }

/* 危险操作区 */
.danger-zone { border-color: color-mix(in srgb, var(--state-error) 40%, transparent); background: color-mix(in srgb, var(--state-error-surface) 35%, var(--card)); }
.danger-zone .card-title { color: var(--state-error); }


/* ── 滑块验证码 ── */
.captcha-widget { margin: 4px 0 10px; }
.captcha-img {
  position: relative; width: 100%; aspect-ratio: 300 / 160;
  border-radius: calc(var(--radius-sm) + 2px); overflow: hidden;
  border: 1px solid var(--border); background: var(--secondary); touch-action: none;
}
.captcha-img .cap-bg { width: 100%; height: 100%; display: block; user-select: none; }
.captcha-img .cap-piece {
  position: absolute; top: 0; left: 0; width: auto; height: auto;
  max-width: none; pointer-events: none; will-change: transform; user-select: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.35));
}
.cap-loading[hidden] { display: none !important; }
.cap-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--secondary); color: var(--muted-foreground); font-size: 13px;
}
.captcha-slider {
  position: relative; height: 40px; margin-top: 8px; border-radius: 999px;
  background: var(--secondary); overflow: visible; touch-action: none;
}
.cap-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--primary) 55%, transparent), color-mix(in srgb, var(--primary) 85%, transparent));
}
.cap-btn {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 44px; height: 40px; border: none; border-radius: 999px;
  background: #fff; box-shadow: var(--shadow-md); cursor: grab; touch-action: none;
  display: flex; align-items: center; justify-content: center; color: var(--muted-foreground);
}
.cap-btn.dragging { cursor: grabbing; }
.cap-btn.ok { background: var(--state-success); color: #fff; }
.cap-tip {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted-foreground); font-size: 13px; pointer-events: none;
}
.captcha-slider.ok { background: var(--state-success-surface); }
.captcha-slider.ok .cap-tip { color: #1e7d38; font-weight: 600; }
.captcha-slider.error .cap-tip { color: var(--state-error); }

/* ── 安全验证弹层 ── */
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(340px, calc(100vw - 32px)); background: var(--card);
  border-radius: var(--radius); box-shadow: var(--shadow-2xl); padding: 18px;
}

/* ── 图形验证码 ── */
.captcha-widget { margin: 6px 0 10px; }
.captcha-row { display: flex; align-items: center; gap: 8px; }
.captcha-row .cap-img {
  width: 132px; height: 44px; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; background: var(--secondary); flex: none; display: block;
}
.captcha-row .cap-text {
  width: 100%; min-width: 90px; margin: 0; letter-spacing: 3px; font-weight: 700;
  text-transform: uppercase; text-align: center;
}
.captcha-row .cap-refresh { flex: none; }
.cap-loading { margin: 4px 0 0; }

/* 登录页停用提示 */
.disabled-notice {
  border: 1px solid color-mix(in srgb, var(--state-error) 40%, transparent);
  background: var(--state-error-surface);
  border-radius: calc(var(--radius-sm) + 2px);
  padding: 12px 14px; margin-bottom: 14px; font-size: 13.5px;
}
.disabled-notice b { color: var(--state-error); display: block; margin-bottom: 6px; }
.disabled-notice dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0 0 8px; }
.disabled-notice dt { color: var(--muted-foreground); }
.disabled-notice dd { margin: 0; color: var(--foreground); font-weight: 600; }
.disabled-notice .support { margin: 0; color: var(--text-600); }

/* ── 审批流程图 ── */
.flow-diagram { display: flex; align-items: flex-start; gap: 6px; overflow-x: auto; padding: 8px 2px 14px; }
.flow-node {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  min-width: 92px; max-width: 120px; gap: 2px; padding: 10px 6px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card);
  box-shadow: var(--shadow-2xs); flex: none;
}
.flow-node .flow-dot {
  width: 30px; height: 30px; border-radius: 999px; display: flex; align-items: center; justify-content: center;
  background: var(--secondary); color: var(--muted-foreground); font-weight: 700; font-size: 13px;
  margin-bottom: 4px;
}
.flow-node.approved .flow-dot { background: var(--state-success); color: #fff; }
.flow-node.rejected .flow-dot { background: var(--state-error); color: #fff; }
.flow-node .flow-dot .ic { width: 16px; height: 16px; }
.flow-node-mine { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.flow-name { font-size: 13.5px; }
.flow-role { color: var(--muted-foreground); font-size: 11px; }
.flow-state { font-size: 11.5px; font-weight: 600; }
.flow-state.ok { color: #1e7d38; }
.flow-state.err { color: var(--state-error); }
.flow-state.cur { color: var(--primary); }
.flow-state.muted-c { color: var(--muted-foreground); }
.flow-comment { font-size: 11px; color: var(--muted-foreground); margin-top: 2px; }
.flow-link {
  flex: none; width: 22px; height: 2px; background: var(--border);
  margin-top: 24px; position: relative; border-radius: 2px;
}
.flow-link::after { content: ''; position: absolute; right: -1px; top: -3px;
  border-left: 6px solid var(--border); border-top: 4px solid transparent; border-bottom: 4px solid transparent; }
.flow-link-skipped { opacity: .4; }
.flow-preview { background: var(--secondary); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; }
.flow-preview small { color: var(--muted-foreground); }
.flow-arrow { color: var(--primary); font-weight: 700; margin: 0 4px; }
