/* OpsPilot light-theme contrast authority.
   Loaded after every feature stylesheet so dark-theme accent colors cannot
   leak onto white surfaces. Dark theme remains controlled by its existing
   component rules. */

html[data-theme="light"] {
    --light-text-strong: #0f172a;
    --light-text: #1e293b;
    --light-text-secondary: #475569;
    --light-text-muted: #64748b;
    --light-blue: #1d4ed8;
    --light-purple: #6d28d9;
    --light-teal: #0f766e;
    --light-green: #047857;
    --light-amber: #92400e;
    --light-orange: #c2410c;
    --light-red: #b91c1c;
}

html[data-theme="light"] body,
html[data-theme="light"] body :is(
    .workspace,
    .content-stage,
    .content-card,
    .chart-card,
    .table-shell,
    .table-wrap,
    .popup-window__body,
    .detail-drawer__content,
    .ai-assistant__content
) {
    color: var(--light-text);
}

html[data-theme="light"] body :is(input, textarea, select, option) {
    color: var(--light-text-strong) !important;
}

html[data-theme="light"] body :is(input, textarea)::placeholder {
    color: var(--light-text-muted) !important;
    opacity: 1;
}

html[data-theme="light"] body :is(th, caption, legend) {
    color: var(--light-text-strong) !important;
}

html[data-theme="light"] body td {
    color: var(--light-text);
}

html[data-theme="light"] body :is(
    .muted-copy,
    .empty-state,
    .loading-state p,
    .field-help,
    .form-help,
    .helper-text,
    .table-widget__footer,
    .table-widget__rows > span,
    .detail-item__label
) {
    color: var(--light-text-secondary) !important;
}

html[data-theme="light"] body a:not(.primary-button, .danger-button) {
    color: var(--light-blue);
}

html[data-theme="light"] body :is(code, kbd, samp) {
    color: #0f3d63;
}

html[data-theme="light"] body :is(.icon-button, .toolbar-button, .secondary-button):not(.danger, .is-danger) {
    color: #334155;
}

/* Shared semantic text and pills use contrast-safe light-theme tones. */
html[data-theme="light"] body :is(.status-pill.soft, .status-pill.neutral) {
    color: #334155 !important;
}

html[data-theme="light"] body :is(.status-pill.info, .info-text) {
    color: var(--light-blue) !important;
}

html[data-theme="light"] body :is(.status-pill.good, .status-pill.success, .success-text) {
    color: var(--light-green) !important;
}

html[data-theme="light"] body :is(.status-pill.warning, .warning-text) {
    color: var(--light-amber) !important;
}

html[data-theme="light"] body :is(.status-pill.bad, .status-pill.danger, .danger-text, .error-text) {
    color: var(--light-red) !important;
}

html[data-theme="light"] body .notice-card.info {
    color: #164e63 !important;
}

html[data-theme="light"] body .notice-card.success {
    color: #065f46 !important;
}

html[data-theme="light"] body .notice-card.warning {
    color: #78350f !important;
}

html[data-theme="light"] body .notice-card.danger {
    color: #991b1b !important;
}

/* Device Context is a specialist workspace with its own accent palette. */
html[data-theme="light"] body .device-context {
    --context-accent: #4f46e5;
    --context-mint: #047857;
}

html[data-theme="light"] body .context-pill--success {
    color: var(--light-green) !important;
}

html[data-theme="light"] body .context-pill--warning {
    color: var(--light-amber) !important;
}

html[data-theme="light"] body .context-pill--danger {
    color: var(--light-red) !important;
}

html[data-theme="light"] body .context-pill--info {
    color: var(--light-blue) !important;
}

html[data-theme="light"] body .context-alert--error {
    color: #991b1b !important;
    background: #fef2f2;
    border-color: #fecaca;
}

html[data-theme="light"] body .context-alert--success {
    color: #065f46 !important;
    background: #ecfdf5;
    border-color: #a7f3d0;
}

html[data-theme="light"] body .context-button--primary {
    color: #ffffff !important;
}

/* Agentic conversation header, operation badges, quota chips, and controls. */
html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__context-item--operation-rca,
html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__context-item--operation-kb {
    color: var(--light-blue) !important;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    :is(.agentic-message__context-item--operation-change, .agentic-message__context-item--operation-compliance) {
    color: var(--light-teal) !important;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__context-item--execution-hitl {
    color: var(--light-amber) !important;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__context-item--execution-fully_agentic {
    color: var(--light-purple) !important;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__context-item--execution-manual {
    color: var(--light-teal) !important;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__quota-item--chat {
    color: var(--light-blue) !important;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__quota-item--voice {
    color: var(--light-purple) !important;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__quota-item--used-percent {
    color: #4338ca !important;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__quota-item--free-percent-healthy {
    color: var(--light-green) !important;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__quota-item--free-percent-watch {
    color: var(--light-amber) !important;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__quota-item--free-percent-low {
    color: var(--light-orange) !important;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__token-usage {
    color: #3730a3 !important;
    border-color: color-mix(in srgb, #4338ca 42%, var(--border));
    background: color-mix(in srgb, #4f46e5 8%, white);
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__token-usage:is(:hover, :focus-visible, :focus-within) {
    color: #312e81 !important;
    border-color: #4f46e5;
    background: #eef2ff;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__meta-actions button {
    color: var(--light-blue) !important;
    border-color: color-mix(in srgb, var(--light-blue) 38%, var(--border));
    background: color-mix(in srgb, var(--light-blue) 6%, white);
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__meta-actions button:is(:hover, :focus-visible) {
    color: #1e40af !important;
    border-color: #2563eb;
    background: #eff6ff;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__meta-actions button:disabled {
    color: var(--light-text-secondary) !important;
    background: #f1f5f9;
    opacity: 0.78;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    :is(.agentic-operation-toolbar, .agentic-voice-toolbar > label, .agentic-voice-toolbar__status) {
    color: #334155 !important;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    :is(.agentic-operation-toolbar select, .agentic-voice-toolbar select) {
    color: var(--light-text-strong) !important;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-message__content .agentic-structured-reply code {
    color: #0c4a6e !important;
    background: #f0f9ff !important;
}

/* The usage rail derives borders and fills from these darker light-mode
   accents, avoiding pastel-on-white text and icons throughout the header. */
html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"] .agentic-run-metric--model {
    --agentic-metric-tone: #6d28d9;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"] .agentic-run-metric--elapsed,
html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"] .agentic-run-metric--chat {
    --agentic-metric-tone: #1d4ed8;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"] .agentic-run-metric--voice {
    --agentic-metric-tone: #7e22ce;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"] .agentic-run-metric--session {
    --agentic-metric-tone: #92400e;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"] .agentic-run-metric--mode {
    --agentic-metric-tone: #047857;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"] .agentic-run-metric__icon {
    color: var(--agentic-metric-tone) !important;
}

html[data-theme="light"] body .app-shell[data-view-kind="agentic_network"]
    .agentic-run-metric__copy :is(small, strong, em) {
    color: var(--light-text) !important;
}
