@import url('/app/static/fonts/noto-sans-sc.css');

/* ── 设计令牌 ──────────────────────────────── */
:root {
  --bg:         #f7f6f3;
  --bg-card:    #ffffff;
  --bg-sidebar: #efede9;

  --accent:     #5b6af0;
  --accent-dim: #eef0fd;

  --green:      #16a34a;
  --green-soft: #dcfce7;
  --red:        #dc2626;
  --red-soft:   #fee2e2;
  --amber:      #ca8a04;
  --amber-soft: #fef9c3;

  --t1: #1a1a1a;
  --t2: #6b6b6b;
  --t3: #a8a29e;
  --t4: #d4cfc9;

  --border: rgba(0,0,0,0.07);
  --sh-sm:  0 1px 3px rgba(0,0,0,0.05);
  --sh:     0 2px 10px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);

  --r-sm: 8px;
  --r:    14px;
  --r-lg: 20px;

  --font:      'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei UI', 'Microsoft YaHei', sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Cascadia Code', 'Consolas', monospace;
}

/* ── 全局 ──────────────────────────────────── */
html, body, [class*="css"] {
  font-family: var(--font) !important;
  -webkit-font-smoothing: antialiased;
}
.stApp { background: var(--bg) !important; }
.main .block-container {
  padding-top: 28px !important;
  max-width: 900px !important;
}

/* ── 页头 ──────────────────────────────────── */
.yn-header { margin-bottom: 28px; }
.yn-header-title {
  font-size: 17px; font-weight: 500;
  color: var(--t1); letter-spacing: -0.02em; margin: 0 0 4px;
}
.yn-header-sub { font-size: 13px; color: var(--t3); margin: 0; }

/* ── 结论卡（左右两张） ──────────────────────── */
.vc-wrap {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 10px;
  margin-bottom: 8px;
}
.vc-main {
  border-radius: var(--r-lg);
  padding: 28px 30px;
}
.vc-main.pass { background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); }
.vc-main.fail { background: linear-gradient(135deg, #fff5f5 0%, #fee2e2 100%); }
.vc-main.warn { background: linear-gradient(135deg, #fffdf0 0%, #fef9c3 100%); }

.vc-amt {
  border-radius: var(--r-lg);
  padding: 26px 26px;
  display: flex;
  flex-direction: column;
}
.vc-amt.pass { background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); }
.vc-amt.fail { background: linear-gradient(135deg, #fff5f5 0%, #fee2e2 100%); }
.vc-amt.warn { background: linear-gradient(135deg, #fffdf0 0%, #fef9c3 100%); }

.vc-amt.pass .amt-label { color: #16a34a; }
.vc-amt.pass .amt-num   { color: #15803d; }
.vc-amt.pass .amt-conf  { color: #4ade80; }
.vc-amt.pass .amt-empty { color: #86efac; }
.vc-amt.pass .amt-basis { color: #166534; border-top-color: rgba(22,163,74,.15); }

.vc-amt.fail .amt-label { color: #dc2626; }
.vc-amt.fail .amt-num   { color: #b91c1c; }
.vc-amt.fail .amt-conf  { color: #f87171; }
.vc-amt.fail .amt-empty { color: #fca5a5; }
.vc-amt.fail .amt-basis { color: #7f1d1d; border-top-color: rgba(220,38,38,.15); }

.vc-amt.warn .amt-label { color: #ca8a04; }
.vc-amt.warn .amt-num   { color: #92400e; }
.vc-amt.warn .amt-conf  { color: #fbbf24; }
.vc-amt.warn .amt-empty { color: #fcd34d; }
.vc-amt.warn .amt-basis { color: #78350f; border-top-color: rgba(202,138,4,.15); }

.vc-status-row { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.vc-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.vc-main.pass .vc-dot { background: var(--green); }
.vc-main.fail .vc-dot { background: var(--red); }
.vc-main.warn .vc-dot { background: var(--amber); }

.vc-status-text { font-size: 12px; font-weight: 500; }
.vc-main.pass .vc-status-text { color: var(--green); }
.vc-main.fail .vc-status-text { color: var(--red); }
.vc-main.warn .vc-status-text { color: var(--amber); }

.vc-title {
  font-size: 42px; font-weight: 400;
  letter-spacing: -0.04em; line-height: 1;
  margin-bottom: 18px;
}
.vc-main.pass .vc-title { color: #15803d; }
.vc-main.fail .vc-title { color: #b91c1c; }
.vc-main.warn .vc-title { color: #92400e; }

.vc-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.vc-pill {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
}
.vc-pill.pass    { background: rgba(22,163,74,.13);  color: #15803d; }
.vc-pill.fail    { background: rgba(220,38,38,.13);  color: #b91c1c; }
.vc-pill.warn    { background: rgba(202,138,4,.13);  color: #92400e; }
.vc-pill.neutral { background: rgba(0,0,0,.07);      color: var(--t2); }

.vc-issues { margin-top: 14px; display: flex; flex-direction: column; gap: 7px; }
.vc-issue {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 13px; color: var(--t1); line-height: 1.55;
}
.vc-issue-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
.vc-issue.fail .vc-issue-dot { background: var(--red); }
.vc-issue.warn .vc-issue-dot { background: var(--amber); }
.vc-issue.unk  .vc-issue-dot { background: var(--t3); }

.amt-label { font-size: 11px; font-weight: 500; color: var(--t3); letter-spacing: 0.04em; margin-bottom: 8px; }
.amt-num {
  font-family: var(--font-mono);
  font-size: 42px; font-weight: 400;
  color: var(--t1); letter-spacing: -2px; line-height: 1;
}
.amt-unit { font-size: 13px; color: var(--t2); font-family: var(--font); font-weight: 400; margin-left: 3px; }
.amt-empty { font-family: var(--font-mono); font-size: 42px; font-weight: 400; color: var(--t4); line-height: 1; }
.amt-conf  { font-size: 11px; color: var(--t3); margin-top: 8px; }
.amt-basis {
  font-size: 11px; color: var(--t2); line-height: 1.7;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ── 区块标题 ───────────────────────────────── */
.yn-section {
  display: flex; align-items: center; justify-content: space-between;
  margin: 28px 0 12px;
}
.yn-section-title { font-size: 13px; font-weight: 500; color: var(--t2); }
.yn-section-meta  { font-size: 12px; color: var(--t3); }

/* ── 合同信息卡（CSS grid） ──────────────────── */
.ic-card {
  background: var(--bg-card);
  border-radius: var(--r);
  box-shadow: var(--sh);
  overflow: hidden;
  margin-bottom: 4px;
}
.ic-grid { display: grid; grid-template-columns: 1fr 1fr; }
.ic-cell {
  padding: 11px 18px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  border-right: 1px solid rgba(0,0,0,0.05);
}
.ic-cell-r    { border-right: none !important; }
.ic-cell-last { border-bottom: none !important; }
.ic-divider   { grid-column: 1/-1; height: 1px; background: rgba(0,0,0,0.07); }
.ic-label { font-size: 11px; font-weight: 500; color: var(--t3); margin-bottom: 3px; }
.ic-val   { font-size: 14px; font-weight: 400; color: var(--t1); }
.ic-val.num {
  font-family: var(--font-mono);
  font-size: 17px; font-weight: 400; color: var(--accent);
}
.ic-val.empty { color: var(--t4); }
.lc-tag {
  display: inline-block;
  background: #fef9c3; color: #a16207;
  border-radius: 4px; padding: 0 5px;
  font-size: 10px; font-weight: 500;
  margin-left: 5px; vertical-align: middle;
}

/* ── 规则行 ─────────────────────────────────── */
.rule-list { display: flex; flex-direction: column; }
.rule-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background .1s;
}
.rule-row:last-child { border-bottom: none; }
.rule-row:hover { background: rgba(0,0,0,0.015); }
.rule-id {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--t3);
  background: rgba(0,0,0,0.05);
  padding: 2px 6px; border-radius: 4px;
  flex-shrink: 0; margin-top: 2px; white-space: nowrap;
}
.yn-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 500;
  flex-shrink: 0; margin-top: 1px; white-space: nowrap;
}
.yn-badge.pass    { background: var(--green-soft); color: #15803d; }
.yn-badge.fail    { background: var(--red-soft);   color: #b91c1c; }
.yn-badge.warn    { background: var(--amber-soft); color: #92400e; }
.yn-badge.manual  { background: #dbeafe;           color: #1e40af; }
.yn-badge.unknown { background: #f1f5f9;           color: #64748b; }
.yn-badge.skip    { background: #f3f4f6;           color: #9ca3af; }
.yn-badge.info    { background: #e0f2fe;           color: #0369a1; }
.rule-content { flex: 1; min-width: 0; }
.rule-name { font-size: 13px; font-weight: 500; color: var(--t1); margin-bottom: 2px; }
.rule-msg  { font-size: 12px; color: var(--t2); line-height: 1.6; }

/* ── 加分卡 ─────────────────────────────────── */
.bonus-card {
  border-radius: var(--r);
  padding: 22px 26px;
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 4px;
}
.bonus-title { font-size: 14px; font-weight: 500; color: #5b21b6; }
.bonus-desc  { font-size: 12px; color: #7c3aed; opacity: .7; margin-top: 3px; }
.bonus-score {
  font-family: var(--font-mono);
  font-size: 40px; font-weight: 400;
  color: #5b21b6; letter-spacing: -1px;
}
.bonus-score em { font-size: 14px; font-style: normal; font-weight: 400; margin-left: 2px; }

/* ── 侧边栏 ─────────────────────────────────── */
[data-testid="stSidebar"],
[data-testid="stSidebar"] > div:first-child {
  background: var(--bg-sidebar) !important;
}
.sb-logo { padding: 0 2px; }
.sb-name { font-size: 13px; font-weight: 600; color: var(--t1); letter-spacing: -0.01em; }
.sb-ref  { font-size: 11px; color: var(--t3); font-family: var(--font-mono); margin-top: 2px; }

.sb-section-label {
  font-size: 11px; font-weight: 500; color: var(--t3);
  display: block; margin: 16px 0 6px 2px;
}
.sb-file {
  background: var(--bg-card);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  box-shadow: var(--sh-sm);
}
.sb-fname { font-size: 12px; font-weight: 500; color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-fmeta { font-size: 11px; color: var(--t3); font-family: var(--font-mono); margin-top: 3px; }

.sb-divider { height: 1px; background: var(--border); margin: 8px 0; }

.sb-footer {
  font-size: 11px; color: var(--t3); line-height: 1.9;
  padding: 12px 2px 0; border-top: 1px solid var(--border); margin-top: 16px;
}
.sb-footer strong { font-size: 11px; font-weight: 500; color: var(--t2); display: block; margin-bottom: 2px; }

/* ── 空状态 ─────────────────────────────────── */
.upload-empty {
  margin: 48px auto 0; max-width: 480px;
  text-align: center; padding: 40px 0 8px;
}
.upload-icon  { font-size: 32px; opacity: 0.3; margin-bottom: 16px; }
.upload-title { font-size: 14px; font-weight: 500; color: var(--t2); margin-bottom: 6px; }
.upload-hint  { font-size: 12px; color: var(--t3); line-height: 1.8; }

/* ── Streamlit 组件覆盖 ──────────────────────── */

/* 文件上传区 */
[data-testid="stFileUploaderDropzone"] {
  border: 2px dashed rgba(0,0,0,0.13) !important;
  border-radius: var(--r) !important;
  background: var(--bg-card) !important;
  transition: border-color .15s, background .15s !important;
}
[data-testid="stFileUploaderDropzone"]:hover {
  border-color: var(--accent) !important;
  background: #fafafe !important;
}

/* 按钮 */
[data-testid="stButton"] button,
[data-testid="stDownloadButton"] button,
[data-testid="stFormSubmitButton"] button {
  font-family: var(--font) !important;
  font-weight: 500 !important;
  border-radius: var(--r-sm) !important;
}
button[kind="primary"],
[data-testid="stFormSubmitButton"] button {
  background-color: var(--t1) !important;
  border: 1px solid var(--t1) !important;
  color: white !important;
  transition: opacity .15s !important;
}
button[kind="primary"]:hover { opacity: 0.82 !important; }
button[kind="secondary"] {
  background-color: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  color: var(--t1) !important;
  box-shadow: var(--sh-sm) !important;
}
button[kind="secondary"]:hover {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}
[data-testid="stDownloadButton"] button {
  background-color: var(--t1) !important;
  border: 1px solid var(--t1) !important;
  color: white !important;
  font-size: 13px !important;
  transition: opacity .15s !important;
}
[data-testid="stDownloadButton"] button:hover {
  opacity: 0.82 !important;
  color: white !important;
  border-color: var(--t1) !important;
}

/* Alert */
[data-testid="stAlert"] {
  border-radius: 0 var(--r-sm) var(--r-sm) 0 !important;
  border-top: none !important; border-bottom: none !important;
  border-right: none !important; border-width: 3px !important;
  font-family: var(--font) !important; font-size: 13px !important;
}

/* Expander（规则模块卡） */
[data-testid="stExpander"] {
  border: none !important;
  border-radius: var(--r) !important;
  background: var(--bg-card) !important;
  box-shadow: var(--sh) !important;
  margin-bottom: 8px !important;
}
[data-testid="stExpander"] summary {
  padding: 13px 20px !important;
  border-radius: var(--r) !important;
}
[data-testid="stExpander"] summary:hover { background: rgba(0,0,0,0.015) !important; }
[data-testid="stExpander"] summary p,
[data-testid="stExpander"] > div > div > div > p {
  font-family: var(--font) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--t1) !important;
}
[data-testid="stExpanderDetails"] {
  border-top: 1px solid rgba(0,0,0,0.05) !important;
  padding: 0 !important;
}

/* 进度状态框 */
[data-testid="stStatusWidget"] {
  background: #0f172a !important;
  border-radius: var(--r) !important;
  border: 1px solid #1e293b !important;
}
[data-testid="stStatusWidget"] * { font-family: var(--font-mono) !important; font-size: 12px !important; }
[data-testid="stStatusWidget"] p,
[data-testid="stStatusWidget"] li { color: #94a3b8 !important; }
[data-testid="stStatusWidget"] [data-testid="stMarkdownContainer"] p { color: #cbd5e1 !important; }

/* Caption */
[data-testid="stCaptionContainer"] p {
  font-family: var(--font) !important;
  font-size: 12px !important;
  color: var(--t2) !important;
}

/* Selectbox */
[data-testid="stSelectbox"] [data-baseweb="select"] > div:first-child {
  background-color: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-sm) !important;
  box-shadow: var(--sh-sm) !important;
  min-height: 34px !important;
}
[data-testid="stSelectbox"] [data-baseweb="select"] [class*="singleValue"],
[data-testid="stSelectbox"] [data-baseweb="select"] [class*="valueContainer"] * {
  font-family: var(--font) !important;
  font-size: 12px !important;
  color: var(--t1) !important;
  font-weight: 400 !important;
}
[data-baseweb="popover"] [role="listbox"],
[data-baseweb="menu"] {
  border: 1px solid var(--border) !important;
  border-radius: var(--r-sm) !important;
  box-shadow: var(--sh) !important;
  background: var(--bg-card) !important;
}
[data-baseweb="menu"] [role="option"],
[data-baseweb="popover"] [role="option"] {
  font-family: var(--font) !important;
  font-size: 12px !important;
  color: var(--t1) !important;
  padding: 8px 14px !important;
  background: transparent !important;
}
[data-baseweb="menu"] [role="option"]:hover { background: var(--bg-sidebar) !important; }
[data-baseweb="menu"] [aria-selected="true"] {
  background: var(--accent-dim) !important;
  color: var(--accent) !important;
  font-weight: 500 !important;
}
