:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-alt: #f8f9fa;
  --nav: #20262c;
  --text: #17212b;
  --muted: #66727f;
  --line: #dfe3e7;
  --brand: #2f6d62;
  --brand-dark: #24564e;
  --blue: #376b9b;
  --amber: #a96d16;
  --red: #b94444;
  --green: #287a52;
  --radius: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--nav); color: #d8dde2; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: var(--radius); background: #e9f3ef; color: var(--brand-dark);
  font-size: 14px; font-weight: 800;
}
.brand-name { font-size: 16px; color: #fff; font-weight: 700; }
.brand-sub { display: block; color: #8d99a5; font-size: 11px; margin-top: 2px; }
.nav-label { padding: 16px 12px 6px; color: #75818d; font-size: 11px; }
.nav-item {
  height: 40px; display: flex; align-items: center; gap: 11px; padding: 0 12px;
  border-radius: var(--radius); color: #c5ccd3; margin: 2px 0;
}
.nav-item:hover { background: #2c343c; color: #fff; }
.nav-item.active { background: #e9f3ef; color: #194d44; font-weight: 700; }
.nav-item i { width: 18px; height: 18px; }
.sidebar-foot { margin-top: 24px; padding: 14px 10px 4px; border-top: 1px solid #343c44; }
.signed-user { color: #fff; font-weight: 600; }
.logout { color: #929da7; display: block; margin-top: 8px; font-size: 12px; }

.main { min-width: 0; }
.topbar {
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; border-bottom: 1px solid var(--line); background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { margin: 0; font-size: 19px; line-height: 1.2; }
.topbar-meta { color: var(--muted); font-size: 12px; }
.content { padding: 22px 28px 40px; max-width: 1600px; margin: 0 auto; }

.toolbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar form { display: contents; }
.field, .select {
  min-height: 36px; border: 1px solid #cfd5da; border-radius: var(--radius);
  background: #fff; padding: 7px 10px; color: var(--text); min-width: 140px;
}
.field:focus, .select:focus { border-color: var(--brand); outline: 2px solid #d8ebe5; }
.button {
  min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
  border-radius: var(--radius); padding: 7px 13px; cursor: pointer; font-weight: 600;
}
.button:hover { background: var(--brand-dark); }
.button.secondary { background: #fff; color: var(--text); border-color: #cfd5da; }
.button.danger { background: #fff; color: var(--red); border-color: #d9baba; }
.button.small { min-height: 30px; padding: 4px 9px; font-size: 12px; }
.icon-button {
  width: 34px; height: 34px; display: inline-grid; place-items: center; flex: 0 0 34px;
  border: 1px solid #cfd5da; border-radius: 50%; background: #fff; color: var(--brand-dark);
  cursor: pointer;
}
.icon-button:hover { border-color: var(--brand); background: #edf6f2; }
.icon-button.playing { background: var(--brand); color: #fff; border-color: var(--brand); }
.icon-button.loading { opacity: .6; cursor: wait; }
.icon-button i, .icon-button svg { width: 16px; height: 16px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.metric {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 17px; min-height: 104px;
}
.metric-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.metric-icon { width: 18px; height: 18px; color: var(--brand); }
.metric-value { font-size: 26px; font-weight: 750; margin-top: 10px; }
.metric-note { color: var(--muted); font-size: 11px; margin-top: 3px; }
.metric.tone-blue { border-top: 3px solid var(--blue); }
.metric.tone-green { border-top: 3px solid var(--green); }
.metric.tone-amber { border-top: 3px solid #d29436; }
.metric.tone-red { border-top: 3px solid var(--red); }

.section { margin-top: 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 10px; }
.section-head h2 { margin: 0; font-size: 16px; }
.section-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-pad { padding: 18px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--surface-alt); color: var(--muted); text-align: left;
  padding: 10px 12px; font-size: 12px; font-weight: 650; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
td { padding: 11px 12px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbfa; }
.row-link { font-weight: 650; color: #225f55; }
.subtext { color: var(--muted); font-size: 12px; margin-top: 2px; }
.number { font-variant-numeric: tabular-nums; }
.empty { padding: 44px 18px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; min-height: 24px; border-radius: 4px; padding: 3px 7px; font-size: 12px; background: #eef1f3; color: #4f5b66; }
.badge.green { background: #e5f2eb; color: var(--green); }
.badge.amber { background: #f8eddc; color: var(--amber); }
.badge.red { background: #f8e7e7; color: var(--red); }
.badge.blue { background: #e7eef6; color: var(--blue); }
.score-high { color: var(--green); font-weight: 700; }
.score-mid { color: var(--amber); font-weight: 700; }
.score-low { color: var(--red); font-weight: 700; }

.progress { width: 110px; height: 7px; border-radius: 4px; background: #e7eaed; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); }

.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; }
.detail-title { margin: 0 0 4px; font-size: 22px; }
.meta-list { display: grid; grid-template-columns: 120px 1fr; gap: 10px 14px; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.text-block { white-space: pre-wrap; line-height: 1.7; overflow-wrap: anywhere; }
.timeline { border-left: 2px solid #dfe5e3; margin-left: 7px; padding-left: 20px; }
.timeline-item { position: relative; padding: 0 0 20px; }
.timeline-item::before { content: ""; position: absolute; left: -26px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; }
.timeline-title { display: flex; align-items: center; gap: 10px; }
.timeline-title .icon-button { width: 30px; height: 30px; flex-basis: 30px; }
audio { width: 100%; min-height: 42px; }
.inline-link { display: inline-flex; align-items: center; gap: 6px; color: var(--brand-dark); margin-top: 10px; font-weight: 650; }
.inline-link i, .inline-link svg { width: 16px; height: 16px; }
.badge-list { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.text-block.compact { margin-top: 7px; color: #3f4a54; }

.result-summary { color: var(--muted); font-size: 12px; margin: -8px 0 12px; }
.customer-grid { display: grid; grid-template-columns: repeat(3, minmax(280px, 1fr)); gap: 12px; }
.customer-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; min-width: 0; display: flex; flex-direction: column; gap: 13px;
}
.customer-card:hover { border-color: #b8c8c3; box-shadow: 0 3px 12px rgba(34, 48, 44, .06); }
.customer-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.customer-name { color: var(--brand-dark); font-size: 17px; font-weight: 750; }
.customer-company { color: var(--muted); font-size: 12px; margin-top: 3px; }
.customer-card-meta { display: flex; gap: 12px; flex-wrap: wrap; color: #46515b; font-size: 12px; }
.customer-card-meta span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.customer-card-meta i, .customer-card-meta svg { width: 14px; height: 14px; color: var(--muted); }
.customer-progress > div:first-child { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.progress.wide { width: 100%; }
.customer-facts { display: grid; grid-template-columns: 68px 1fr; gap: 7px 9px; margin: 0; font-size: 12px; }
.customer-facts dt { color: var(--muted); }
.customer-facts dd { margin: 0; overflow-wrap: anywhere; }
.customer-audio { min-height: 54px; padding: 9px 10px; background: #f5f8f7; border: 1px solid #e3e9e6; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-radius: 4px; }
.customer-audio strong { font-size: 12px; display: block; }
.customer-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; border-top: 1px solid #edf0f2; padding-top: 11px; }
.customer-card-foot .row-link { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.customer-card-foot i, .customer-card-foot svg { width: 14px; height: 14px; }

.insight-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.insight-box { position: relative; border: 1px solid var(--line); background: var(--surface-alt); padding: 14px; min-height: 116px; border-radius: 4px; }
.insight-label { color: var(--muted); font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.opening-score { color: var(--green); font-size: 18px; font-weight: 800; margin-top: 9px; }

.insight-tabs { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); margin: 4px 0 16px; overflow-x: auto; }
.insight-tab { min-height: 42px; display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 650; cursor: pointer; }
.insight-tab svg { width: 16px; height: 16px; }
.insight-tab:hover { color: var(--text); background: #f6f8f8; }
.insight-tab.is-active { color: var(--brand-dark); border-bottom-color: var(--brand); }
.insight-tab-panel[hidden] { display: none; }
.evidence-metrics { margin-top: 2px; }
.metric-value.compact-value { min-height: 36px; display: flex; align-items: center; font-size: 17px; line-height: 1.25; overflow-wrap: anywhere; }
.chart-canvas.chart-tall { height: 340px; }
.method-note { display: flex; align-items: flex-start; gap: 7px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.6; padding-top: 10px; }
.method-note svg { width: 15px; height: 15px; flex: 0 0 15px; color: var(--blue); }
.review-list { display: grid; gap: 8px; }
.review-item { display: grid; grid-template-columns: minmax(150px, 210px) minmax(0, 1fr) auto; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; }
.review-status { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; }
.review-status svg { width: 17px; height: 17px; flex: 0 0 17px; }
.review-status.is-risk { color: var(--amber); }
.review-status.is-benchmark { color: var(--green); }
.review-copy { min-width: 0; }
.review-copy p { margin: 5px 0 0; color: #46515b; font-size: 12px; line-height: 1.55; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.review-actions, .evidence-actions { display: flex; align-items: center; gap: 7px; }
.review-actions > span { min-width: 42px; text-align: right; }
.evidence-actions .icon-button, .review-actions .icon-button { width: 30px; height: 30px; flex-basis: 30px; }
.evidence-table { min-width: 940px; }
.coaching-issues { display: flex; gap: 5px; flex-wrap: wrap; min-width: 240px; }
.coaching-issues span { display: inline-flex; background: #f8eddc; color: var(--amber); border-radius: 3px; padding: 3px 6px; font-size: 11px; }
.coaching-issues span.is-good { background: #e5f2eb; color: var(--green); }

.analytics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.chart-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.chart-panel.span-2 { grid-column: span 2; }
.modern-charts .chart-panel { padding: 18px; min-height: 340px; }
.chart-canvas { position: relative; width: 100%; height: 270px; }
.chart-canvas.chart-wide { height: 300px; }
.chart-foot-labels { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chart-foot-labels span { padding: 3px 6px; border-radius: 3px; background: #f5f6f7; color: var(--muted); font-size: 10px; }
.chart-legend { display: flex; gap: 16px; color: var(--muted); font-size: 12px; }
.chart-legend span::before { content: ""; width: 9px; height: 9px; display: inline-block; margin-right: 5px; border-radius: 2px; }
.legend-call::before { background: var(--blue); }
.legend-connect::before { background: var(--green); }
.legend-rate::before { background: #d29436; }
.daily-chart { height: 230px; display: flex; align-items: stretch; gap: 6px; padding-top: 10px; overflow-x: auto; }
.daily-chart.compact-chart { height: 190px; }
.daily-chart.compact-chart .daily-bars { height: 125px; }
.daily-column { min-width: 34px; flex: 1 0 34px; display: grid; grid-template-rows: 1fr 18px 18px; align-items: end; text-align: center; }
.daily-bars { height: 165px; display: flex; align-items: flex-end; justify-content: center; gap: 3px; border-bottom: 1px solid var(--line); }
.daily-bars span { width: 8px; min-height: 2px; border-radius: 2px 2px 0 0; }
.bar-call { background: var(--blue); }
.bar-connect { background: var(--green); }
.daily-column strong { font-size: 11px; }
.daily-column small { color: var(--muted); font-size: 10px; white-space: nowrap; }
.horizontal-chart { display: grid; gap: 12px; }
.chart-row > div:first-child { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; margin-bottom: 5px; }
.chart-track { height: 8px; background: #e9ecef; border-radius: 4px; overflow: hidden; }
.chart-track span { display: block; height: 100%; border-radius: 4px; }
.outcome-bar { background: var(--blue); }
.stage-bar { background: var(--green); }
.objection-bar { background: var(--amber); }
.objection-chart { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }

.opening-list { display: grid; gap: 8px; }
.opening-item { display: grid; grid-template-columns: 34px minmax(0, 1fr) 64px; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); padding: 13px 16px; border-radius: var(--radius); }
.opening-rank { width: 28px; height: 28px; display: grid; place-items: center; color: var(--muted); background: #eef1f3; border-radius: 50%; font-weight: 750; }
.opening-copy { min-width: 0; }
.opening-meta { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.opening-meta strong { color: var(--text); }
.opening-copy blockquote { margin: 7px 0; font-size: 14px; line-height: 1.6; color: #35414b; }
.opening-actions { display: flex; align-items: center; gap: 9px; }
.opening-actions .icon-button { width: 28px; height: 28px; flex-basis: 28px; }
.opening-item > .opening-score { text-align: right; font-size: 22px; margin: 0; }
.date-divider { color: var(--muted); font-size: 12px; }
.section-stat { color: var(--brand-dark); background: #e9f3ef; border-radius: 4px; padding: 5px 8px; font-size: 12px; font-weight: 700; }
.signal-panels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.signal-panels > div { padding: 16px; border-right: 1px solid var(--line); min-width: 0; }
.signal-panels > div:last-child { border-right: 0; }
.signal-panels h3 { display: flex; align-items: center; gap: 7px; margin: 0 0 12px; font-size: 13px; }
.signal-panels h3 svg { width: 16px; color: var(--brand); }
.signal-line, .signal-kpi { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid #edf0f2; padding: 8px 0; font-size: 12px; }
.signal-line strong, .signal-kpi strong { color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.signal-kpi strong { font-size: 18px; }
.signal-kpi span { color: var(--muted); text-align: right; }
.compact-empty { padding: 24px 4px; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 12px; }
.form-group label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.form-group .field, .form-group .select { width: 100%; }
.form-group.span-all { grid-column: 1 / -1; }
textarea.field { resize: vertical; line-height: 1.55; }
.table-actions, .target-form { display: flex; align-items: center; gap: 7px; }
.table-actions { flex-wrap: wrap; }
.target-field { width: 78px; min-width: 78px; }
.target-form .icon-button { width: 30px; height: 30px; flex-basis: 30px; border-radius: var(--radius); }
.error-box { border: 1px solid #e0b4b4; background: #fff2f2; color: var(--red); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(300px, 440px) 1fr; background: #fff; }
.login-panel { padding: 12vh 54px 40px; border-right: 1px solid var(--line); }
.login-panel .brand { padding-left: 0; }
.login-panel .brand-name { color: var(--text); }
.login-panel h1 { font-size: 25px; margin: 36px 0 8px; }
.login-panel p { color: var(--muted); line-height: 1.7; }
.login-form { margin-top: 26px; }
.login-form .field { width: 100%; margin-bottom: 12px; min-height: 42px; }
.login-form .button { width: 100%; min-height: 42px; }
.login-context { background: #eef3f1; padding: 12vh 8vw; display: flex; flex-direction: column; justify-content: center; }
.login-context h2 { font-size: 28px; max-width: 560px; line-height: 1.45; margin: 0 0 14px; }
.login-context p { color: #50615c; max-width: 560px; line-height: 1.8; }

.mobile-menu { display: none; }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 70px minmax(0, 1fr); }
  .sidebar { padding: 14px 8px; }
  .brand-name, .brand-sub, .nav-item span, .nav-label, .sidebar-foot { display: none; }
  .brand { justify-content: center; padding: 0 0 18px; }
  .nav-item { justify-content: center; padding: 0; }
  .metric-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .customer-grid { grid-template-columns: repeat(2, minmax(260px, 1fr)); }
}
@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; display: flex; overflow-x: auto; align-items: center; padding: 8px; }
  .sidebar .brand { padding: 0 8px 0 0; }
  .sidebar nav { display: flex; }
  .nav-item { width: 42px; flex: 0 0 42px; margin-right: 3px; }
  .nav-label, .sidebar-foot { display: none; }
  .topbar { height: 56px; padding: 0 14px; }
  .content { padding: 14px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric { padding: 13px; min-height: 94px; }
  .metric-value { font-size: 22px; }
  .table-wrap table { min-width: 680px; }
  .table-wrap td { white-space: nowrap; }
  .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .customer-grid, .analytics-grid, .insight-pair { grid-template-columns: 1fr; }
  .chart-panel.span-2 { grid-column: auto; }
  .objection-chart { grid-template-columns: 1fr; }
  .opening-item { grid-template-columns: 28px minmax(0, 1fr) 46px; padding: 12px; gap: 8px; }
  .review-item { grid-template-columns: 1fr auto; gap: 9px; }
  .review-status { grid-column: 1 / -1; }
  .review-copy p { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .review-actions { align-self: end; }
  .login-page { display: block; }
  .login-panel { min-height: 100vh; padding: 48px 24px; border: 0; }
  .login-context { display: none; }
}

.notice { padding: 10px 13px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; font-size: 13px; }
.notice.success { background: #eef8f2; border-color: #a9d7ba; color: #23653c; }
.notice.error { background: #fff2f2; border-color: #e0b4b4; color: var(--red); }
.notice.info { background: #f4f8fb; border-color: #b9cfdf; color: #31556f; }
.import-band { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.import-band h2 { margin: 0 0 5px; font-size: 16px; }
.import-band p { margin: 0; color: var(--muted); font-size: 12px; max-width: 560px; }
.import-band form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.file-field { max-width: 225px; padding: 7px; }
.star-icon { width: 17px; height: 17px; fill: #f3b61f; color: #d89a00; vertical-align: -3px; margin-right: 5px; }
.signal-row { display: flex; gap: 5px; flex-wrap: wrap; min-height: 23px; margin-top: 10px; }
.wide-select, .wide-button { width: 100%; }
.wide-button { margin-top: 8px; justify-content: center; }
.buying-bar { background: var(--green); }
.need-bar { background: var(--blue); }
.sentiment-bar { background: #70847c; }
.sentiment-chart { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.sync-error { max-width: 290px; overflow-wrap: anywhere; margin-top: 4px; }

.ai-workspace { display: grid; grid-template-columns: 280px minmax(0, 1fr); height: calc(100vh - 104px); min-height: 580px; border: 1px solid var(--line); background: var(--surface); }
.ai-scope { padding: 18px; border-right: 1px solid var(--line); background: #f7f8f8; }
.ai-presets { display: grid; gap: 7px; margin-top: 18px; }
.ai-presets button { border: 1px solid var(--line); background: #fff; color: var(--text); padding: 10px 11px; text-align: left; cursor: pointer; border-radius: var(--radius); font-size: 13px; }
.ai-presets button:hover { border-color: var(--blue); color: var(--blue); }
.ai-status { display: flex; align-items: center; gap: 7px; margin-top: 22px; font-size: 12px; color: var(--muted); }
.ai-status svg { width: 16px; height: 16px; }
.ai-status.ready { color: var(--green); }
.ai-status.warning { color: var(--amber); }
.ai-chat { min-width: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.ai-messages { overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.ai-message { max-width: min(760px, 88%); padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; line-height: 1.75; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-message.assistant { align-self: flex-start; background: #f7f9f8; }
.ai-message.user { align-self: flex-end; background: #eaf2ff; border-color: #b8d0f3; }
.ai-message.loading { color: var(--muted); }
.ai-message.error { color: var(--red); background: #fff2f2; }
.ai-message small { display: block; border-top: 1px solid var(--line); margin-top: 10px; padding-top: 6px; color: var(--muted); font-size: 11px; }
.ai-composer { border-top: 1px solid var(--line); padding: 14px; display: grid; grid-template-columns: minmax(0, 1fr) 42px; gap: 9px; align-items: end; }
.ai-composer textarea { resize: none; width: 100%; min-height: 68px; max-height: 160px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; line-height: 1.5; }
.ai-send { width: 42px; height: 42px; background: var(--blue); color: #fff; border-color: var(--blue); }
.ai-send:disabled { opacity: .55; cursor: wait; }

.provider-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.provider-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px; min-width: 0; }
.provider-card.provider-default { border-top: 3px solid var(--brand); }
.provider-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.provider-head h3 { margin: 0; font-size: 16px; }
.provider-code { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.provider-card .form-group { margin-bottom: 10px; }
.provider-card .field { width: 100%; }
.provider-form-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(100px, 1fr); gap: 10px; }
.provider-options { display: flex; align-items: center; gap: 18px; padding: 4px 0 12px; color: #46515b; font-size: 12px; }
.provider-options label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.provider-readiness { margin: -2px 0 10px; font-size: 11px; color: var(--green); }
.provider-readiness.failed { color: var(--red); }
.provider-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.provider-actions { display: flex; }
.provider-test { position: absolute; right: 17px; bottom: 63px; }
.provider-test .button:disabled { opacity: .45; cursor: not-allowed; }
.provider-test-result { min-height: 43px; border-top: 1px solid #edf0f2; margin-top: 14px; padding-top: 10px; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.provider-test-result strong { color: var(--text); }
.provider-test-result.ok strong { color: var(--green); }
.provider-test-result.failed strong { color: var(--red); }
.provider-test-result span { min-width: 0; overflow-wrap: anywhere; }
.provider-test-result small { margin-left: auto; white-space: nowrap; }

@media (max-width: 980px) {
  .import-band { align-items: flex-start; flex-direction: column; }
  .import-band form { justify-content: flex-start; }
  .ai-workspace { grid-template-columns: 230px minmax(0, 1fr); }
  .signal-panels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .signal-panels > div:nth-child(2) { border-right: 0; }
  .signal-panels > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 680px) {
  .sentiment-chart { grid-template-columns: 1fr; }
  .ai-workspace { display: flex; flex-direction: column; height: calc(100vh - 88px); min-height: 620px; }
  .ai-scope { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px; }
  .ai-scope .section-head p, .ai-status { display: none; }
  .ai-presets { display: flex; overflow-x: auto; margin-top: 10px; }
  .ai-presets button { flex: 0 0 auto; }
  .ai-chat { flex: 1; min-height: 0; }
  .ai-messages { padding: 12px; }
  .provider-grid, .signal-panels { grid-template-columns: 1fr; }
  .signal-panels > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .signal-panels > div:last-child { border-bottom: 0; }
  .provider-test { position: static; margin-top: 8px; }
  .provider-test-result { margin-top: 10px; }
  .modern-charts .chart-panel { min-height: 320px; }
}
.inline-form{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.compact-field{width:132px;min-width:112px;padding:7px 9px}
