/* ==========================================================================
   在线签署收集 · 「一纸文书 · 印章红」
   （视觉保持原样，仅追加 UI 动效层：见文件下方「动效」一节）
   ========================================================================== */

:root {
  --paper: #f4efe4;
  --paper-2: #fbf7ee;
  --paper-3: #efe8d8;
  --ink: #241d16;
  --ink-soft: #6f655a;
  --ink-faint: #9a8f80;
  --seal: #b0322a;
  --seal-dark: #8c2620;
  --seal-soft: #f3d9d4;
  --line: #e2d8c4;
  --line-strong: #d4c7ad;
  --gold: #b8945a;
  --ok: #2f7d4f;
  --warn: #b0762a;
  --danger: #b0322a;
  --serif: "Songti SC", "Noto Serif SC", "SimSun", "STSong", "宋体", serif;
  --kai: "Kaiti SC", "KaiTi", "STKaiti", "楷体", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "微软雅黑", -apple-system, "Segoe UI", sans-serif;
  --shadow-sm: 0 1px 2px rgba(36, 29, 22, .06), 0 1px 3px rgba(36, 29, 22, .08);
  --shadow-md: 0 6px 20px rgba(36, 29, 22, .10);
  --shadow-lg: 0 14px 40px rgba(36, 29, 22, .16);
  --radius: 10px;
  --radius-sm: 7px;

  /* 动效节奏（新增，仅影响动画时长曲线，不影响视觉） */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --dur: .18s;
  --dur-slow: .34s;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

/* 给 html 也铺上纸色：页面刷新时那一瞬间的空白、以及滚过头时的边缘，
   都是米色而不是刺眼的白色，切换观感柔和很多 */
html { background-color: var(--paper); }

body {
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(184, 148, 90, .06), transparent 50%),
    radial-gradient(ellipse at 90% 100%, rgba(176, 50, 42, .04), transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.05'/%3E%3C/svg%3E");
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

a { color: var(--seal); text-decoration: none; }
a:hover { color: var(--seal-dark); }

::selection { background: var(--seal); color: #fff; }

/* ---- 排版 ---- */
h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: .01em; }
.serif { font-family: var(--serif); }
.kai { font-family: var(--kai); }

/* ---- 按钮 ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  text-decoration: none; line-height: 1.4; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--seal); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--seal-dark); color: #fff; }
.btn-outline { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-outline:hover { border-color: var(--ink-soft); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--paper-3); color: var(--ink); }
.btn-danger { background: transparent; color: var(--danger); border-color: #e4bfb9; }
.btn-danger:hover { background: var(--seal-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* ---- 表单 ---- */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field > label .req { color: var(--seal); margin-left: 2px; }
.input, .textarea, .select {
  /* 字号必须是 16px：iOS Safari 在输入框字号小于 16px 时，聚焦会强制放大整个页面，
     点完输入框页面就"缩"了。改成 16px 后聚焦不再缩放，保持原样。 */
  width: 100%; font-family: var(--sans); font-size: 16px; color: var(--ink);
  padding: 11px 13px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fffdf8; transition: border-color .12s, box-shadow .12s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--seal); box-shadow: 0 0 0 3px var(--seal-soft);
}
.textarea { min-height: 84px; resize: vertical; }
.hint { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }

/* ---- 徽章 ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
}
.badge-seal { background: var(--seal-soft); color: var(--seal-dark); }
.badge-ok { background: #e2efe6; color: var(--ok); }
.badge-mute { background: var(--paper-3); color: var(--ink-soft); }
.badge-warn { background: #f3e7d3; color: var(--warn); }

/* ==========================================================================
   后台布局
   ========================================================================== */
.admin-shell { display: flex; min-height: 100vh; }
.admin-side {
  width: 228px; flex-shrink: 0;
  background: linear-gradient(180deg, #251e16 0%, #2f2619 100%);
  color: #ece3d2; padding: 26px 18px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.admin-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 30px; }
.admin-brand .seal-mark {
  width: 40px; height: 40px; border-radius: 8px; background: var(--seal);
  display: grid; place-items: center; font-family: var(--kai); font-size: 20px; color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
.admin-brand .t { font-family: var(--serif); font-size: 18px; font-weight: 700; }
.admin-brand .s { font-size: 11px; color: #a89b86; letter-spacing: .1em; }
.admin-brand .brand-logo { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: #fff; }
.admin-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.admin-nav a {
  display: flex; align-items: center; gap: 10px; color: #cfc4b0;
  padding: 10px 12px; border-radius: 8px; font-size: 14px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.admin-nav a:hover { background: rgba(255,255,255,.06); color: #fff; transform: translateX(3px); }
.admin-nav a.active { background: var(--seal); color: #fff; }
.admin-side-foot {
  font-size: 12px; color: #8d816f; padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.admin-main { flex: 1; padding: 30px 38px 60px; min-width: 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: 26px; }
.page-head .sub { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }

.card {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 22px; margin-bottom: 20px;
  transition: box-shadow var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-title { font-size: 17px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* 统计看板 */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px 20px;
  transition: box-shadow var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-num { font-family: var(--serif); font-size: 30px; font-weight: 700; color: var(--seal); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }

/* 列表页 tab 切换 */
.list-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 2px solid var(--line); }
.list-tab { padding: 9px 18px; font-size: 14px; font-weight: 600; color: var(--ink-soft); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color var(--dur) var(--ease); }
.list-tab:hover { color: var(--ink); }
.list-tab.active { color: var(--seal); border-bottom-color: var(--seal); }

/* 表格 */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-soft);
  padding: 10px 12px; border-bottom: 2px solid var(--line-strong); letter-spacing: .04em;
}
.table td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: rgba(184, 148, 90, .05); }
.table td { transition: background var(--dur) var(--ease); }
.table .num { font-variant-numeric: tabular-nums; }
.resp-table td.rec-actions { text-align: right; white-space: nowrap; }
.resp-table td.rec-actions form { display: inline; }

/* 空状态 */
.empty { text-align: center; padding: 48px 20px; color: var(--ink-faint); }
.empty .glyph { width: 52px; height: 52px; border-radius: 12px; background: var(--seal); color: #fff; display: grid; place-items: center; font-size: 26px; margin: 0 auto 14px; opacity: .92; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }

/* 提示条 */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: var(--seal-soft); color: var(--seal-dark); border: 1px solid #e7c3bd; }
.alert-ok { background: #e2efe6; color: var(--ok); border: 1px solid #c6e0cd; }
.alert-warn { background: #f3e7d3; color: var(--warn); border: 1px solid #ead6b4; }

/* 分享链接框 */
.share-box { display: flex; gap: 10px; align-items: center; }
.share-box .input { font-family: monospace; font-size: 14px; flex: 1; }

/* 字段编辑器 */
.fb-row {
  display: grid; grid-template-columns: 28px 1.2fr 1fr auto 84px; gap: 10px; align-items: center;
  padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 10px;
  background: #fffdf8; transition: box-shadow .12s;
}
.fb-row:hover { box-shadow: var(--shadow-sm); }
.fb-row .drag { color: var(--ink-faint); text-align: center; cursor: grab; user-select: none; }
.fb-row .ops { display: flex; gap: 4px; }
.fb-opt { grid-column: 2 / -1; margin-top: 6px; display: none; }
.fb-opt.show { display: block; }

/* 签名预览 */
.sig-img { max-height: 120px; max-width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.sig-text { font-family: var(--kai); font-size: 34px; color: var(--ink); transform: rotate(-3deg); display: inline-block; }

/* 详情键值 */
.kv { display: flex; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: none; }
.kv-label { width: 120px; flex-shrink: 0; color: var(--ink-soft); font-size: 13px; font-weight: 600; padding-top: 2px; }
.kv-value { flex: 1; font-size: 15px; word-break: break-all; }

/* 工具行 */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.search { width: 240px; }

/* 审批卡片 */
.req-item { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 10px; background: #fffdf8; transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
.req-item:hover { box-shadow: var(--shadow-sm); transform: translateX(2px); }
.req-item .who { flex: 1; }
.req-item .reason { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

/* 登录页 */
.login-body {
  /* 在原有纸质底上加两团金色/朱砂光晕，把视线聚到中间 */
  background-image:
    radial-gradient(ellipse 60% 46% at 50% 0%, rgba(184, 148, 90, .16), transparent 62%),
    radial-gradient(ellipse 52% 42% at 50% 100%, rgba(176, 50, 42, .07), transparent 62%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.05'/%3E%3C/svg%3E");
}

/* 飘落层（金箔 / 雪花） */
.flakes { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }

.flake {
  position: absolute; top: 0;
  animation: driftA 14s linear infinite;
  will-change: transform;
}

/* 三种飘法：把左右摇摆直接烘焙进单条 transform 动画里，
   这样不需要嵌套元素，也不会出现两条动画抢同一个 transform 的问题 */
.flake.d0 { animation-name: driftA; }
.flake.d1 { animation-name: driftB; }
.flake.d2 { animation-name: driftC; }

/* 金箔：小方片，金色渐变 + 微光 */
.flake--gold {
  border-radius: 1.5px;
  background: linear-gradient(135deg, #f7e3a6 0%, #ddb96d 45%, #a8823f 100%);
  box-shadow: 0 0 5px rgba(206, 168, 96, .55);
}

@keyframes driftA {
  0%   { transform: translate3d(0, -14vh, 0) rotate(0deg); }
  20%  { transform: translate3d(26px, 12vh, 0) rotate(72deg); }
  40%  { transform: translate3d(-16px, 38vh, 0) rotate(150deg); }
  60%  { transform: translate3d(24px, 64vh, 0) rotate(228deg); }
  80%  { transform: translate3d(-12px, 88vh, 0) rotate(300deg); }
  100% { transform: translate3d(6px, 114vh, 0) rotate(360deg); }
}
@keyframes driftB {
  0%   { transform: translate3d(0, -14vh, 0) rotate(0deg); }
  25%  { transform: translate3d(-30px, 16vh, 0) rotate(-90deg); }
  50%  { transform: translate3d(18px, 44vh, 0) rotate(-180deg); }
  75%  { transform: translate3d(-24px, 74vh, 0) rotate(-270deg); }
  100% { transform: translate3d(-6px, 114vh, 0) rotate(-360deg); }
}
@keyframes driftC {
  0%   { transform: translate3d(0, -14vh, 0) rotate(0deg); }
  30%  { transform: translate3d(14px, 22vh, 0) rotate(120deg); }
  55%  { transform: translate3d(-22px, 52vh, 0) rotate(210deg); }
  80%  { transform: translate3d(12px, 82vh, 0) rotate(300deg); }
  100% { transform: translate3d(-4px, 114vh, 0) rotate(380deg); }
}

.login-wrap { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 20px; }

.login-card {
  position: relative; overflow: hidden;
  width: 390px; max-width: 100%;
  background: linear-gradient(180deg, #fffdf8 0%, var(--paper-2) 100%);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 40px 36px 34px;
  box-shadow: var(--shadow-lg), 0 0 0 6px rgba(255, 253, 248, .5);
}
/* 顶部一道金→朱砂→金的装饰线 */
.login-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 28%, var(--seal) 50%, var(--gold) 72%, transparent 100%);
}
.login-card .seal-mark {
  width: 60px; height: 60px; border-radius: 14px; background: var(--seal);
  display: grid; place-items: center; font-family: var(--kai); font-size: 30px; color: #fff;
  margin: 0 auto 18px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25), 0 6px 16px rgba(176,50,42,.28);
}
.login-card .login-logo { width: 60px; height: 60px; border-radius: 14px; object-fit: cover; display: block; margin: 0 auto 18px; background: #fff; box-shadow: var(--shadow-sm); }
.login-card h1 { text-align: center; font-size: 23px; letter-spacing: .04em; margin-bottom: 5px; }
.login-card .sub { text-align: center; color: var(--ink-soft); font-size: 13px; letter-spacing: .06em; }

/* 「管理登录」分隔线 */
.login-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 22px; }
.login-divider::before,
.login-divider::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
}
.login-divider span { font-size: 11px; color: var(--ink-faint); letter-spacing: .22em; white-space: nowrap; }

/* ==========================================================================
   签字页（手机 H5）
   ========================================================================== */
.sign-wrap { min-height: 100vh; padding: 20px 14px 44px; }
.sign-card {
  max-width: 460px; margin: 0 auto; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-md);
  padding: 26px 22px 30px;
}
.sign-head { text-align: center; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 2px solid var(--line); }
.sign-head .seal { font-family: var(--kai); color: var(--seal); font-size: 30px; line-height: 1; margin-bottom: 10px; }
.sign-head .seal.logo img { width: 72px; height: 72px; object-fit: contain; display: inline-block; }
.sign-head h1 { font-size: 21px; }
.sign-head .desc { color: var(--ink-soft); font-size: 13px; margin-top: 6px; }

/* 签名区 */
.sig-section { margin-top: 20px; }
.sig-section .sig-title { font-size: 14px; font-weight: 600; color: var(--ink-soft); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.sig-tabs { display: flex; background: var(--paper-3); border-radius: 8px; padding: 3px; margin-bottom: 12px; }
.sig-tab {
  flex: 1; text-align: center; padding: 8px; font-size: 14px; cursor: pointer;
  border-radius: 6px; color: var(--ink-soft); transition: all .15s;
}
.sig-tab.active { background: #fffdf8; color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
.sig-pad {
  position: relative; width: 100%; height: 180px; background: #fffdf8;
  border: 1.5px dashed var(--line-strong); border-radius: 10px; overflow: hidden; touch-action: none;
}
.sig-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sig-pad .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-faint); font-size: 14px; pointer-events: none; font-family: var(--kai); }
.sig-toolbar { display: flex; justify-content: flex-end; margin-top: 8px; }
.sig-name-wrap { display: none; }
.sig-name-wrap.show { display: block; }
.sig-name-preview { font-family: var(--kai); font-size: 40px; color: var(--ink); min-height: 54px; margin-top: 4px; transform: rotate(-2deg); }

/* 提交成功 */
.done-mark { width: 64px; height: 64px; border-radius: 50%; background: var(--seal); color: #fff; display: grid; place-items: center; font-size: 32px; margin: 8px auto 16px; box-shadow: 0 6px 16px rgba(176,50,42,.35); }

/* ==========================================================================
   打印样式
   ========================================================================== */
.print-doc { max-width: 700px; margin: 0 auto; }
.print-doc .title { font-family: var(--serif); font-size: 24px; text-align: center; margin-bottom: 4px; }
.print-doc .sub { text-align: center; color: var(--ink-soft); font-size: 13px; margin-bottom: 20px; }
.print-table { width: 100%; border-collapse: collapse; margin-bottom: 26px; }
.print-table th, .print-table td { border: 1px solid var(--line-strong); padding: 10px 12px; font-size: 14px; text-align: left; }
.print-table th { background: var(--paper-3); width: 130px; font-weight: 600; color: var(--ink-soft); }
.print-sig { margin-top: 24px; text-align: right; }
.print-sig .sig-img { max-height: 90px; }
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .print-doc { box-shadow: none; border: none; }
}

/* ==========================================================================
   动效（新增）
   全部只用 transform / opacity —— GPU 合成，不触发重排，不影响速度
   ========================================================================== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes stampIn {
  0%   { opacity: 0; transform: scale(.4) rotate(-12deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes alertIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 后台主区：进入时依次淡入上浮（逐个错开 60ms，形成轻微节奏） */
.admin-main > .page-head { animation: fadeUp var(--dur-slow) var(--ease) both; }
.admin-main > .card,
.admin-main > .stat-row,
.admin-main > .list-tabs { animation: fadeUp var(--dur-slow) var(--ease) both; animation-delay: .05s; }
.admin-main > *:nth-child(3) { animation-delay: .11s; }
.admin-main > *:nth-child(4) { animation-delay: .17s; }
.admin-main > *:nth-child(5) { animation-delay: .23s; }
.admin-main > *:nth-child(6) { animation-delay: .29s; }

/* 统计卡片依次浮现 */
.stat-row .stat-card { animation: fadeUp var(--dur-slow) var(--ease) both; }
.stat-row .stat-card:nth-child(1) { animation-delay: .10s; }
.stat-row .stat-card:nth-child(2) { animation-delay: .16s; }
.stat-row .stat-card:nth-child(3) { animation-delay: .22s; }
.stat-row .stat-card:nth-child(4) { animation-delay: .28s; }

/* 提示条滑入 */
.alert { animation: alertIn var(--dur-slow) var(--ease) both; }

/* 登录卡片弹入 */
.login-card { animation: popIn var(--dur-slow) var(--ease) both; }

/* 签署卡片淡入 */
.sign-card { animation: fadeUp var(--dur-slow) var(--ease) both; }

/* 提交成功：印章式落下（带一点回弹） */
.done-mark { animation: stampIn .5s cubic-bezier(.34, 1.56, .64, 1) both; }

/* 字段选项区展开时淡入 */
.fb-opt.show { animation: fadeUp var(--dur-slow) var(--ease) both; }

/* 表格行背景色过渡 */
.table tbody tr:hover td { transition: background var(--dur) var(--ease); }

/* 打印时关闭所有动效 */
@media print {
  * { animation: none !important; transition: none !important; }
}

/* 尊重系统「减少动态效果」设置（无障碍，也照顾低性能设备） */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  /* 飘落元素在这种模式下直接隐藏，避免静止地"挂"在画面上 */
  .flakes { display: none; }
}

/* ==========================================================================
   暗色模式
   —— 只覆盖变量和少数写死了浅色的规则，浅色样式一行都不动
   ========================================================================== */

html[data-theme="dark"] {
  --paper: #191612;
  --paper-2: #221e18;
  --paper-3: #2b261e;
  --ink: #ece5d8;
  --ink-soft: #a99d8b;
  --ink-faint: #7e7466;
  --seal: #d4574a;
  --seal-dark: #e0776a;
  --seal-soft: #3a2320;
  --line: #35302a;
  --line-strong: #48413a;
  --gold: #d0ad6d;
  --ok: #59b07c;
  --warn: #d4a04a;
  --danger: #d4574a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .40), 0 1px 3px rgba(0, 0, 0, .35);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, .45);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, .55);
}

/* 背景纹理换成暗色版 */
html[data-theme="dark"] body {
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(184, 148, 90, .07), transparent 50%),
    radial-gradient(ellipse at 90% 100%, rgba(212, 87, 74, .06), transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.05'/%3E%3C/svg%3E");
}

/* 原来写死成 #fffdf8 的地方（输入框、内嵌块、填写区…） */
html[data-theme="dark"] .input,
html[data-theme="dark"] .textarea,
html[data-theme="dark"] .select,
html[data-theme="dark"] .fb-row,
html[data-theme="dark"] .req-item,
html[data-theme="dark"] .sig-tab.active,
html[data-theme="dark"] .sig-pad {
  background: #2a251e;
}

/* 状态色块：浅底换成深底，边框同步调暗 */
html[data-theme="dark"] .badge-ok,
html[data-theme="dark"] .alert-ok { background: #1e3327; border-color: #2d4a39; }
html[data-theme="dark"] .badge-warn,
html[data-theme="dark"] .alert-warn { background: #33291a; border-color: #4a3b24; }
html[data-theme="dark"] .alert-error { border-color: #4d2b26; }
html[data-theme="dark"] .btn-danger { border-color: #4d2b26; }
html[data-theme="dark"] .btn-outline,
html[data-theme="dark"] .btn-danger { background: transparent; }
html[data-theme="dark"] .btn-danger:hover { background: var(--seal-soft); }

/* 侧边栏：原本就是深色，暗色下再压暗一档，和内容区拉开层次 */
html[data-theme="dark"] .admin-side {
  background: linear-gradient(180deg, #14110e 0%, #1c1813 100%);
}
html[data-theme="dark"] .admin-brand .brand-logo,
html[data-theme="dark"] .login-card .login-logo,
html[data-theme="dark"] .sig-img { background: #efeae0; }

/* 移动端的记录卡片 */
html[data-theme="dark"] .resp-table tr { background: #2a251e; }
html[data-theme="dark"] .resp-table td[data-label]::before,
html[data-theme="dark"] .resp-table td.rec-check::before { color: var(--ink-faint); }

/* 登录页 */
html[data-theme="dark"] .login-body {
  background-image:
    radial-gradient(ellipse 60% 46% at 50% 0%, rgba(184, 148, 90, .10), transparent 62%),
    radial-gradient(ellipse 52% 42% at 50% 100%, rgba(212, 87, 74, .09), transparent 62%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.05'/%3E%3C/svg%3E");
}
html[data-theme="dark"] .login-card {
  background: linear-gradient(180deg, #262119 0%, var(--paper-2) 100%);
  box-shadow: var(--shadow-lg), 0 0 0 6px rgba(255, 255, 255, .04);
}

/* 打印时永远用浅色，别把纸打成黑的 */
@media print {
  html[data-theme="dark"] { --paper: #fff; --paper-2: #fff; --ink: #000; }
  html[data-theme="dark"] body { background: #fff; background-image: none; }
}

/* 切换主题时的过渡（只在切换那一下加，平时不加，避免影响性能） */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color .22s ease, color .22s ease,
              border-color .22s ease, box-shadow .22s ease !important;
}

/* ---- 主题切换按钮 ---- */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255, 255, 255, .06);
  color: #cfc4b0;
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 8px; padding: 6px 10px;
  font-family: inherit; font-size: 12px; line-height: 1;
  cursor: pointer; white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.theme-toggle:hover { background: rgba(255, 255, 255, .13); color: #fff; }
.theme-toggle .ico { font-size: 13px; }

/* 登录页上的切换按钮：浮在右上角 */
.login-theme-toggle {
  position: fixed; top: 16px; right: 16px; z-index: 5;
  background: rgba(255, 255, 255, .55);
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
}
.login-theme-toggle:hover { background: #fff; color: var(--ink); }
html[data-theme="dark"] .login-theme-toggle {
  background: rgba(255, 255, 255, .08);
  color: var(--ink-soft);
  border-color: var(--line-strong);
}
html[data-theme="dark"] .login-theme-toggle:hover { background: rgba(255, 255, 255, .16); color: var(--ink); }

/* ==========================================================================
   响应式适配（手机 / 平板）
   ========================================================================== */
@media (max-width: 768px) {
  /* 后台：顶部横条 —— 品牌 + 退出登录一行，导航横向滑动 */
  .admin-shell { flex-direction: column; }
  .admin-side {
    width: 100%; height: auto; position: static;
    flex-direction: row; align-items: center; flex-wrap: wrap;
    padding: 10px 14px 12px; gap: 8px;
  }
  .admin-brand { order: 1; margin: 0 auto 0 0; gap: 8px; }
  .admin-brand .seal-mark { width: 34px; height: 34px; border-radius: 8px; font-size: 17px; }
  .admin-brand .t { font-size: 16px; }
  .admin-brand .s { display: none; }
  .admin-brand .brand-logo { width: 34px; height: 34px; }
  .admin-side-foot { order: 2; padding: 0; border-top: none; white-space: nowrap; }
  .admin-nav {
    order: 3; flex: 0 0 100%;
    flex-direction: row; flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    gap: 6px; padding-bottom: 2px;
  }
  .admin-nav a { flex-shrink: 0; white-space: nowrap; padding: 7px 13px; font-size: 13px; gap: 6px; }
  .admin-nav a:hover { transform: none; }
  .admin-main { padding: 18px 14px 44px; }

  /* 触屏上关闭悬浮位移，避免"粘住"的怪异手感 */
  .card:hover, .stat-card:hover, .req-item:hover { transform: none; }

  /* 统计看板：两列 */
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px 16px; }
  .stat-num { font-size: 24px; }

  /* 页面标题与操作按钮 */
  .page-head { flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
  .page-head h1 { font-size: 21px; }
  .page-head > *:not(:first-child) { flex-wrap: wrap; }

  /* 卡片与表格：横向滚动，操作列按钮整齐换行 */
  .card { padding: 16px; overflow-x: auto !important; }
  .table { min-width: 560px; }
  .table td[style*="white-space:nowrap"] {
    white-space: normal !important;
    display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; align-items: center;
  }
  .table td[style*="white-space:nowrap"] form { display: inline-flex; }
  .table td[style*="white-space:nowrap"] .btn { padding: 4px 10px; font-size: 12px; }

  /* 升级记录：移动端转卡片 */
  .resp-table { min-width: 0 !important; }
  .resp-table thead { display: none; }
  .resp-table, .resp-table tbody, .resp-table tr, .resp-table td { display: block; width: 100%; }
  .resp-table tr {
    border: 1px solid var(--line); border-radius: 12px; background: #fffdf8;
    margin-bottom: 14px; padding: 8px 0 2px; box-shadow: var(--shadow-sm);
  }
  .resp-table tr:hover td { background: transparent; }
  .resp-table td { border: 0; padding: 7px 14px; text-align: left; }
  .resp-table td[data-label] { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
  .resp-table td[data-label]::before {
    content: attr(data-label); flex-shrink: 0;
    font-size: 12px; font-weight: 600; color: #a89b86; padding-top: 2px;
  }
  .resp-table td.rec-check { display: flex; align-items: center; gap: 8px; padding: 2px 14px 9px; border-bottom: 1px dashed var(--line); }
  .resp-table td.rec-check::before { content: "选择"; font-size: 12px; font-weight: 600; color: #a89b86; }
  .resp-table td.rec-detail, .resp-table td.rec-note { display: block; }
  .resp-table td.rec-detail::before, .resp-table td.rec-note::before { display: block; margin-bottom: 4px; padding-top: 0; }
  .resp-table td.rec-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 14px 12px; border-top: 1px dashed var(--line); }
  .resp-table td.rec-actions form { display: inline-flex; }

  /* 分享链接框、搜索框 */
  .share-box { flex-direction: column; align-items: stretch; }
  .toolbar form { flex-wrap: wrap; }
  .search { width: 100%; }

  /* 详情键值对：纵向 */
  .kv { flex-direction: column; gap: 2px; }
  .kv-label { width: auto; }

  /* 审批卡片 */
  .req-item { flex-wrap: wrap; }

  /* 字段编辑器：堆叠 */
  .fb-row {
    grid-template-columns: 24px 1fr auto;
    grid-template-areas:
      "drag label ops"
      "drag type  ops"
      "drag req   ops";
    row-gap: 8px;
  }
  .fb-row .drag { grid-area: drag; }
  .fb-row .fb-label { grid-area: label; }
  .fb-row .fb-type { grid-area: type; }
  .fb-row .fb-req { grid-area: req; }
  .fb-row .ops { grid-area: ops; flex-direction: column; }
  .fb-row .fb-opt { grid-column: 1 / -1; margin-top: 2px; }
}

/* 更小屏：签字页 / 登录页收紧 */
@media (max-width: 480px) {
  .sign-wrap { padding: 12px 10px 36px; }
  .sign-card { padding: 20px 16px 24px; }
  .sign-head h1 { font-size: 19px; }
  .sign-head .seal { font-size: 26px; }
  .sig-pad { height: 160px; }
  .login-card { padding: 30px 24px; }
  /* 手机上只留 12 片，减轻负担、省电 */
  .flakes .flake:nth-child(n+13) { display: none; }
}
