/* 新地律所办公系统 — 响应式样式（桌面 + 手机） */
:root {
  --fs: 1.2; /* 全站字号缩放: s=1.1 中=1.2(默认) 大=1.3 */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --border: #e2e6ec;
  --text: #1b2330;
  --text-2: #5b6675;
  --muted: #8a94a3;
  --primary: #1f4fd8;
  --primary-d: #163aa8;
  --gold: #aa8822;
  --green: #1e8e3e;
  --red: #d93025;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.08);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 60px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: calc(15px * var(--fs));
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; color: var(--text); }

/* ===== 顶栏 ===== */
.app-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  background: #10182b;
  color: #fff;
}
.brand a { color: inherit; text-decoration: none; cursor: pointer; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-dot { width: 12px; height: 12px; border-radius: 3px; background: linear-gradient(135deg,#ffd54a,#e0a800); flex: 0 0 auto; }
.brand-text { font-weight: 700; font-size: calc(17px * var(--fs)); letter-spacing: .5px; white-space: nowrap; }
.env-tag {
  font-size: calc(12px * var(--fs)); font-weight: 500;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(255,80,80,.2); color: #ffd0d0; white-space: nowrap;
}
.top-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.divider { width: 1px; height: 24px; background: rgba(255,255,255,.2); }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 999px;
  background: rgba(255,255,255,.1); color: #fff; white-space: nowrap;
}
.user-chip:hover { text-decoration: none; background: rgba(255,255,255,.18); }
.user-name { font-weight: 600; color: #EEEE22; }
.user-uid { font-size: calc(12px * var(--fs)); color: rgba(255,255,255,.6); }
.gear { width: 16px; height: 16px; filter: invert(1); opacity: .8; }

/* 日期时钟 */
.datetime { display: flex; align-items: baseline; gap: 2px; font-variant-numeric: tabular-nums; color: #e8ecf3; }
.datetime .ym { font-size: calc(13px * var(--fs)); color: rgba(255,255,255,.75); }
.datetime .d { font-size: calc(17px * var(--fs)); font-weight: 700; }
.datetime .wd { font-size: calc(13px * var(--fs)); color: rgba(255,255,255,.75); }
.datetime .tm { font-size: calc(14px * var(--fs)); color: #ffd54a; margin-left: 6px; }
.datetime .tl { opacity: .6; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: calc(14px * var(--fs)); font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-d); text-decoration: none; }
.btn-outline { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.btn-outline:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.btn-ghost { background: #fff; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); text-decoration: none; }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: calc(13px * var(--fs)); }

/* ===== 标签导航（盖章申请 / 审批 / 主页）===== */
.tabnav {
  display: flex; gap: 8px;
  max-width: 1080px; margin: 0 auto;
  padding: 14px 18px 0;
}
.tab {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 999px;
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border); font-size: calc(14px * var(--fs)); font-weight: 500;
}
.tab svg { opacity: .85; }
.tab:hover { text-decoration: none; color: var(--primary); border-color: #c3d0f2; }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tab.active svg { opacity: 1; }

/* ===== 主体 ===== */
.app-main {
  max-width: 1080px; margin: 0 auto;
  padding: 18px 18px 40px;
  min-height: calc(100vh - var(--header-h) - 60px);
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}
.card h2 { font-size: calc(18px * var(--fs)); margin: 0 0 4px; }
.card .sub { color: var(--muted); font-size: calc(13px * var(--fs)); margin-bottom: 16px; }

.alert {
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: calc(14px * var(--fs)); margin-bottom: 14px;
}
.alert-info { background: #eaf1ff; color: #1f4fd8; border: 1px solid #cfe0ff; }
.alert-success { background: #e6f4ea; color: var(--green); border: 1px solid #c6e7d0; }
.alert-warn { background: #fff6e0; color: #9a6b00; border: 1px solid #ffe6a8; }
.alert-error { background: #fdeceb; color: var(--red); border: 1px solid #f7c9c4; }

/* 表单 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: calc(13px * var(--fs)); font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: calc(15px * var(--fs)); font-family: inherit; color: var(--text);
  background: #fff;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31,79,216,.12); }
.form-row { display: flex; gap: 12px; }
.form-row .field { flex: 1; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.err-list { color: var(--red); font-size: calc(13px * var(--fs)); margin-top: 4px; }

/* 表格 */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table.tbl { width: 100%; border-collapse: collapse; font-size: calc(14px * var(--fs)); min-width: 560px; }
.tbl th, .tbl td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.tbl thead th { background: var(--surface-2); font-weight: 600; color: var(--text-2); position: sticky; top: 0; white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: #f7f9fc; }
.tbl .num { color: var(--muted); width: 36px; text-align: center; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: calc(12px * var(--fs)); font-weight: 600; }
.badge-signed { background: #e6f4ea; color: var(--green); }
.badge-unsigned { background: #fff0ec; color: var(--red); }
.badge-muted { background: #eef1f5; color: var(--text-2); }

/* 分页 */
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.pager .pinfo { color: var(--text-2); font-size: calc(13px * var(--fs)); }

/* 键值信息表 */
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.kv > div { padding: 11px 14px; border-bottom: 1px solid var(--border); }
.kv > div:nth-last-child(-n+2) { border-bottom: none; }
.kv .k { background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: calc(13px * var(--fs)); }
.kv .v { font-size: calc(14px * var(--fs)); }

/* 提示闪烁文字 */
.blink { color: var(--primary); font-weight: 600; }
.blink2 { color: #7a5cff; font-weight: 600; }
@keyframes blinkA { 50% { opacity: .35; } }
.blinkA { animation: blinkA 1.2s infinite; }

/* ===== 盖章编辑器 ===== */
.editor-wrap { max-width: 900px; }
.editor-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.editor-bar .grow { flex: 1; min-width: 200px; }
.pdf-stage {
  position: relative;
  background: #e9edf2;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 78vh;
  padding: 16px;
  display: flex; justify-content: center; align-items: flex-start;
}
.pdf-canvas-wrap { position: relative; display: inline-block; }
.pdf-inner { position: relative; transform-origin: top left; overflow: hidden; } /* 印章页外部分裁掉，只露页内部分 */
#pdfCanvas { display: block; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.stamp-layer { position: absolute; inset: 0; pointer-events: none; }  /* 点击穿透到 canvas；.x 删除按钮自身 pointer-events:auto */
.stamp { position: absolute; pointer-events: none; cursor: default; }
.stamp-ghost { position: absolute; pointer-events: none; opacity: .5; outline: 1px dashed rgba(200,0,0,.7); }  /* 骑缝预览：后续页右边界上的印章片段（半透明示意） */
.stamp .x {
  position: absolute; top: -10px; left: -10px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--red); color: #fff; font-size: calc(12px * var(--fs)); line-height: 20px;
  text-align: center; cursor: pointer; pointer-events: auto;
}
.pdf-canvas-wrap { cursor: crosshair; }

/* 文件上传 */
.file-drop {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 22px; text-align: center; color: var(--text-2);
  transition: border-color .15s, background .15s; cursor: pointer;
}
.file-drop:hover { border-color: var(--primary); background: #f7faff; }
.file-drop.has { border-style: solid; border-color: #c6e7d0; background: #f2fbf5; color: var(--green); }
.file-name { font-weight: 600; color: var(--text); }

/* ===== 主页 ===== */
.hero { text-align: center; padding: 30px 10px 10px; }
.hero img { width: 200px; max-width: 60vw; border-radius: 8px; }
.hero h1 { font-size: calc(24px * var(--fs)); margin: 18px 0 6px; }
.hero p { color: var(--text-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.contact-line { padding: 10px 0; border-bottom: 1px solid var(--border); }
.contact-line:last-child { border-bottom: none; }

/* ===== 手机适配 ===== */
@media (max-width: 760px) {
  :root { --header-h: 52px; }
  .app-header { padding: 0 12px; flex-wrap: wrap; height: auto; min-height: var(--header-h); }
  .brand-text { font-size: calc(14px * var(--fs)); }
  .top-right { width: 100%; justify-content: space-between; }
  .datetime { display: none; }
  .divider { display: none; }
  .user-uid { display: none; }
  .tabnav { padding: 10px 12px 0; }
  .tab { flex: 1; justify-content: center; padding: 9px 6px; font-size: calc(13px * var(--fs)); }
  .app-main { padding: 14px 12px 40px; }
  .card { padding: 16px; }
  .form-row { flex-direction: column; gap: 0; }
  .grid2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 96px 1fr; }
  .tbl th, .tbl td { padding: 9px 10px; font-size: calc(13px * var(--fs)); }
  .hero img { width: 150px; }
  .pdf-stage { max-height: 66vh; padding: 10px; }
}
@media (max-width: 420px) {
  .brand-text { font-size: calc(13px * var(--fs)); }
  .btn { padding: 7px 12px; font-size: calc(13px * var(--fs)); }
}
/* ===== 主题切换（light / dark） ===== */
[data-theme=dark] {
  --bg: #0e1117;
  --surface: #161b24;
  --surface-2: #1d2431;
  --border: #2a3342;
  --text: #e7ebf2;
  --text-2: #a6b0c0;
  --muted: #6c7889;
  --primary: #5b8cff;
  --primary-d: #4a76e6;
  --gold: #d9b445;
  --green: #34a853;
  --red: #ef5350;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.3);
}
[data-theme=dark] .app-header { background: #0a0d13; }
[data-theme=dark] .pub-nav a:hover { background: #1d2431; }
[data-theme=dark] .pub-nav a.active { background: #1b2436; }
[data-theme=dark] .btn-ghost { background: var(--surface); color: var(--text-2); }
[data-theme=dark] .btn-ghost:hover { background: var(--surface-2); }
[data-theme=dark] .input { background: var(--surface-2); }
[data-theme=dark] .tab:hover { border-color: var(--border); }
[data-theme=dark] .alert-info { background: #152238; color: #8ab4ff; border-color: #1f3556; }
[data-theme=dark] .alert-success { background: #12291c; color: #7fd598; border-color: #1e4230; }
[data-theme=dark] .alert-warn { background: #2a2312; color: #e6c26a; border-color: #4a3d1e; }
[data-theme=dark] .alert-error { background: #2c1513; color: #f08c88; border-color: #4d2622; }
[data-theme=dark] .tbl tbody tr:hover { background: #1d2431; }
[data-theme=dark] .badge-unsigned { background: #2c1513; color: #f08c88; }
[data-theme=dark] .badge-muted { background: #232b3a; color: var(--text-2); }
[data-theme=dark] .file-drop:hover { background: #131a26; }
[data-theme=dark] .file-drop.has { background: #12291c; border-color: #1e4230; }
[data-theme=dark] .pdf-stage { background: #11151c; }
[data-theme=dark] .env-tag { background: rgba(255,80,80,.25); color: #ffd0d0; }
.theme-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: rgba(255,255,255,.1); color: #fff;
  border: 1px solid transparent; cursor: pointer;
  font-size: calc(13px * var(--fs)); font-weight: 500; line-height: 1; white-space: nowrap;
}
.theme-btn:hover { background: rgba(255,255,255,.2); text-decoration: none; }
.theme-btn .t-ico { width: 16px; height: 16px; filter: invert(1); opacity: .9; }

/* ===== 字号切换: 小/中/大 (默认中=1.2 号) ===== */
[data-fs=s] { --fs: 1.0; }
[data-fs=m] { --fs: 1.2; }
[data-fs=l] { --fs: 1.4; }
.fs-seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 9px; background: rgba(255,255,255,.12); }
.fs-seg button { border: 0; background: transparent; color: rgba(255,255,255,.78); font-size: calc(12px * var(--fs)); font-weight: 500; padding: 3px 9px; border-radius: 7px; cursor: pointer; line-height: 1.4; }
.fs-seg button:hover { background: rgba(255,255,255,.14); }
.fs-seg button.on { background: #fff; color: #172137; font-weight: 600; }
