:root {
  --ink: #0a223b;
  --ink-2: #183b5a;
  --paper: #f5f8fa;
  --card: #ffffff;
  --line: #dce6ec;
  --muted: #667b8d;
  --teal: #00cba9;
  --teal-dark: #008f7a;
  --danger: #c43f4e;
  --gold: #efb733;
  --shadow: 0 18px 50px rgba(7, 31, 54, .10);
  color-scheme: light;
}

html[data-theme="dark"] {
  --ink: #eaf3f8;
  --ink-2: #bdd0dd;
  --paper: #071728;
  --card: #0e253a;
  --line: #254259;
  --muted: #93aabd;
  --shadow: 0 18px 50px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif; color: var(--ink); background: var(--paper); }
button, input, select { font: inherit; }
button, .button-link { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 10px; color: var(--teal-dark); font-weight: 800; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; color: #06293a; background: var(--teal); border-radius: 16px; font-weight: 900; letter-spacing: -.05em; }
.brand-mark.small { width: 40px; height: 40px; border-radius: 11px; font-size: 13px; }
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-lockup div { display: flex; flex-direction: column; }
.brand-lockup strong { font-size: 15px; }
.brand-lockup small { color: var(--muted); font-size: 10px; letter-spacing: .12em; }
.primary, .ghost, .danger-text, .text-button, .reader-tools button, .utility-buttons button, .page-nav button, .share-button { border: 0; border-radius: 9px; padding: 11px 16px; font-weight: 750; transition: .18s ease; }
.primary { color: #05243a; background: var(--teal); box-shadow: 0 8px 24px rgba(0, 203, 169, .18); }
.primary:hover { transform: translateY(-1px); background: #13dfbc; }
.ghost { color: var(--ink); background: transparent; border: 1px solid var(--line); }
.ghost:hover { border-color: var(--teal-dark); }
.wide { width: 100%; }
.small-button { padding: 7px 11px; }
.danger-text { color: var(--danger); background: transparent; }
.button-link { display: inline-flex; justify-content: center; text-decoration: none; }
.alert { padding: 12px; border-radius: 9px; margin: 14px 0; }
.alert.danger { color: #8f2130; background: #fff0f2; border: 1px solid #f6ccd2; }
.muted, .fine-print { color: var(--muted); }
.fine-print { font-size: 12px; line-height: 1.55; }

/* Authentication */
.auth-page { min-height: 100vh; background: #071d34; color: white; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.25fr .75fr; }
.auth-brand { padding: 9vw; display: flex; flex-direction: column; justify-content: center; background: radial-gradient(circle at 80% 12%, #18476a 0 18%, transparent 18.2%), linear-gradient(145deg, #071d34, #0c2d4b); }
.auth-brand h1 { max-width: 700px; font-size: clamp(42px, 7vw, 96px); line-height: .96; margin: 20px 0; letter-spacing: -.05em; }
.auth-brand > p:last-child { color: #afc4d3; max-width: 570px; font-size: 18px; }
.auth-card { color: #0a223b; background: white; margin: auto; width: min(440px, 86%); padding: 50px; border-radius: 22px; box-shadow: 0 30px 100px rgba(0,0,0,.28); }
.auth-card h2 { font-size: 30px; margin: 0 0 25px; }
.stack-form { display: grid; gap: 16px; }
.stack-form label, .upload-grid label, .dialog-card label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; }
input, select { width: 100%; min-height: 45px; padding: 10px 12px; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 9px; outline: none; }
input:focus, select:focus { border-color: var(--teal-dark); box-shadow: 0 0 0 3px rgba(0, 203, 169, .10); }

/* Admin */
.admin-header { position: sticky; top: 0; z-index: 30; height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1320px) / 2)); background: color-mix(in srgb, var(--card) 92%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.header-actions { display: flex; gap: 14px; align-items: center; }
.header-actions form { margin: 0; }
.status-dot { display: inline-flex; align-items: center; gap: 7px; color: var(--teal-dark); font-size: 12px; font-weight: 800; }
.status-dot::before, .status-dot i { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 5px rgba(0,203,169,.1); }
.admin-email { color: var(--muted); font-size: 13px; }
.admin-main { width: min(1320px, calc(100% - 48px)); margin: 0 auto; padding: 65px 0 100px; }
.hero-grid { display: grid; grid-template-columns: 1fr 360px; align-items: end; gap: 60px; margin-bottom: 60px; }
.hero-grid h1 { margin: 0; max-width: 790px; font-size: clamp(40px, 5vw, 72px); line-height: 1.02; letter-spacing: -.045em; }
.hero-copy { max-width: 760px; color: var(--muted); font-size: 17px; line-height: 1.8; }
.plan-card { padding: 26px; background: var(--ink); color: var(--paper); border-radius: 18px; box-shadow: var(--shadow); }
html[data-theme="dark"] .plan-card { background: #123450; }
.plan-card > span { display: block; color: #8eb0c4; font-size: 12px; }
.plan-card > strong { display: block; margin: 8px 0 2px; font-size: 26px; }
.plan-card > b { color: var(--teal); }
.plan-card > small { display: block; color: #8eb0c4; margin-top: 15px; }
.usage-row { display: flex; justify-content: space-between; margin-top: 20px; color: #b8cfdd; font-size: 12px; }
.usage-row em { color: white; font-style: normal; font-weight: 800; }
.usage-bar { height: 5px; margin-top: 8px; overflow: hidden; background: #27475e; border-radius: 9px; }
.usage-bar i { display: block; width: min(calc(var(--progress, 0) * 1%), 100%); height: 100%; background: var(--teal); }
.panel, .document-card { padding: 30px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 30px rgba(7,31,54,.04); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.section-heading h2 { margin: 0; font-size: 27px; }
.section-heading > span { color: var(--muted); font-size: 13px; }
.upload-grid { display: grid; grid-template-columns: 2fr .7fr .7fr 1.4fr 1.2fr 1.2fr auto; align-items: end; gap: 12px; }
.file-input input { padding: 9px; }
.documents-section { margin-top: 65px; }
.document-card { margin-bottom: 22px; }
.doc-main { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; }
.doc-badge { width: 58px; height: 68px; display: grid; place-items: end center; padding-bottom: 10px; color: white; background: linear-gradient(145deg, #0d3556, #116181); border-radius: 8px 15px 8px 8px; font-size: 11px; font-weight: 800; }
.doc-title h3 { margin: 8px 0 4px; font-size: 22px; }
.doc-title p { margin: 0; color: var(--muted); font-size: 12px; }
.doc-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.pill { display: inline-flex; margin-right: 5px; padding: 4px 8px; border-radius: 50px; color: var(--teal-dark); background: rgba(0,203,169,.1); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.pill.revoked { color: var(--danger); background: rgba(196,63,78,.1); }
.pill.replaced { color: #82610f; background: rgba(239,183,51,.16); }
.pill.neutral { color: var(--muted); background: color-mix(in srgb, var(--muted) 10%, transparent); }
.metrics-grid { margin: 25px 0; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.metrics-grid div { padding: 18px; border-right: 1px solid var(--line); }
.metrics-grid div:last-child { border-right: 0; }
.metrics-grid strong { display: block; font-size: 25px; }
.metrics-grid span { color: var(--muted); font-size: 11px; }
.doc-details-grid { display: grid; grid-template-columns: 1.65fr 1fr; gap: 24px; }
.doc-details-grid h4 { margin: 0 0 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { color: var(--muted); background: var(--paper); font-size: 10px; letter-spacing: .06em; }
td b, td small { display: block; }
td small { color: var(--muted); margin-top: 2px; }
.text-button { padding: 3px 0; color: var(--teal-dark); background: none; font-size: 11px; margin-right: 8px; }
.lead-list { display: grid; gap: 8px; }
.lead-card { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; padding: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
.lead-card div { display: flex; flex-direction: column; }
.lead-card small { color: var(--muted); }
.lead-card > strong { color: var(--teal-dark); font-size: 19px; }
.lead-card .text-button { justify-self: start; }
.hot { position: absolute; right: 8px; top: -8px; color: #6c4a00; background: var(--gold); padding: 2px 6px; border-radius: 5px; font-size: 8px; font-weight: 900; }
.page-heat { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.page-heat span { padding: 6px 8px; color: var(--muted); background: var(--paper); border-radius: 7px; font-size: 10px; }
.page-heat i { color: var(--ink); font-style: normal; font-weight: 800; }
.empty-state { padding: 55px; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: 18px; }
.empty-state strong { color: var(--ink); font-size: 20px; }
.audit-panel { margin-top: 65px; }
.privacy-panel { margin-top: 22px; }
.audit-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.audit-list div { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 12px; background: var(--paper); border-radius: 9px; font-size: 11px; }
.audit-list time { color: var(--muted); }
.audit-list span { grid-column: 2; color: var(--muted); }

/* Dialogs and toast */
.dialog-card { width: min(480px, calc(100% - 32px)); padding: 35px; color: var(--ink); background: var(--card); border: 0; border-radius: 18px; box-shadow: 0 25px 100px rgba(0,0,0,.3); }
.dialog-card::backdrop { background: rgba(4, 20, 34, .72); backdrop-filter: blur(5px); }
.dialog-card form { display: grid; gap: 14px; }
.dialog-card h2 { margin: 0 0 10px; }
.dialog-close { position: absolute; right: 15px; top: 12px; border: 0; color: var(--muted); background: transparent; font-size: 24px; }
.invite-result { display: grid; gap: 12px; margin-top: 22px; }
.invite-result img { width: 180px; height: 180px; padding: 5px; background: white; border: 1px solid var(--line); border-radius: 12px; justify-self: center; }
.invite-result p { color: var(--muted); font-size: 12px; text-align: center; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 28px; transform: translate(-50%, 140%); padding: 12px 18px; color: white; background: #08233b; border-radius: 50px; box-shadow: var(--shadow); opacity: 0; transition: .25s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* Gate */
.gate-page { min-height: 100vh; background: #071c32; color: white; }
.gate-shell { min-height: 100vh; display: grid; grid-template-columns: 1.2fr .8fr; }
.gate-document { position: relative; overflow: hidden; padding: 7vw; display: flex; flex-direction: column; justify-content: space-between; background: radial-gradient(circle at 85% 12%, #16496a 0 17%, transparent 17.2%), linear-gradient(140deg, #061b31, #0b3352); }
.gate-document::after { content: "DOCTRACE"; position: absolute; left: 45%; top: 45%; color: rgba(255,255,255,.025); font-size: 12vw; font-weight: 900; transform: rotate(-28deg); }
.gate-document .brand-lockup small { color: #86a8bc; }
.gate-copy { position: relative; z-index: 1; margin: 80px 0; }
.gate-copy h1 { max-width: 750px; margin: 10px 0; font-size: clamp(40px, 5vw, 78px); line-height: 1.02; letter-spacing: -.04em; }
.gate-copy > p:last-child { color: #9bb6c8; }
.gate-facts { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.gate-facts div { padding: 16px; background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.1); border-radius: 12px; }
.gate-facts b { display: block; color: var(--teal); font-size: 12px; }
.gate-facts span { display: block; margin-top: 7px; color: #c3d5df; font-size: 12px; line-height: 1.5; }
.honest-boundary { position: relative; z-index: 1; color: #829fb3; font-size: 11px; }
.gate-form-card { align-self: center; justify-self: center; width: min(470px, 80%); padding: 48px; color: var(--ink); background: var(--card); border-radius: 22px; box-shadow: 0 28px 100px rgba(0,0,0,.3); }
.gate-form-card h2 { margin: 0; font-size: 31px; }
.gate-form-card > p:not(.eyebrow):not(.fine-print) { color: var(--muted); line-height: 1.6; }
.channel-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.channel-tabs label { cursor: pointer; }
.channel-tabs input { position: absolute; opacity: 0; }
.channel-tabs span { display: grid; place-items: center; min-height: 42px; padding: 8px; color: var(--muted); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; font-size: 11px; }
.channel-tabs input:checked + span { color: var(--teal-dark); border-color: var(--teal-dark); background: rgba(0,203,169,.08); }
.consent { grid-template-columns: auto 1fr !important; align-items: start; font-weight: 500 !important; line-height: 1.55; color: var(--muted); }
.consent input { width: 17px; min-height: 17px; margin-top: 2px; }
.form-message { min-height: 24px; margin-top: 12px; color: var(--teal-dark); font-size: 12px; }
.form-message.error { color: var(--danger); }
.utility-buttons { position: fixed; z-index: 10; right: 18px; top: 18px; display: flex; gap: 6px; }
.utility-buttons button, .reader-tools button { min-width: 39px; padding: 9px; color: white; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.13); }

/* Reader */
.reader-page { height: 100vh; overflow: hidden; background: #061523; color: white; user-select: none; }
.reader-app { height: 100vh; display: grid; grid-template-rows: 68px 1fr 62px; }
.reader-header, .reader-footer { z-index: 5; display: flex; align-items: center; padding: 0 22px; background: #081e31; border-color: #1d3b52; }
.reader-header { justify-content: space-between; border-bottom: 1px solid #17364d; }
.reader-header .brand-lockup small { color: #7596aa; }
.reader-status { display: flex; gap: 18px; align-items: center; color: #9db5c5; font-size: 12px; }
.reader-tools { display: flex; gap: 6px; }
.reader-tools button.active { color: #07243a; background: var(--teal); }
.document-stage { position: relative; overflow: auto; display: grid; place-items: start center; padding: 26px; background: #0a1620; }
.document-stage img { display: block; max-width: min(1500px, 96%); height: auto; box-shadow: 0 18px 70px rgba(0,0,0,.45); }
.page-loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; color: #94acbb; background: #0a1620; }
.page-loading span { width: 35px; height: 35px; border: 3px solid #264357; border-top-color: var(--teal); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.reader-footer { justify-content: space-between; border-top: 1px solid #17364d; }
.reader-footer > p { color: #718fa3; font-size: 11px; }
.page-nav { display: flex; gap: 12px; align-items: center; }
.page-nav button { padding: 8px 14px; color: white; background: #12334c; }
.page-nav button:disabled { opacity: .35; }
.share-button { color: #06283a; background: var(--teal); }

/* Revoked */
.revoked-page { min-height: 100vh; display: grid; place-items: center; background: #071d34; }
.revoked-card { width: min(500px, calc(100% - 34px)); padding: 50px; text-align: center; color: #0a223b; background: white; border-radius: 22px; box-shadow: 0 30px 100px rgba(0,0,0,.3); }
.revoked-icon { width: 64px; height: 64px; margin: 0 auto 24px; display: grid; place-items: center; color: white; background: var(--danger); border-radius: 50%; font-size: 35px; }
.revoked-card h1 { margin: 5px 0; }
.revoked-card p:not(.eyebrow), .revoked-card small { color: #6d8292; }

@media (max-width: 1100px) {
  .upload-grid { grid-template-columns: repeat(3, 1fr); }
  .doc-details-grid { grid-template-columns: 1fr; }
  .gate-shell { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .auth-shell, .gate-shell, .hero-grid { grid-template-columns: 1fr; }
  .auth-brand { min-height: 43vh; padding: 45px 28px; }
  .auth-brand h1 { font-size: 48px; }
  .auth-card { margin: 45px auto; padding: 30px; }
  .admin-header { padding: 0 16px; }
  .admin-email, .status-dot { display: none; }
  .admin-main { width: min(100% - 24px, 1320px); padding-top: 35px; }
  .hero-grid { gap: 24px; }
  .hero-grid h1 { font-size: 42px; }
  .upload-grid { grid-template-columns: 1fr; }
  .panel, .document-card { padding: 20px; }
  .doc-main { grid-template-columns: auto 1fr; }
  .doc-actions { grid-column: 1 / -1; justify-content: stretch; }
  .doc-actions > * { flex: 1; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .metrics-grid div:nth-child(2) { border-right: 0; }
  .metrics-grid div { border-bottom: 1px solid var(--line); }
  .audit-list { grid-template-columns: 1fr; }
  .gate-document { min-height: 55vh; padding: 35px 24px; }
  .gate-copy { margin: 65px 0 35px; }
  .gate-copy h1 { font-size: 42px; }
  .gate-facts { grid-template-columns: 1fr; }
  .gate-form-card { width: calc(100% - 30px); margin: 25px auto 45px; padding: 28px; }
  .utility-buttons { top: 10px; right: 10px; }
  .reader-header { padding: 0 10px; }
  .reader-header .brand-lockup strong { max-width: 150px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .reader-status { display: none; }
  .document-stage { padding: 8px; }
  .document-stage img { max-width: 100%; }
  .reader-footer { padding: 0 10px; }
  .reader-footer > p { display: none; }
  .share-button { padding: 9px 11px; font-size: 11px; }
}

@media print {
  body * { visibility: hidden !important; }
  body::after { content: "此材料仅支持受控在线阅读，不提供打印。"; visibility: visible; position: fixed; inset: 0; display: grid; place-items: center; color: black; background: white; }
}
