:root {
  --navy: #071e41;
  --navy-2: #0d2f61;
  --orange: #ff6b00;
  --orange-soft: #fff1e7;
  --ink: #172033;
  --muted: #697386;
  --line: #dfe3ea;
  --surface: #ffffff;
  --background: #f5f6f8;
  --success: #18794e;
  --success-bg: #eaf7f0;
  --warning: #a45b00;
  --warning-bg: #fff4df;
  --danger: #b42318;
  --danger-bg: #fff0ee;
  --shadow: 0 18px 48px rgba(7, 30, 65, 0.12);
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--background);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--background); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 18px 20px; background: var(--navy); color: #fff; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 28px; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.13); }
.brand-mark { color: var(--orange); font-size: 40px; line-height: 1; font-weight: 950; font-style: italic; letter-spacing: -5px; padding-right: 5px; }
.brand-copy { display: grid; gap: 4px; }
.brand-copy strong { font-size: 15px; letter-spacing: .04em; }
.brand-copy small { color: #93a8c7; font-size: 8px; letter-spacing: .13em; }
.side-nav { display: grid; gap: 4px; margin-top: 24px; }
.nav-item { width: 100%; min-height: 46px; display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 8px; padding: 0 12px; border: 0; border-left: 3px solid transparent; background: transparent; color: #b8c7dc; text-align: left; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(255,107,0,.13); border-left-color: var(--orange); color: #fff; font-weight: 750; }
.nav-index { color: #7188a8; font-size: 10px; letter-spacing: .08em; }
.nav-item.active .nav-index { color: var(--orange); }
.nav-badge { min-width: 22px; height: 22px; display: inline-grid; place-items: center; padding: 0 6px; border-radius: 11px; background: var(--orange); color: #fff; font-size: 11px; }
.sidebar-policy { margin-top: auto; padding: 16px; border: 1px solid rgba(255,255,255,.15); background: #0b2956; }
.policy-kicker { color: var(--orange); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.sidebar-policy strong { display: block; margin-top: 9px; font-size: 14px; }
.sidebar-policy p { margin: 8px 0 0; color: #aabbd3; font-size: 12px; line-height: 1.65; }
.back-link { margin: 14px 8px 0; color: #aabbd3; font-size: 12px; text-decoration: none; }
.back-link:hover { color: #fff; }

.main-content { min-width: 0; padding: 32px 36px 48px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; }
.eyebrow { color: var(--orange); font-size: 10px; font-weight: 850; letter-spacing: .16em; }
.topbar h1 { margin: 8px 0 7px; color: var(--navy); font-size: 32px; line-height: 1.15; letter-spacing: -.035em; }
.topbar p, .section-heading p, .modal-header p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.admin-chip { height: 42px; display: flex; align-items: center; gap: 8px; padding: 0 14px; border: 1px solid var(--line); background: #fff; color: var(--navy); font-size: 13px; font-weight: 700; }
.admin-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 17px; border: 1px solid transparent; text-decoration: none; font-size: 13px; font-weight: 760; transition: transform .15s ease, background .15s ease, border-color .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button-primary { background: var(--orange); color: #fff; border-color: var(--orange); }
.button-primary:hover { background: #e85f00; }
.button-secondary { background: #fff; color: var(--navy); border-color: #cfd5df; }
.button-danger { background: #fff; color: var(--danger); border-color: #e8b6b0; }
.text-button { border: 0; background: transparent; color: var(--muted); font-size: 13px; }
.text-button:hover { color: var(--navy); }

.workflow { min-height: 66px; display: grid; grid-template-columns: auto minmax(480px, 1fr) auto; align-items: center; gap: 24px; margin-top: 26px; padding: 12px 18px; border: 1px solid var(--line); background: var(--surface); }
.workflow-title { color: var(--navy); font-size: 12px; font-weight: 850; }
.workflow ol { display: flex; align-items: center; margin: 0; padding: 0; list-style: none; }
.workflow li { position: relative; flex: 1; display: flex; align-items: center; gap: 7px; color: #7c8799; font-size: 12px; white-space: nowrap; }
.workflow li:not(:last-child)::after { content: ""; height: 1px; flex: 1; margin: 0 10px; background: #d9dee7; }
.workflow li span { width: 23px; height: 23px; display: inline-grid; place-items: center; border: 1px solid #bac3d0; border-radius: 50%; background: #fff; font-size: 10px; }
.workflow li.done { color: var(--navy); font-weight: 700; }
.workflow li.done span { background: var(--navy); border-color: var(--navy); color: #fff; }
.workflow-note { color: var(--muted); font-size: 11px; text-align: right; }

.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 14px; border: 1px solid var(--line); background: #fff; }
.metric { min-width: 0; padding: 18px 22px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin: 6px 0 3px; color: var(--navy); font-size: 26px; line-height: 1; }
.metric small { color: #8c95a4; font-size: 10px; }

.view-section { margin-top: 24px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.section-heading h2 { margin: 0 0 5px; color: var(--navy); font-size: 20px; }
.section-actions { display: flex; gap: 8px; }
.filter-bar { display: grid; grid-template-columns: minmax(190px, 1.5fr) repeat(4, minmax(126px, .8fr)) auto auto; gap: 10px; align-items: end; margin-top: 16px; padding: 14px; border: 1px solid var(--line); background: #fff; }
label > span, .filter-bar label > span { display: block; margin-bottom: 6px; color: #566176; font-size: 11px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #cfd5df; background: #fff; color: var(--ink); outline: none; }
input, select { height: 40px; padding: 0 11px; }
textarea { padding: 10px 11px; line-height: 1.6; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(13,47,97,.09); }
.search-field input { padding-left: 12px; }
.table-shell { margin-top: 12px; overflow: auto; border: 1px solid var(--line); background: #fff; }
table { width: 100%; min-width: 1120px; border-collapse: collapse; }
thead { background: #f1f3f6; }
th { padding: 11px 12px; color: #536077; font-size: 10px; font-weight: 820; letter-spacing: .04em; text-align: left; white-space: nowrap; }
td { padding: 14px 12px; border-top: 1px solid #e8ebf0; color: #39455a; font-size: 12px; vertical-align: middle; }
tbody tr:hover { background: #fafbfc; }
.document-cell { min-width: 230px; }
.document-title { display: flex; align-items: flex-start; gap: 8px; color: var(--navy); font-size: 13px; font-weight: 800; }
.version-label { flex: none; padding: 2px 5px; border: 1px solid #cad1dd; color: #66758b; font-size: 9px; }
.document-meta { margin-top: 5px; color: #8891a0; font-size: 10px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; max-width: 210px; }
.tag { display: inline-flex; padding: 3px 6px; background: #eef2f7; color: #53637b; font-size: 9px; white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 7px; font-size: 10px; font-weight: 750; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-published, .status-approved { color: var(--success); background: var(--success-bg); }
.status-pending_review { color: var(--warning); background: var(--warning-bg); }
.status-rejected, .status-failed { color: var(--danger); background: var(--danger-bg); }
.status-archived { color: #667085; background: #eef0f3; }
.progress-cell { min-width: 90px; }
.progress-line { height: 4px; margin-top: 5px; background: #e9edf2; }
.progress-line span { display: block; height: 100%; background: var(--success); }
.row-actions { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.row-actions button { border: 0; padding: 0; background: transparent; color: var(--navy-2); font-size: 11px; font-weight: 700; }
.row-actions button:hover { color: var(--orange); }
.actions-column { min-width: 130px; }
.loading-cell { height: 160px; color: var(--muted); text-align: center; }
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 12px 2px; color: var(--muted); font-size: 11px; }
.pagination > div { display: flex; align-items: center; gap: 10px; }
.page-button { min-height: 32px; padding: 0 11px; border: 1px solid var(--line); background: #fff; color: var(--navy); font-size: 11px; }
.page-button:disabled { opacity: .4; cursor: not-allowed; }

.backdrop, .modal-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(4, 18, 39, .48); }
.detail-drawer { position: fixed; z-index: 31; top: 0; right: 0; width: min(560px, 92vw); height: 100vh; display: flex; flex-direction: column; background: #fff; box-shadow: var(--shadow); }
.drawer-header, .modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding: 24px 26px 20px; border-bottom: 1px solid var(--line); }
.drawer-header h2, .modal-header h2 { margin: 7px 0 4px; color: var(--navy); font-size: 21px; }
.drawer-header p { margin: 0; color: var(--muted); font-size: 12px; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); background: #fff; color: var(--navy); font-size: 24px; line-height: 1; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 26px; }
.drawer-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 26px; border-top: 1px solid var(--line); background: #fafbfc; }
.detail-status-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.detail-status-row strong { color: var(--navy); }
.metadata-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; margin: 18px 0; }
.metadata-item span { display: block; color: var(--muted); font-size: 10px; }
.metadata-item strong { display: block; margin-top: 4px; color: #2e3a50; font-size: 12px; font-weight: 700; }
.detail-section { margin-top: 22px; }
.detail-section h3 { margin: 0 0 10px; color: var(--navy); font-size: 13px; }
.chunk-list { display: grid; gap: 10px; }
.chunk-card { padding: 13px; border: 1px solid var(--line); background: #fbfcfd; }
.chunk-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.chunk-source { color: var(--orange); font-size: 10px; font-weight: 800; }
.chunk-card h4 { margin: 7px 0 5px; color: var(--navy); font-size: 12px; }
.chunk-card p { display: -webkit-box; overflow: hidden; margin: 0; color: #596477; font-size: 11px; line-height: 1.65; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.toggle-label { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; }
.toggle-label input { width: 15px; height: 15px; margin: 0; accent-color: var(--orange); }
.safety-note { margin-top: 18px; padding: 13px 14px; border-left: 3px solid var(--orange); background: var(--orange-soft); color: #7d4219; font-size: 11px; line-height: 1.7; }

.modal-backdrop { z-index: 40; display: grid; place-items: center; padding: 24px; }
.modal { width: min(860px, 96vw); max-height: calc(100vh - 48px); display: flex; flex-direction: column; background: #fff; box-shadow: var(--shadow); }
.upload-modal { width: min(920px, 96vw); }
.modal form { min-height: 0; display: flex; flex: 1; flex-direction: column; }
.modal-scroll { min-height: 0; overflow-y: auto; padding: 22px 26px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 15px 26px; border-top: 1px solid var(--line); background: #fafbfc; }
.drop-zone { min-height: 132px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 18px; border: 1px dashed #aeb8c7; background: #fafbfc; text-align: center; cursor: pointer; }
.drop-zone.dragover { border-color: var(--orange); background: var(--orange-soft); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-mark { width: 34px; height: 34px; display: grid; place-items: center; margin: 0 0 8px !important; border: 1px solid var(--navy); border-radius: 50%; color: var(--navy) !important; font-size: 18px !important; }
.drop-zone strong { color: var(--navy); font-size: 14px; }
.drop-zone small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.drop-zone em { margin-top: 9px; color: var(--orange); font-size: 10px; font-style: normal; font-weight: 700; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin-top: 20px; }
.span-2 { grid-column: 1 / -1; }
.scope-fieldset { display: flex; flex-wrap: wrap; gap: 16px; margin: 0; padding: 13px; border: 1px solid var(--line); }
.scope-fieldset legend { padding: 0 5px; color: #566176; font-size: 11px; font-weight: 700; }
.scope-fieldset label { display: inline-flex; align-items: center; gap: 7px; color: #3f4c62; font-size: 11px; }
.scope-fieldset input, .rights-confirm input { width: 16px; height: 16px; margin: 0; accent-color: var(--orange); }
.rights-confirm { display: flex; align-items: flex-start; gap: 9px; margin-top: 16px; padding: 12px; background: #fff8f2; color: #74411e; font-size: 11px; line-height: 1.6; }
.rights-confirm span { margin: 0; color: inherit; font-size: inherit; }
.retrieval-modal { width: min(780px, 96vw); }
.retrieval-form { display: grid !important; grid-template-columns: minmax(0, 1fr) 180px auto; gap: 12px; align-items: end; padding: 20px 26px; border-bottom: 1px solid var(--line); }
.retrieval-results { min-height: 260px; max-height: 50vh; overflow-y: auto; padding: 20px 26px; }
.retrieval-hit { padding: 14px 0; border-bottom: 1px solid var(--line); }
.retrieval-hit:first-child { padding-top: 0; }
.retrieval-hit h3 { margin: 0 0 5px; color: var(--navy); font-size: 13px; }
.retrieval-hit small { color: var(--orange); font-size: 10px; font-weight: 700; }
.retrieval-hit p { margin: 7px 0 0; color: #556176; font-size: 11px; line-height: 1.65; }
.empty-state { min-height: 140px; display: grid; place-items: center; padding: 24px; color: var(--muted); font-size: 12px; text-align: center; }
.audit-timeline { margin-top: 16px; border: 1px solid var(--line); background: #fff; }
.audit-item { display: grid; grid-template-columns: 150px minmax(0, 1fr) 130px; gap: 16px; padding: 14px 18px; border-top: 1px solid var(--line); font-size: 12px; }
.audit-item:first-child { border-top: 0; }
.audit-item time, .audit-item small { color: var(--muted); font-size: 10px; }
.audit-item strong { color: var(--navy); }
.placeholder-panel { min-height: 480px; display: grid; place-items: center; align-content: center; padding: 40px; border: 1px solid var(--line); background: #fff; text-align: center; }
.placeholder-panel > span { color: #d9dee7; font-size: 72px; font-weight: 900; }
.placeholder-panel h2 { margin: -12px 0 8px; color: var(--navy); }
.placeholder-panel p { max-width: 430px; margin: 0 0 20px; color: var(--muted); line-height: 1.7; }
.auth-gate { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(245,246,248,.96); }
.auth-gate > div { width: min(420px, 90vw); padding: 40px; border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow); text-align: center; }
.auth-gate h2 { margin: 18px 0 8px; color: var(--navy); }
.auth-gate p { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 28px; transform: translateX(-50%); max-width: min(540px, 90vw); padding: 12px 18px; background: var(--navy); color: #fff; box-shadow: var(--shadow); font-size: 12px; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .main-content { padding: 28px 24px 40px; }
  .filter-bar { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
  .workflow { grid-template-columns: 1fr; gap: 10px; }
  .workflow-note { text-align: left; }
}

@media (max-width: 800px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 18px; }
  .brand { padding-bottom: 16px; }
  .side-nav { grid-template-columns: 1fr 1fr; margin-top: 14px; }
  .sidebar-policy, .back-link { display: none; }
  .main-content { padding: 22px 16px 36px; }
  .topbar { display: grid; }
  .top-actions { justify-content: space-between; }
  .workflow ol { overflow-x: auto; }
  .workflow li { min-width: 105px; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .filter-bar, .form-grid, .retrieval-form { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .detail-drawer { width: 100%; }
  .metadata-grid { grid-template-columns: 1fr; }
  .audit-item { grid-template-columns: 1fr; gap: 5px; }
}

.index-status { display:flex; align-items:center; flex-wrap:wrap; gap:12px; min-height:52px; border-bottom:1px solid var(--line); font-size:13px; }
.index-status strong[data-state="FAILED"], .index-status strong[data-state="NOT_READY"] { color:#b22929; }
.index-status strong[data-state="READY"] { color:#207d60; }
.index-status #indexDetail { color:var(--muted); }
.index-status .icon-button { margin-left:auto; flex:0 0 36px; display:grid; place-items:center; }
.upload-mode { display:flex; flex-direction:column; gap:8px; margin-bottom:18px; }
.upload-progress { padding:10px 0; color:#9a3c17; line-height:1.5; overflow-wrap:anywhere; }
#preparedFileList { margin:16px 0; padding:0; list-style:none; }
#preparedFileList li { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:10px 0; border-bottom:1px solid var(--line); font-size:13px; }
#preparedFileList span { min-width:0; overflow-wrap:anywhere; }
#preparedFileList small { flex-shrink:0; color:var(--muted); }
#uploadModal .modal-header, #uploadModal .modal-footer { flex-shrink:0; }
#uploadModal .modal-scroll { flex:1; }
@media(max-width:600px) { #preparedFileList li { flex-direction:column; align-items:flex-start; gap:4px; } .modal-footer { flex-wrap:wrap; } }
@media(max-width:800px) { .modal-backdrop { padding:10px; } .modal { max-height:calc(100dvh - 20px); } .form-grid { grid-template-columns:minmax(0,1fr); } .form-grid .span-2 { grid-column:auto; } .modal-header { gap:10px; padding:16px; } .modal-scroll { padding:16px; } .modal-header .icon-button { flex:0 0 36px; } .modal-footer { padding:12px 16px; } }

/* Five-dimension knowledge taxonomy */
.filter-bar { grid-template-columns: repeat(4,minmax(130px,1fr)); }
.taxonomy-note { color: var(--muted); line-height: 1.7; font-size: 13px; }
.taxonomy-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.taxonomy-card { border:1px solid var(--line); background:#fff; padding:20px; }
.taxonomy-card h3 { color:var(--navy); margin:0 0 14px; font-size:16px; }
.taxonomy-chips { display:flex; flex-wrap:wrap; gap:8px; }
.taxonomy-chip { display:flex; align-items:center; gap:12px; border:1px solid var(--line); background:#f7f8fa; color:var(--navy); padding:8px 10px; border-radius:4px; text-align:left; }
.taxonomy-chip:hover { border-color:var(--orange); background:#fff5ec; }
.taxonomy-chip strong { font-variant-numeric:tabular-nums; color:var(--orange); }
.taxonomy-checks { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; padding:12px 0; }
.taxonomy-checks label { display:flex; align-items:center; gap:6px; font-size:12px; }
.taxonomy-checks input { width:auto; }
#taxonomyForm fieldset { margin:18px 0; border:1px solid var(--line); }
#taxonomyForm legend { color:var(--navy); font-weight:700; font-size:13px; }
.relevance-note { color:#8b4a14; background:#fff4e9; padding:6px 8px; font-size:12px; }
@media(max-width:760px) { .taxonomy-grid { grid-template-columns:1fr; } .filter-bar { grid-template-columns:repeat(2,minmax(0,1fr)); } .taxonomy-checks { grid-template-columns:repeat(2,minmax(0,1fr)); } }
