:root {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #191d29;
  background: #f4f1ea;
  --navy: #11182c;
  --teal: #1d5860;
  --gold: #b98a42;
  --berry: #843e5f;
  --line: #ddd6c9;
  --paper: #fffdf8;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f4f1ea; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.is-hidden { display: none !important; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at top, #263655, #0c1120 70%); }
.login-card { width: min(440px,100%); padding: 38px; border: 1px solid #8b744d; border-radius: 22px; color: #fff7e9; background: rgba(12,18,34,.92); box-shadow: 0 28px 80px #0008; }
.login-card h1 { margin: 5px 0 24px; font: 500 36px Georgia, serif; }
.eyebrow { margin: 0; color: #d4b77f; letter-spacing: .18em; font-size: 11px; }
.form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 13px; }
input, select { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; color: inherit; background: white; }
.login-card input { border-color: #575e70; color: white; background: #151c31; }
.btn { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 15px; color: #212534; background: white; }
.btn-primary { border-color: #cf9f55; color: #18130d; background: linear-gradient(135deg,#f0d195,#c89448); font-weight: 700; }
.btn-danger { color: #7b1e2f; border-color: #d9a5ae; background: #fff2f4; }
.form-status { min-height: 20px; color: #efb3bd; font-size: 13px; }
.app { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0,1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 25px 16px; color: #f8f2e7; background: linear-gradient(180deg,#11182c,#161d31); }
.brand { padding: 5px 10px 22px; border-bottom: 1px solid #ffffff1c; }
.brand strong { display: block; margin-top: 6px; font: 500 25px Georgia,serif; }
.nav { display: grid; gap: 7px; margin-top: 22px; }
.nav button { min-height: 44px; border: 0; border-radius: 10px; padding: 10px 12px; text-align: left; color: #cbd0dc; background: transparent; }
.nav button:hover, .nav button.is-active { color: white; background: #ffffff13; }
.sidebar-footer { position: absolute; left: 16px; right: 16px; bottom: 20px; display: grid; gap: 8px; }
.sidebar-footer small { color: #969ead; }
.sidebar-footer .btn { color: white; border-color: #ffffff28; background: transparent; }
.main { min-width: 0; padding: 28px clamp(18px,4vw,52px) 80px; }
.page-header { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 24px; }
.page-header h1 { margin: 2px 0 0; font: 500 34px Georgia,"Songti SC",serif; }
.muted { color: #6e7280; }
.metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; }
.metric, .card { border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: 0 9px 26px #2621170b; }
.metric { padding: 18px; }
.metric small { color: #707482; }
.metric strong { display: block; margin-top: 7px; font-size: 27px; }
.metric span { display: block; margin-top: 6px; color: #777b87; font-size: 11px; line-height: 1.45; }
.metric-accent { border-color: #c5a66c; background: linear-gradient(145deg,#fffdf8,#f8efdc); }
.metric-accent strong { color: #7a5523; }
.metric-warning { border-color: #ddbbc1; background: #fff8f8; }
.metric-warning strong { color: #8a3445; }
.card { margin-top: 18px; padding: 20px; overflow: hidden; }
.card-head, .toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.card h2, .card h3 { margin: 0; font-size: 18px; }
.card-head small { color: #777b87; }
.toolbar { margin-bottom: 14px; justify-content: flex-start; }
.toolbar input { width: min(300px,100%); }
.export-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.table-wrap { overflow: auto; margin: 0 -20px -20px; }
table { width: 100%; min-width: 780px; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 14px; border-top: 1px solid #e7e1d7; text-align: left; white-space: nowrap; }
th { color: #666b78; background: #faf8f3; }
tr:hover td { background: #fffcf5; }
.page-summary { max-width: 640px; margin: 8px 0 0; line-height: 1.55; }
.analytics-header { align-items: flex-start; }
.analytics-controls { display: flex; align-items: end; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.analytics-controls label { min-width: 150px; }
.analytics-controls small { flex-basis: 100%; text-align: right; }
.analytics-status { min-height: 20px; margin-top: -10px; color: var(--berry); font-size: 13px; }
.definition-note { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 16px; padding: 17px 19px; border: 1px solid #d8c69f; border-radius: 14px; color: #4e4537; background: #fffaf0; }
.definition-note strong { color: #785b2d; white-space: nowrap; }
.definition-note p { margin: 0; line-height: 1.65; }
.analytics-section { margin-top: 34px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 22px; padding: 0 2px; }
.section-heading h2 { margin: 3px 0 0; font: 500 25px Georgia,"Songti SC",serif; }
.section-heading > p { max-width: 550px; margin: 0; color: #6e7280; font-size: 13px; line-height: 1.5; text-align: right; }
.analytics-metrics { grid-template-columns: repeat(auto-fit,minmax(175px,1fr)); margin-top: 15px; }
.analytics-table { min-width: 980px; }
.analytics-table th { position: sticky; top: 0; z-index: 1; }
.analytics-table td strong + .item-id { margin-top: 3px; }
.analytics-table tr.is-highlight td { background: #fff8e7; }
.analytics-table tr.is-highlight:hover td { background: #fff4d9; }
.item-id { display: block; color: #8a8d96; font: 10px/1.35 ui-monospace,monospace; }
.number-positive { color: #126044; font-weight: 650; }
.number-negative { color: #9a3146; font-weight: 650; }
.rank-badge, .category-tag { display: inline-flex; align-items: center; min-height: 24px; border-radius: 999px; padding: 3px 8px; color: #4c5261; background: #edf0f2; font-size: 11px; }
.rank-badge.is-best { color: #704810; background: #f5ddb0; font-weight: 700; }
.rank-badge.is-free { color: #2e6659; background: #e1f0e8; }
.rank-empty { color: #a6a8ad; }
.category-outfits { color: #6f3852; background: #f4e2ea; }
.category-dialogues, .category-voices { color: #315b70; background: #e3eff4; }
.category-cards { color: #6c501e; background: #f3ead5; }
.category-poses { color: #436351; background: #e7f0e9; }
.item-filters { margin-bottom: 16px; }
.result-count { margin-left: auto; color: #616672; font-size: 12px; }
.items-table { min-width: 1180px; }
.outfit-table { min-width: 1050px; }
.status { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 11px; background: #e9edf1; }
.status-paid, .status-active { color: #126044; background: #dcf3e9; }
.status-refunded, .status-frozen, .status-verification_failed { color: #8a293b; background: #fae3e7; }
.status-new, .status-creating { color: #72511a; background: #faedcf; }
.status-open { color: #8a293b; background: #fae3e7; }
.status-confirmed { color: #5d2432; background: #ecd6dc; }
.status-repaired { color: #126044; background: #dcf3e9; }
.status-false_positive { color: #4f5968; background: #e8ebef; }
.risk-header { align-items: flex-start; }
.risk-scan-actions { display: grid; justify-items: end; gap: 8px; max-width: 340px; }
.risk-scan-actions small { line-height: 1.5; text-align: right; }
.risk-table { min-width: 1100px; }
.risk-title-cell { max-width: 300px; white-space: normal; line-height: 1.45; }
.risk-row-critical td { background: #fffafa; }
.risk-row-critical:hover td { background: #fff2f4; }
.risk-severity { display: inline-flex; align-items: center; min-height: 26px; border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 700; }
.risk-critical { color: #8a293b; background: #fae3e7; }
.risk-warning { color: #76521b; background: #faedcf; }
.risk-evidence { margin-top: 18px; padding: 17px; border: 1px solid #e2d5bd; border-radius: 14px; background: #fffaf1; }
.risk-evidence h3 { margin: 0 0 10px; }
.risk-evidence p { color: #636773; font-size: 13px; }
.resolution-note { margin-top: 16px; padding: 14px 16px; border-left: 4px solid #52806e; background: #eef7f2; }
.resolution-note p { margin: 5px 0 0; line-height: 1.55; }
.risk-decisions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.detail-heading { margin: 24px 0 12px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; display: grid; grid-template-columns: 18px minmax(0,1fr); gap: 10px; padding: 0 0 18px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 15px; bottom: 0; width: 1px; background: #ddd6c9; }
.timeline li:last-child::before { display: none; }
.timeline-dot { position: relative; z-index: 1; width: 13px; height: 13px; margin-top: 3px; border: 3px solid #f4f1ea; border-radius: 50%; background: #79828f; box-shadow: 0 0 0 1px #c7c1b6; }
.timeline-risk { background: #a4465a; }
.timeline-ledger { background: #2f7661; }
.timeline-order { background: #b38336; }
.timeline-chest, .timeline-entitlement { background: #6d4d83; }
.timeline-head { display: flex; justify-content: space-between; gap: 12px; }
.timeline-head time { flex: 0 0 auto; color: #818590; font-size: 11px; }
.timeline details { margin-top: 6px; }
.timeline summary { cursor: pointer; color: #666b78; font-size: 12px; }
.timeline .json { margin: 8px 0 0; padding: 10px; border-radius: 9px; background: #f5f3ee; }
.tab-page { display: none; }
.tab-page.is-active { display: block; }
.detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.detail-block { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.detail-block strong { display: block; margin-top: 4px; }
.json { max-height: 440px; overflow: auto; white-space: pre-wrap; word-break: break-word; font: 12px/1.55 ui-monospace,monospace; }
dialog { width: min(980px,calc(100% - 24px)); max-height: calc(100vh - 24px); border: 0; border-radius: 18px; padding: 0; box-shadow: 0 35px 100px #0008; }
dialog::backdrop { background: #0b1022aa; backdrop-filter: blur(5px); }
.dialog-body { max-height: calc(100vh - 24px); overflow: auto; padding: 24px; }
.dialog-body > .card-head { align-items: flex-start; }
.dialog-body > .card-head h2 { min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
@media (max-width: 900px) {
  .app { display: block; }
  .sidebar { position: static; height: auto; }
  .nav { grid-template-columns: repeat(3,1fr); }
  .sidebar-footer { position: static; margin-top: 18px; }
  .metrics { grid-template-columns: repeat(2,1fr); }
  .section-heading { align-items: flex-start; }
  .risk-scan-actions { justify-items: stretch; max-width: none; }
  .risk-scan-actions small { text-align: left; }
}
@media (max-width: 560px) {
  .nav { grid-template-columns: repeat(2,1fr); }
  .metrics, .detail-grid { grid-template-columns: 1fr; }
  .main { padding: 20px 12px 60px; }
  .page-header, .section-heading { display: block; }
  .page-header .toolbar, .analytics-controls { margin-top: 14px; justify-content: stretch; }
  .analytics-controls label, .analytics-controls select, .analytics-controls .btn { width: 100%; }
  .analytics-controls small { text-align: left; }
  .definition-note { grid-template-columns: 1fr; gap: 7px; }
  .section-heading > p { margin-top: 8px; text-align: left; }
  .analytics-section { margin-top: 28px; }
  .result-count { flex-basis: 100%; margin-left: 0; }
  .risk-filters input, .risk-filters select, .risk-filters .btn { width: 100%; }
  .risk-filters input, .risk-filters select, .risk-filters .btn, .risk-scan-actions .btn { min-height: 44px; }
  .risk-decisions { display: grid; }
  dialog .btn { min-height: 44px; }
  .dialog-body { overflow-x: hidden; }
  .dialog-body > .card-head { display: grid; grid-template-columns: minmax(0,1fr) auto; }
  .timeline-head { display: block; }
  .timeline-head time { display: block; margin-top: 4px; }
}
