/* KaiEscola — 五个 PWA 共用样式
   颜色：大西洋深蓝（品牌，学校可改成自己的主色）+ 暖沙色背景 + 国旗黄强调；系统字体，断网也能显示 */
:root {
  --brand: #0B5E8A; --accent: #F2B705; --accent-ink: #3b2c00;
  --bg: #f4f2ec; --panel: #fffefb; --panel-2: #f7f5ef; --line: #e3dfd4; --line-2: #d2ccbe;
  --ink: #17232b; --ink-2: #45545e; --ink-3: #74828b;
  --good: #1f7a4d; --warn: #b54708; --bad: #b42318; --info: #175cd3;
  --good-soft: #e3f4ea; --warn-soft: #fef0c7; --bad-soft: #fee4e2; --info-soft: #e0eaff;
  --brand-soft: color-mix(in srgb, var(--brand) 12%, var(--panel));
  --radius: 12px; --radius-sm: 8px; --shadow: 0 1px 2px rgba(20,30,40,.06), 0 6px 20px rgba(20,30,40,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f161b; --panel: #161f26; --panel-2: #1b262e; --line: #26333c; --line-2: #33434d;
    --ink: #e6edf1; --ink-2: #b4c1c9; --ink-3: #85949d;
    --good-soft: #12301f; --warn-soft: #3a2a10; --bad-soft: #3b1715; --info-soft: #14244a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f161b; --panel: #161f26; --panel-2: #1b262e; --line: #26333c; --line-2: #33434d;
  --ink: #e6edf1; --ink-2: #b4c1c9; --ink-3: #85949d;
  --good-soft: #12301f; --warn-soft: #3a2a10; --bad-soft: #3b1715; --info-soft: #14244a; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--brand); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
.muted { color: var(--ink-3); } .small { font-size: 13px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stack { display: flex; flex-direction: column; gap: 12px; } .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; } .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; }
.span2 { grid-column: span 2; } .span3 { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }
.loading, .empty { padding: 32px 12px; text-align: center; color: var(--ink-3); } .empty.bad { color: var(--bad); }

/* ---------- 按钮、表单 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--brand); } .btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { filter: brightness(1.08); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 13px; } .btn.block { width: 100%; } .btn.lg { min-height: 52px; font-size: 17px; }
.icon-btn { border: 0; background: transparent; color: inherit; font-size: 18px; width: 38px; height: 38px; border-radius: 50%; cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--panel-2); }
.link { border: 0; background: none; color: var(--brand); font: inherit; cursor: pointer; padding: 4px 0; text-align: left; }
.field { display: flex; flex-direction: column; gap: 4px; } .field > span { font-size: 13px; color: var(--ink-2); font-weight: 600; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 9px 11px; min-height: 40px; width: 100%; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand); }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; } .checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; } legend { font-weight: 700; padding: 0 6px; }
.search { max-width: 340px; }

/* ---------- 徽章 ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; } .badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; } .badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

/* ---------- 卡片、指标 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card h3 { font-size: 16px; } .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { font-size: 13px; color: var(--ink-3); } .stat .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat.warn .v { color: var(--warn); } .stat.bad .v { color: var(--bad); } .stat.good .v { color: var(--good); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; } .toolbar .grow { flex: 1; }
.section { margin: 22px 0 10px; font-size: 15px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; } .kv dt { color: var(--ink-3); } .kv dd { margin: 0; }

/* ---------- 表格（手机上变成卡片） ---------- */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.tbl { width: 100%; border-collapse: collapse; } .tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; background: var(--panel-2); position: sticky; top: 0; }
.tbl tr:last-child td { border-bottom: 0; } .tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: var(--panel-2); }
@media (max-width: 720px) {
  .tbl thead { display: none; } .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { border-bottom: 1px solid var(--line); padding: 8px 4px; } .tbl td { border: 0; padding: 3px 10px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .tbl td::before { content: attr(data-label); color: var(--ink-3); font-size: 12px; text-align: left; } .tbl td.r { text-align: right; }
}

/* ---------- 外框 ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
.side-brand small { display: block; font-weight: 400; color: var(--ink-3); font-size: 12px; }
.side-nav { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--ink-2); text-decoration: none; font-weight: 500; }
.side-nav a:hover { background: var(--panel-2); } .side-nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.side-nav .ico { width: 22px; text-align: center; } .side-nav .cnt { margin-left: auto; background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; }
.side-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top-title { flex: 1; margin: 0; font-size: 18px; } .top-actions { display: flex; align-items: center; gap: 8px; } .top-user { color: var(--ink-3); font-size: 14px; }
.menu-btn { display: none; }
.bell .dot { position: absolute; top: 2px; right: 0; background: var(--bad); color: #fff; font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px; line-height: 16px; padding: 0 3px; }
.content { padding: 20px; max-width: 1240px; width: 100%; outline: none; }
.banner { background: var(--warn-soft); color: var(--warn); padding: 8px 20px; font-size: 14px; } .banner a { color: inherit; font-weight: 700; }
.tabs { display: none; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 50; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .app.nav-open .side { transform: none; } .menu-btn { display: inline-block; } .top-user { display: none; }
  .content { padding: 14px 14px 90px; }
  .tabs { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 30; }
  .tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 9px; font-size: 11px; color: var(--ink-3); text-decoration: none; }
  .tabs a .ico { font-size: 20px; } .tabs a.on { color: var(--brand); font-weight: 700; }
}
.logo { width: 38px; height: 38px; border-radius: 10px; object-fit: contain; background: #fff; flex: none; }
.logo.lg { width: 76px; height: 76px; border-radius: 18px; } .logo-ph { display: inline-flex; align-items: center; justify-content: center; background: var(--brand); color: #fff; font-weight: 800; font-size: 18px; }
.logo.lg.logo-ph { font-size: 34px; }
.lang { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; }
.lang button { border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: 12px; padding: 4px 10px; cursor: pointer; } .lang button.on { background: var(--brand); color: #fff; }

/* ---------- 登录 ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px 24px; box-shadow: var(--shadow); }
.login-top { display: flex; justify-content: center; margin-bottom: 12px; } .login h1 { text-align: center; font-size: 21px; margin-bottom: 4px; } .login p { text-align: center; margin-top: 0; }
.login-extra { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; align-items: center; } .login-foot { margin-top: 18px; }

/* ---------- 弹窗、提示 ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10,18,24,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal { background: var(--panel); border-radius: 16px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 860px; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); } .modal h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
@media (max-width: 640px) { .modal-back { align-items: flex-end; padding: 0; } .modal { border-radius: 16px 16px 0 0; max-height: 92vh; } }
#toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 440px); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); transition: opacity .4s, transform .4s; font-size: 14px; }
.toast.good { background: var(--good); color: #fff; } .toast.bad { background: var(--bad); color: #fff; } .toast.info { background: var(--brand); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-8px); }
.secret { display: grid; gap: 8px; } .secret div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--panel-2); border-radius: 8px; }
.secret b { font-family: ui-monospace, monospace; font-size: 18px; letter-spacing: 1px; }

/* ---------- 通知 ---------- */
.notif-list { display: flex; flex-direction: column; } .notif { display: flex; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.notif.new { background: var(--brand-soft); border-radius: 8px; padding: 10px; } .notif p { margin: 2px 0; } .ni { font-size: 22px; }

/* ---------- 门口扫码 ---------- */
.gate { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 900px) { .gate { grid-template-columns: 1fr; } }
.gate-big { text-align: center; padding: 26px 16px; border-radius: 18px; background: var(--panel); border: 2px dashed var(--line-2); }
.gate-big.in { background: var(--good-soft); border: 2px solid var(--good); } .gate-big.out { background: var(--info-soft); border: 2px solid var(--info); }
.gate-big.err { background: var(--bad-soft); border: 2px solid var(--bad); } .gate-big .nm { font-size: 26px; font-weight: 800; } .gate-big .ic { font-size: 54px; }
.gate-input { font-size: 22px; text-align: center; letter-spacing: 1px; }

/* ---------- 成绩表、点名 ---------- */
.sheet input.score { width: 84px; text-align: right; font-variant-numeric: tabular-nums; }
.roll { display: flex; gap: 4px; } .roll button { border: 1px solid var(--line-2); background: var(--panel); border-radius: 8px; min-width: 40px; height: 36px; font: inherit; font-weight: 700; cursor: pointer; }
.roll button.on.present { background: var(--good); color: #fff; border-color: var(--good); } .roll button.on.absent { background: var(--bad); color: #fff; border-color: var(--bad); }
.roll button.on.late { background: var(--warn); color: #fff; border-color: var(--warn); } .roll button.on.justified { background: var(--info); color: #fff; border-color: var(--info); }
.grade-good { color: var(--good); font-weight: 700; } .grade-bad { color: var(--bad); font-weight: 700; }

/* ---------- 家长端 / 学生端（手机优先） ---------- */
body.portal .content { max-width: 760px; margin: 0 auto; }
.child { display: flex; gap: 14px; align-items: center; } .child .av { width: 52px; height: 52px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; flex: none; overflow: hidden; }
.child .av img { width: 100%; height: 100%; object-fit: cover; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.due-card { border-left: 4px solid var(--warn); } .due-card.overdue { border-left-color: var(--bad); } .due-card.paid { border-left-color: var(--good); }
.amount { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; } .cal div { aspect-ratio: 1; border-radius: 8px; background: var(--panel-2); display: flex; align-items: center; justify-content: center; font-size: 13px; position: relative; }
.cal .hd { background: none; color: var(--ink-3); font-size: 11px; aspect-ratio: auto; } .cal .in { background: var(--good-soft); color: var(--good); font-weight: 700; }
.cal .abs { background: var(--bad-soft); color: var(--bad); font-weight: 700; } .cal .hol { background: var(--info-soft); color: var(--info); } .cal .today { outline: 2px solid var(--brand); }
.subj { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); } .subj:last-child { border: 0; }
.avg { font-size: 20px; font-weight: 800; min-width: 52px; text-align: right; }
.tile-btns { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.tile-btns a, .tile-btns button { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font: inherit; cursor: pointer; text-align: left; }
.tile-btns .ico { font-size: 24px; }

/* ---------- 首页（选择门户） ---------- */
.hub { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 48px 16px; gap: 24px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 16%, var(--bg)), var(--bg) 60%); }
.hub h1 { font-size: 30px; text-align: center; } .hub-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; width: 100%; max-width: 980px; }
.hub-grid a { display: flex; flex-direction: column; gap: 8px; padding: 20px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.hub-grid a:hover { border-color: var(--brand); } .hub-grid .ico { font-size: 32px; } .hub-grid b { font-size: 17px; }
.stars { color: var(--accent); letter-spacing: 3px; }

@keyframes kc-scan { 0%, 100% { top: 22%; } 50% { top: 76%; } }
@media print { .side, .top, .tabs, .toolbar, .banner, #toasts, .modal footer, .modal header .icon-btn { display: none !important; } .app { display: block; } .modal-back { position: static; background: none; } .modal { box-shadow: none; max-height: none; } }
/* ---------- 扫码 ---------- */
.scanner { position: fixed; inset: 0; background: #000; z-index: 300; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; }
.scanner .scan-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(14px + env(safe-area-inset-top)) 16px 10px; text-align: center; font-size: 16px; }
.scanner .scan-view { position: relative; width: 100%; max-width: 480px; aspect-ratio: 4 / 3; max-height: 55vh; overflow: hidden; background: #000; flex: none; }
.scanner .scan-view.off video, .scanner .scan-view.off .scan-line { display: none; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .scan-corners { position: absolute; inset: 0; pointer-events: none; }
.scanner .scan-corners i { position: absolute; width: 36px; height: 36px; border: 0 solid #fff; }
.scanner .scan-corners i:nth-child(1) { top: 18%; left: 12%; border-top-width: 3px; border-left-width: 3px; border-radius: 4px 0 0 0; }
.scanner .scan-corners i:nth-child(2) { top: 18%; right: 12%; border-top-width: 3px; border-right-width: 3px; border-radius: 0 4px 0 0; }
.scanner .scan-corners i:nth-child(3) { bottom: 18%; left: 12%; border-bottom-width: 3px; border-left-width: 3px; border-radius: 0 0 0 4px; }
.scanner .scan-corners i:nth-child(4) { bottom: 18%; right: 12%; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 4px 0; }
.scanner .scan-line { position: absolute; left: 12%; right: 12%; top: 18%; height: 2px; background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: kc-scan 1.8s ease-in-out infinite; }
.scanner .scan-flash { position: absolute; inset: 0; background: rgba(52, 211, 153, .4); opacity: 0; pointer-events: none; transition: opacity .15s; }
.scanner .scan-line { animation: none; top: 50%; }
.scanner .scan-hint { color: rgba(255,255,255,.85); font-size: 14px; margin: 16px 0 0; padding: 0 20px; text-align: center; }
.scanner .scan-btns { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 14px 0 0; padding: 0 16px; }
.scanner .scan-pill { padding: 10px 22px; border-radius: 999px; border: 1.5px solid rgba(255,255,255,.45); background: rgba(255,255,255,.12); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.scanner .scan-pill.on { background: var(--accent); border-color: var(--accent); color: #2b1d05; }
.scanner .bar { position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); width: 100%; max-width: 480px; }
.scanner .bar input { flex: 1; min-width: 0; }
.scanner .scan-view { max-width: 360px; }
.scanner .scan-hint { margin-top: 8px; }
.scan-result { border-left: 4px solid var(--brand); }
.toolbar > select, .toolbar > input { width: auto; min-width: 150px; max-width: 100%; } .toolbar > input.search { min-width: 220px; }
a.card { text-decoration: none; color: inherit; } a.card:hover { border-color: var(--brand); }
details.subj-d summary { list-style: none; cursor: pointer; } details.subj-d summary::-webkit-details-marker { display: none; }
@media (max-width: 640px) { .toolbar > select, .toolbar > input, .toolbar > input.search { flex: 1 1 100%; } }

/* Google 登录 */
.google-login { margin-top: 14px; }
.google-login .or { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 13px; margin: 4px 0 12px; }
.google-login .or::before, .google-login .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.google-login .gbtn, .modal .gbtn { display: flex; justify-content: center; min-height: 44px; }

/* 单据模版（1.2） */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin-bottom: 10px; }
.seg a { padding: 6px 14px; border-radius: 999px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 14px; }
.seg a.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tpl-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.tpl-card.on { border-color: var(--brand, #0B5E8A); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand, #0B5E8A) 35%, transparent); }
.tpl-thumb { height: 230px; overflow: hidden; background: #e9edf0; border-bottom: 1px solid var(--line); position: relative; }
.tpl-thumb iframe { width: 794px; height: 1123px; border: 0; transform: scale(.32); transform-origin: 0 0; pointer-events: none; background: #fff; position: absolute; left: 50%; margin-left: -127px; }
.tpl-info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.tpl-info .tpl-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; } .tpl-info .tpl-name b { margin-right: 2px; }
.tpl-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.tpl-preview { width: 100%; height: min(70vh, 760px); border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.modal.wide:has(.tpl-editor) { max-width: 1280px; }
.tpl-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.tpl-editor textarea.code { font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; tab-size: 2; width: 100%; }
.tpl-side .tpl-preview { height: 52vh; }
.tpl-fields { display: flex; flex-wrap: wrap; gap: 6px; max-height: 24vh; overflow: auto; margin-top: 4px; }
.chip { border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 8px; padding: 3px 8px; font-size: 12px; cursor: pointer; text-align: left; color: var(--ink); }
.chip:hover { border-color: var(--brand, #0B5E8A); } .chip code { color: var(--brand, #0B5E8A); }
@media (max-width: 900px) { .tpl-editor { grid-template-columns: 1fr; } .tpl-side .tpl-preview { height: 60vh; } }
