:root {
  --ink: #1d2024;
  --muted: #687078;
  --line: #dde1e5;
  --line-strong: #c9ced4;
  --surface: #ffffff;
  --surface-soft: #f5f6f7;
  --canvas: #eceff1;
  --nav: #17191c;
  --nav-soft: #25282d;
  --accent: #d33a32;
  --accent-dark: #b62923;
  --teal: #177c72;
  --amber: #a96512;
  --blue: #2d6fa8;
  --danger: #b42318;
  --shadow: 0 14px 36px rgba(21, 24, 28, .12);
  --radius: 6px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); color: var(--ink); }
body { font-size: 14px; line-height: 1.5; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
[hidden] { display: none !important; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.login-view { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 520px) 1fr; background: var(--nav); }
.login-panel { background: var(--surface); padding: 42px clamp(32px, 6vw, 76px); display: flex; flex-direction: column; justify-content: center; min-height: 100vh; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 15px; }
.brand-dark { position: absolute; top: 34px; color: var(--ink); }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; color: #fff; background: var(--accent); border-radius: 5px; font-size: 17px; }
.login-copy { margin-bottom: 30px; max-width: 380px; }
.login-copy h1 { margin: 5px 0 8px; font-size: 32px; line-height: 1.2; }
.login-copy p:last-child { color: var(--muted); margin: 0; }
.eyebrow, .page-eyebrow { color: var(--accent); font-size: 12px; font-weight: 700; margin: 0; }
.login-context { min-height: 100vh; display: grid; place-items: end start; padding: 64px; background: linear-gradient(145deg, #17191c 0%, #242a2b 62%, #153d38 100%); }
.context-grid { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); width: 100%; border-top: 1px solid rgba(255,255,255,.18); }
.context-grid div { padding: 22px 24px 0 0; color: #fff; }
.context-grid strong, .context-grid span { display: block; }
.context-grid strong { font-size: 18px; margin-bottom: 5px; }
.context-grid span { color: #bfc7c7; font-size: 12px; }

.form-stack { display: grid; gap: 17px; max-width: 380px; }
.field { display: grid; gap: 7px; color: #3d4349; font-weight: 600; }
.field small { color: var(--muted); font-weight: 400; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius); background: #fff; color: var(--ink); outline: none; }
input, select { min-height: 40px; padding: 8px 11px; }
textarea { min-height: 120px; padding: 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(23,124,114,.12); }
.form-error { min-height: 20px; margin: -3px 0; color: var(--danger); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-span-2 { grid-column: 1 / -1; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--nav); color: #eef1f3; display: flex; flex-direction: column; z-index: 30; }
.sidebar-brand { height: 74px; padding: 0 22px; border-bottom: 1px solid rgba(255,255,255,.08); }
.main-nav { display: grid; gap: 4px; padding: 18px 12px; }
.nav-item { display: grid; grid-template-columns: 25px 1fr auto; align-items: center; width: 100%; min-height: 42px; padding: 8px 11px; border: 0; border-radius: 5px; background: transparent; color: #bfc4ca; text-align: left; }
.nav-item:hover { background: var(--nav-soft); color: #fff; }
.nav-item.active { background: #30343a; color: #fff; box-shadow: inset 3px 0 var(--accent); }
.nav-symbol { font-size: 17px; line-height: 1; text-align: center; }
.nav-count { min-width: 20px; padding: 1px 6px; border-radius: 9px; background: rgba(255,255,255,.1); font-size: 11px; text-align: center; }
.sidebar-foot { margin-top: auto; padding: 18px 22px 22px; color: #888f97; font-size: 12px; }
.sidebar-foot p { margin: 7px 0 0; }
.system-state { display: flex; align-items: center; gap: 8px; color: #c7ccd1; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #45ad73; box-shadow: 0 0 0 3px rgba(69,173,115,.13); }

.workspace { min-width: 0; }
.topbar { height: 74px; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; }
.topbar h1 { margin: 1px 0 0; font-size: 20px; line-height: 1.25; }
.topbar-actions { display: flex; align-items: center; gap: 12px; position: relative; }
.page-eyebrow { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.user-button { height: 44px; padding: 4px 8px 4px 5px; display: flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--ink); }
.user-button:hover { background: var(--surface-soft); border-color: var(--line); }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: #e5eceb; color: var(--teal); font-weight: 700; }
.user-meta { display: grid; text-align: left; line-height: 1.2; }
.user-meta strong { font-size: 13px; }
.user-meta small { color: var(--muted); font-size: 11px; }
.user-menu { position: absolute; top: 50px; right: 0; width: 150px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 50; }
.user-menu button { width: 100%; padding: 9px 10px; border: 0; border-radius: 4px; background: transparent; text-align: left; }
.user-menu button:hover { background: var(--surface-soft); }
.main-content { padding: 24px 28px 48px; max-width: 1540px; margin: 0 auto; outline: none; }

.button, .icon-button { border: 1px solid transparent; border-radius: var(--radius); font-weight: 650; transition: background .15s, border-color .15s; }
.button { min-height: 38px; padding: 8px 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-dark); }
.button-secondary { background: #fff; border-color: var(--line-strong); color: #353a40; }
.button-secondary:hover { background: var(--surface-soft); }
.button-quiet { background: transparent; color: #414850; }
.button-quiet:hover { background: var(--surface-soft); }
.button-danger { background: #fff; border-color: #efc4c0; color: var(--danger); }
.button-block { width: 100%; }
.button-small { min-height: 32px; padding: 5px 9px; font-size: 12px; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; padding: 0; background: transparent; color: #4c535a; font-size: 21px; }
.icon-button:hover { background: var(--surface-soft); }
.button-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; margin-bottom: 16px; }
.section-heading h2 { margin: 0 0 3px; font-size: 18px; }
.section-heading p { margin: 0; color: var(--muted); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.metric { padding: 17px 18px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--line-strong); border-radius: var(--radius); }
.metric.red { border-top-color: var(--accent); }
.metric.teal { border-top-color: var(--teal); }
.metric.amber { border-top-color: var(--amber); }
.metric.blue { border-top-color: var(--blue); }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { display: block; margin-top: 4px; font-size: 27px; font-weight: 750; line-height: 1.2; }
.metric-note { color: var(--muted); font-size: 11px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, .7fr); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-header { min-height: 55px; padding: 13px 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.panel-header h2, .panel-header h3 { margin: 0; font-size: 15px; }
.panel-body { padding: 16px; }
.quick-actions { display: grid; gap: 10px; }
.quick-action { min-height: 56px; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; text-align: left; }
.quick-action:hover { border-color: var(--line-strong); background: var(--surface-soft); }
.quick-icon { width: 32px; height: 32px; display: grid; place-items: center; background: #edf3f2; color: var(--teal); border-radius: 4px; font-size: 18px; }
.quick-action strong, .quick-action small { display: block; }
.quick-action small { margin-top: 2px; color: var(--muted); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input { width: min(280px, 38vw); }
.filters select { width: auto; min-width: 130px; }
.search-field { position: relative; }
.search-field input { padding-left: 31px; }
.search-field::before { content: "⌕"; position: absolute; left: 10px; top: 7px; color: var(--muted); font-size: 18px; }
.status-tabs { display: flex; gap: 3px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.status-tab { padding: 9px 13px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); }
.status-tab:hover { color: var(--ink); }
.status-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }

.data-table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; min-width: 820px; }
.data-table th { height: 39px; padding: 8px 12px; background: #f4f5f6; border-bottom: 1px solid var(--line); color: #5b626a; font-size: 11px; text-align: left; white-space: nowrap; }
.data-table td { padding: 12px; border-bottom: 1px solid #eceef0; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafbfb; }
.title-cell { min-width: 310px; max-width: 540px; }
.title-link { color: var(--ink); font-weight: 650; background: transparent; border: 0; padding: 0; text-align: left; }
.title-link:hover { color: var(--accent); }
.subline { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score { display: inline-flex; align-items: center; gap: 5px; color: #3b4249; }
.score-bar { width: 42px; height: 4px; background: #e3e6e8; border-radius: 2px; overflow: hidden; }
.score-bar i { display: block; height: 100%; background: var(--teal); }
.tag, .status-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 4px; font-size: 11px; white-space: nowrap; }
.tag { background: #eef1f2; color: #4b535a; }
.tag-risk { background: #fff0ee; color: var(--danger); }
.tag-demo { background: #fff5df; color: #8a570d; }
.status-badge { background: #eef1f2; color: #47505a; font-weight: 650; }
.status-待发布 { background: #e8f4f1; color: #176d64; }
.status-已发布 { background: #e8f3ea; color: #2e7342; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; white-space: normal; }
.empty-state { min-height: 250px; display: grid; place-items: center; padding: 34px; text-align: center; }
.empty-state strong { display: block; margin-bottom: 6px; font-size: 16px; }
.empty-state p { color: var(--muted); margin: 0 0 15px; }
.empty-symbol { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto 12px; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--muted); font-size: 22px; }

.draft-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.editor-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.editor-toolbar { padding: 11px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.editor-form { padding: 18px; display: grid; gap: 15px; }
.editor-title { font-size: 20px; font-weight: 700; min-height: 46px; }
.body-editor { min-height: 520px; line-height: 1.8; }
.side-stack { display: grid; gap: 12px; }
.detail-list { display: grid; gap: 11px; }
.detail-row { display: grid; grid-template-columns: 78px 1fr; gap: 8px; align-items: start; }
.detail-row dt { color: var(--muted); }
.detail-row dd { margin: 0; word-break: break-word; }
.fact-list { margin: 0; padding-left: 20px; display: grid; gap: 7px; }
.risk-list { display: grid; gap: 7px; }
.risk-item { padding: 8px 10px; background: #fff4f2; border-left: 3px solid var(--danger); color: #70332d; font-size: 12px; }
.candidate-list { display: grid; gap: 6px; }
.candidate { padding: 8px 9px; border: 1px solid var(--line); border-radius: 4px; background: #fff; text-align: left; }
.candidate:hover { border-color: var(--teal); }

.settings-panel { margin-bottom: 16px; }
.prompt-form { display: grid; gap: 16px; }
.prompt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.prompt-field-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.prompt-field-heading small { color: var(--muted); font-weight: 400; white-space: nowrap; }
.prompt-field textarea { min-height: 310px; line-height: 1.7; }
.prompt-field textarea[readonly] { background: var(--surface-soft); color: #4c535a; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(13,15,18,.55); }
.modal { width: min(620px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; }
.modal.modal-wide { width: min(880px, 100%); }
.modal-header { padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 2px 0 0; font-size: 18px; }
.modal-body { padding: 18px; overflow: auto; }
.modal-footer { min-height: 62px; padding: 12px 18px; display: flex; justify-content: flex-end; align-items: center; gap: 8px; border-top: 1px solid var(--line); background: #fafafa; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: grid; gap: 8px; }
.toast { min-width: 260px; max-width: 420px; padding: 11px 13px; border-radius: var(--radius); background: #25292e; color: #fff; box-shadow: var(--shadow); }
.toast.error { background: #892c25; }
.toast.success { background: #1e6a54; }
.loading { min-height: 260px; display: grid; place-items: center; color: var(--muted); }
.spinner { width: 22px; height: 22px; margin-right: 9px; display: inline-block; vertical-align: middle; border: 2px solid #ccd1d5; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.mobile-only { display: none; }

@media (max-width: 980px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid, .draft-layout, .prompt-grid { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: 1fr 1fr; }
  .login-context { display: none; }
  .login-view { grid-template-columns: 1fr; }
  .login-panel { align-items: center; }
  .login-panel > * { width: min(420px, 100%); }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -240px; width: 224px; transition: left .2s; box-shadow: var(--shadow); }
  .sidebar.open { left: 0; }
  .mobile-only { display: grid; }
  .topbar { padding: 0 14px; }
  .topbar > div:first-of-type { margin-right: auto; margin-left: 8px; }
  .topbar-actions .button { display: none; }
  .user-meta { display: none; }
  .main-content { padding: 16px 12px 36px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric { padding: 13px; }
  .metric-value { font-size: 23px; }
  .toolbar, .section-heading { align-items: stretch; flex-direction: column; }
  .toolbar > .button-row, .section-heading > .button-row { justify-content: flex-start; }
  .filters input, .filters select { width: 100%; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .filters .search-field { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: auto; }
  .side-stack { grid-template-columns: 1fr; }
  .context-grid { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
  .login-panel { padding: 28px 20px; }
  .brand-dark { top: 24px; }
  .metric-grid { grid-template-columns: 1fr; }
  .status-tabs { overflow-x: auto; }
  .modal-backdrop { padding: 8px; }
  .modal { max-height: calc(100vh - 16px); }
}
