:root {
  --bg: #e7e1d6;
  --ink: #1c1714;
  --muted: #6f675f;
  --line: #e3d8cb;
  --card: #fffaf4;
  --side: #241f1b;
  --side-text: #f3ebe3;
  --seal: #8c2f24;
  --seal-soft: #f6e7e2;
  --pine: #1f5c57;
  --gold: #8a6232;
  --warn: #9a6408;
  --ok: #1d6b42;
  --shadow: 0 16px 40px rgba(48, 32, 18, 0.08);
  --sans: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  --serif: "Palatino Linotype", "Songti SC", "SimSun", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(140, 47, 36, 0.08), transparent 55%),
    linear-gradient(180deg, #efe8de, var(--bg));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.booting { padding: 48px; color: var(--muted); }
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side);
  color: var(--side-text);
  padding: 22px 16px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 18px; }
.brand strong { display: block; font-family: var(--serif); font-size: 18px; letter-spacing: 0.04em; }
.brand span { color: #cbbfb3; font-size: 12px; }
.seal {
  width: 42px; height: 42px; display: grid; place-items: center;
  border: 1.5px solid #e7c7bf; color: #f6d7d1; border-radius: 4px;
  font-family: var(--serif); font-size: 22px; transform: rotate(-8deg); flex: none;
}
.seal.big { width: 64px; height: 64px; font-size: 34px; color: var(--seal); border-color: var(--seal); margin-bottom: 8px; }
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav a {
  text-decoration: none; padding: 10px 12px; border-radius: 8px; color: #e7ddd4; font-size: 14px;
}
.side nav a.active, .side nav a:hover { background: rgba(255, 248, 244, 0.08); color: white; }
.side nav a.active { box-shadow: inset 2px 0 0 #e7c7bf; }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 16px; }
.side-foot p { margin: 0; color: #b7aa9f; font-size: 12px; line-height: 1.5; word-break: break-all; }
.main { min-width: 0; }
.top {
  display: flex; justify-content: space-between; gap: 16px; align-items: flex-end;
  padding: 28px 32px 8px;
}
.eyebrow { margin: 0 0 4px; color: var(--gold); font-size: 12px; letter-spacing: 0.14em; }
h1 { margin: 0; font-family: var(--serif); font-size: 32px; font-weight: 600; }
h2 { margin: 0 0 12px; font-family: var(--serif); font-size: 22px; }
h3 { margin: 0 0 8px; font-size: 15px; }
.content { padding: 12px 32px 40px; }
.top-actions, .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 8px;
  padding: 8px 12px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.btn.primary { background: var(--seal); color: #fffaf7; border-color: var(--seal); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--seal); }
.btn.block { width: 100%; }
.side .btn.ghost { color: #f3ebe3; border-color: rgba(243, 235, 227, 0.25); }
.btn:disabled { opacity: 0.6; cursor: progress; }

.grid-4, .grid-3, .grid-2 { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  background: var(--card); border: 1px solid rgba(227, 216, 203, 0.9); border-radius: 14px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat b { display: block; margin-top: 8px; font-family: var(--serif); font-size: 30px; font-weight: 600; }
.stat span, .muted, .fine { color: var(--muted); }
.fine { font-size: 12px; line-height: 1.6; }
.stack { display: grid; gap: 14px; }
.list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.list a { text-decoration: none; }
.list li, .mail-item, .lib-card {
  display: block; padding: 12px 0; border-bottom: 1px solid var(--line);
}
.list li:last-child, .mail-item:last-child { border-bottom: 0; }
.between { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.task { padding-left: 12px; border-left: 3px solid var(--seal); }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr:hover td { background: rgba(255, 250, 244, 0.7); }
td a { text-decoration: none; font-weight: 650; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }

.pill {
  display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px;
  background: #eee7de; color: #5c534c; font-size: 12px; white-space: nowrap;
}
.pill[data-s="new"] { background: #e7f3ec; color: #1d6b42; }
.pill[data-s="review"], .pill[data-s="draft"] { background: #f8efd8; color: #8a5a10; }
.pill[data-s="preparing"] { background: #e7eef8; color: #1d4f8f; }
.pill[data-s="submitted"], .pill[data-s="final"] { background: #ece7f7; color: #533e86; }
.pill[data-s="won"] { background: #e5f6ec; color: #0f6b3a; }
.pill[data-s="lost"] { background: #f8e8e5; color: #8c2f24; }
.pill[data-s="dropped"] { background: #eeeae4; color: #6f675f; }
.pill[data-s="result"], .pill[data-s="结果"], .pill[data-s="low"] { background: #e5f3f2; color: #1f5c57; }
.pill[data-s="招标"], .pill[data-s="high"], .pill[data-s="kept"] { background: #e7f3ec; color: #1d6b42; }
.pill[data-s="变更"], .pill[data-s="mid"], .pill[data-s="pending"] { background: #f8efd8; color: #8a5a10; }
.pill[data-s="其他"], .pill[data-s="none"], .pill[data-s="dropped"] { background: #eeeae4; color: #6f675f; }
.due { display: inline-flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; }
.due small { color: var(--muted); font-size: 12px; }
.due.hot small, .due.over small { color: var(--seal); font-weight: 700; }
.due.warm small { color: var(--warn); }

.filters, .form-grid { display: grid; gap: 12px; }
.filters { grid-template-columns: minmax(180px, 1fr) 160px 140px auto; align-items: end; margin-bottom: 14px; }
.form-grid { grid-template-columns: 1fr 1fr; }
.field { display: grid; gap: 6px; }
.field.wide { grid-column: 1 / -1; }
.field span, .check span { font-size: 13px; color: #4e463f; }
input, select, textarea {
  width: 100%; border: 1px solid #ddd3c6; background: #fffdfb; border-radius: 8px; padding: 9px 10px;
}
textarea { resize: vertical; line-height: 1.6; }
.paper {
  font-family: var(--serif); font-size: 16px; line-height: 1.75; min-height: 320px; background: #fffefb;
}
.checkline, .check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.check input, .checkline input { width: auto; margin-top: 3px; }
.checks { display: grid; gap: 8px; }

.banner {
  border-radius: 12px; padding: 12px 14px; background: var(--seal-soft); color: #6d241c; margin-bottom: 14px;
  line-height: 1.6; word-break: break-word;
}
.banner.bad { background: #f8e8e5; }
.banner.ok { background: #e7f3ec; color: #145233; }
.pre { white-space: pre-wrap; word-break: break-word; line-height: 1.7; }
.prose { max-width: 760px; }
.prose p { line-height: 1.8; }
.lib-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.lib-card { border: 0; padding: 4px 2px 12px; }
.lib-card b { font-family: var(--serif); font-size: 18px; }

.editor { display: grid; grid-template-columns: 190px minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
.editor nav, .editor aside { position: sticky; top: 16px; display: grid; gap: 8px; }
.editor nav button, .jump {
  text-align: left; background: transparent; border: 0; border-left: 2px solid transparent; padding: 6px 8px; color: var(--muted);
}
.editor nav button.active { border-left-color: var(--seal); color: var(--ink); font-weight: 700; }
.section-block { margin-bottom: 22px; }
.guide { background: #f7f1e8; border-radius: 10px; padding: 10px 12px; color: #4e463f; line-height: 1.6; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(460px, 100%); background: var(--card); border-radius: 18px; padding: 32px 28px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 36px; margin: 4px 0 8px; }
.lede { line-height: 1.7; color: #4e463f; }
.login-error { color: var(--seal); min-height: 1.2em; }

.toast {
  position: fixed; right: 16px; top: 16px; z-index: 20; display: grid; gap: 8px; width: min(360px, calc(100% - 32px));
}
.toast div { background: var(--ink); color: white; border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); }
.toast .bad { background: var(--seal); }
.toast .ok { background: var(--pine); }
.rows { display: grid; gap: 8px; }
.row-card { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 8px; background: #fbf7f2; border-radius: 10px; }
.row-card.case { grid-template-columns: 1.2fr 1fr 0.6fr 0.7fr; }
.row-card .wide { grid-column: 1 / -1; }
.group-title { margin: 8px 0 0; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: relative; height: auto; }
  .side nav { flex-direction: row; overflow: auto; }
  .grid-4, .grid-3, .editor, .lib-grid, .filters, .form-grid { grid-template-columns: 1fr; }
  .top, .content { padding-left: 16px; padding-right: 16px; }
  .editor nav, .editor aside { position: static; }
}
