:root {
    --ink: #1c1915;
    --muted: #6f675d;
    --paper: #f3efe6;
    --card: #fffdf8;
    --line: #e4daca;
    --sidebar: #1b2330;
    --seal: #b4332a;
    --ok: #1f7a4d;
    --shadow: 0 10px 30px rgba(40, 30, 16, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    color: var(--ink);
    background: var(--paper);
    font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: #8d2c24; text-decoration: none; }
a:hover { text-decoration: underline; }
.app { min-height: 100vh; display: grid; grid-template-columns: 220px 1fr; }
.sidebar { background: var(--sidebar); color: #f4efe6; padding: 22px 16px; display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; gap: 10px; align-items: center; color: inherit; text-decoration: none; }
.brand strong { display: block; font-size: 18px; letter-spacing: 2px; }
.brand small { color: #c8bfb2; }
.brand-mark {
    width: 36px; height: 36px; border: 2px solid #e7b6b2; color: #f0d2ce;
    display: grid; place-items: center; font-family: "Songti SC", "SimSun", serif; font-size: 20px;
}
.brand-mark.big { width: 64px; height: 64px; margin: 0 auto 8px; border-color: var(--seal); color: var(--seal); font-size: 34px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { color: #ddd4c8; padding: 10px 12px; border-radius: 8px; text-decoration: none; }
.sidebar nav a.active, .sidebar nav a:hover { background: rgba(255,255,255,.08); color: white; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; border-bottom: 1px solid var(--line); background: rgba(255,253,248,.9); }
.top-title { font-weight: 650; }
.top-user { display: flex; gap: 12px; align-items: center; color: var(--muted); }
.top-user button, .ops button, .seal-list button { background: none; border: 0; color: var(--seal); cursor: pointer; padding: 0; }
.content { padding: 22px 24px 40px; }
.is-workspace .content { padding: 12px; height: calc(100vh - 56px); }
.page-head, .btn-row, .pane-tools, .top-user, .search { display: flex; gap: 10px; align-items: center; }
.page-head { justify-content: space-between; margin-bottom: 16px; }
.page-head h2, .login-card h1 { margin: 0 0 4px; font-weight: 650; }
.page-head p, .hint, .login-card p { margin: 0; color: var(--muted); line-height: 1.6; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.btn.primary { background: var(--ink); color: #fffdf8; border-color: var(--ink); }
.btn.seal { background: var(--seal); color: white; border-color: var(--seal); }
.btn.full { width: 100%; }
.btn:disabled { opacity: .6; cursor: wait; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stats div, .panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.stats div { padding: 16px 18px; }
.stats strong { display: block; font-size: 28px; }
.stats span, .doc-no { color: var(--muted); }
.panel { padding: 8px 16px 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-table { width: 100%; border-collapse: collapse; }
.sheet-table th, .sheet-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.sheet-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.ops { white-space: nowrap; display: flex; gap: 10px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #efe8dc; }
.pill.ok { background: #e5f3eb; color: var(--ok); }
.empty { padding: 28px 8px; color: var(--muted); }
.banner, .flash, .form-error { margin: 0 24px 12px; background: #fff4e8; border: 1px solid #f0d7b8; padding: 10px 12px; border-radius: 10px; }
.flash { margin-top: 12px; }
.form-error { margin: 0 0 12px; background: #fdeceb; border-color: #f0c2be; }
.search { margin-bottom: 12px; }
.search input, .form-grid input, .login-card input, textarea { width: 100%; border: 1px solid var(--line); background: white; border-radius: 8px; padding: 8px 10px; }
.search input { max-width: 320px; }
.pager { display: flex; gap: 6px; margin-top: 14px; }
.pager a { min-width: 32px; text-align: center; padding: 6px; border-radius: 8px; background: white; text-decoration: none; color: var(--ink); }
.pager a.active { background: var(--ink); color: white; }
.login-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at top, #f7f1e6, #e7e0d4 55%, #d9cfc0); }
.login-card { width: min(420px, calc(100% - 32px)); background: var(--card); border-radius: 18px; padding: 32px 28px; box-shadow: var(--shadow); }
.login-card h1 { text-align: center; letter-spacing: 4px; }
.login-card p { margin: 8px 0 18px; text-align: center; }
.login-card label, .form-grid label, .notes-label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.split { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; align-items: start; }
.form-grid.tight { margin-top: 22px; padding-top: 8px; border-top: 1px solid var(--line); }
.stack { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.seal-list { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.seal-list article { display: flex; gap: 12px; align-items: center; }
.seal-list img { width: 84px; height: 84px; object-fit: contain; background: repeating-conic-gradient(#f3efe6 0% 25%, #fff 0% 50%) 50% / 16px 16px; border-radius: 8px; }
.seal-list form { display: inline; }
.workspace { height: 100%; display: grid; grid-template-columns: 300px minmax(0, 1fr) 320px; gap: 12px; }
.pane { background: var(--card); border: 1px solid var(--line); border-radius: 14px; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pane-head, .pane-tools { padding: 10px 12px; border-bottom: 1px solid var(--line); justify-content: space-between; flex-wrap: wrap; }
.pane-head h3 { margin: 0; font-size: 15px; }
.materials, .chat { padding-bottom: 10px; }
.notes-label, .drop, .files { margin: 0 12px; }
.notes-label textarea { min-height: 140px; resize: vertical; }
.drop { margin-top: 8px; border: 1px dashed #c8bba6; border-radius: 12px; padding: 14px; text-align: center; background: #fbf8f2; position: relative; }
.drop strong, .drop span { display: block; }
.drop span { color: var(--muted); font-size: 12px; margin-top: 4px; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop.over { border-color: var(--seal); background: #fff5f3; }
.files { list-style: none; padding: 0; margin-top: 10px; overflow: auto; }
.files li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.files small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.files button { margin-top: 4px; }
.preview-pane iframe, .editor { flex: 1; border: 0; width: 100%; min-height: 0; background: #ece6dc; }
.editor { overflow: auto; padding: 12px 14px 20px; background: #fffdf8; }
.editor.hidden, .preview-pane iframe.hidden { display: none; }
.tabs { display: flex; gap: 4px; }
.tabs button, .mobile-tabs button { border: 0; background: transparent; padding: 6px 8px; cursor: pointer; color: var(--muted); }
.tabs button.active { color: var(--ink); font-weight: 650; box-shadow: inset 0 -2px 0 var(--seal); }
.check { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }
.chat-log { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 95%; padding: 8px 10px; border-radius: 10px; white-space: pre-wrap; line-height: 1.55; }
.bubble.user { align-self: flex-end; background: #1b2330; color: white; }
.bubble.assistant { align-self: flex-start; background: #f6f1e8; }
.chat form { padding: 0 12px; display: flex; flex-direction: column; gap: 8px; }
.chat textarea { min-height: 74px; resize: vertical; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.field-grid .wide, .editor h4 { grid-column: 1 / -1; }
.editor h4 { margin: 14px 0 6px; }
.item-row, .section-row { display: grid; gap: 6px; grid-template-columns: 1fr 1.3fr .5fr .7fr .85fr auto; margin-bottom: 8px; align-items: start; }
.section-row { grid-template-columns: 140px 1fr auto; }
.item-row input, .item-row textarea, .section-row input, .section-row textarea { width: 100%; }
.item-row textarea { min-height: 72px; resize: vertical; }
.busy { position: fixed; inset: 0; background: rgba(28,25,21,.35); color: white; display: grid; place-items: center; font-size: 18px; z-index: 20; }
.busy[hidden] { display: none; }
.mobile-tabs { display: none; }
@media (max-width: 1100px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { flex-direction: row; align-items: center; padding: 10px; gap: 12px; }
    .sidebar nav { flex-direction: row; overflow: auto; }
    .split, .stats, .workspace { grid-template-columns: 1fr; }
    .is-workspace .content { height: auto; }
    .workspace { height: auto; }
    .pane { display: none; min-height: 70vh; }
    .pane.show { display: flex; }
    .mobile-tabs { display: flex; position: sticky; bottom: 0; background: #fffdf8; border-top: 1px solid var(--line); }
    .mobile-tabs button { flex: 1; padding: 12px; }
    .mobile-tabs button.active { color: var(--seal); font-weight: 650; }
    .preview-pane iframe { min-height: 70vh; }
}
