.main-content:has(.ai-page) { padding: 16px 20px 20px; }
.ai-page { display: flex; flex-direction: column; gap: 12px; }
.ai-page .page-header {
    margin-bottom: 0; padding: 12px 16px; border-radius: 14px;
    align-items: center; gap: 12px; flex-wrap: wrap;
}
.ai-page .page-header h2 { font-size: 18px; }
.ai-page .page-header h2 i { width: 32px; height: 32px; border-radius: 10px; font-size: 15px; }
.ai-sub { margin: 4px 0 0; font-size: 12px; color: var(--gray-500); line-height: 1.4; }
.ai-kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
@media (max-width: 900px) { .ai-kpis { grid-template-columns: repeat(2, minmax(0,1fr)); } }
.ai-kpi {
    display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 8px;
    padding: 10px 12px; border-radius: 12px;
    background: var(--surface-strong); border: 1px solid var(--border-soft);
    box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.ai-kpi::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--kpi, #2563eb);
}
.ai-kpi i {
    width: 30px; height: 30px; border-radius: 8px; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    color: var(--kpi, #2563eb);
    background: color-mix(in srgb, var(--kpi, #2563eb) 12%, transparent);
}
.ai-kpi b {
    display: block; font-size: 20px; font-weight: 780; line-height: 1.1;
    font-variant-numeric: tabular-nums; color: var(--gray-900);
}
.ai-kpi em { display: block; font-style: normal; font-size: 12px; color: var(--gray-600); font-weight: 550; }
.ai-board {
    display: grid;
    grid-template-columns: minmax(280px, 380px) minmax(0,1fr);
    gap: 12px;
    min-height: calc(100vh - 268px);
}
@media (max-width: 1100px) { .ai-board { grid-template-columns: 1fr; } }
.ai-pane {
    min-width: 0; min-height: 0;
    display: flex; flex-direction: column;
    background: var(--surface-strong);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.ai-pane.grow { min-height: 460px; }
.ai-pane-h {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 10px 12px; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap;
}
.ai-pane-h h5 { margin: 0; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.ai-pane-b { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.ai-pane.grow .ai-pane-b { flex: 1; min-height: 0; }
.ai-hint {
    margin: 0; font-size: 12px; color: var(--gray-500); line-height: 1.5;
    background: var(--surface-muted); border-radius: 10px; padding: 10px 12px;
}
.ai-hint strong { color: var(--gray-700); font-weight: 650; }
.ai-src {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 650;
    background: rgba(100,116,139,.12); color: #64748b;
}
.ai-src.ai { background: rgba(37,99,235,.12); color: #2563eb; }
.ai-src.local { background: rgba(16,185,129,.12); color: #059669; }
.ai-src.err { background: rgba(239,68,68,.12); color: #dc2626; }
.ai-result {
    position: relative;
    flex: 1; min-height: 360px; overflow: auto;
    background: var(--surface-muted); border: 1px solid var(--border-soft);
    border-radius: 12px; padding: 16px 18px; color: var(--gray-800);
}
.ai-result.is-busy { pointer-events: none; }
.ai-busy {
    display: none; position: absolute; inset: 0;
    align-items: center; justify-content: center; flex-direction: column; gap: 10px;
    background: color-mix(in srgb, var(--surface-strong) 86%, transparent);
    color: var(--gray-600); font-size: 13px; z-index: 2;
}
.ai-result.is-busy .ai-busy { display: flex; }
.ai-md, .ai-output.ai-md, .report-output.ai-md, .analysis-output.ai-md {
    white-space: normal; font-family: inherit; font-size: 13.5px; line-height: 1.7;
}
.ai-md .ai-h, .ai-md h2, .ai-md h3, .ai-md h4 {
    margin: 16px 0 8px; font-size: 14px; font-weight: 750; color: var(--gray-900);
}
.ai-md h2.ai-h { font-size: 16px; }
.ai-md p { margin: 0 0 8px; }
.ai-md .ai-ul { margin: 0 0 10px; padding-left: 18px; }
.ai-md .ai-ul li { margin: 3px 0; }
.ai-md strong { font-weight: 700; }
.ai-md code {
    font-family: 'JetBrains Mono', Consolas, monospace; font-size: 12px;
    background: var(--surface-strong); border: 1px solid var(--border-soft);
    border-radius: 4px; padding: 0 4px;
}
.ai-code {
    background: #0f172a; color: #e2e8f0; border-radius: 10px;
    padding: 12px 14px; overflow: auto; font-size: 12.5px; line-height: 1.6;
    margin: 8px 0 12px;
}
.ai-table-wrap { overflow: auto; margin: 8px 0 12px; }
.ai-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ai-table th, .ai-table td {
    border: 1px solid var(--border-soft); padding: 6px 8px; text-align: left; vertical-align: top;
}
.ai-table th { background: var(--surface-strong); color: var(--gray-600); font-weight: 700; }
.ai-empty { color: var(--gray-400); text-align: center; padding: 40px 12px; }
.ai-score {
    text-align: center; padding: 22px 16px; border-radius: 14px; color: #fff;
    background: linear-gradient(135deg, #64748b, #475569);
}
.ai-score.excellent { background: linear-gradient(135deg, #10b981, #059669); }
.ai-score.good { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.ai-score.warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.ai-score.danger { background: linear-gradient(135deg, #ef4444, #dc2626); }
.ai-score h1 { font-size: 48px; margin: 0; font-weight: 750; }
.ai-score p { margin: 8px 0 0; opacity: .92; font-size: 13px; font-weight: 550; }
.ai-tpl { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-tpl button {
    padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border-soft);
    background: var(--surface); font-size: 12px; cursor: pointer;
    color: var(--gray-600); font-weight: 550;
}
.ai-tpl button:hover { background: #2563eb; color: #fff; border-color: #2563eb; }
.ai-term {
    background: #0f172a; color: #e2e8f0; border-radius: 12px; padding: 16px 18px;
    min-height: 360px; overflow: auto; font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 13px; line-height: 1.7; white-space: pre-wrap; flex: 1;
}
.ai-term.is-busy { color: #94a3b8; font-family: inherit; }
.status-badge {
    padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 650;
}
.status-badge.pending { background: rgba(100,116,139,.12); color: #64748b; }
.status-badge.checking { background: rgba(251,191,36,.14); color: #d97706; }
.status-badge.normal { background: rgba(16,185,129,.12); color: #059669; }
.status-badge.warning { background: rgba(245,158,11,.14); color: #d97706; }
.status-badge.error { background: rgba(239,68,68,.12); color: #dc2626; }
