/* Stüdyo and Atlas share component styles and provide separate layouts and palettes. */

html[data-theme="atlas"] {
    --canvas: #0b141e; --surface: #142131; --subtle: #1c2d42; --line: #344962;
    --ink: #edf6ff; --muted: #b4c6d9; --accent: #6ee1e2; --on-accent: #102738; --tint: #213d4b;
    --nav: #101a27; --nav-ink: #e1eefb; --title-font: "Bricolage Grotesque", Inter, sans-serif;
    --ui-font: "Instrument Sans", Arial, sans-serif; --shape: 6px; --button-shape: 4px;
    --content-space: 20px; --banner: #142536; --banner-ink: #eaf8ff;
    --panel-shadow: none;
    color-scheme: dark;
}

html[data-theme="studyo"] {
    --canvas: #f0f3fa; --surface: #fff; --subtle: #ebeffa; --line: #d5deee;
    --ink: #1b2b51; --muted: #526482; --accent: #334ac0; --on-accent: #fff; --tint: #e6eaff;
    --nav: #e6ecf9; --nav-ink: #243764; --title-font: "Bricolage Grotesque", Inter, sans-serif;
    --ui-font: "Instrument Sans", Arial, sans-serif; --shape: 20px; --button-shape: 999px;
    --content-space: 32px; --banner: #dce5ff; --banner-ink: #26375d;
    --panel-shadow: 0 8px 25px #354f8214;
    color-scheme: light;
}

html[data-theme] {
    --bg-dark: var(--canvas); --bg-card: var(--surface); --bg-panel: var(--surface); --bg-subtle: var(--subtle);
    --text-main: var(--ink); --text-muted: var(--muted); --primary: var(--accent); --primary-hover: var(--accent);
    --border-color: var(--line); --radius-sm: var(--button-shape); --radius-md: var(--shape); --radius-lg: var(--shape);
    --scrollbar-track: var(--canvas); --scrollbar-thumb: var(--line);
    --theme-page: var(--canvas); --theme-surface: var(--surface); --theme-surface-2: var(--subtle);
    --theme-text: var(--ink); --theme-muted: var(--muted); --theme-border: var(--line);
    --shadow-card: none;
}

[data-theme] body { color: var(--ink); background: var(--canvas); font-family: var(--ui-font); }
[data-theme] :is(h1,h2) { font-family: var(--title-font); }
[data-theme] :is(a,button,input,select,textarea,summary):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[data-theme] .app-header {
    color: var(--nav-ink); background: var(--nav); border-color: var(--line); box-shadow: none;
    padding-inline: clamp(12px, 3vw, 40px);
}
[data-theme] .app-header .logo-text :is(strong,span,em) { color: var(--nav-ink); }
[data-theme] .app-header .logo-text strong { font-family: var(--title-font); font-size: 23px; }
[data-theme] .header-actions :is(a,button), [data-theme] .sidebar-toggle {
    color: var(--nav-ink); background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--button-shape); box-shadow: none;
}
[data-theme] .sidebar-toggle span { background: var(--nav-ink); }
[data-theme] .side-nav {
    color: var(--nav-ink); background: var(--nav); border-color: var(--line); box-shadow: none;
}
[data-theme] .side-nav :is(.nav-home,a,summary) { color: var(--nav-ink); }
[data-theme] .side-nav .nav-home { display: none; }
[data-theme] .side-nav .nav-accordion { background: transparent; border-color: var(--line); border-radius: var(--shape); }
[data-theme] .side-nav .nav-accordion-links a { border-radius: var(--button-shape); }
[data-theme] .side-nav .nav-accordion-links :is(a.active,a:hover) { color: var(--nav-ink); background: var(--tint); border-color: var(--line); }
.office-connection-notice { display: flex; flex-wrap: wrap; gap: .5rem 1rem; justify-content: space-between; margin: 1rem auto; max-width: 1200px; padding: .8rem 1rem; color: var(--nav-ink); background: var(--tint); border: 1px solid var(--line); border-radius: .75rem; }
.office-connection-notice a { color: var(--accent); font-weight: 700; }
[data-theme] .side-nav .nav-accordion-links a b { color: var(--accent); background: var(--subtle); }
[data-theme] .side-nav-foot { border-color: var(--line); color: var(--muted); }
[data-theme] .side-nav-foot small { color: var(--accent); }
[data-theme] .main-content { background: var(--canvas); color: var(--ink); }

/* Apply the shared treatment to every module while retaining its own workflow and tables. */
html[data-theme] .main-content :is([class$="-page"],.console-page) { color: var(--ink); }
html[data-theme] .main-content :is([class$="-hero"],[class*="-hero "],.workspace-heading) {
    color: var(--banner-ink); background: var(--banner); border: 1px solid var(--line);
    border-radius: var(--shape); padding: clamp(17px, 2.2vw, 30px); box-shadow: none;
}
html[data-theme] .main-content :is([class$="-hero"],[class*="-hero "],.workspace-heading) :is(h1,h2,h3,p) { color: var(--banner-ink); }
html[data-theme] .main-content :is([class$="-card"],[class*="-card "],[class$="-panel"],[class*="-panel "],.document-queue,.dashboard-empty-state) {
    color: var(--ink); background: var(--surface); border-color: var(--line);
    border-radius: var(--shape); box-shadow: none;
}
html[data-theme] .main-content :is([class$="-card"],[class*="-card "],[class$="-panel"],[class*="-panel "],.document-queue,.dashboard-empty-state) :is(h1,h2,h3,h4,label) { color: var(--ink); }
html[data-theme] .main-content :is([class$="-card"],[class*="-card "],[class$="-panel"],[class*="-panel "],.dashboard-empty-state) :is(p,small) { color: var(--muted); }
html[data-theme] .main-content :is(input:not([type=checkbox]):not([type=radio]),select,textarea) {
    color: var(--ink); background: var(--surface); border-color: var(--line); border-radius: var(--button-shape);
}
html[data-theme] .main-content :is(.btn,.portal-primary,.portal-secondary,.file-input-label,[class$="-primary"],[class$="-secondary"]) {
    border-radius: var(--button-shape); box-shadow: none;
}
html[data-theme] .main-content :is(.btn-success,.btn-accent,.portal-primary,.file-input-label,[class$="-primary"]) {
    color: var(--on-accent); background: var(--accent); border-color: var(--accent);
}
html[data-theme] .main-content :is(.btn-secondary,.portal-secondary,[class$="-secondary"]) {
    color: var(--ink); background: var(--subtle); border-color: var(--line);
}
html[data-theme] .main-content :is(button:disabled,.btn:disabled) {
    color: var(--muted); background: var(--subtle); border-color: var(--line); opacity: .65;
}
html[data-theme] .main-content table :is(th,td) { border-color: var(--line); }
html[data-theme] .main-content table th { color: var(--ink); background: var(--subtle); }
html[data-theme] .main-content table td { color: var(--ink); }
html[data-theme] .main-content table tr:nth-child(even) td { background: color-mix(in srgb,var(--subtle),transparent 55%); }
html[data-theme] .main-content :is(.eyebrow,.catalog-kicker,.settings-backup-label) { color: var(--accent); }
html[data-theme] .main-content .catalog-stats article {
    color: var(--ink); background: var(--surface); border-color: var(--line); border-radius: var(--shape);
}
html[data-theme] .main-content .catalog-stats article span { color: var(--muted); }
html[data-theme] .main-content .catalog-stats article strong { color: var(--ink); }
html[data-theme] .main-content .catalog-disclosure {
    color: var(--ink); background: var(--surface); border-color: var(--line); border-radius: var(--shape);
}
html[data-theme] .main-content .catalog-disclosure summary small {
    margin-left: 8px; padding: 3px 7px; border-radius: var(--button-shape); color: var(--ink); background: var(--tint);
}
html[data-theme] .main-content :is(.console-metrics article,.console-ticket,.profile-photo-field,.profile-fields label) {
    color: var(--ink); background: var(--surface); border-color: var(--line); border-radius: var(--shape);
}
html[data-theme] .main-content :is(.console-metrics article,.console-ticket) :is(strong,span) { color: var(--ink); }
html[data-theme] .main-content :is(.console-toolbar,.console-form) button[type="submit"] {
    color: var(--on-accent); background: var(--accent); border-color: var(--accent); border-radius: var(--button-shape);
}
html[data-theme] .main-content :is(.console-hero > span,.console-form small) { color: var(--muted); }
html[data-theme] .main-content :is(.settings-loading,.settings-backup-grid > article,.settings-backup-file,.settings-backup-includes > span,
    .settings-control-row,.settings-number,.settings-flow > span,.invoice-order-precedence,.settings-shield) {
    color: var(--ink); background: var(--subtle); border-color: var(--line); border-radius: var(--shape);
}
html[data-theme] .main-content :is(.settings-loading,.settings-flow,.settings-control-row,.settings-backup-file,.settings-shield) :is(strong,small,span) { color: var(--ink); }
html[data-theme] .main-content :is(.settings-icon,.settings-flow b,.settings-server-package span) { color: var(--accent); background: var(--tint); }
html[data-theme] .main-content :is(.settings-invoice-order-save,.settings-backup-download,.settings-backup-validate,.settings-server-package) {
    color: var(--on-accent); background: var(--accent); border-color: var(--accent); border-radius: var(--button-shape); box-shadow: none;
}
html[data-theme] .main-content .settings-server-package :is(strong,small) { color: inherit; }
html[data-theme] .main-content :is(.settings-invoice-order-save,.settings-backup-validate):disabled {
    color: var(--muted); background: var(--subtle); border-color: var(--line); opacity: .75;
}
html[data-theme] .theme-option {
    color: var(--ink); background: var(--surface); border-color: var(--line); border-radius: var(--shape);
}
html[data-theme] .theme-option small { color: var(--muted); }
html[data-theme] .theme-option:is(:hover,.selected) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
html[data-theme] .theme-option b { color: var(--on-accent); background: var(--accent); }
.theme-option.studyo .theme-preview { background: #f0f3fa; }
.theme-option.studyo .theme-preview i:first-child { background: #dce5ff; }
.theme-option.studyo .theme-preview i:nth-child(2) { background: #334ac0; }
.theme-option.studyo .theme-preview i:nth-child(3) { background: #f4dcd7; }
.theme-option.atlas .theme-preview { background: #0b141e; }
.theme-option.atlas .theme-preview i:first-child { background: #1c2d42; }
.theme-option.atlas .theme-preview i:nth-child(2) { background: #6ee1e2; }
.theme-option.atlas .theme-preview i:nth-child(3) { background: #344962; }

/* Invoice workbench. */
html[data-theme] .dashboard-wrapper {
    --work-ink: var(--ink); --work-muted: var(--muted); --work-border: var(--line); --work-primary: var(--accent);
    padding: clamp(14px, 2.5vw, var(--content-space)); background: var(--canvas); color: var(--ink);
}
html[data-theme] .dashboard-wrapper .direction-toggle-group { background: var(--subtle); border-color: var(--line); border-radius: var(--button-shape); }
html[data-theme] .dashboard-wrapper .btn-toggle { color: var(--ink); border-radius: var(--button-shape); }
html[data-theme] .dashboard-wrapper .btn-toggle.active { color: var(--on-accent); background: var(--accent); }
html[data-theme] .dashboard-wrapper .clear-workspace-button { color: var(--ink); background: var(--surface); border-color: var(--line); border-radius: var(--button-shape); }
html[data-theme] .dashboard-wrapper .upload-dropzone {
    color: var(--ink); background: var(--surface); border-color: var(--accent); border-radius: var(--shape);
}
html[data-theme] .dashboard-wrapper .dropzone-content :is(h2,p,svg) { color: var(--ink); }
html[data-theme] .dashboard-wrapper .document-queue-summary h2 { color: var(--ink); }
html[data-theme] .dashboard-wrapper .document-queue-summary h2 span { color: var(--ink); background: var(--subtle); }
html[data-theme] .dashboard-wrapper .document-queue-item { color: var(--ink); background: var(--surface); border-color: var(--line); border-radius: var(--shape); }
html[data-theme] .dashboard-wrapper .document-queue-item.active { border-color: var(--accent); background: var(--tint); }
html[data-theme] .dashboard-wrapper .document-queue-item > span { color: var(--ink); background: var(--subtle); }
html[data-theme] .dashboard-wrapper .document-queue-item small { color: var(--muted); }
html[data-theme] .dashboard-wrapper .document-queue-nav :is(button,span) { color: var(--ink); background: var(--subtle); border-color: var(--line); }
html[data-theme] .dashboard-wrapper :is(.panel-header,.document-viewer-body,.accounting-mode-selector,.mode-info-banner) { color: var(--ink); background: var(--subtle); border-color: var(--line); }
html[data-theme] .dashboard-wrapper .accounting-mode-selector button.active { color: var(--on-accent); background: var(--accent); }
html[data-theme] .dashboard-wrapper .invoice-paper { background: var(--surface); color: var(--ink); border-color: var(--line); border-radius: var(--shape); }
html[data-theme] .dashboard-wrapper .inv-customer { color: var(--ink); background: var(--subtle); border-color: var(--line); }
html[data-theme] .dashboard-wrapper .invoice-paper :is(.inv-header,.inv-totals) { border-color: var(--line); }
html[data-theme] .dashboard-wrapper .classification-table .amount-debit { color: var(--accent); }
html[data-theme] .dashboard-wrapper .classification-table .amount-credit { color: var(--ink); }
html[data-theme] .dashboard-wrapper :is(.panel.left-panel,.panel.right-panel) {
    color: var(--ink); background: var(--surface); border-radius: var(--shape); box-shadow: var(--panel-shadow);
}
html[data-theme] .dashboard-wrapper .invoice-paper .grand-total { color: var(--accent); }
html[data-theme="studyo"] .document-queue-item em.valid { color: #126049; background: #d9f2e4; }
html[data-theme="studyo"] .document-queue-item em.review { color: #764600; background: #ffedc9; }
html[data-theme="studyo"] .document-queue-item em.duplicate { color: #902f3b; background: #fbe2e8; }

/* Authentication, registration and the ofis entry. */
html[data-theme] :is(.auth-only-layout,.rifki-login,.standalone-auth-shell,.office-welcome) { color: var(--ink); background: var(--canvas); }
html[data-theme] .rifki-login :is(.login-intro h1,.login-brand,.login-card h2),
html[data-theme] :is(.standalone-auth-shell,.office-welcome) :is(h1,h2,label) { color: var(--ink); }
html[data-theme] :is(.rifki-login,.standalone-auth-shell,.office-welcome) p { color: var(--muted); }
html[data-theme] .rifki-login .login-card .login-registration { color: var(--muted); }
html[data-theme] .rifki-login .login-intro em { color: var(--accent); background: none; -webkit-text-fill-color: currentColor; }
html[data-theme] :is(.rifki-login,.standalone-auth-shell,.office-welcome) :is(.auth-card,.office-welcome-card) {
    color: var(--ink); background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--shape); box-shadow: none; backdrop-filter: none;
}
html[data-theme] :is(.rifki-login,.standalone-auth-shell) .auth-card :is(input:not([type=checkbox]),select) { color: var(--ink); background: var(--subtle); border-color: var(--line); border-radius: var(--button-shape); }
html[data-theme] .rifki-login .login-card label { color: var(--ink); }
html[data-theme] :is(.rifki-login,.standalone-auth-shell,.office-welcome) :is(.portal-primary,.office-welcome-primary) { color: var(--on-accent); background: var(--accent); border-radius: var(--button-shape); box-shadow: none; }
html[data-theme] :is(.login-registration,.office-welcome-links) a { color: var(--accent); }
html[data-theme] :is(.login-brand,.office-welcome-brand) strong { color: var(--accent); }
html[data-theme] .login-scene { mask-image: none; border-radius: var(--shape); overflow: hidden; }

@media (min-width: 900px) {

    html[data-theme="atlas"] .side-nav { width: 204px; flex-basis: 204px; }
    html[data-theme="atlas"] .rifki-login { grid-template-columns: minmax(0, 680px) minmax(320px, 390px); }
    html[data-theme="studyo"] .side-nav { width: 228px; flex-basis: 228px; margin: 13px 0 13px 13px; border: 1px solid var(--line); border-radius: 24px; }
    html[data-theme="studyo"] .rifki-login { grid-template-columns: minmax(0, 570px) minmax(320px, 460px); }
}

html[data-theme="atlas"] .dashboard-wrapper .workspace-heading { min-height: 84px; padding-block: 14px; border-left: 3px solid var(--accent); }
html[data-theme="atlas"] .main-content :is([class$="-hero"],[class*="-hero "]) { border-left: 3px solid var(--accent); }
html[data-theme="atlas"] .workspace-heading h1 { font-size: clamp(1.55rem,2.7vw,2.2rem); }
html[data-theme="atlas"] :is(.classification-table,.inv-lines-table) { font-size: 11.5px; }
html[data-theme="atlas"] :is(.amount-debit,.amount-credit,.account-code-cell,.document-queue-nav) { font-family: "IBM Plex Mono", monospace; }
html[data-theme="atlas"] .dashboard-wrapper .classification-table :is(th,td) { padding-inline: 7px; }
html[data-theme="atlas"] .dashboard-wrapper .inv-title { color: var(--accent); }
html[data-theme="atlas"] .dashboard-wrapper .doc-badge { color: var(--ink); background: var(--tint); border-color: var(--line); }
html[data-theme="atlas"] .rifki-login { background: radial-gradient(ellipse at 82% 22%,#18384d,transparent 52%),var(--canvas); }
html[data-theme="atlas"] .login-card { border-top: 3px solid var(--accent); }

html[data-theme="studyo"] .dashboard-wrapper .workspace-heading { padding-block: 23px; background: linear-gradient(115deg,#e2e9ff 30%,#f7dcd6); }
html[data-theme="studyo"] .main-content :is([class$="-hero"],[class*="-hero "]) { background: linear-gradient(115deg,#e2e9ff 30%,#f7e5e0); }
html[data-theme="studyo"] .dashboard-wrapper .upload-dropzone { border-style: solid; }
html[data-theme="studyo"] .dashboard-wrapper .direction-toggle-group { border: 0; padding: 3px; }
html[data-theme="studyo"] .dashboard-wrapper .operation-actions { grid-template-columns: 1fr; }
html[data-theme="studyo"] .dashboard-wrapper .document-queue-item { border-radius: 14px; }
html[data-theme="studyo"] .rifki-login { background: radial-gradient(ellipse at 16% 22%,#f9ded5,transparent 49%),radial-gradient(ellipse at 83% 75%,#dde6ff,transparent 55%),var(--canvas); }
html[data-theme="studyo"] .rifki-login .login-card { padding-block: clamp(26px,5vw,55px); box-shadow: 0 20px 70px #233c7822; }

@media (min-width: 1540px) {

    html[data-theme="atlas"] .dashboard-wrapper:has(.document-queue) {
        display: grid; grid-template-columns: minmax(0,1fr) minmax(200px, 228px);
        grid-template-areas: "heading heading" "direction direction" "upload upload" "review queue";
        align-content: start;
    }
    html[data-theme="atlas"] .workspace-heading { grid-area: heading; }
    html[data-theme="atlas"] .dashboard-wrapper .direction-bar { grid-area: direction; }
    html[data-theme="atlas"] .dashboard-wrapper .upload-dropzone { grid-area: upload; }
    html[data-theme="atlas"] .dashboard-wrapper .document-queue { grid-area: queue; align-self: start; }
    html[data-theme="atlas"] .dashboard-wrapper .dual-panel-layout { grid-area: review; }
    html[data-theme="atlas"] .dashboard-wrapper .document-queue-list { flex-direction: column; overflow: visible; }
    html[data-theme="atlas"] .dashboard-wrapper .document-queue-item { min-width: 0; width: 100%; grid-template-columns: 21px minmax(0,1fr); }
    html[data-theme="atlas"] .dashboard-wrapper .document-queue-item em { grid-column: 2; justify-self: start; }
    html[data-theme="atlas"] .dashboard-wrapper .document-queue-summary { flex-wrap: wrap; }
}

@media (min-width: 1420px) {
    html[data-theme="atlas"] .dashboard-wrapper .classification-table { min-width: 0; table-layout: fixed; }
    html[data-theme="atlas"] .classification-table thead th:nth-child(1) { width: 19%; }
    html[data-theme="atlas"] .classification-table thead th:nth-child(2) { width: 32%; }
    html[data-theme="atlas"] .classification-table thead th:nth-child(3),
    html[data-theme="atlas"] .classification-table thead th:nth-child(4) { width: 17%; }
    html[data-theme="atlas"] .classification-table thead th:nth-child(5) { width: 15%; }
    html[data-theme="atlas"] .classification-table tfoot th { font-size: 10px; }
    html[data-theme="atlas"] .classification-table .confidence-badge { padding-inline: 4px; font-size: 10px; }
}

@media (max-width: 760px) {
    html[data-theme] .app-header { padding-inline: 8px; }
    html[data-theme] .app-header .logo-text strong { font-size: 17px; }
    html[data-theme] .app-header .rifki-brand-mark { width: 35px; height: 35px; }
    html[data-theme] .login-intro { border-left: 0; }
}

/* Legacy modules and nested states use the same palette as the application shell. */
html[data-theme="studyo"] {
    --success-ink: #17644d; --success-surface: #e0f3ea; --success-line: #9bceba;
    --warning-ink: #795019; --warning-surface: #fff0d7; --warning-line: #ddbd86;
    --danger-ink: #952d47; --danger-surface: #fbe8ed; --danger-line: #e1a5b4;
}

html[data-theme="atlas"] {
    --success-ink: #a0e8c9; --success-surface: #19382f; --success-line: #437b69;
    --warning-ink: #ffda9f; --warning-surface: #382e21; --warning-line: #856742;
    --danger-ink: #ffc0ca; --danger-surface: #3b2431; --danger-line: #865063;
}

html[data-theme] .main-content :is(.bank-page,.portal-page,.review-page,.company-catalog-page,.duplicate-page,.profit-page,.compliance-page,.coming-soon-module) {
    background: var(--canvas);
    color: var(--ink);
}

html[data-theme] .main-content :is(.z-import,.z-results,.z-summary,.z-report,.rifki-ai-composer,.rifki-customer-menu,
    .account-settings-state,.account-bulk-toolbar,.account-bulk-customer,.account-bulk-result,.account-action-explanation,
    .root-allocation-item,.account-install-summary > div,.account-install-confirm,.rule-precedence,.rule-item,
    .rule-ordering-list article,.business-actions,.business-toolbar,.profit-toolbar,.duplicate-toolbar,
    .duplicate-actions,.duplicate-empty,.review-toolbar,.review-detail,.review-list,.review-approval,.batch-safety,.batch-preview-list article,
    .bank-metrics article,.bank-decision,.bank-transfer-pair,.catalog-empty,.portal-report-switcher,.portal-period-state) {
    color: var(--ink);
    background: var(--surface);
    border-color: var(--line);
    border-radius: var(--shape);
}

html[data-theme] .main-content :is(.rifki-ai-hero .rifki-mode,.rifki-prompt-shell,.rifki-prompt-footer,.rifki-customer-trigger,
    .rifki-customer-menu-head,.rifki-customer-menu-foot,.rule-precedence > div,.rule-match,.review-list-item,.review-section-heading,
    .review-gate-strip > div,.source-tabs,.bank-file span,.bank-review-card > header,.preview-actions,.z-files span,
    .z-identities span,.batch-approval-summary,.batch-safety div,.batch-progress,.duplicate-group header,.coming-soon-scope) {
    color: var(--ink);
    background: var(--subtle);
    border-color: var(--line);
}

html[data-theme] .main-content :is(.rifki-customer-trigger,.review-list-item,.rifki-customer-option,.rule-item,.batch-preview-list article):is(:hover,.open,.active,.selected) {
    color: var(--ink);
    background: var(--tint);
    border-color: var(--accent);
}

html[data-theme] .main-content :is(.rifki-customer-trigger,.rifki-customer-menu,.rifki-mode,.rifki-prompt-shell,.rule-item,.review-list-item) :is(b,strong),
html[data-theme] .main-content :is(.rule-match strong,.root-allocation-item strong,.account-install-summary strong,.review-document-header strong,.z-identities strong,
    .review-section-heading h3,.batch-metrics strong,.z-summary strong,.bank-metrics strong,.batch-safety strong,.coming-soon-module h1) {
    color: var(--ink);
}

html[data-theme] .main-content .rifki-prompt-shell textarea::placeholder,
html[data-theme] .main-content :is(.rifki-mode span,.rifki-prompt-footer span,.rifki-customer-trigger small,
    .rifki-customer-menu small,.rifki-customer-menu-foot strong,.rifki-scope-grid label span,.rifki-field-label,.rifki-customer-trigger i,
    .rule-precedence p,.rule-command-card span,.rule-editor-card label > span,.rule-editor-card label small,.rule-form-help,.rule-item-top span,
    .rule-item footer > span,.rule-ordering-list small,.rule-ordering-list time,.rule-ordering-list em,.rule-match :is(span,b),
    .account-settings-state span,.account-install-summary span,.account-install-hint,.account-install-result span,.root-allocation-item em,
    .batch-title p,.batch-fields label > span,.batch-metrics small,.batch-preview-list small,.batch-preview-list article > span,.batch-table td small,
    .z-fields small,.z-files small,.z-summary span,.z-report-head span,.z-identities span,.bank-empty,.bank-fields small,.bank-metrics span,
    .bank-file span,.catalog-empty,.review-list-item small,.review-list-item span,.review-detail small,.portal-page .table-sub,.coming-soon-module p) {
    color: var(--muted);
}

html[data-theme] .main-content :is(.coming-soon-kicker,.account-settings-kicker,.z-drop span,.z-results header span,
    .z-report-head em,.rule-card-head span,.rule-text-button,.rule-item footer button,.rifki-customer-menu button,.portal-icon-button,
    .portal-profile-action,.review-section-heading .secondary,.rule-back-link,.portal-link) {
    color: var(--accent);
}

html[data-theme] .main-content :is(.rifki-ai-hero h1 em,.rifki-prompt-footer span b) {
    color: var(--accent);
    background: none;
    -webkit-text-fill-color: currentColor;
}

html[data-theme] .main-content :is(.rifki-prompt-mark,.rifki-section-heading > span,.rule-precedence > div span,.batch-title > span,
    .review-section-heading > div > span,.step-number,.coming-soon-icon) {
    color: var(--accent);
    background: var(--tint);
    border-color: var(--line);
    box-shadow: none;
}

html[data-theme] .main-content :is(.batch-back,.rule-back-link,.review-section-heading .secondary,.portal-ghost,.portal-icon-button,.source-tabs button,
    .portal-report-switcher button,.console-tabs button,.catalog-secondary,.account-secondary) {
    color: var(--ink);
    background: var(--subtle);
    border-color: var(--line);
    border-radius: var(--button-shape);
}

html[data-theme] .main-content :is(.direction-action,.source-tabs button,.portal-report-switcher button,.console-tabs button):is(.active,[aria-selected="true" i],[aria-pressed="true" i]) {
    color: var(--on-accent);
    background: var(--accent);
    border-color: var(--accent);
}

html[data-theme] .main-content :is(.direction-action:not(.active),.rifki-customer-option.all) {
    color: var(--ink);
    background: var(--subtle);
    border-color: var(--line);
}

html[data-theme] .main-content :is(.direction-action,.portal-icon-button,.console-tabs button) :is(span,strong) { color: inherit; }
html[data-theme] .main-content :is(.rifki-prompt-footer button,.rifki-customer-menu-foot button,.bank-fields button,.rule-primary,
    .z-fields button,.z-results .prepare,.account-install-button,.account-zirve-read,.catalog-primary) {
    color: var(--on-accent);
    background: var(--accent);
    border-color: var(--accent);
    border-radius: var(--button-shape);
    box-shadow: none;
}

/* The older Z report rules declare both button colors as important. */
html[data-theme] .main-content :is(.z-fields button,.z-results .prepare) {
    color: var(--on-accent) !important;
    background: var(--accent) !important;
}

html[data-theme] .main-content :is(.z-fields button,.z-results .prepare,.rifki-prompt-footer button,.bank-fields button,.rule-primary):disabled {
    color: var(--muted) !important;
    background: var(--subtle) !important;
    border-color: var(--line);
}

html[data-theme] .main-content :is(.z-fields label,.bank-fields label,.duplicate-toolbar label,.profit-toolbar label,
    .review-toolbar label,.batch-fields label,.business-toolbar label,.account-action-explanation) { color: var(--ink); }

html[data-theme] .main-content :is(.account-catalog-table thead,.review-table thead,.bank-table thead) { background: var(--subtle); }
html[data-theme] .main-content :is(.review-table,.bank-table,.batch-table) td { color: var(--ink); }

html[data-theme] .main-content :is(.account-install-badge,.account-settings-state.warning strong,.batch-notice,.batch-confirm.danger,.batch-status.attention,
    .business-metrics .review,.z-issues,.review-message.warning,.account-code-status.missing,.rule-item > small) {
    color: var(--warning-ink);
    background: var(--warning-surface);
    border-color: var(--warning-line);
}

html[data-theme] .main-content :is(.z-message,.batch-status.done,.batch-notice.success,.batch-confirm:not(.danger),.account-install-result,
    .account-settings-state.ready strong,.yes-no.yes,.rule-item-top i,.coming-soon-module > strong,.preview-actions .balanced) {
    color: var(--success-ink);
    background: var(--success-surface);
    border-color: var(--success-line);
}

html[data-theme] .main-content :is(.z-message.error,.z-issues.blocking,.rule-delete-confirm,.yes-no.no,.portal-danger,.preview-actions .unbalanced) {
    color: var(--danger-ink);
    background: var(--danger-surface);
    border-color: var(--danger-line);
}

html[data-theme] .main-content :is(.rule-delete-confirm strong,.rule-delete-confirm span,.rule-item footer button.danger) { color: var(--danger-ink); }
html[data-theme] .main-content :is(.rule-item.inactive i,.batch-status.queued) { color: var(--muted); background: var(--subtle); }
html[data-theme] .main-content :is(.batch-title em,.batch-hero h1 em,.catalog-kicker,.console-form small,.profile-fields label > span) { color: var(--accent); }
html[data-theme] .main-content :is(.profile-fields label,.console-card) :is(p,small) { color: var(--muted); }

html[data-theme] .platform-console {
    --console-ink: var(--ink);
    --console-muted: var(--muted);
    --console-accent: var(--accent);
    --console-line: var(--line);
}

html[data-theme] .platform-console :is(.console-reply,.console-events li) {
    color: var(--ink);
    background: var(--subtle);
}

html[data-theme] .platform-console :is(.console-ticket[aria-pressed="true" i],.console-badge) {
    color: var(--ink);
    background: var(--tint);
}

html[data-theme] .main-content :is(.console-alert,.profile-message.error,.dashboard-operation-message.error) {
    color: var(--danger-ink);
    background: var(--danger-surface);
    border-color: var(--danger-line);
}

html[data-theme] .main-content :is(.console-notice,.profile-message.success,.dashboard-operation-message:not(.error)) {
    color: var(--success-ink);
    background: var(--success-surface);
    border-color: var(--success-line);
}

html[data-theme] .main-content :is(.profile-card header > div:last-child > span,.rifki-chat-bubble strong,.rifki-chat-sources > a) { color: var(--accent); }
html[data-theme] .main-content :is(.profile-photo-field small,.rifki-chat-bubble small,.rifki-chat-sources > b) { color: var(--muted); }
html[data-theme] .main-content :is(.profile-photo-field button,.profile-save,.rifki-chat-bubble > span) {
    color: var(--on-accent);
    background: var(--accent);
    border-color: var(--accent);
}

html[data-theme] .main-content .rifki-chat-bubble > div {
    color: var(--ink);
    background: var(--surface);
    border-color: var(--line);
    box-shadow: var(--panel-shadow);
}

html[data-theme] .main-content .rifki-chat-bubble.user > div { background: var(--tint); }
html[data-theme] .main-content .catalog-disclosure > summary { color: var(--ink); }
html[data-theme] .main-content .catalog-disclosure > summary:hover { background: var(--tint); }

html[data-theme] .main-content :is(.rifki-capabilities span,.rifki-memory-link,.review-gate-strip > span,.basis-box) {
    color: var(--ink);
    background: var(--subtle);
    border-color: var(--line);
}

html[data-theme] .main-content :is(.rifki-memory-link strong,.rifki-composer-title h2,.review-issue strong,
    .review-gate-strip strong,.review-empty strong,.business-empty strong,.business-actions > div > strong) { color: var(--ink); }

html[data-theme] .main-content :is(.rifki-memory-link small,.rifki-composer-title p,.review-empty span,.review-issue p,.review-issue span,
    .business-empty span,.business-actions > div > span,.business-transfer-confirm span,.basis-box span,.portal-report-switcher span,
    .batch-selection-actions span,.z-fields small) { color: var(--muted); }

html[data-theme] .main-content :is(.bank-hero span,.bank-review-card header span,.z-hero span,.business-ledger-card header span,
    .review-hero span,.portal-card .portal-profile-action,.account-settings-card .account-install-badge) { color: var(--accent); }

html[data-theme] .main-content :is(.bank-hero > strong,.review-hero > strong,.z-hero > strong,.business-ledger-hero > strong.ready,.basis-box .ready) {
    color: var(--success-ink);
    background: var(--success-surface);
    border-color: var(--success-line);
}

html[data-theme] .main-content .business-ledger-hero > strong.review {
    color: var(--warning-ink);
    background: var(--warning-surface);
    border-color: var(--warning-line);
}

html[data-theme] .main-content .rule-item footer button.delete {
    color: var(--danger-ink);
    background: var(--danger-surface);
    border-color: var(--danger-line);
}

html[data-theme] .main-content :is(.bank-review-card header button,.review-toolbar > button):not(:disabled) {
    color: var(--on-accent);
    background: var(--accent);
    border-color: var(--accent);
    border-radius: var(--button-shape);
}

html[data-theme] .main-content .bank-fields {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 165px), 1fr));
}

html[data-theme] .main-content .bank-fields > label { min-width: 0; }
html[data-theme] .main-content .bank-fields > label :is(input,select) { width: 100%; min-width: 0; }

html[data-theme] .main-content .portal-user .portal-profile-action { color: var(--accent) !important; }
html[data-theme] .main-content :is(.account-bulk-toolbar > span,.portal-period-state span,.portal-period-state small,
    .credential-panel span,.safety-note span,.review-document-header :is(span,p),.review-learn-check span,
    .review-approval span,.batch-page .batch-loading,.batch-safety span) {
    color: var(--muted);
}

html[data-theme] .main-content :is(.account-card-heading > div > span,.kdv-safety-card > div > span,.rifki-avatar > span,.custom-purpose-picker-category h4) {
    color: var(--accent);
    background: var(--tint);
}

html[data-theme] .main-content :is(.account-action-explanation strong,.kdv-safety-card li.required,
    .account-bulk-customer strong,.credential-panel strong) { color: var(--ink); }
html[data-theme] .main-content .business-ledger-hero span { color: var(--accent); }
html[data-theme] .main-content .kdv-safety-card li.locked { color: var(--danger-ink); }
html[data-theme] .main-content :is(.invoice-order-precedence b,.safety-note strong,.credential-panel.ready strong) { color: var(--success-ink); }
html[data-theme] .main-content :is(.rifki-report-card.warning em,.basis-box strong.warning) { color: var(--warning-ink); }

html[data-theme] .main-content .account-bulk-customer > input[type="checkbox"] {
    width: 1em;
    min-width: 1em;
    background: var(--surface);
    accent-color: var(--accent);
}

html[data-theme] .dashboard-wrapper :is(.tag-approved,.confidence-badge.conf-high,.document-queue-item em.valid) {
    color: var(--success-ink);
    background: var(--success-surface);
    border-color: var(--success-line);
}

html[data-theme] .dashboard-wrapper :is(.tag-review,.confidence-badge.conf-mid,.document-queue-item em.review,.dashboard-transfer-confirm) {
    color: var(--warning-ink);
    background: var(--warning-surface);
    border-color: var(--warning-line);
}

html[data-theme] .dashboard-wrapper :is(.confidence-badge.conf-low,.document-queue-item em.duplicate) {
    color: var(--danger-ink);
    background: var(--danger-surface);
    border-color: var(--danger-line);
}

html[data-theme] .dashboard-wrapper .classification-table .amount-empty { color: var(--muted); }
html[data-theme] .dashboard-wrapper .inv-lines-table { min-width: min(390px, 100%); }

/* The conversation and prompt are separate surfaces from the Rıfkı page banner. */
html[data-theme] .rifki-page .rifki-conversation {
    color: var(--ink);
    background: var(--subtle);
    border-color: var(--line);
    border-radius: var(--shape);
}

html[data-theme] .rifki-page .rifki-ai-composer {
    background: var(--surface);
    border-color: var(--line);
    box-shadow: var(--panel-shadow);
}

html[data-theme] .main-content .rifki-page .rifki-prompt-shell {
    background: var(--surface);
    border-color: var(--line);
    border-radius: var(--shape);
    box-shadow: none;
}

html[data-theme] .main-content .rifki-page .rifki-prompt-shell:focus-within { border-color: var(--accent); }
html[data-theme] .main-content .rifki-page .rifki-prompt-shell textarea {
    color: var(--ink);
    background: transparent;
    border-radius: 0;
}

html[data-theme] .rifki-page .rifki-prompt-footer {
    background: var(--subtle);
    border-radius: 0 0 var(--shape) var(--shape);
}

html[data-theme] .rifki-page :is(.rifki-composer-title,.rifki-chat-approval-head,.rifki-chat-approval-scope span) {
    border-color: var(--line);
}

html[data-theme] .rifki-page :is(.rifki-chat-approval-head p,.rifki-chat-approval-steps small,.rifki-chat-confirmation small) {
    color: var(--muted);
}

html[data-theme] .rifki-page :is(.rifki-chat-approval-scope,.rifki-chat-approval-steps li,.rifki-chat-confirmation) {
    background: var(--subtle);
    border-color: var(--line);
}

html[data-theme] .rifki-page :is(.rifki-chat-approval-head b,.rifki-chat-approval-firms .ready) {
    color: var(--success-ink);
    background: var(--success-surface);
    border-color: var(--success-line);
}

html[data-theme] .rifki-page .rifki-chat-approval-firms .warning {
    color: var(--warning-ink);
    background: var(--warning-surface);
    border-color: var(--warning-line);
}

@media (max-width: 650px) {
    html[data-theme] .main-content .bank-fields { grid-template-columns: minmax(0, 1fr); }
    html[data-theme] .main-content :is(.bank-hero > strong,.review-hero > strong) { white-space: normal; }
    html[data-theme] .main-content .bank-review-card header > div:last-child { flex-wrap: wrap; }
}

html[data-theme] .office-welcome .app-logout-button {
    color: var(--danger-ink);
    background: var(--danger-surface);
    border-color: var(--danger-line);
    border-radius: var(--button-shape);
}
