.ai-actions { min-width: 0; }
.ai-actions__count { white-space: nowrap; }
.ai-actions__count, .ai-muted { color: var(--text-secondary, #68736c); font-size: 12px; }
.ai-actions__filters { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.ai-actions__filters label:first-child { flex: 1; }
.ai-actions__filters input, .ai-actions__filters select { width: 100%; min-height: 40px; border: 1px solid var(--border-color, #dce4de); border-radius: var(--radius-sm, 8px); padding: 9px 12px; font: inherit; background: var(--surface-primary, #fff); color: inherit; }
.ai-actions__filters label { min-width: 0; }
.ai-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.ai-actions__groups { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ai-action-group { min-width: 0; backdrop-filter: none; box-shadow: none; border: 1px solid var(--brand-border); background: var(--surface-card); padding: 18px; }
.ai-action-group:hover { border-color: var(--brand-green); }
.ai-actions__groups { align-items: start; }
.ai-action-group > summary { display: flex; align-items: center; gap: 10px; list-style: none; cursor: pointer; min-height: 32px; }
.ai-action-group > summary::-webkit-details-marker { display: none; }
.ai-action-group h3 { flex: 1; min-width: 0; margin: 0; font: 600 13px/1.5 var(--font-heading); overflow-wrap: anywhere; }
.ai-action-group__icon { display: flex; color: var(--brand-green-dark); flex: 0 0 36px; width: 36px; height: 36px; align-items: center; justify-content: center; border-radius: 10px; background: var(--brand-green-soft); }
.ai-action-group svg { display: block; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ai-action-group__count { color: var(--brand-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.ai-action-group__chevron { color: var(--brand-muted); flex-shrink: 0; }
.ai-action-group__chevron svg { width: 14px; height: 14px; }
.ai-action-group[open] > summary .ai-action-group__chevron { transform: rotate(180deg); }
.ai-action-group__list { list-style: none; padding: 3px; margin: 14px -8px -8px; max-height: min(360px, 50dvh); overflow-y: auto; overscroll-behavior: contain; }
.ai-action-group__list li + li { border-top: 1px solid var(--brand-border); }
.ai-action-link { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 8px; background: none; border: 0; border-radius: 8px; cursor: pointer; font: inherit; text-align: left; color: var(--brand-ink); }
.ai-action-link:hover { background: var(--brand-green-soft); }
.ai-action-link__body { flex: 1; min-width: 0; }
.ai-action-link__title { font-size: 12px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.ai-action-link--inherited .ai-action-link__title { font-weight: 400; }
.ai-action-link:focus-visible, .ai-action-group > summary:focus-visible, .ai-editor button:focus-visible, .ai-actions input:focus-visible, .ai-actions select:focus-visible { outline: 2px solid var(--brand-green-dark); outline-offset: 3px; }
.ai-action-subline { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 4px; font-size: 11px; font-weight: 400; line-height: 1.5; color: var(--brand-muted); overflow-wrap: anywhere; }
.ai-draft-dot { display: inline-flex; gap: 5px; align-items: center; color: #866319; }
.ai-draft-dot::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.ai-action-version { color: var(--brand-muted); font-size: 11px; font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 1199px) { .ai-actions__groups { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ai-actions__empty { padding: 40px 16px; text-align: center; color: var(--text-secondary, #68736c); }
.ai-actions__status { margin: 10px 0; font-size: 13px; }
.ai-actions__status[data-error=true] { color: #a23e36; }
.ai-editor { position: fixed; inset: 0; margin: auto; width: min(920px, calc(100% - 48px)); height: min(920px, calc(100dvh - 48px)); max-width: 100%; max-height: 100dvh; padding: 0; border: 1px solid var(--brand-border); border-radius: var(--radius-shell, 24px); background: var(--surface-primary, #fff); color: var(--brand-ink); box-shadow: var(--brand-shadow); }
.ai-editor::backdrop { background: #16281d55; backdrop-filter: blur(3px); }
.ai-editor[open] { display: flex; flex-direction: column; }
.ai-editor__header { padding: 22px 28px; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--border-color, #e6ebe7); }
.ai-editor__header h2 { margin: 5px 0 0; font-size: 21px; line-height: 1.35; }
.ai-editor__header button { flex: 0 0 auto; }
.ai-editor__body { flex: 1; min-height: 0; overflow-y: auto; padding: 24px 28px; overscroll-behavior: contain; }
.ai-editor__description { margin: 0; color: var(--text-secondary, #68736c); line-height: 1.6; font-size: 13px; }
.ai-editor__field { display: flex; flex-direction: column; gap: 8px; margin: 0 0 22px; font-size: 13px; font-weight: 600; }
.ai-editor__field select, .ai-editor__field input, .ai-editor__field textarea { width: 100%; box-sizing: border-box; border: 1px solid var(--border-color, #dce4de); border-radius: var(--radius-sm, 8px); padding: 11px 12px; color: inherit; background: var(--surface-primary, #fff); font: inherit; font-weight: 400; }
.ai-editor__field textarea { min-height: 240px; resize: vertical; line-height: 1.65; font-family: var(--font-body, 'Open Sans', sans-serif); font-size: 13px; tab-size: 2; }
.ai-editor__field textarea[data-ai-system] { min-height: 160px; }
.ai-editor__label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ai-editor__field small { font-size: 11px; font-weight: 400; color: var(--text-secondary, #68736c); }
.ai-editor details { border-top: 1px solid var(--border-color, #e6ebe7); padding: 14px 0; font-size: 13px; }
.ai-editor summary { cursor: pointer; font-weight: 600; }
.ai-editor details > :not(summary) { margin-top: 14px; }
.ai-editor__footer { padding: 16px 28px; border-top: 1px solid var(--border-color, #e6ebe7); background: var(--surface-primary, #fff); }
.ai-editor__actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.ai-editor__notice { font-size: 12px; margin: 0 0 12px; line-height: 1.5; color: var(--text-secondary, #68736c); }
.ai-editor__notice:empty { display: none; }
.ai-editor__notice[data-error=true] { color: #a23e36; }
.ai-editor__checks { list-style: none; padding: 0; margin: 16px 0; }
.ai-editor__checks li { padding: 7px 0; font-size: 12px; }
.ai-editor__checks li::before { content: '✓'; color: var(--brand-primary, #267646); display: inline-block; width: 22px; }
.ai-editor__checks li[data-passed=false]::before { content: '○'; color: #a23e36; }
.ai-editor__checks small { display: block; margin: 5px 0 0 22px; color: var(--text-secondary, #68736c); }
.ai-editor__history { list-style: none; padding: 0; }
.ai-editor__history li { display: flex; gap: 14px; justify-content: space-between; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border-color, #e6ebe7); }
.ai-editor__history p { margin: 4px 0; font-size: 12px; overflow-wrap: anywhere; }
.ai-editor__history button { flex: 0 0 auto; }
.ai-editor__diff { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ai-editor__diff pre { margin: 7px 0 0; padding: 12px; background: var(--surface-secondary, #f5f7f5); border-radius: var(--radius-sm, 8px); font: 12px/1.6 var(--font-body, sans-serif); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 330px; overflow: auto; }
.ai-editor__confirm { padding: 14px; background: var(--surface-secondary, #f5f7f5); border-radius: var(--radius-sm, 8px); margin-bottom: 14px; font-size: 13px; line-height: 1.6; }
@media (max-width: 680px) {
 .ai-actions__filters { flex-direction: column; align-items: stretch; gap: 8px; }
 .ai-actions__groups { grid-template-columns: minmax(0, 1fr); }
 .ai-editor__header { padding: 18px 16px 14px; }
 .ai-editor__header h2 { font-size: 18px; }
 .ai-editor__body { padding: 18px 16px; }
 .ai-editor__footer { padding: 12px 16px max(12px, env(safe-area-inset-bottom)); }
 .ai-editor__actions { justify-content: stretch; }
 .ai-editor__actions button { flex: 1; }
 .ai-editor__diff { grid-template-columns: 1fr; }
 .ai-editor__field textarea { min-height: 230px; }
}

.ai-inventory { margin: 20px 0 0; border-top: 1px solid var(--brand-border); padding-top: 16px; font-size: 13px; }
.ai-codex-auth { border: 1px solid var(--brand-border); border-radius: 12px; background: var(--surface-card); padding: 16px; margin-bottom: 16px; font-size: 13px; }
.ai-codex-auth__head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.ai-codex-auth h3 { margin: 0; font: 600 14px var(--font-heading); }
.ai-codex-auth__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.ai-codex-auth__device { border-top: 1px solid var(--brand-border); margin-top: 12px; padding-top: 4px; }
.ai-codex-auth__device code { display: inline-block; font-size: 20px; letter-spacing: 2px; margin: 0 12px 12px 0; overflow-wrap: anywhere; }
.ai-codex-auth__link { margin: 8px 0 12px; min-width: 0; }
.ai-codex-auth__link a { display: block; max-height: 3.6em; overflow: auto; overflow-wrap: anywhere; color: var(--brand-green-dark); }
.ai-claude-auth__code { display: grid; gap: 4px; margin: 12px 0 8px; max-width: 360px; }
.ai-claude-auth__code input { min-width: 0; width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--brand-border); border-radius: 8px; background: var(--surface-card); font: 14px var(--font-body); }
@media (max-width: 600px) { .ai-codex-auth__actions { width: 100%; margin-left: 0; } .ai-codex-auth .v2-button { min-height: 44px; } }
.ai-inventory > summary { display: flex; gap: 12px; align-items: center; cursor: pointer; list-style: none; padding: 4px 0; }
.ai-inventory summary::-webkit-details-marker { display: none; }
.ai-inventory > summary strong { font: 600 14px var(--font-heading); }
.ai-inventory__icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 34px; height: 34px; border-radius: 9px; background: var(--brand-green-soft); color: var(--brand-green-dark); }
.ai-inventory svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ai-inventory__total { padding: 3px 8px; background: var(--surface-muted); border-radius: 6px; color: var(--brand-muted); font-size: 12px; }
.ai-inventory__toggle { margin-left: auto; color: var(--brand-muted); font-size: 20px; }
.ai-inventory[open] > summary .ai-inventory__toggle { font-size: 0; }
.ai-inventory[open] > summary .ai-inventory__toggle::after { content: '−'; font-size: 20px; }
.ai-inventory__toolbar { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin: 16px 0; font-size: 12px; }
.ai-inventory__sections { margin-top: 18px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; align-items: start; }
.ai-inventory__section { min-width: 0; }
.ai-inventory__section h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font: 600 12px var(--font-heading); }
.ai-inventory__section h3 > span { color: var(--brand-muted); font: 400 11px var(--font-body); }
.ai-inventory__provider { border: 1px solid var(--brand-border); border-radius: 12px; margin: 8px 0; background: var(--surface-card); }
.ai-inventory__provider > summary { display: flex; align-items: center; gap: 10px; padding: 14px; cursor: pointer; list-style: none; }
.ai-inventory__identity { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ai-inventory__identity strong { font-size: 12px; }
.ai-inventory__identity small { display: block; font-size: 10px; color: var(--brand-muted); margin-top: 4px; }
.ai-inventory__availability { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; color: #996821; }
.ai-inventory__availability[data-healthy="true"] { color: var(--brand-green-dark); }
.ai-inventory__availability svg { width: 14px; height: 14px; flex-shrink: 0; }
.ai-inventory__model-count { min-width: 35px; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; }
.ai-inventory__model-count small { display: block; color: var(--brand-muted); font-size: 9px; }
.ai-inventory__chevron { color: var(--brand-muted); display: flex; }
.ai-inventory__chevron svg { width: 12px; height: 12px; }
.ai-inventory__provider[open] > summary .ai-inventory__chevron { transform: rotate(180deg); }
.ai-inventory__provider-body { padding: 0 14px 12px; }
.ai-inventory__models { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 14px; list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; overscroll-behavior: contain; }
.ai-inventory__models li { min-width: 0; padding: 10px 0; border-top: 1px solid var(--brand-border); overflow-wrap: anywhere; }
.ai-inventory__models code { display: block; margin-top: 3px; font: 10px/1.5 var(--font-body); color: var(--brand-muted); }
.ai-inventory__models small { display: inline-block; font-size: 10px; margin-top: 4px; color: var(--brand-muted); }
.ai-inventory__error { color: #996821; font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
.ai-inventory__note { color: var(--brand-muted); font-size: 11px; line-height: 1.6; margin: 16px 0 0; }
.ai-inventory summary:focus-visible { outline: 2px solid var(--brand-green-dark); outline-offset: 3px; border-radius: 8px; }
.ai-billing { font-size: .72rem; color: var(--brand-muted); }
@media(max-width:900px) { .ai-inventory__sections { grid-template-columns: 1fr; gap: 14px; } }
@media(max-width:680px) {
 .ai-inventory__toolbar { align-items: flex-start; }
 .ai-inventory__provider > summary { flex-wrap: wrap; gap: 8px; padding: 12px; }
 .ai-inventory__identity { flex-basis: calc(100% - 84px); }
 .ai-inventory__availability { margin-left: 42px; flex: 1; }
 .ai-inventory__models { grid-template-columns: 1fr; }
 .ai-actions__filters > .ai-actions__count { font-size: 11px; }
 .ai-actions__filters > label:nth-child(2) { grid-column: 1 / -1; }
}

/* Popover top layer keeps help outside the scrollable action list's clipping. */
.ai-action-help {
 position: fixed; inset: auto; margin: 0; box-sizing: border-box;
 width: min(380px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); overflow: auto;
 padding: 16px 18px; border: 1px solid var(--brand-border); border-radius: var(--radius-sm, 8px);
 background: var(--surface-primary, #fff); color: var(--brand-ink);
 box-shadow: 0 8px 28px #12261b1c; font: 12px/1.65 var(--font-body, 'Open Sans', sans-serif);
 overflow-wrap: anywhere;
}
.ai-action-help strong { font-size: 13px; font-weight: 600; }
.ai-action-help p { margin: 7px 0 0; }

/* Follow the Dashboard hierarchy within this Admin section only. */
.v2-shell:has([data-v2-admin-mode="ai-models"] .ai-actions) .v2-shell__header {
 position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); padding: 0; margin: -1px;
}
.ai-editor__eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--brand-muted); font-size: 11px; }
.ai-editor__version { padding: 3px 8px; border-radius: 6px; background: var(--brand-green-soft); color: var(--brand-green-dark); }
.ai-editor .ai-editor__about { border: 0; padding: 0 0 18px; }
.ai-editor__about summary { color: var(--brand-muted); font-size: 12px; font-weight: 400; }
.ai-editor__about .ai-editor__description { margin: 10px 0 0; }
.ai-editor__disclosure > summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; list-style: none; padding: 2px 0; }
.ai-editor__disclosure > summary::-webkit-details-marker { display: none; }
.ai-editor__disclosure > summary::after { content: '+'; color: var(--brand-muted); font-size: 18px; font-weight: 400; }
.ai-editor__disclosure[open] > summary::after { content: '−'; }
.ai-editor__disclosure > summary > span:first-child { flex: 1; }
.ai-editor__disclosure summary small { display: block; color: var(--brand-muted); font: 400 11px/1.6 var(--font-body); margin-top: 3px; }
.ai-editor__disclosure p { line-height: 1.65; }
.ai-editor__change { margin: 18px 0; }
.ai-editor__change h3 { font: 600 13px var(--font-heading); margin: 0 0 10px; }
.ai-editor__diff-label { color: var(--brand-muted); font-size: 11px; }
.ai-editor__diff > div { min-width: 0; }
.ai-editor__diff > div:last-child pre { background: var(--brand-green-soft); }
.ai-editor__unchanged { color: var(--brand-muted); font-size: 12px; }
.ai-editor summary:focus-visible, .ai-editor textarea:focus-visible, .ai-editor select:focus-visible, .ai-editor input:focus-visible { outline: 2px solid var(--brand-green-dark); outline-offset: 2px; }
.ai-action-subline .ai-billing { padding: 1px 6px; border-radius: 4px; background: var(--surface-muted); font-size: 10px; }
.ai-action-subline .ai-billing:is([data-billing="cli"],[data-billing="free"],[data-billing="local"],[data-billing="subscription"]) { color: var(--brand-green-dark); background: var(--brand-green-soft); }
.ai-editor__footer .v2-button { min-height: 38px; }
@media (max-width: 680px) {
 .ai-editor { width: 100%; height: 100dvh; border-radius: 0; border: 0; }
 .ai-actions__filters { display: grid; grid-template-columns: minmax(0,1fr) auto; }
 .ai-actions__filters label:first-child { grid-column: 1 / -1; }
 .ai-editor__label-row { flex-wrap: wrap; }
 .ai-editor__disclosure > summary > .ai-muted { font-size: 10px; }
 .ai-editor__footer .v2-button { min-width: 0; padding: 8px; font-size: 10px; }
 .ai-editor__footer .ai-editor__actions { flex-wrap: nowrap; }
}

/* An expanded group uses the row, keeping action lists out of empty columns. */
@media (min-width: 681px) {
 .ai-action-group[open] { grid-column: 1 / -1; }
 .ai-action-group[open] .ai-action-group__list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 18px; }
 .ai-action-group__list li + li { border-top: 0; }
 .ai-action-group__list li { border-bottom: 1px solid var(--brand-border); }
}
@media (min-width: 681px) and (max-width: 1199px) {
 .ai-action-group[open] .ai-action-group__list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
