:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-soft: #f7f9f8;
  --surface-strong: #e9efec;
  --text: #15231f;
  --muted: #66746f;
  --line: #dce4e0;
  --line-strong: #cbd7d1;
  --primary: #0d6b57;
  --primary-dark: #095243;
  --primary-soft: #e4f2ed;
  --sidebar: #10231f;
  --sidebar-soft: #19312b;
  --success: #187447;
  --warning: #a36212;
  --danger: #b23a31;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 12px 32px rgb(22 44 37 / 8%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { min-width: 320px; margin: 0; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgb(13 107 87 / 18%); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: currentColor; }
h1, h2, h3, p { margin-top: 0; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 6px; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }

.primary, .secondary, .text-button, .icon-button, .mobile-menu {
  border: 0;
  border-radius: var(--radius-sm);
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
.primary { min-height: 40px; padding: 0 16px; background: var(--primary); color: #fff; font-weight: 750; }
.primary:hover { background: var(--primary-dark); }
.secondary { min-height: 38px; padding: 0 13px; border: 1px solid var(--line-strong); background: #fff; color: var(--text); font-weight: 700; }
.secondary:hover { border-color: var(--primary); color: var(--primary); }
.text-button { padding: 7px 0; background: transparent; color: var(--primary); font-size: 13px; font-weight: 750; }
.wide { width: 100%; }
.icon-button, .mobile-menu { width: 36px; height: 36px; display: grid; place-items: center; background: transparent; color: inherit; }
.icon-button:hover, .mobile-menu:hover { background: rgb(255 255 255 / 8%); }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
}
input, select { height: 42px; padding: 0 12px; }
textarea { min-height: 130px; padding: 11px 12px; line-height: 1.65; resize: vertical; }
input::placeholder, textarea::placeholder { color: #98a39f; }

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(280px, 520px) minmax(360px, 500px);
  place-content: center;
  gap: 72px;
  padding: 52px;
  background: var(--sidebar);
  color: #fff;
}
body.authenticated .login-screen { display: none; }
.login-brand { position: absolute; top: 34px; left: 40px; display: flex; align-items: center; gap: 12px; }
.login-brand strong, .brand strong { display: block; font-size: 15px; }
.login-brand span, .brand span { display: block; margin-top: 3px; color: #92a8a1; font-size: 10px; letter-spacing: .05em; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgb(255 255 255 / 18%); border-radius: 9px; background: var(--primary); color: #fff; font-size: 13px; font-weight: 850; letter-spacing: -.04em; }
.login-screen > .login-brand + .login-card::before { content: ""; }
.login-card {
  grid-column: 2;
  width: 100%;
  display: grid;
  gap: 18px;
  padding: 34px;
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: var(--radius-lg);
  background: #fff;
  color: var(--text);
  box-shadow: 0 28px 80px rgb(0 0 0 / 24%);
}
.login-card h1 { margin-bottom: 14px; font-size: clamp(28px, 3vw, 40px); line-height: 1.18; letter-spacing: -.04em; }
.login-copy { margin-bottom: 0; color: var(--muted); font-size: 14px; line-height: 1.75; }
.login-card label, .stack-form label { display: grid; gap: 7px; }
.login-card label > span, .stack-form label > span, .inline-form label > span { font-size: 12px; font-weight: 750; }
.form-message { min-height: 18px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.form-message.error { color: var(--danger); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
body:not(.authenticated) .app-shell { visibility: hidden; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 238px;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 14px;
  background: var(--sidebar);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 7px 22px; border-bottom: 1px solid rgb(255 255 255 / 8%); }
.brand .brand-mark { width: 38px; height: 38px; }
nav { display: grid; gap: 4px; margin-top: 18px; }
nav > p { margin: 16px 10px 6px; color: #6f8a81; font-size: 10px; font-weight: 800; letter-spacing: .13em; }
nav a { min-height: 40px; display: flex; align-items: center; gap: 11px; padding: 0 11px; border-radius: 7px; color: #aebdb8; font-size: 13px; font-weight: 650; text-decoration: none; }
nav a svg { width: 18px; height: 18px; }
nav a:hover { background: rgb(255 255 255 / 5%); color: #fff; }
nav a.active { background: var(--sidebar-soft); color: #fff; box-shadow: inset 3px 0 var(--primary); }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 14px 6px 0; border-top: 1px solid rgb(255 255 255 / 8%); }
.user-block { min-width: 0; flex: 1; display: flex; align-items: center; gap: 9px; }
.avatar { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--primary); font-size: 12px; font-weight: 850; }
.user-block strong, .user-block small { max-width: 118px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-block strong { font-size: 12px; }
.user-block small { margin-top: 2px; color: #829a92; font-size: 10px; }

.main { grid-column: 2; min-width: 0; }
.topbar { height: 76px; display: flex; align-items: center; gap: 13px; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 92%); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); }
.topbar p { margin: 0 0 2px; color: var(--muted); font-size: 11px; }
.topbar h1 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.topbar-meta { margin-left: auto; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 4px rgb(163 98 18 / 10%); }
.status-dot.ok { background: var(--success); box-shadow: 0 0 0 4px rgb(24 116 71 / 10%); }
.mobile-menu { display: none; }
.global-message { display: none; margin: 18px 28px 0; padding: 11px 14px; border: 1px solid #ecc3bf; border-radius: var(--radius-sm); background: #fff2f0; color: var(--danger); font-size: 12px; }
.global-message.show { display: block; }

.page { display: none; padding: 24px 28px 44px; }
.page.active { display: block; }
.page-intro { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.page-intro h2 { margin-bottom: 5px; font-size: 22px; letter-spacing: -.03em; }
.page-intro p { max-width: 760px; margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.page-intro.with-control { align-items: center; gap: 20px; }
.model-select { width: min(360px, 42vw); }

.hero-panel {
  min-height: 182px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding: 28px 30px;
  border: 1px solid #24433a;
  border-radius: var(--radius-lg);
  background: var(--sidebar);
  color: #fff;
}
.hero-panel h2 { margin-bottom: 10px; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.04em; }
.hero-panel p:not(.eyebrow) { max-width: 720px; margin-bottom: 0; color: #aebdb8; font-size: 13px; line-height: 1.75; }
.hero-panel .primary { flex: 0 0 auto; background: #fff; color: var(--primary-dark); }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0; }
.metric-card { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.metric-card > span { color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin: 8px 0 5px; font-size: 27px; letter-spacing: -.04em; }
.metric-card small { color: #86938e; font-size: 11px; }

.panel { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.two-column { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(340px, .85fr); gap: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
.workflow { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.workflow li { position: relative; display: flex; gap: 13px; padding: 0 0 16px; }
.workflow li:last-child { padding-bottom: 0; }
.workflow li:not(:last-child)::after { content: ""; position: absolute; top: 25px; bottom: 3px; left: 14px; width: 1px; background: var(--line); }
.workflow li > span { position: relative; z-index: 1; width: 29px; height: 29px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: #fff; color: var(--primary); font-size: 9px; font-weight: 850; }
.workflow strong, .workflow small { display: block; }
.workflow strong { margin: 3px 0 3px; font-size: 13px; }
.workflow small { color: var(--muted); font-size: 11px; line-height: 1.5; }

.model-list, .task-list { display: grid; gap: 9px; }
.model-row, .task-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.model-row:last-child, .task-row:last-child { border-bottom: 0; }
.model-row h3, .task-row h3 { margin: 0 0 5px; font-size: 13px; }
.model-row p, .task-row p { margin: 0; color: var(--muted); font-size: 11px; }
.tag { display: inline-flex; align-items: center; min-height: 23px; padding: 0 8px; border-radius: 99px; background: var(--surface-strong); color: var(--muted); font-size: 10px; font-weight: 750; }
.tag.complete { background: #e7f5ed; color: var(--success); }
.tag.running, .tag.pending { background: #fff2df; color: var(--warning); }
.tag.failed { background: #fceae8; color: var(--danger); }
.empty-state { min-height: 170px; display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; }

.upload-panel { margin-bottom: 16px; }
.upload-copy { display: flex; align-items: center; gap: 14px; }
.upload-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; background: var(--primary-soft); color: var(--primary); }
.upload-copy h3 { margin-bottom: 5px; font-size: 15px; }
.upload-copy p { margin: 0; color: var(--muted); font-size: 12px; }
.upload-form { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(180px, .7fr) auto; gap: 9px; margin-top: 18px; }
.file-picker { height: 42px; display: flex; align-items: center; padding: 0 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); color: var(--muted); font-size: 12px; cursor: pointer; overflow: hidden; }
.file-picker input { display: none; }
.file-picker span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-progress { height: 3px; margin-top: 14px; overflow: hidden; border-radius: 3px; background: var(--surface-strong); opacity: 0; }
.upload-progress.active { opacity: 1; }
.upload-progress span { width: 35%; height: 100%; display: block; background: var(--primary); animation: progress 1.2s ease-in-out infinite alternate; }
@keyframes progress { from { transform: translateX(-100%); } to { transform: translateX(280%); } }

.table-panel { padding: 0; overflow: hidden; }
.table-panel .section-head { margin: 0; padding: 18px 20px; }
.table-wrap { overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { height: 39px; padding: 0 13px; background: var(--surface-soft); color: var(--muted); font-size: 10px; font-weight: 800; text-align: left; white-space: nowrap; }
td { height: 54px; padding: 8px 13px; border-top: 1px solid var(--line); white-space: nowrap; }
tbody tr:hover { background: #fbfcfc; }
td strong, td small { display: block; }
td strong { font-size: 12px; }
td small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.distill-layout, .diagnose-layout, .coach-layout { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 16px; align-items: start; }
.setup-card { position: sticky; top: 100px; }
.stack-form { display: grid; gap: 16px; }
.stack-form small, .inline-form small { color: var(--muted); font-size: 10px; line-height: 1.55; }
.progress-line { width: 190px; height: 5px; margin-top: 7px; overflow: hidden; border-radius: 5px; background: var(--surface-strong); }
.progress-line span { height: 100%; display: block; border-radius: inherit; background: var(--primary); }
.task-meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 10px; }

.centered-empty { min-height: 300px; display: grid; place-content: center; justify-items: center; padding: 38px; text-align: center; }
.centered-empty h3 { margin-bottom: 8px; font-size: 16px; }
.centered-empty p { max-width: 480px; margin-bottom: 18px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.dna-summary { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, .7fr); gap: 30px; align-items: center; margin-bottom: 22px; }
.dna-summary h2 { margin-bottom: 8px; font-size: 25px; }
.dna-summary p:not(.eyebrow) { color: var(--muted); font-size: 13px; line-height: 1.75; }
.evidence-strip { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.evidence-strip span { padding: 5px 8px; border-radius: 5px; background: var(--surface-soft); color: var(--muted); font-size: 10px; }
.skill-radar { display: grid; gap: 10px; }
.skill-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) 34px; align-items: center; gap: 9px; font-size: 11px; }
.skill-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-track { height: 7px; overflow: hidden; border-radius: 7px; background: var(--surface-strong); }
.score-track i { height: 100%; display: block; border-radius: inherit; background: var(--primary); }
.content-section { margin-bottom: 22px; }
.dna-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.dna-card { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.dna-number { width: 27px; height: 27px; display: grid; place-items: center; margin-bottom: 13px; border-radius: 7px; background: var(--primary-soft); color: var(--primary); font-size: 10px; font-weight: 850; }
.dna-card h3 { margin-bottom: 7px; font-size: 14px; }
.dna-card > p { min-height: 42px; color: var(--muted); font-size: 11px; line-height: 1.65; }
.dna-card dl { display: grid; gap: 9px; margin: 14px 0 0; padding-top: 13px; border-top: 1px solid var(--line); }
.dna-card dt { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.dna-card dd { margin: 3px 0 0; font-size: 11px; line-height: 1.55; }
.behavior-list { margin: 4px 0 0; padding-left: 16px; }
.behavior-list li { margin: 4px 0; }
.sales-flow { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(210px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 5px; }
.flow-stage { position: relative; padding: 15px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.flow-stage:not(:last-child)::after { content: "→"; position: absolute; right: -10px; top: 17px; z-index: 1; color: var(--primary); font-weight: 850; }
.flow-stage > span { color: var(--primary); font-size: 9px; font-weight: 850; }
.flow-stage h3 { margin: 5px 0 7px; font-size: 13px; }
.flow-stage p, .flow-stage li { color: var(--muted); font-size: 10px; line-height: 1.55; }
.flow-stage ul { margin: 7px 0; padding-left: 15px; }
.objection-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.objection-card { padding: 15px; border: 1px solid var(--line); border-radius: 8px; }
.objection-card h3 { margin-bottom: 7px; font-size: 13px; }
.objection-card p { margin-bottom: 8px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.objection-card blockquote { margin: 10px 0 0; padding: 10px 12px; border-left: 3px solid var(--primary); background: var(--surface-soft); font-size: 11px; line-height: 1.6; }

.result-panel { min-height: 460px; }
.result-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.result-header h2 { margin-bottom: 6px; font-size: 18px; }
.result-header p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.big-score { width: 65px; height: 65px; flex: 0 0 auto; display: grid; place-items: center; border: 6px solid var(--primary-soft); border-radius: 50%; color: var(--primary); font-size: 20px; font-weight: 850; }
.result-section { margin-top: 18px; }
.result-section h3 { margin-bottom: 10px; font-size: 13px; }
.compare-list { display: grid; gap: 10px; }
.compare-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) 48px; align-items: center; gap: 9px; font-size: 10px; }
.compare-bars { display: grid; gap: 3px; }
.compare-bars i { height: 5px; display: block; border-radius: 5px; background: var(--primary-soft); }
.compare-bars i:last-child { background: var(--primary); }
.gap-card, .reply-card, .plan-row { padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); }
.gap-card + .gap-card, .reply-card + .reply-card, .plan-row + .plan-row { margin-top: 8px; }
.gap-card h4, .reply-card h4 { margin: 0 0 5px; font-size: 12px; }
.gap-card p, .reply-card p, .plan-row p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.reply-card blockquote { margin: 8px 0; font-size: 12px; line-height: 1.7; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-list span { padding: 5px 8px; border-radius: 99px; background: var(--surface-strong); color: var(--muted); font-size: 10px; }

.training-setup { margin-bottom: 16px; }
.inline-form { display: flex; align-items: flex-end; gap: 10px; }
.inline-form label { min-width: 240px; display: grid; gap: 6px; }
.inline-form .grow { flex: 1; }
.training-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.scenario-card { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.scenario-card > span { color: var(--primary); font-size: 9px; font-weight: 850; letter-spacing: .1em; }
.scenario-card h3 { margin: 6px 0 8px; font-size: 14px; }
.scenario-card p { color: var(--muted); font-size: 11px; line-height: 1.65; }
.scenario-opening { padding: 11px; border-left: 3px solid var(--primary); background: var(--surface-soft); color: var(--text) !important; }
.rubric { margin: 10px 0 0; padding: 10px 0 0 17px; border-top: 1px solid var(--line); }
.rubric li { margin: 5px 0; color: var(--muted); font-size: 10px; }
.full-span { grid-column: 1 / -1; }

.preview-dialog { width: min(850px, calc(100vw - 36px)); max-height: calc(100vh - 36px); padding: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; box-shadow: var(--shadow); }
.preview-dialog::backdrop { background: rgb(7 19 15 / 55%); }
.dialog-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); background: #fff; }
.dialog-head h2 { margin: 0; font-size: 17px; }
.dialog-head .icon-button { color: var(--muted); }
.dialog-head .icon-button:hover { background: var(--surface-strong); }
.preview-content { display: grid; gap: 10px; padding: 18px 20px 24px; }
.preview-item { padding: 13px; border: 1px solid var(--line); border-radius: 7px; }
.preview-meta { display: flex; gap: 12px; margin-bottom: 8px; color: var(--muted); font-size: 10px; }
.preview-item pre { max-height: 150px; overflow: auto; margin: 0; color: #43514c; font: 10px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dna-grid, .training-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .login-screen { grid-template-columns: 1fr; padding: 90px 20px 30px; }
  .login-card { grid-column: 1; max-width: 480px; justify-self: center; }
  .login-brand { top: 22px; left: 24px; }
  .app-shell { display: block; }
  .sidebar { transform: translateX(-100%); box-shadow: 20px 0 50px rgb(0 0 0 / 20%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main { width: 100%; }
  .mobile-menu { display: grid; }
  .topbar { padding: 0 16px; }
  .page { padding: 18px 16px 36px; }
  .global-message { margin: 14px 16px 0; }
  .distill-layout, .diagnose-layout, .coach-layout { grid-template-columns: 1fr; }
  .setup-card { position: static; }
  .dna-summary { grid-template-columns: 1fr; }
  .upload-form { grid-template-columns: 1fr; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .inline-form label { min-width: 0; }
}

@media (max-width: 580px) {
  .login-card { padding: 25px 20px; }
  .hero-panel { align-items: stretch; flex-direction: column; padding: 22px; }
  .hero-panel .primary { align-self: flex-start; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { padding: 14px; }
  .metric-card strong { font-size: 23px; }
  .dna-grid, .training-grid, .objection-grid { grid-template-columns: 1fr; }
  .page-intro.with-control { align-items: stretch; flex-direction: column; }
  .model-select { width: 100%; }
  .topbar-meta { display: none; }
  .upload-copy { align-items: flex-start; }
}
