:root {
  --navy-950: #08151f;
  --navy-900: #0d202c;
  --navy-800: #163443;
  --ink: #17242c;
  --muted: #6d7b83;
  --line: #dce5e8;
  --surface: #ffffff;
  --canvas: #f3f6f5;
  --teal: #087f75;
  --teal-dark: #05665f;
  --teal-soft: #dff4f0;
  --blue: #326f9f;
  --amber: #c88824;
  --violet: #7661a8;
  --danger: #b64a4a;
  --shadow: 0 12px 36px rgba(22, 52, 67, .08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { background: var(--canvas); color: var(--ink); font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; }
body { margin: 0; min-width: 320px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 20px 22px; background: linear-gradient(180deg, var(--navy-950), var(--navy-900)); color: #e6f1f2; display: flex; flex-direction: column; z-index: 30; }
.brand, .login-brand { display: flex; align-items: center; gap: 12px; }
.brand { padding: 0 10px 28px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: #20aa9c; color: white; font-weight: 800; letter-spacing: -.5px; box-shadow: 0 8px 18px rgba(32,170,156,.25); }
.brand strong, .login-brand strong { display: block; font-size: 17px; letter-spacing: .2px; }
.brand span, .login-brand span { display: block; margin-top: 2px; color: #8da8b1; font-size: 12px; }
.nav-list { display: grid; gap: 6px; margin-top: 24px; }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 13px; border-radius: 10px; color: #adc0c6; transition: .18s ease; }
.nav-item:hover { color: white; background: rgba(255,255,255,.06); }
.nav-item.active { background: linear-gradient(90deg, rgba(32,170,156,.22), rgba(32,170,156,.08)); color: white; box-shadow: inset 3px 0 0 #32c3b5; }
.nav-icon { width: 21px; text-align: center; font-size: 19px; color: #72a9a8; }
.sidebar-note { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: 12px; background: rgba(255,255,255,.05); }
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note strong { font-size: 12px; }
.sidebar-note small { margin-top: 2px; color: #77939c; font-size: 11px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #40d2a1; box-shadow: 0 0 0 5px rgba(64,210,161,.1); }

.main-area { min-width: 0; }
.topbar { height: 94px; padding: 0 34px; background: rgba(255,255,255,.88); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 20; }
.topbar h1 { margin: 2px 0 0; font-size: 23px; letter-spacing: -.5px; }
.eyebrow { margin: 0; color: var(--teal); font-size: 9px; font-weight: 800; letter-spacing: 1.6px; }
.topbar-action { margin-left: auto; }
.menu-button { display: none !important; }
.content-wrap { width: min(1540px, 100%); padding: 30px 34px 60px; }

.hero-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 0 0 22px; }
.hero-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.hero-row h2, .detail-heading h2 { margin: 0 0 7px; font-size: 28px; letter-spacing: -.8px; }
.hero-row p, .detail-heading p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.hero-badge { white-space: nowrap; display: flex; align-items: center; gap: 9px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 99px; background: white; color: #52646d; font-size: 12px; }
.hero-badge span { width: 7px; height: 7px; border-radius: 50%; background: #31b092; }

.button { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 15px; border: 1px solid transparent; border-radius: 9px; font-weight: 700; font-size: 13px; transition: .16s ease; }
.button-primary { background: var(--teal); color: white; box-shadow: 0 6px 15px rgba(8,127,117,.16); }
.button-primary:hover { background: var(--teal-dark); transform: translateY(-1px); }
.button-ghost { border-color: var(--line); background: white; color: #3c5059; }
.button-ghost:hover { border-color: #a9c1c5; background: #f8fbfb; }
.button-danger-soft { border-color: #ecc8c8; background: #fff4f3; color: #a84646; }
.button-danger-soft:hover { border-color: #dca7a7; background: #ffebe9; }
.button-text { background: transparent; color: var(--muted); }
.button-small { min-height: 32px; padding: 0 10px; font-size: 12px; }
.button-block { width: 100%; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: #61747b; font-size: 21px; }
.icon-button:hover { background: #eef4f4; }

.filter-bar { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.7); }
.filter-bar label, .stack-form label { display: grid; gap: 6px; color: #52636b; font-size: 11px; font-weight: 700; }
.filter-bar input, .filter-bar select, .stack-form input, .stack-form select, .stack-form textarea { min-height: 40px; border: 1px solid #cad7da; border-radius: 8px; background: white; padding: 8px 11px; color: var(--ink); outline: none; transition: .15s ease; }
.filter-bar input:focus, .filter-bar select:focus, .stack-form input:focus, .stack-form select:focus, .stack-form textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,117,.09); }
.filter-wide label { min-width: 130px; }
.filter-wide .search-field { min-width: 220px; flex: 1; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.metric-card { position: relative; overflow: hidden; padding: 20px 20px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: 0 5px 20px rgba(22,52,67,.035); }
.metric-card::after { content: ""; position: absolute; width: 88px; height: 88px; border-radius: 50%; right: -35px; top: -34px; background: currentColor; opacity: .06; }
.metric-label { display: flex; justify-content: space-between; align-items: center; color: #607079; font-size: 12px; font-weight: 700; }
.metric-icon { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 8px; background: currentColor; color: white; font-size: 12px; }
.metric-card > strong { display: block; margin: 16px 0 7px; color: var(--ink); font-size: 31px; letter-spacing: -1px; }
.metric-card small { color: #829097; font-size: 11px; }
.accent-teal { color: var(--teal); border-top: 3px solid var(--teal); }
.accent-blue { color: var(--blue); border-top: 3px solid var(--blue); }
.accent-amber { color: var(--amber); border-top: 3px solid var(--amber); }
.accent-violet { color: var(--violet); border-top: 3px solid var(--violet); }

.panel { margin-bottom: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.panel-header { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-bottom: 1px solid #e6edef; }
.panel-header h3 { margin: 0 0 4px; font-size: 16px; }
.panel-header p { margin: 0; color: var(--muted); font-size: 11px; }
.record-count { padding: 6px 10px; border-radius: 99px; background: #eff5f4; color: #57706f; font-size: 11px; }
.chart-wrap { height: 300px; padding: 18px 20px 14px; }
.chart-wrap canvas { width: 100%; height: 100%; }
.trend-chart-wrap { position: relative; }
.trend-tooltip { position: absolute; z-index: 4; min-width: 158px; padding: 10px 12px; border: 1px solid rgba(35,65,74,.12); border-radius: 9px; background: rgba(25,44,51,.94); color: #fff; box-shadow: 0 8px 24px rgba(16,34,40,.2); pointer-events: none; font-size: 11px; line-height: 1.55; }
.trend-tooltip[hidden] { display: none; }
.trend-tooltip strong, .trend-tooltip span { display: block; }
.trend-tooltip strong { margin-bottom: 4px; color: #d6f1ec; font-size: 12px; }
.chart-legend { display: flex; gap: 18px; color: var(--muted); font-size: 11px; }
.chart-legend span::before { content: ""; display: inline-block; width: 14px; height: 4px; margin-right: 6px; vertical-align: 2px; border-radius: 4px; }
.legend-bar::before { background: rgba(8,127,117,.35); }
.legend-line::before { background: var(--amber); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 12px 18px; background: #f7f9f9; color: #6f7e84; font-size: 10px; letter-spacing: .35px; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 14px 18px; border-top: 1px solid #edf1f2; vertical-align: middle; }
tbody tr:hover { background: #fbfdfd; }
tfoot td { background: #f6faf9; font-weight: 800; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 800; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; font-variant-numeric: tabular-nums; }
.store-chip { display: inline-flex; max-width: 260px; padding: 5px 9px; border-radius: 6px; background: #eef4f4; color: #36575b; font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rate-pill, .category-pill { display: inline-flex; padding: 5px 9px; border-radius: 99px; background: var(--teal-soft); color: var(--teal-dark); font-weight: 800; font-size: 11px; }
.risk-pill { min-width: 28px; display: inline-grid; place-items: center; padding: 5px 8px; border-radius: 99px; font-size: 10px; font-weight: 900; }
.risk-pill.risk-high { background: #fce4e6; color: #b33e4d; }
.risk-pill.risk-medium { background: #fff0d3; color: #9a6717; }
.risk-pill.risk-low { background: #e2f4ed; color: #257865; }
.risk-pill.risk-unknown { background: #e9eff2; color: #617984; }
.session-table td { min-width: 118px; }
.session-table td:first-child, .session-table td:last-child { min-width: auto; }
.session-table td strong, .session-table td small { display: block; }
.session-table td small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.row-link { padding: 0; border: 0; background: transparent; white-space: nowrap; color: var(--teal); font-weight: 800; font-size: 12px; }
.row-link:hover { color: var(--teal-dark); }

.status { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 99px; background: #eef2f3; color: #687980; font-size: 10px; font-weight: 800; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-success, .status-valid { background: #e1f5ec; color: #23835e; }
.status-running { background: #e4f0f7; color: #347a9d; }
.status-queued, .status-pending, .status-untested { background: #f0f1f2; color: #738087; }
.status-retry_wait { background: #fff2d7; color: #99702d; }
.status-collecting, .status-partial { background: #fff2d7; color: #99702d; }
.sampling-panel .job-message { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sampling-table th, .sampling-table td { white-space: nowrap; }
.status-failed, .status-invalid { background: #fae9e8; color: #ae4b4b; }
.status-expired { background: #eceff0; color: #68757b; }
.status-paused { background: #fff2d7; color: #99702d; }
.status-stopped { background: #eceff0; color: #68757b; }
.status-completed { background: #e1f5ec; color: #23835e; }
.status-empty { background: #fff2d7; color: #99702d; }
.account-row > div small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }

.ai-progress-track { height: 9px; overflow: hidden; border-radius: 99px; background: #e6eeee; }
.ai-progress-track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), #45baa8); transition: width .3s ease; }
.ai-progress-dialog { overflow: hidden; }
.ai-progress-body { padding: 20px 22px 22px; }
.ai-progress-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 11px; }
.ai-progress-heading > strong { color: var(--teal-dark); font-size: 26px; font-variant-numeric: tabular-nums; }
.ai-progress-track-large { height: 10px; }
.ai-progress-meta { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin: 10px 0 18px; color: #718086; font-size: 10px; }
.ai-live-terminal { overflow: hidden; border: 1px solid #1e343d; border-radius: 11px; background: #071319; box-shadow: inset 0 1px 14px rgba(0,0,0,.28); }
.ai-terminal-title { height: 36px; display: flex; align-items: center; gap: 6px; padding: 0 12px; border-bottom: 1px solid #1b3139; background: #0c1c23; }
.ai-terminal-title i { width: 8px; height: 8px; border-radius: 50%; background: #d65c5c; }
.ai-terminal-title i:nth-child(2) { background: #d5a646; }
.ai-terminal-title i:nth-child(3) { background: #4eae78; }
.ai-terminal-title span { margin-left: 6px; color: #78939d; font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; }
.ai-terminal-output { height: 310px; overflow-y: auto; padding: 13px 14px 18px; color: #b6c9ce; font: 11px/1.65 ui-monospace, SFMono-Regular, Consolas, "Microsoft YaHei", monospace; }
.terminal-line { display: grid; grid-template-columns: 58px 58px minmax(0, 1fr); gap: 8px; padding: 4px 0; }
.terminal-line time { color: #58737d; }
.terminal-line b { color: #68a8bc; font-weight: 800; }
.terminal-line span { min-width: 0; overflow-wrap: anywhere; }
.terminal-line p { grid-column: 3; margin: 2px 0 5px; color: #e2ecee; overflow-wrap: anywhere; }
.terminal-ok b, .terminal-success b { color: #55c991; }
.terminal-error b { color: #f07979; }
.terminal-run b { color: #e1b659; }
.terminal-warning b { color: #e1b659; }
.terminal-stop b { color: #899ba1; }
.ai-progress-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 66px; padding: 13px 22px; border-top: 1px solid var(--line); background: #f8fafa; }
.ai-progress-actions > span { min-width: 0; color: #65767c; font-size: 10px; }
.ai-progress-actions > div { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }

.empty-state { padding: 54px 20px; color: #849197; text-align: center; font-size: 12px; }
.empty-state.compact { padding: 100px 20px; }
.flash-stack { display: grid; gap: 8px; margin-bottom: 18px; }
.flash { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 9px; border: 1px solid #cfe4df; background: #eaf7f3; color: #256a57; font-size: 12px; font-weight: 700; }
.flash button { border: 0; background: transparent; color: inherit; font-size: 18px; }
.flash-error { border-color: #f0d1d1; background: #fff0ef; color: #a34545; }
.flash-warning { border-color: #eadbb8; background: #fff6df; color: #8c6826; }

.modal { position: fixed; inset: 0; display: none; place-items: center; padding: 24px; background: rgba(5,17,25,.56); backdrop-filter: blur(4px); z-index: 100; }
.modal.open { display: grid; }
.modal-card { width: min(520px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; border-radius: 16px; background: white; box-shadow: 0 25px 80px rgba(0,0,0,.28); }
.modal-wide { width: min(760px, 100%); }
.modal-header { display: flex; justify-content: space-between; gap: 15px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.modal-header h3 { margin: 0 0 5px; }
.modal-header p { margin: 0; color: var(--muted); font-size: 11px; }
.stack-form { display: grid; gap: 15px; padding: 22px; }
.stack-form textarea { resize: vertical; line-height: 1.5; }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.callout { padding: 12px 14px; border-radius: 9px; background: #f1f6f5; color: #58706e; font-size: 11px; line-height: 1.65; }
.callout.security { padding-left: 36px; position: relative; }
.callout.security::before { content: "⚿"; position: absolute; left: 14px; color: var(--teal); }
.checkbox { display: flex !important; grid-template-columns: 18px auto; align-items: center; gap: 8px !important; }
.checkbox input { min-height: 0; width: 16px; height: 16px; padding: 0; }
.hidden { display: none !important; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 10px; background: #edf2f2; }
.segmented label { display: block; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: grid; place-items: center; min-height: 38px; border-radius: 8px; color: var(--muted); font-size: 12px; font-weight: 800; cursor: pointer; }
.segmented input:checked + span { background: white; color: var(--teal); box-shadow: 0 3px 10px rgba(22,52,67,.1); }

.purpose-note-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.purpose-note-grid article { display: flex; gap: 14px; padding: 17px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.purpose-note-grid strong { font-size: 13px; }
.purpose-note-grid p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.purpose-icon { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; color: white; font-weight: 900; }
.purpose-icon.teal { background: var(--teal); }
.purpose-icon.violet { background: var(--violet); }
.account-list { display: grid; }
.account-row { min-height: 82px; display: grid; grid-template-columns: 64px minmax(200px, 1.4fr) minmax(120px, .7fr) minmax(100px, .6fr) auto; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid #edf1f2; }
.account-row:first-child { border-top: 0; }
.disabled-row { opacity: .56; background: #f7f8f8; }
.account-purpose { width: 52px; height: 38px; display: grid; place-items: center; border-radius: 8px; font-size: 10px; font-weight: 900; }
.purpose-kpi { background: var(--teal-soft); color: var(--teal-dark); }
.purpose-detail { background: #eeeaf8; color: #675395; }
.account-main strong, .account-main span { display: block; }
.account-main span { margin-top: 5px; color: var(--muted); font-size: 11px; }
.credential-state { color: #607279; font-size: 11px; }
.lock-dot { color: #37ad83; margin-right: 7px; }
.row-actions { display: flex; align-items: center; gap: 6px; }

.breadcrumb { display: flex; gap: 8px; margin-bottom: 18px; color: var(--muted); font-size: 11px; }
.breadcrumb a { color: var(--teal); font-weight: 700; }
.detail-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.detail-heading h2 { margin-top: 10px; }
.detail-actions { display: flex; gap: 9px; }
.facts-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; margin-bottom: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--line); }
.facts-grid > div { min-width: 0; padding: 15px; background: white; }
.facts-grid span, .metadata-grid span { display: block; color: var(--muted); font-size: 10px; }
.facts-grid strong, .metadata-grid strong { display: block; margin-top: 6px; overflow-wrap: anywhere; font-size: 12px; }
.split-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); gap: 18px; }
.conversation, .analysis-panel { min-height: 430px; }
.conversation { max-height: 620px; overflow-y: auto; padding: 20px; background: #f7f9f9; }
.message { width: min(86%, 650px); margin-bottom: 14px; padding: 11px 13px; border: 1px solid #dce7e6; border-radius: 4px 13px 13px 13px; background: white; }
.message-customer { margin-left: auto; border-radius: 13px 4px 13px 13px; background: #e7f5f1; border-color: #c5e4dd; }
.message-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 9px; }
.message-meta strong { color: #455b63; }
.message p { margin: 7px 0 0; font-size: 12px; line-height: 1.75; white-space: pre-wrap; }
.confidence { color: var(--teal); font-size: 11px; font-weight: 800; }
.analysis-category { margin: 20px; padding: 16px; border-radius: 11px; background: linear-gradient(135deg, #e6f5f1, #f5fbf9); }
.analysis-category span, .analysis-category small { display: block; color: var(--muted); font-size: 10px; }
.analysis-category strong { display: block; margin: 7px 0 4px; color: var(--teal-dark); font-size: 20px; }
.analysis-list { margin: 0; padding: 0 20px 18px; }
.analysis-list > div { padding: 13px 0; border-top: 1px solid #edf1f2; }
.analysis-list dt { margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 800; }
.analysis-list dd { margin: 0; font-size: 12px; line-height: 1.7; }
.analysis-list .recommendation { margin-top: 4px; padding: 13px; border: 1px solid #d9e9e5; border-radius: 10px; background: #f6fbf9; }
.model-note { display: block; padding: 0 20px 18px; color: #8b979c; }
.metadata-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; padding: 6px 20px 20px; }
.metadata-grid > div { padding: 14px 0; border-bottom: 1px solid #edf1f2; }
.metadata-grid > div:nth-child(even) { padding-left: 20px; }
.metadata-grid .wide { grid-column: 1 / -1; padding-left: 0 !important; }

.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; padding: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.pagination a { color: var(--teal); font-weight: 800; }
.job-message { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

.session-modal { padding: 18px; }
.session-dialog { width: min(1080px, 100%); height: min(820px, calc(100vh - 36px)); display: flex; flex-direction: column; overflow: hidden; border-radius: 18px; background: #f5f5f5; box-shadow: 0 30px 100px rgba(0,0,0,.36); }
.session-dialog-header { min-height: 72px; display: flex; align-items: center; gap: 13px; padding: 13px 18px; border-bottom: 1px solid #d8ddde; background: rgba(250,250,250,.96); }
.session-dialog-avatar { width: 43px; height: 43px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; background: #1aad19; color: white; font-size: 14px; font-weight: 900; box-shadow: 0 5px 12px rgba(26,173,25,.2); }
.session-dialog-title { min-width: 0; }
.session-dialog-title h3 { margin: 0 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.session-dialog-title p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #7d8589; font-size: 11px; }
.session-dialog-header .icon-button { margin-left: 2px; }
.session-source { margin-left: auto; padding: 5px 9px; border-radius: 99px; background: #e7ebeb; color: #697579; font-size: 10px; font-weight: 800; white-space: nowrap; }
.session-source.is-live { background: #e3f5df; color: #348329; }
.session-source.is-error { background: #fae9e8; color: #a84d4d; }
.session-modal-loading { flex: 1; display: grid; place-items: center; align-content: center; gap: 10px; color: #566267; text-align: center; }
.session-modal-loading p { margin: 0; color: #899194; font-size: 11px; }
.loading-ring { width: 26px; height: 26px; display: inline-block; border: 3px solid #d8dfdf; border-top-color: #1aad19; border-radius: 50%; animation: loading-spin .8s linear infinite; }
.loading-ring.small { width: 16px; height: 16px; border-width: 2px; }
@keyframes loading-spin { to { transform: rotate(360deg); } }
.session-modal-error { margin: 18px; padding: 13px 15px; border: 1px solid #efcece; border-radius: 10px; background: #fff0ef; color: #a24646; font-size: 12px; line-height: 1.6; }
.session-dialog-body { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 310px; }
.wechat-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid #d8ddde; background: #ededed; }
.wechat-daybar { min-height: 34px; display: grid; place-items: center; color: #92999b; font-size: 10px; background: #ededed; }
.wechat-conversation { min-height: 0; flex: 1; overflow-y: auto; padding: 10px 22px 24px; scroll-behavior: smooth; }
.wx-message { display: flex; align-items: flex-start; gap: 10px; margin: 18px 0; }
.wx-message-agent { flex-direction: row-reverse; }
.wx-message-system { justify-content: center; }
.wx-avatar { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 5px; background: #879397; color: white; font-size: 12px; font-weight: 900; }
.wx-message-agent .wx-avatar { background: #1aad19; }
.wx-message-customer .wx-avatar { background: #7087a0; }
.wx-message-main { max-width: min(72%, 560px); }
.wx-message-agent .wx-message-main { display: flex; flex-direction: column; align-items: flex-end; }
.wx-message-meta { display: flex; gap: 9px; margin: 0 3px 5px; color: #8b9497; font-size: 9px; }
.wx-message-agent .wx-message-meta { flex-direction: row-reverse; }
.wx-message-meta strong { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #626d71; font-weight: 600; }
.wx-bubble { position: relative; padding: 10px 13px; border: 1px solid #d7dcdd; border-radius: 5px; background: white; color: #202528; font-size: 13px; line-height: 1.68; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 1px 2px rgba(0,0,0,.025); }
.wx-message-customer .wx-bubble::before, .wx-message-agent .wx-bubble::before { content: ""; position: absolute; top: 13px; width: 8px; height: 8px; transform: rotate(45deg); }
.wx-message-customer .wx-bubble::before { left: -5px; border-left: 1px solid #d7dcdd; border-bottom: 1px solid #d7dcdd; background: white; }
.wx-message-agent .wx-bubble { border-color: #86cf73; background: #95ec69; }
.wx-message-agent .wx-bubble::before { right: -5px; border-top: 1px solid #86cf73; border-right: 1px solid #86cf73; background: #95ec69; }
.wx-system-text { padding: 5px 10px; border-radius: 4px; background: rgba(0,0,0,.08); color: #7c8588; font-size: 10px; }
.wechat-empty { min-height: 100%; display: grid; place-items: center; align-content: center; gap: 8px; color: #899194; text-align: center; font-size: 12px; }
.wechat-empty::before { content: "…"; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.6); color: #9aa2a4; font-size: 22px; }
.wechat-footer { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 12px 18px; border-top: 1px solid #d6dcdd; background: #f7f7f7; }
.wechat-footer strong, .wechat-footer span { display: block; }
.wechat-footer strong { margin-bottom: 3px; font-size: 12px; }
.wechat-footer span { color: #90989a; font-size: 9px; }
.session-inspector { min-height: 0; overflow-y: auto; padding: 16px; background: #f7f8f8; }
.session-summary-card, .modal-analysis-card { padding: 16px; border: 1px solid #e0e5e6; border-radius: 12px; background: white; }
.summary-store { display: inline-flex; padding: 4px 8px; border-radius: 5px; background: #e7f5e3; color: #347e2e; font-size: 10px; font-weight: 800; }
.session-summary-card h4 { margin: 13px 0 5px; font-size: 16px; line-height: 1.45; }
.session-summary-card > p { margin: 0; color: #7a8589; font-size: 11px; line-height: 1.5; }
.session-facts { margin: 15px 0 0; }
.session-facts > div { padding: 10px 0; border-top: 1px solid #edf0f1; }
.session-facts dt, .modal-analysis-card dt { color: #8a9396; font-size: 9px; }
.session-facts dd, .modal-analysis-card dd { margin: 5px 0 0; overflow-wrap: anywhere; font-size: 11px; line-height: 1.55; }
.modal-analysis-card { margin-top: 13px; }
.analysis-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.analysis-card-heading span { color: #7d888c; font-size: 10px; font-weight: 800; }
.analysis-card-heading strong { color: var(--teal-dark); font-size: 13px; }
.modal-analysis-card > p { margin: 12px 0 0; color: #5d6a6f; font-size: 11px; line-height: 1.65; }
.modal-analysis-card dl { margin: 12px 0 0; }
.modal-analysis-card dl > div { padding: 10px 0; border-top: 1px solid #edf0f1; }
.analysis-progress { display: flex; align-items: center; gap: 8px; margin-top: 14px; color: #607074; font-size: 11px; }
.secondary-category-list { display: grid; gap: 8px; }
.secondary-category-item { display: grid; gap: 7px; padding: 9px 10px; border: 1px solid #dfe8e8; border-radius: 8px; background: #f8fbfb; }
.secondary-category-item span { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 8px; align-items: baseline; }
.secondary-category-item small { color: #8a9396; font-size: 9px; font-weight: 800; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 20%, rgba(32,170,156,.15), transparent 34%), linear-gradient(135deg, #08151f, #17333f); }
.login-card { width: min(430px, 100%); padding: 34px; border-radius: 20px; background: rgba(255,255,255,.98); box-shadow: 0 30px 100px rgba(0,0,0,.35); }
.login-brand { margin-bottom: 34px; }
.login-brand span { color: var(--muted); }
.login-copy h1 { margin: 5px 0 8px; font-size: 30px; }
.login-copy > p:last-child { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.login-card .stack-form { padding: 18px 0 0; }
.security-hint { margin: 18px 0 0; text-align: center; color: var(--muted); font-size: 10px; }
.error-page { padding: 100px 20px; text-align: center; }
.error-page > strong { color: var(--teal); font-size: 72px; }
.error-page h2 { margin: 8px 0; }
.error-page p { margin: 0 0 22px; color: var(--muted); }
.sidebar-scrim { display: none; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split-grid { grid-template-columns: 1fr; }
  .account-row { grid-template-columns: 54px minmax(180px, 1fr) minmax(100px, .7fr) auto; }
  .account-row > div:nth-child(4) { display: none; }
  .row-actions { grid-column: 2 / -1; }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: 252px; transition: transform .2s ease; box-shadow: 20px 0 50px rgba(0,0,0,.25); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 25; background: rgba(5,17,25,.45); }
  .sidebar-scrim.open { display: block; }
  .menu-button { display: grid !important; }
  .topbar { height: 82px; padding: 0 18px; }
  .topbar h1 { font-size: 20px; }
  .content-wrap { padding: 24px 18px 50px; }
  .hero-row, .detail-heading { align-items: flex-start; flex-direction: column; }
  .metric-grid, .purpose-note-grid { grid-template-columns: 1fr; }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .facts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-row { grid-template-columns: 50px 1fr; }
  .account-row > div:nth-child(3), .account-row > div:nth-child(4) { display: none; }
  .row-actions { grid-column: 1 / -1; flex-wrap: wrap; }
  .filter-bar { align-items: stretch; }
  .filter-bar label, .filter-wide label { min-width: 0; width: calc(50% - 6px); }
  .filter-bar .search-field { width: 100%; }
  .chart-wrap { height: 250px; padding-left: 8px; padding-right: 8px; }
  .session-dialog-body { grid-template-columns: 1fr; overflow-y: auto; }
  .wechat-pane { min-height: 560px; border-right: 0; border-bottom: 1px solid #d8ddde; }
  .session-inspector { overflow: visible; }
  .ai-progress-meta, .ai-progress-actions { align-items: stretch; flex-direction: column; }
  .ai-progress-actions > div { justify-content: flex-start; }
}

@media (max-width: 520px) {
  .metric-grid { grid-template-columns: 1fr; }
  .filter-bar label, .filter-wide label { width: 100%; }
  .filter-bar .button { flex: 1; }
  .facts-grid { grid-template-columns: 1fr 1fr; }
  .metadata-grid { grid-template-columns: 1fr; }
  .metadata-grid > div:nth-child(even) { padding-left: 0; }
  .detail-actions { width: 100%; }
  .detail-actions form, .detail-actions .button { flex: 1; }
  .modal { padding: 10px; }
  .modal-card { max-height: calc(100vh - 20px); }
  .session-modal { padding: 0; }
  .session-dialog { height: 100vh; max-height: none; border-radius: 0; }
  .session-dialog-header { padding: 10px 12px; }
  .session-source { display: none; }
  .wechat-conversation { padding-left: 12px; padding-right: 12px; }
  .wx-message-main { max-width: 78%; }
  .wechat-footer { align-items: stretch; flex-direction: column; }
  .wechat-footer .button { width: 100%; }
  .login-card { padding: 25px; }
}
.wide-metrics-table { min-width: 2300px; }
.wide-metrics-table th { white-space: nowrap; }
.data-board-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.data-board-tab { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--text); box-shadow: 0 4px 18px rgba(16, 42, 48, .035); }
.data-board-tab strong { font-size: 15px; }
.data-board-tab span { color: var(--muted); font-size: 11px; }
.data-board-tab.active { border-color: #7bc8b8; background: linear-gradient(135deg, #eefaf7, #fff); box-shadow: inset 3px 0 0 var(--teal), 0 5px 20px rgba(22, 137, 116, .08); }
.board-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 22px 0 16px; }
.board-heading h3 { margin: 3px 0 5px; font-size: 20px; }
.board-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.board-kicker { color: var(--teal-dark); font-size: 9px; font-weight: 800; letter-spacing: .14em; }
.full-field-scroll { position: relative; }
.assessment-table, .brand-metrics-table { width: max-content; min-width: 100%; border: 1px solid #c7d3d5; border-collapse: separate; border-spacing: 0; }
.assessment-table th, .assessment-table td,
.brand-metrics-table th, .brand-metrics-table td { width: auto; min-width: 0; padding-left: 11px; padding-right: 11px; white-space: nowrap; border-right: 1px solid #c7d3d5; border-bottom: 1px solid #d7e0e1; }
.assessment-table th:last-child, .assessment-table td:last-child,
.brand-metrics-table th:last-child, .brand-metrics-table td:last-child { border-right: 0; }
.assessment-table thead th, .brand-metrics-table thead th { background: #edf3f3; color: #334b52; }
.assessment-table tbody tr:nth-child(even) td,
.brand-metrics-table tbody tr:nth-child(even) td { background: #f7fafa; }
.assessment-table tbody tr:hover td,
.brand-metrics-table tbody tr:hover td { background: #eaf6f3; }
.assessment-table .number, .brand-metrics-table .number { text-align: right; }
.sticky-col { position: sticky; z-index: 2; background: inherit; }
thead .sticky-col { z-index: 4; background: #f6f9f9; }
.sticky-col-date { left: 0; width: 104px !important; min-width: 104px !important; }
.sticky-col-store { left: 104px; width: 150px !important; min-width: 150px !important; box-shadow: 8px 0 12px -10px rgba(30, 56, 62, .5); }
tbody tr:nth-child(odd) .sticky-col { background: #fff; }
tbody tr:nth-child(even) .sticky-col { background: #fbfcfc; }

.analysis-hero h2 { margin: 4px 0 8px; }
.analysis-purpose-note { display: flex; align-items: center; gap: 14px; margin: 0 0 18px; padding: 14px 17px; border: 1px solid #cfe5df; border-radius: 12px; background: linear-gradient(135deg, #eef9f6, #fbfdfc); }
.analysis-purpose-note strong { color: var(--teal-dark); font-size: 12px; }
.analysis-purpose-note p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.purpose-note-icon { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; background: var(--teal); color: white; font-size: 19px; font-weight: 900; }
.analysis-kpi-grid .metric-card strong { font-variant-numeric: tabular-nums; }
.analysis-trend-panel { margin-top: 18px; }
.analysis-chart-wrap { height: 300px; }
.chart-legend .responsible::before { background: #e39b33; }
.chart-legend .high-risk::before { background: #c85d69; }
.analysis-breakdown-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin: 18px 0; }
.analysis-breakdown-card { margin: 0; }
.distribution-list { display: grid; gap: 15px; padding: 18px 20px 22px; }
.distribution-row { display: grid; gap: 7px; }
.distribution-label { display: flex; align-items: baseline; justify-content: space-between; gap: 15px; }
.distribution-label strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.distribution-label span { flex: 0 0 auto; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.distribution-track { height: 7px; overflow: hidden; border-radius: 99px; background: #edf1f2; }
.distribution-fill { display: block; height: 100%; min-width: 2px; border-radius: inherit; }
.fill-teal { background: linear-gradient(90deg, #2b9c8c, #62c3b2); }
.fill-blue { background: linear-gradient(90deg, #477da7, #76a8c9); }
.fill-amber { background: linear-gradient(90deg, #d58b2d, #efb760); }
.fill-violet { background: linear-gradient(90deg, #7965a7, #aa93d2); }
.analysis-lower-grid { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 18px; margin-bottom: 18px; }
.risk-structure { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 18px 20px 22px; }
.risk-pie-layout { min-height: 280px; display: grid; grid-template-columns: minmax(240px, .9fr) minmax(180px, 1.1fr); align-items: center; gap: 12px; padding: 18px 20px 22px; }
.risk-pie-layout canvas { display: block; margin: 0 auto; }
.risk-pie-legend { display: grid; gap: 9px; }
.risk-block { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 3px 10px; padding: 13px; border: 1px solid #e2e8e9; border-radius: 10px; background: #f8fafa; }
.risk-block span { color: var(--muted); font-size: 10px; font-weight: 800; }
.risk-block strong { grid-row: span 2; font-size: 22px; }
.risk-block small { color: #899398; font-size: 9px; }
.risk-high { border-color: #efc9ce; background: #fff3f4; color: #ad4050; }
.risk-medium { border-color: #efdcb9; background: #fff9ed; color: #a56f1e; }
.risk-low { border-color: #cbe5df; background: #f1faf7; color: #247c6e; }
.risk-unknown { border-color: #d6e0e4; background: #f3f7f8; color: #607a86; }
.keyword-cloud { display: flex; align-content: flex-start; flex-wrap: wrap; gap: 9px; min-height: 145px; padding: 20px; }
.keyword-cloud > span { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid #dbe6e5; border-radius: 99px; background: #f7fbfa; color: #40565c; font-size: 11px; }
.keyword-cloud small { min-width: 18px; padding: 2px 5px; border-radius: 99px; background: #dceeea; color: var(--teal-dark); text-align: center; font-size: 8px; font-weight: 900; }
.focus-panel { margin-bottom: 18px; }
.focus-table { min-width: 1320px; }
.focus-table td { vertical-align: top; }
.focus-action { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #566970; }
.opportunity-number { color: #b56f12; font-weight: 900; }
.risk-number { color: #b84d5b; font-weight: 900; }
.store-opportunity-table { min-width: 900px; }
.coverage-cell { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.coverage-cell > span { width: 76px; height: 6px; overflow: hidden; border-radius: 99px; background: #e9eeee; }
.coverage-cell i { display: block; height: 100%; border-radius: inherit; background: var(--teal); }
.coverage-cell strong { color: #586b71; font-size: 10px; font-variant-numeric: tabular-nums; }
.settings-hero { align-items: center; }
.settings-hero h2 { margin: 4px 0 8px; }
.settings-version { padding: 7px 11px; border-radius: 99px; background: #edf1f2; color: #69787d; font-size: 10px; font-weight: 900; }
.settings-version.is-custom { background: var(--teal-soft); color: var(--teal-dark); }
.prompt-editor-form { padding: 20px; }
.prompt-editor-form textarea { width: 100%; min-height: 560px; padding: 18px; resize: vertical; border: 1px solid #cdd8da; border-radius: 10px; background: #fbfcfc; color: #263b42; font: 12px/1.75 Consolas, "Microsoft YaHei", monospace; }
.prompt-editor-form textarea:focus { outline: 2px solid rgba(32, 156, 139, .18); border-color: var(--teal); }
.prompt-actions { margin-top: 16px; }
.reset-prompt-form { display: flex; justify-content: flex-end; margin-top: -8px; }
.danger-link { color: #b64e59 !important; }
.category-summary { display: flex; gap: 8px; }
.category-summary span { min-width: 92px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--muted); font-size: 10px; text-align: center; }
.category-summary strong { display: block; margin-bottom: 2px; color: var(--teal-dark); font-size: 18px; }
.category-management-table { min-width: 1180px; }
.category-management-table td { vertical-align: top; }
.category-management-table td > strong, .category-management-table td > small { display: block; }
.category-management-table td > strong { max-width: 240px; font-size: 11px; line-height: 1.55; }
.category-management-table td > small { margin-top: 5px; color: #8a969a; font: 9px/1.3 Consolas, monospace; }
.compact-actions { gap: 10px; white-space: nowrap; }
.compact-actions form { margin: 0; }
.compact-actions button { padding: 0; border: 0; background: transparent; cursor: pointer; }
.category-edit-heading { align-items: center; }
.category-edit-heading p { color: var(--muted); font-size: 11px; }
.category-edit-form { overflow: visible; }
.category-status-toggle { color: var(--teal-dark); font-size: 11px; font-weight: 800; }
.category-form-body { display: grid; gap: 17px; padding: 22px; }
.category-form-body > label { display: grid; gap: 7px; color: #607278; font-size: 10px; font-weight: 800; }
.category-form-body input, .category-form-body select, .category-form-body textarea { width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid #cad7da; border-radius: 8px; background: white; color: var(--ink); outline: none; transition: .15s ease; }
.category-form-body input:focus, .category-form-body select:focus, .category-form-body textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,117,.09); }
.category-form-body input[readonly] { background: #f1f4f4; color: #7c898d; cursor: not-allowed; }
.category-form-body textarea { resize: vertical; line-height: 1.6; }
.category-level-grid, .category-reference-grid { padding-bottom: 18px; border-bottom: 1px solid #e6ebec; }
.model-settings-form { overflow: visible; }
.model-form-body { display: grid; gap: 18px; padding: 22px; }
.model-form-body > label, .model-form-body .form-grid label { display: grid; gap: 7px; color: #607278; font-size: 10px; font-weight: 800; }
.model-form-body input, .model-form-body select { width: 100%; min-height: 42px; padding: 8px 11px; border: 1px solid #cad7da; border-radius: 8px; background: white; color: var(--ink); outline: none; }
.model-form-body input:focus, .model-form-body select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,117,.09); }
.model-form-body input[readonly] { background: #f1f4f4; color: #66777c; }
.model-form-body label > small { color: #89969a; font-size: 9px; font-weight: 500; line-height: 1.5; }
.clear-key-option { display: flex !important; grid-template-columns: 18px auto; width: fit-content; }

@media (max-width: 720px) {
  .data-board-tabs { grid-template-columns: 1fr; }
  .board-heading { align-items: stretch; flex-direction: column; }
  .board-heading form, .board-heading .button { width: 100%; }
  .analysis-breakdown-grid, .analysis-lower-grid { grid-template-columns: 1fr; }
  .risk-pie-layout { grid-template-columns: 1fr; }
  .analysis-purpose-note { align-items: flex-start; }
  .settings-hero { align-items: flex-start; }
  .category-summary { width: 100%; }
  .category-summary span { flex: 1; }
  .prompt-editor-form textarea { min-height: 430px; }
}
