/* Public components: panels, toolbars, forms, tabs, tables, menus and feedback. */
.panel,.settings-block { min-width: 0; padding: 24px; border: 1px solid var(--line); border-radius: var(--panel-radius); background: var(--surface); }
.panel + .panel,.settings-block + .settings-block { margin-top: 24px; }
.panel .panel,.panel .settings-block { padding: 16px; }
.panel-head,.overview-panel-head,.list-panel-head,.ai-schemes-toolbar,.section-row,.modal-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; min-width: 0; }
.panel-head > div,.list-panel-heading { min-width: 0; }
.panel-head p,.overview-panel-head p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.ai-schemes-actions,.button-group,.action-row,.list-row-actions,.filter-actions,.modal-action-group,.list-panel-actions,.account-footer-actions,.ai-scheme-tool-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.button-group.compact { gap: 6px; }
.toolbar,.filter-bar,.role-console-toolbar,.runtime-filter-toolbar,.ai-schemes-filters { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar > label,.filter-bar > label,.role-console-toolbar > label { flex: 1 1 160px; }
.search-field { position: relative; min-width: 120px; }
.form-grid,.ai-scheme-grid,.filter-grid,.conversation-policy-grid,.credential-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.form-grid.one-column,.one-column { grid-template-columns: minmax(0,1fr); }
.wide-label,.form-grid > .wide,.filter-grid > .wide { grid-column: 1 / -1; }
.form-grid > label,.ai-scheme-field { min-width: 0; }
.modal-form-section,.modal-section,.settings-form-section { padding-block: 20px; border-bottom: 1px solid var(--line); }
.modal-form-section:first-child,.modal-section:first-child { padding-top: 0; }
.modal-form-section:last-child,.modal-section:last-child { border-bottom: 0; padding-bottom: 0; }
.modal-section-head { margin-bottom: 16px; }
.metrics-grid,.role-metric-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 16px; margin-bottom: 24px; }
.metric-card { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--panel-radius); background: var(--surface); display: grid; align-content: start; gap: 8px; }
.metric-card > span,.metric-card p { color: var(--muted); font-size: 12px; }
.metric-card > strong,.metric-value { font-size: 26px; line-height: 1.25; font-weight: 600; letter-spacing: -.03em; }
.metric-card button { justify-self: start; }
.tabs,.role-console-tabs,.scheduled-mode-tabs,.runtime-mode-tabs,.redemption-mode-tabs,.segmented-control { display: flex; flex-wrap: nowrap; gap: 4px; border-bottom: 1px solid var(--line); max-width: 100%; overflow-x: auto; scrollbar-width: var(--scrollbar-width); margin: 0 0 20px; }
.tabs > button,.tab-button,.scheduled-tab,.runtime-mode-tab,.segmented-control > button { position: relative; flex: 0 0 auto; border: 0; border-radius: 0; background: transparent; color: var(--muted); min-height: 41px; padding: 8px 16px; font-weight: 500; white-space: nowrap; }
.tabs > button:hover:not(:disabled),.tab-button:hover:not(:disabled),.scheduled-tab:hover:not(:disabled),.runtime-mode-tab:hover:not(:disabled),.segmented-control > button:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.tabs > .active,.tab-button.active,.scheduled-tab.active,.runtime-mode-tab.active,.segmented-control > [aria-selected="true"],.tabs > [aria-selected="true"] { color: var(--brand); box-shadow: inset 0 -2px var(--brand); }
.table-wrap,.role-console-table,.ai-schemes-list { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; border: 1px solid var(--line); border-radius: var(--radius); scrollbar-width: var(--scrollbar-width); }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
th,td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; line-height: 1.6; }
th { font-weight: 550; color: var(--muted); background: var(--surface-subtle); font-size: 12px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--hover); }
td small { display: block; }
td .button-group,td.list-row-actions { flex-wrap: nowrap; }
.ui-table-overflow { outline-offset: 2px; }
.ui-table-overflow:focus-visible { outline: 2px solid var(--brand); }
.table-wrap table,.role-console-table table,.ai-schemes-table { min-width: 680px; }
.table-wrap td:last-child,.role-console-table td:last-child { white-space: nowrap; }
.table-pagination,.role-console-pagination,.reply-records-pagination,.ai-schemes-pagination,.overview-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 16px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.table-pagination > div,.role-console-pagination > div,.ai-schemes-pagination > div { display: flex; gap: 8px; }
.status-chip,.policy-status-chip,.status-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; min-height: 24px; border-radius: 999px; background: var(--surface-subtle); color: var(--muted); font-size: 11px; font-weight: 500; line-height: 18px; white-space: nowrap; }
.status-chip:is(.success,.on,.strong-on,.running,.active),.status-badge.success { color: var(--success); background: var(--success-tint); }
.status-chip:is(.warning,.strong-warn,.warn),.status-badge.warning { color: var(--warning); background: var(--warning-tint); }
.status-chip:is(.error,.danger,.failed),.status-badge.error { color: var(--danger); background: var(--danger-tint); }
.status-chip.info { color: var(--brand); background: var(--brand-tint); }
.inline-status { padding: 10px 12px; background: var(--surface-subtle); border-radius: var(--radius); color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.inline-status:empty { display: none; }
.inline-status:is(.error,.danger) { color: var(--danger); background: var(--danger-tint); }
.inline-status.warning { color: var(--warning); background: var(--warning-tint); }
.inline-status.success { color: var(--success); background: var(--success-tint); }
.compact-status { padding: 6px 8px; }
.ai-schemes-empty,.list-empty,.empty-guide,.role-empty-state,.ui-empty-state,.ui-state { min-height: 220px; padding: 40px 24px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; color: var(--muted); text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--panel-radius); background: transparent; font-size: 13px; }
.list-empty:has(> .empty-guide),.list-empty:has(> .ui-state) { padding: 0; border: 0; }
.empty-guide strong,.ui-state-title,.ui-empty-state h3 { color: var(--ink); font-size: 16px; font-weight: 550; }
.empty-guide p,.ui-state-description { max-width: 460px; }
.list-empty button,.empty-guide button,.ui-state button { margin-top: 6px; }
.role-error-state,.page-list-error,.ui-state-error { min-height: 180px; padding: 24px; text-align: center; display: grid; justify-items: center; align-content: center; gap: 12px; border: 1px solid var(--line); border-radius: var(--panel-radius); background: var(--surface); color: var(--danger); }
.page-list-error-message { max-width: 500px; overflow-wrap: anywhere; }
.summary-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.summary-list > div { display: grid; gap: 4px; padding: 12px; background: var(--surface-subtle); border-radius: var(--radius); min-width: 0; overflow-wrap: anywhere; }
.summary-list strong { color: var(--muted); font-size: 12px; font-weight: 450; }
.summary-list span { font-size: 13px; }
.modal-summary-card,.danger-summary,.danger-zone,.account-modal-mode-strip { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-subtle); margin-bottom: 16px; font-size: 13px; overflow-wrap: anywhere; }
.danger-summary,.danger-zone { background: var(--danger-tint); color: var(--danger); }
.modal-summary-card strong,.account-modal-mode-strip strong { display: block; margin-top: 4px; font-size: 12px; }
.disclosure-panel,.modal-disclosure,.ai-scheme-details,.policy-advanced-panel { border: 1px solid var(--line); border-radius: var(--radius); margin-top: 16px; }
summary { cursor: pointer; padding: 12px 14px; font-weight: 550; list-style-position: inside; }
summary::marker { color: var(--muted); }
summary + div,.ai-scheme-detail-body { padding: 0 16px 16px; }
.enhanced-select { position: relative; width: 100%; min-width: 0; }
.enhanced-select-native { position: absolute!important; width: 1px!important; height: 1px!important; padding: 0!important; min-height: 0!important; opacity: 0; pointer-events: none; }
.enhanced-select-button { display: flex; width: 100%; min-width: 0; padding: 8px 12px; justify-content: space-between; color: var(--muted); background: color-mix(in srgb,var(--ink) 1%,var(--surface)); border: 1px solid var(--line); font-weight: 450; text-align: left; }
.enhanced-select-button:hover:not(:disabled) { background: var(--hover); border-color: var(--line-strong); }
.enhanced-select-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.enhanced-select-icon,.searchable-entity-chevron { display: inline-block; flex: 0 0 16px; width: 16px; height: 16px; background: currentColor; mask: url("icons/chevron-down.svg") center / contain no-repeat; color: var(--muted); }
.enhanced-select-menu { display: none; position: fixed; z-index: 12000; flex-direction: column; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; max-width: calc(100vw - 24px); }
.enhanced-select-menu[data-open="true"] { display: flex; }
input.enhanced-select-search { flex-shrink: 0; border: 0!important; border-bottom: 1px solid var(--line)!important; border-radius: 0!important; min-height: 36px!important; margin-bottom: 4px; }
.enhanced-select-options { overflow-y: auto; overscroll-behavior: contain; min-height: 0; padding: 0; }
.enhanced-select-option { position: relative; width: 100%; min-height: 35px; padding: 6px 8px 6px 32px; gap: 8px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); text-align: left; justify-content: flex-start; font-size: 14px; line-height: 22.75px; font-weight: 500; }
.enhanced-select-option-label { min-width: 0; overflow-wrap: anywhere; }
.enhanced-select-option[aria-selected="true"] { background: var(--brand-tint); color: var(--brand); }
.enhanced-select-option .enhanced-select-check { display: none; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; }
.enhanced-select-option[aria-selected="true"] .enhanced-select-check { display: block; }
.enhanced-select-option:hover:not(:disabled),.enhanced-select-option:focus-visible { background: var(--hover); color: var(--brand); outline: none; }
.enhanced-select-menu[data-searchable="true"] .enhanced-select-option { padding-left: 8px; padding-right: 28px; }
.enhanced-select-menu[data-searchable="true"] .enhanced-select-option[aria-selected="true"] { color: var(--ink); background: transparent; }
.enhanced-select-menu[data-searchable="true"] .enhanced-select-check { display: none; }
.enhanced-select-menu[data-searchable="true"] .enhanced-select-option[aria-selected="true"]::before { content: ""; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 8px; height: 8px; background: currentColor; border-radius: 50%; }
.enhanced-select-empty { padding: 20px 12px; color: var(--muted); font-size: 13px; text-align: center; }
.searchable-entity-picker { position: relative; min-width: 0; }
.searchable-entity-input-shell { display: flex; align-items: center; position: relative; }
.searchable-entity-input-shell input { padding-right: 36px!important; }
.searchable-entity-chevron { position: absolute; right: 12px; pointer-events: none; }
.searchable-entity-menu { position: fixed; z-index: 12000; max-height: 300px; overflow: auto; overscroll-behavior: contain; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.searchable-entity-option { display: flex; flex-direction: column; align-items: stretch; width: 100%; min-height: 40px; padding: 8px; border: 0; border-radius: 4px; text-align: left; color: var(--ink); background: transparent; }
.searchable-entity-option:hover:not(:disabled),.searchable-entity-option.active { background: var(--hover); color: var(--brand); }
.searchable-entity-option.selected { background: var(--brand-tint); color: var(--brand); }
.searchable-entity-option small { color: var(--muted); }
.searchable-entity-empty { padding: 16px; color: var(--muted); text-align: center; }
.custom-date-picker,.custom-time-picker { position: relative; min-width: 0; }
.custom-date-button,.custom-time-button { width: 100%; justify-content: space-between; background: var(--surface); color: var(--ink); border-color: var(--line-strong); font-weight: 450; }
.custom-date-button:hover:not(:disabled),.custom-time-button:hover:not(:disabled) { background: var(--hover); }
.custom-date-icon { width: 16px; height: 16px; background: currentColor; mask: url("icons/calendar.svg") center / contain no-repeat; }
.custom-date-menu,.custom-time-menu { display: none; position: fixed; z-index: 12000; overflow: auto; overscroll-behavior: contain; width: 288px; max-width: calc(100vw - 24px); padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface); }
.custom-date-menu[data-open="true"],.custom-time-menu[data-open="true"] { display: block; }
.custom-date-head,.custom-date-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px; }
.custom-date-grid,.custom-date-weekdays { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); text-align: center; gap: 2px; }
.custom-date-weekdays { font-size: 11px; color: var(--muted); padding: 6px 0; }
.custom-date-day,.custom-date-nav,.custom-date-link { padding: 4px; min-height: 32px; color: var(--ink); background: transparent; border: 0; }
.custom-date-day[aria-selected="true"] { background: var(--brand); color: var(--on-brand); }
.custom-date-day[data-today="true"] { box-shadow: inset 0 0 0 1px var(--brand); }
.custom-date-day:hover:not(:disabled),.custom-date-nav:hover:not(:disabled),.custom-date-link:hover:not(:disabled) { background: var(--brand-tint); color: var(--brand); }
.custom-date-day.muted { color: var(--muted); opacity: .5; }
.custom-time-menu { max-height: 250px; width: 100%; overflow: auto; }
.custom-time-option { position: relative; background: transparent; color: var(--muted); width: 100%; text-align: left; justify-content: flex-start; padding-left: 28px; }
.custom-time-option[aria-selected="true"]::before { content: ""; position: absolute; left: 8px; width: 14px; height: 14px; background: currentColor; mask: url("icons/check.svg") center / contain no-repeat; }
.custom-time-icon { width: 16px; height: 16px; background: currentColor; mask: url("icons/clock.svg") center / contain no-repeat; }
.custom-time-option[aria-selected="true"],.custom-time-option:hover:not(:disabled) { background: var(--brand-tint); color: var(--brand); }
.account-action-menu,.ai-persona-action-menu,.ai-persona-action-popover,.row-action-menu { position: fixed; z-index: 12000; width: 200px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; box-shadow: var(--shadow); }
.account-action-menu button,.ai-persona-action-menu button,.ai-persona-action-popover button,.row-action-menu button { width: 100%; justify-content: flex-start; background: transparent; color: var(--ink); border: 0; min-height: 35px; padding: 7px 8px; }
.account-action-menu button:hover:not(:disabled),.ai-persona-action-menu button:hover:not(:disabled),.ai-persona-action-popover button:hover:not(:disabled),.row-action-menu button:hover:not(:disabled) { background: var(--hover); }
.account-action-menu .danger-text,.ai-persona-action-menu .danger-text,.ai-persona-action-popover .danger-text { color: var(--danger); }
.ai-persona-action-menu-title { padding: 8px; color: var(--muted); font-size: 12px; }
.ai-persona-secondary-actions { display: grid; gap: 2px; }
@media(max-width:1000px) { .metrics-grid,.role-metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media(max-width:768px) {
  .panel,.settings-block { padding: 16px; } .panel .panel,.panel .settings-block { padding: 12px; }
  .panel-head,.list-panel-head,.ai-schemes-toolbar { align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
  .toolbar,.filter-bar,.role-console-toolbar,.runtime-filter-toolbar { gap: 10px; }
  .form-grid,.ai-scheme-grid,.filter-grid,.credential-fields { grid-template-columns: minmax(0,1fr); }
  .wide-label { grid-column: auto; }
  .metric-card { padding: 14px; }
  .metric-card > strong { font-size: 24px; }
  .tabs > button,.tab-button,.scheduled-tab,.runtime-mode-tab,.segmented-control > button { min-height: 44px; padding-inline: 12px; }
  .list-empty,.empty-guide { min-height: 200px; padding: 28px 16px; }
  .table-wrap td:last-child,.table-wrap th:last-child,.role-console-table td:last-child,.role-console-table th:last-child { position: sticky; right: 0; background: var(--surface); box-shadow: -1px 0 var(--line); }
  .table-pagination,.role-console-pagination,.reply-records-pagination { align-items: flex-start; }
  .enhanced-select-option { min-height: 44px; }
  .account-action-menu button,.ai-persona-action-menu button,.ai-persona-action-popover button,.row-action-menu button { min-height: 44px!important; }
  .summary-list { grid-template-columns: minmax(0,1fr); }
}

/* Compact card rows preserve table roles and expose every row action on phones. */
@media(max-width:768px) {
  .ai-schemes-table { display: block; min-width: 0; }
  .ai-schemes-table thead { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
  .ai-schemes-table tbody { display: grid; }
  .ai-schemes-table tr { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); padding: 14px; gap: 14px 12px; border-bottom: 1px solid var(--line); }
  .ai-schemes-table td { min-width: 0; border: 0; padding: 0; }
  .ai-schemes-table td:first-child,.ai-schemes-table td:last-child { grid-column: 1 / -1; }
  .ai-schemes-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
  .ai-schemes-actions { flex-wrap: nowrap; gap: 6px; }
  .ai-schemes-actions button { padding-inline: 8px; }
}
