:root {
    --ink: #15223a;
    --muted: #67758c;
    --line: #e2e8f1;
    --bg: #f4f7fc;
    --card: #ffffff;
    --blue: #0b2b57;
    --blue-2: #143d75;
    --accent: #1d5fbf;
    --accent-weak: #e9f1fc;
    --ok: #17795f;
    --ok-bg: #e8f5ef;
    --warn: #9a5600;
    --warn-bg: #fdf3e2;
    --danger: #a62a20;
    --danger-bg: #fbecea;
    --radius: 2px;
    --shadow: 0 1px 2px rgba(16, 35, 70, .06), 0 10px 30px rgba(16, 35, 70, .05);
    --font-serif: "Songti SC", "STSong", "Source Han Serif SC", "SimSun", serif;
    --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.75 var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 {
    font-family: var(--font-serif);
    color: var(--blue);
    font-weight: 600;
    line-height: 1.4;
    margin: 0;
}

.app { min-height: 100vh; }

/* ---------- sidebar ---------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 232px;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #0b2b57 0%, #0a2245 100%);
    color: #c6d5ec;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--blue);
    font: 700 15px/1 var(--font-serif);
    letter-spacing: .5px;
}

.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand-text strong { color: #fff; font-size: 15px; font-family: var(--font-serif); }
.brand-text span { color: #8fa6c6; font-size: 12px; }

.nav { padding: 12px 0; flex: 1; }

.nav-item {
    display: block;
    padding: 11px 22px;
    color: #c6d5ec;
    font-size: 14.5px;
    border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-item.is-active {
    background: rgba(255, 255, 255, .12);
    border-left-color: #8fb6f0;
    color: #fff;
}

.sidebar-foot { padding: 18px 22px; border-top: 1px solid rgba(255, 255, 255, .08); }
.sidebar-foot a { color: #9fb4d2; font-size: 13px; }

/* ---------- main ---------- */
.main { margin-left: 232px; min-height: 100vh; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 32px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--line);
}

.page-title { font-size: 22px; }
.topbar-note { color: var(--muted); font-size: 13px; letter-spacing: .5px; }

.content { padding: 24px 32px 72px; max-width: 1120px; }

/* ---------- cards ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    margin-bottom: 20px;
}

.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h2 { font-size: 18px; }

.cols { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 20px; align-items: start; }

.section-title { font-size: 17px; margin: 6px 0 16px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }

/* ---------- stats ---------- */
.stat-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }

.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--blue);
}
.stat-warn { border-top-color: var(--danger); }
.stat-label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.stat-num { font-family: var(--font-serif); font-size: 30px; color: var(--blue); line-height: 1; }
.stat-warn .stat-num { color: var(--danger); }

/* ---------- table ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { background: #f1f5fb; color: var(--muted); font-weight: 600; font-size: 13px; }
.table tr:hover td { background: #fafcff; }
.table .right { text-align: right; }

.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 18px 0; }
.right { text-align: right; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 1px 9px; font-size: 12px; border-radius: var(--radius); border: 1px solid transparent; }
.badge-draft { color: var(--warn); background: var(--warn-bg); border-color: #f0dcb8; }
.badge-reviewed { color: var(--accent); background: var(--accent-weak); border-color: #c7dbf7; }
.badge-published { color: var(--ok); background: var(--ok-bg); border-color: #bfe5d6; }

/* ---------- notices ---------- */
.notice { margin: 14px 0 0; padding: 10px 12px; border-radius: var(--radius); font-size: 13.5px; }
.notice-ok { background: var(--ok-bg); color: var(--ok); }
.notice-warn { background: var(--warn-bg); color: var(--warn); }
.notice-ok a, .notice-warn a { color: inherit; text-decoration: underline; }

.kv { display: grid; grid-template-columns: 84px 1fr; gap: 8px 12px; margin: 14px 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

/* ---------- forms ---------- */
.form-card { padding: 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.field-full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13.5px; color: #3a4a63; font-weight: 600; }

.field input, .field select, .field textarea, .toolbar input {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #cfd8e6;
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 72px; }
.field input:focus, .field select:focus, .field textarea:focus, .toolbar input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(29, 95, 191, .16);
}

.field-hint { color: var(--muted); font-size: 12px; font-style: normal; }

.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12.5px; }

.form-error { color: var(--danger); background: var(--danger-bg); padding: 8px 10px; border-radius: var(--radius); font-size: 13.5px; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: 14px/1 var(--font-sans);
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-2); }

.btn-ghost { background: #fff; color: var(--blue); border-color: #cfd8e6; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger { background: #fff; color: var(--danger); border-color: #ecc6c2; }
.btn-danger:hover { background: var(--danger-bg); }

.btn-block { width: 100%; }

.link { color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
.link-danger { color: var(--danger); }

.status-select {
    height: 32px;
    padding: 0 8px;
    border: 1px solid #cfd8e6;
    border-radius: var(--radius);
    background: #fff;
    font: 13px var(--font-sans);
    color: var(--ink);
    cursor: pointer;
}

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input { max-width: 360px; }

/* ---------- progress ---------- */
.progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding: 12px 14px;
    background: var(--accent-weak);
    color: var(--blue-2);
    border-radius: var(--radius);
    font-size: 14px;
}
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #b8cdec;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- result ---------- */
.result { display: block; }

.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.eyebrow { display: inline-block; color: var(--accent); font-size: 12.5px; letter-spacing: .5px; margin-bottom: 4px; }
.res-title { font-size: 21px; margin-top: 2px; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.meta-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.meta-item {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: var(--shadow);
}
.meta-item span { color: var(--muted); font-size: 12px; }
.meta-item strong { font-size: 14px; word-break: break-all; }

/* ---------- tabs ---------- */
.tabs-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); background: #f7f9fd; padding: 0 8px; }
.tab {
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    padding: 12px 14px;
    font: 14px var(--font-sans);
    color: var(--muted);
    cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.tab-panes { padding: 22px 24px 28px; }
.pane { display: none; }
.pane.is-active { display: block; }

/* ---------- preview article ---------- */
.preview { max-width: 780px; }
.preview-title { font-size: 26px; margin-bottom: 18px; line-height: 1.35; }
.preview h2 { font-size: 21px; margin: 30px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.preview h3 { font-size: 17.5px; margin: 22px 0 8px; }
.preview p { margin: 0 0 14px; line-height: 1.95; color: #24334d; }
.preview ul, .preview ol { margin: 0 0 16px; padding-left: 24px; }
.preview li { margin: 6px 0; }
.preview blockquote { margin: 16px 0; padding: 12px 16px; background: #f2f6fd; border-left: 3px solid var(--blue); color: var(--muted); }
.preview table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
.preview th, .preview td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.preview th { background: #eef3fa; }

.code {
    margin: 0;
    padding: 16px;
    background: #101c33;
    color: #d8e4f6;
    border-radius: var(--radius);
    font: 12.5px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow: auto;
    max-height: 640px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ---------- compliance ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { display: inline-block; padding: 2px 10px; font-size: 12.5px; border-radius: var(--radius); border: 1px solid transparent; }
.chip-high { color: var(--danger); background: var(--danger-bg); border-color: #ecc6c2; }
.chip-medium { color: var(--warn); background: var(--warn-bg); border-color: #f0dcb8; }
.chip-low { color: var(--accent); background: var(--accent-weak); border-color: #c7dbf7; }

.compliance-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.compliance-list li { border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--radius); padding: 10px 12px; }
.cl-high { border-left-color: var(--danger); background: #fffafa; }
.cl-medium { border-left-color: #e0a94a; background: #fffdf7; }
.cl-low { border-left-color: #79a6e0; background: #fafcff; }
.cl-head { display: flex; align-items: baseline; gap: 10px; }
.cl-head strong { font-size: 14.5px; color: var(--ink); }
.cl-head span { font-size: 12px; color: var(--muted); }
.compliance-list p { margin: 6px 0 0; color: #3a4a63; font-size: 13.5px; }
.cl-sug { color: var(--accent) !important; }

.ok-note { color: var(--ok); background: var(--ok-bg); padding: 12px 14px; border-radius: var(--radius); font-size: 14px; }

.link-list, .faq-mini { list-style: none; margin: 8px 0 18px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.link-list li, .faq-mini li { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.link-list strong, .faq-mini strong { display: block; font-size: 14px; }
.link-list span, .faq-mini span { color: var(--muted); font-size: 13px; }

.draft-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.draft-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- auth ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(160deg, #0b2b57 0%, #123a6e 55%, #1d5fbf 100%); }
.auth-wrap { width: 100%; max-width: 400px; padding: 24px; }
.auth-brand { display: flex; align-items: center; gap: 12px; color: #fff; font-family: var(--font-serif); font-size: 18px; margin-bottom: 18px; }
.auth-brand .brand-mark { width: 40px; height: 40px; }
.auth-card { background: #fff; border-radius: var(--radius); box-shadow: 0 18px 50px rgba(5, 20, 45, .35); padding: 28px 26px; }
.auth-title { font-size: 22px; margin-bottom: 4px; }
.auth-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-tip { color: var(--muted); font-size: 12.5px; margin: 14px 0 0; }
.auth-foot { text-align: center; color: #c3d4ec; font-size: 12px; margin-top: 16px; }

/* ---------- toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%);
    background: var(--blue);
    color: #fff;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    box-shadow: 0 10px 30px rgba(5, 20, 45, .3);
    z-index: 100;
    max-width: 90vw;
}
.toast.toast-error { background: var(--danger); }
.toast.toast-ok { background: var(--ok); }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
    .cols { grid-template-columns: 1fr; }
    .stat-row { grid-template-columns: repeat(2, 1fr); }
    .meta-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 860px) {
    .sidebar { position: static; width: auto; flex-direction: row; align-items: center; flex-wrap: wrap; }
    .brand { border-bottom: 0; padding: 14px 16px; }
    .nav { display: flex; flex: 1; padding: 0; overflow-x: auto; }
    .nav-item { border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; }
    .nav-item.is-active { border-left: 0; border-bottom-color: #8fb6f0; }
    .sidebar-foot { display: none; }
    .main { margin-left: 0; }
    .content { padding: 18px 16px 56px; }
    .topbar { padding: 14px 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .meta-grid { grid-template-columns: repeat(2, 1fr); }
}
