/* Aicon visual system. Loaded after layout and component styles.
   Owns appearance only; sizing/visibility/interaction stay in their original components. */
:root {
    --aicon-weight-regular: 400;
    --aicon-weight-medium: 500;
    --aicon-weight-semibold: 600;
    --aicon-brand-blue: #073b78;
    --aicon-brand-orange: #ff6b00;
    --aicon-canvas: #f5f6f8;
    --aicon-surface: #fff;
    --aicon-soft: #f8f9fb;
    --aicon-border: #dfe4eb;
    --aicon-ink: #233449;
    --aicon-muted: #5d6b7e;
    --aicon-radius: 8px;
    --aicon-shadow: 0 1px 3px rgb(22 38 61 / 5%);
}

.app-shell {
    --main: var(--aicon-canvas);
    --line: var(--aicon-border);
    --border: var(--aicon-border);
    --panel: var(--aicon-surface);
    --panel-2: var(--aicon-surface);
    --panel-soft: var(--aicon-soft);
    --text: var(--aicon-ink);
    --muted: var(--aicon-muted);
    --muted-2: #667487;
    --hover: #f1f4f8;
    font-weight: var(--aicon-weight-regular);
}

/* Navigation preserves the institutional blue and the existing compact rail. */
.app-shell .sidebar { background: #093765; }
.app-shell .nav-label,
.app-shell .account-name { font-weight: var(--aicon-weight-medium); }
.app-shell .nav-entry { border-radius: 7px; }
.app-shell .nav-entry.active {
    background: #ffffff12;
    box-shadow: inset 2px 0 0 var(--aicon-brand-orange);
}
.app-shell .topbar { box-shadow: none; }
.app-shell .material-symbols-rounded {
    font-weight: 400;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

/* Modules share a calm canvas, a readable title and a common toolbar language. */
.app-shell .module-page,
.app-shell .workspace,
.app-shell .kanban-page { background-color: var(--aicon-canvas); }
.app-shell :is(.page-heading, .my-topics > header) h1 { font-weight: 600; font-size: 24px; letter-spacing: -.025em; }
.app-shell :is(.page-heading, .my-topics > header) p { color: var(--aicon-muted); line-height: 1.5; }
.app-shell .page-heading > div:first-child { min-width: 0; }
.app-shell .page-description { margin: 6px 0 0; max-width: 78ch; font-size: 13px; }
.app-shell .unit-toolbar {
    background: var(--aicon-surface);
    border: 1px solid var(--aicon-border);
    border-radius: var(--aicon-radius);
    padding: 12px;
    gap: 12px;
    align-items: end;
}
.app-shell .unit-toolbar > * { min-width: 0; }
.app-shell .contact-toolbar { display: grid; grid-template-columns: minmax(0, 1fr); }
.app-shell .contact-toolbar .contact-toolbar-config {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    border-top: 1px solid var(--aicon-border);
    padding-top: 10px;
}
.app-shell .contact-toolbar .contact-search-field { width: 100%; }
.app-shell :is(.connection-card, .mini-card, .campaign-card, .metric-card, .plan-card,
    .support-card, .ai-panel, .prompt-panel, .profile-card, .theme-card, .chart-card,
    .table-card, .permission-panel, .permission-toolbar, .permission-tabs,
    .reports-header, .reports-filter-bar, .report-tabs, .report-card, .setting-row,
    .diagnostic-check-card, .diagnostic-metric-grid article, .form-card, .my-topic-card) {
    background-color: var(--aicon-surface);
    border: 1px solid var(--aicon-border);
    border-radius: var(--aicon-radius);
    box-shadow: var(--aicon-shadow);
}
.app-shell .error-card {
    background: var(--aicon-surface);
    border: 1px solid var(--aicon-border);
    border-radius: 10px;
    box-shadow: var(--aicon-shadow);
}
.app-shell .error-card h1 { font-size: 24px; line-height: 1.3; font-weight: 600; }
.app-shell :is(.contact-toolbar, .company-toolbar, .team-toolbar, .catalog-toolbar) {
    gap: 12px;
}
.app-shell :is(.permission-tabs, .report-tabs) { padding: 4px; }
.app-shell :is(.permission-tabs, .report-tabs) button { font-weight: 500; border-radius: 6px; }

/* Existing semantic states (danger, SLA, branch, priority) retain their colors. */
.app-shell .primary-pill {
    border-radius: var(--aicon-radius);
    font-weight: 500;
    box-shadow: none;
}
.app-shell .primary-pill:not(.secondary):not(.icon-only):not(.danger),
.login-panel .login-button,
.app-shell :is(.permission-tabs, .report-tabs) button.active {
    color: #10243a;
}
.app-shell :is(.notification-badge, .unread-badge) { color: #10243a; }
.app-shell .secondary-button {
    border-radius: var(--aicon-radius);
    background: #f0f3f7;
    color: #29425e;
    font-weight: 500;
    box-shadow: none;
}
.app-shell .secondary-button:hover { background: #e7edf4; }
.app-shell .chat-header-actions :is(.primary-pill.secondary, .refresh-pill, .icon-only) {
    background: #f3f5f8;
    color: #29425e;
    border: 1px solid var(--aicon-border);
}
.app-shell :is(.card-menu, .small-icon-button) { box-shadow: none; }
.app-shell :is(.modal-form, .module-page, .kanban-settings, .my-topics)
    :is(input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]):not([type=file]), select, textarea) {
    border: 1px solid #cbd4df;
    border-radius: 7px;
    background-color: var(--aicon-surface);
    color: var(--aicon-ink);
    font-weight: 400;
    padding: 9px 11px;
    max-width: 100%;
    min-width: 0;
}
.app-shell :is(.modal-form, .module-page, .kanban-settings, .my-topics) label {
    font-weight: 500;
    color: var(--aicon-muted);
}
.app-shell :is(input, textarea)::placeholder { color: #65748a; font-weight: 400; }
.app-shell :is(.modal-panel, .kanban-settings) {
    border: 1px solid var(--aicon-border);
    border-radius: 10px;
    box-shadow: 0 16px 48px rgb(17 32 53 / 18%);
}
.app-shell :is(.modal-panel, .kanban-settings) header {
    border-bottom: 1px solid var(--aicon-border);
    padding-bottom: 12px;
}
.app-shell :is(.modal-panel, .kanban-settings) h2 { font-weight: 600; letter-spacing: -.02em; }
.app-shell .modal-heading { min-width: 0; flex: 1; }
.app-shell .modal-heading h2 { margin-bottom: 0; }
.app-shell .modal-description { margin: 7px 0 0; font-size: 12px; line-height: 1.5; color: var(--aicon-muted); max-width: 70ch; }

/* Tables retain their column/overflow contracts and all row actions. */
.app-shell .table-card { background-image: none; }
.app-shell .table-card th {
    background: var(--aicon-soft);
    color: #526176;
    font-weight: 500;
    border-bottom-color: var(--aicon-border);
}
.app-shell .table-card td { border-bottom-color: #e9edf2; }
.app-shell .table-card td strong { font-weight: 600; }
.app-shell .table-card tbody tr:hover { background-color: #f8fafc; }
.app-shell :is(.connection-card dt, .report-stat-card small, .diagnostic-check-card small) {
    font-weight: 500;
    color: var(--aicon-muted);
    letter-spacing: .015em;
}
.app-shell .connection-card dd { font-family: Inter, 'Segoe UI', sans-serif; }
.app-shell .connection-title h2 { font-weight: 600; line-height: 1.4; }
.app-shell .connection-status { font-weight: 500; }
.app-shell .connection-card strong { font-weight: 600; }
.app-shell .connection-card .connection-operational { padding-block: 12px; gap: 12px; }
.app-shell .connection-card .connection-operational dd { font-size: 13px; line-height: 1.5; color: var(--aicon-ink); }
.app-shell .connection-technical { border-top: 1px solid var(--aicon-border); padding-top: 10px; min-width: 0; }
.app-shell .connection-technical summary { cursor: pointer; color: var(--aicon-muted); font-size: 12px; padding-block: 5px; }
.app-shell .connection-technical .connection-meta-grid { margin-top: 10px; }
.app-shell .connection-technical dd { overflow-wrap: anywhere; }
.app-shell .connection-card .usage-bar { border-radius: 4px; }

/* Inbox density is deliberately unchanged: no row height/padding/font-size edits. */
.app-shell .conversation-title,
.app-shell .chat-header h1 { font-weight: 600; }
.app-shell .conversation-preview,
.app-shell .chat-header p { font-weight: 400; }
.app-shell .conversation-item { box-shadow: none; border-bottom-color: var(--aicon-border); }
.app-shell .conversation-item.selected { background: #f0f5fb; }
.app-shell .conversation-item:hover { background: #f7f9fc; }
.app-shell .conversation-list .conversation-item { border-left-width: 3px; }
.app-shell .conversation-badges > span { font-weight: 500; }
.app-shell .routing-strip label { font-weight: 500; }
.app-shell .conversation-topics > summary,
.app-shell .contact-case-search > summary,
.app-shell .provider-tools > summary { font-weight: 500; background: #fafbfc; }
.app-shell .message-surface { background-color: #f3f1ec; background-image: none; }
.app-shell .message-bubble { box-shadow: var(--aicon-shadow); border-radius: 8px; font-weight: 400; }
.app-shell .message-bubble strong { font-weight: 600; }
.app-shell .date-separator { box-shadow: none; font-weight: 500; }

/* Kanban and topics use the same surfaces, without changing their workflows. */
.app-shell .kanban-page .kanban-toolbar:first-child { border-radius: 8px; box-shadow: none; border-color: var(--aicon-border); }
.app-shell .kanban-toolbar h1 { font-weight: 600; }
.app-shell .kanban-heading { flex: 1 1 100%; min-width: 0; }
.app-shell .kanban-heading h1 { margin: 0; }
.app-shell .kanban-heading p { color: var(--aicon-muted); margin: 6px 0 4px; font-size: 13px; line-height: 1.5; }
.app-shell .kanban-page .kanban-card .kanban-card-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-shell .kanban-page .kanban-card .kanban-card-agent { font-weight: 500; color: #405773; }
.app-shell .kanban-page .kanban-lane { background: #f0f2f5; border-color: var(--aicon-border); border-radius: 8px; }
.app-shell .kanban-page .kanban-lane h2 { box-shadow: none; font-weight: 600; border-left-width: 3px; }
.app-shell .kanban-page .kanban-card { border-radius: 8px; border-color: var(--aicon-border); box-shadow: var(--aicon-shadow); }
.app-shell .kanban-page .kanban-card button { font-weight: 600; }
.app-shell .kanban-page .kanban-card:hover { box-shadow: 0 2px 6px rgb(22 38 61 / 8%); }
.app-shell .kanban-page .kanban-card select { background: #fff; }
.app-shell .kanban-page .kanban-lane.drop-target { background: #e6f0fb; border-color: #2468ab; }
.app-shell .kanban-toolbar button { font-weight: 500; }
.app-shell .my-topics > .form-card { padding: 14px 16px; }
.app-shell .my-topics > .form-card summary { cursor: pointer; font-weight: 500; }
.app-shell .my-topics > .form-card p { max-width: 85ch; line-height: 1.65; color: var(--aicon-muted); }
.app-shell .my-topic-card > strong { font-size: 15px; font-weight: 600; }
.app-shell .my-topic-card > small { color: var(--aicon-muted); }

/* Login/password and error screens belong to the same brand system. */
.login-stage { background: var(--aicon-canvas); }
.login-stage .login-panel {
    background: #fff;
    color: var(--aicon-ink);
    border: 1px solid var(--aicon-border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgb(22 38 61 / 8%);
}
.login-panel label { font-weight: 500; }
.login-panel input { border: 1px solid #cbd4df; border-radius: 7px; }
.login-panel .login-button { border-radius: 8px; font-weight: 500; }

:is(.app-shell, .login-panel) :is(button, a, input, select, textarea, summary):focus-visible {
    outline: 2px solid #1a66b3;
    outline-offset: 3px;
}
.app-shell .sidebar :is(a, button):focus-visible { outline-color: #fff; }

@media (min-width: 1000px) {
    .app-shell { grid-template-rows: 52px minmax(0, 1fr); }
}
@media (max-width: 640px) {
    .app-shell .contact-toolbar .contact-toolbar-config { justify-content: flex-start; }
    .app-shell .contact-toolbar .contact-toolbar-config > label { min-width: 0; max-width: 100%; }
    .app-shell .contact-toolbar .contact-toolbar-config select { max-width: 100%; }
    .app-shell .kanban-settings { grid-template-columns: minmax(0, 1fr); }
    .app-shell .kanban-settings > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
    .app-shell .kanban-settings header { gap: 8px; }
    .app-shell .kanban-settings header button { flex-shrink: 0; }
    .app-shell .kanban-settings .kanban-column-edit { flex-wrap: wrap; }
    .app-shell .kanban-settings .kanban-column-edit input { min-width: 0; }
    .app-shell .modal-form { grid-template-columns: minmax(0, 1fr); min-width: 0; }
    .app-shell .modal-form > * { min-width: 0; max-width: 100%; }
    .app-shell .modal-form select { width: 100%; }
    .app-shell :is(.page-heading, .my-topics > header) h1 { font-size: 22px; }
    .app-shell .module-page { padding-inline: 14px; }
    .app-shell :is(.module-page, .modal-panel, .kanban-settings) :is(button, .primary-pill, .secondary-button),
    .app-shell .kanban-toolbar button,
    .app-shell .chat-header-actions button { min-height: 44px; }
    .app-shell :is(.module-page, .modal-panel, .kanban-settings, .my-topics)
        :is(input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]):not([type=file]), select, textarea),
    .login-panel input { font-size: 16px; min-height: 44px; }
    .app-shell :is(.module-page, .modal-panel, .kanban-settings) :is(input[type=checkbox], input[type=radio]) {
        min-height: 22px;
        min-width: 22px;
        flex-shrink: 0;
    }
    .app-shell .my-topic-card { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
    .app-shell :is(button, a, .kanban-card) { transition-duration: 0s; }
}

.quick-reply-files p,.quick-reply-staged small {color:var(--text-muted,#64748b);font-size:.8rem;display:block;margin:4px 0 8px}
.quick-reply-files>div,.quick-reply-staged>div{display:flex;align-items:center;gap:8px;justify-content:space-between;min-width:0}
.quick-reply-files span,.quick-reply-staged span{overflow-wrap:anywhere;min-width:0}
.quick-reply-staged{padding:8px 12px;background:var(--surface,#fff);border:1px solid var(--border,#dbe2ea);max-height:180px;overflow:auto}
.quick-reply-staged button{min-height:32px;border:1px solid #dbe2ea;background:white;border-radius:6px;color:#163b65}
@media(max-width:600px){.quick-reply-staged button{min-height:44px}.quick-reply-files input{max-width:100%}}

.quick-reply-files > [hidden]{display:none !important}
.quick-reply-file-count{display:block;color:var(--text-muted,#64748b);font-size:.75rem}

.work-page{box-sizing:border-box;height:100%;min-height:0;overflow-y:auto;scrollbar-gutter:stable;padding:24px;max-width:1400px;margin:auto;min-width:0;padding-bottom:max(24px,env(safe-area-inset-bottom))}.work-page h1{font-size:1.6rem;font-weight:600}.work-page h2{font-size:1.1rem}.work-page p{line-height:1.5}.work-card{background:var(--surface,#fff);border:1px solid #dbe3ec;border-radius:10px;padding:16px;margin:16px 0;min-width:0}.work-card header,.work-toolbar,.work-actions{display:flex;gap:12px;align-items:center;flex-wrap:wrap}.work-card header{justify-content:space-between}.work-card summary{cursor:pointer;font-weight:600}.work-page label,.work-case-picker label{display:flex;flex-direction:column;gap:6px;margin:10px 0;min-width:0}.work-page input:not([type=checkbox]),.work-page select,.work-page textarea,.work-search-dialog input{box-sizing:border-box;width:100%;min-width:0;max-width:100%;border:1px solid #ccd6e2;border-radius:7px;padding:10px;font:inherit;background:#fff;color:#163b65}.work-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.work-wide{grid-column:1/-1}.work-page button,.work-page a,.work-search-dialog button{min-height:36px}.work-actions a{display:inline-flex;align-items:center}.work-line{padding:8px 12px;background:#f2f6fa;border-radius:6px}.work-message{white-space:pre-wrap;overflow-wrap:anywhere}.work-global-button{display:flex;gap:6px;align-items:center;border:1px solid #dbe3ec;background:#fff;border-radius:7px;color:#163b65;padding:7px 10px}.work-chat-links{display:flex;gap:12px;flex-wrap:wrap;padding:4px 16px;font-size:.8rem}.work-search-backdrop{position:fixed;inset:0;background:#091a3590;z-index:3000;display:flex;justify-content:center;align-items:flex-start;padding:8vh 12px;box-sizing:border-box}.work-search-dialog{background:white;color:#163b65;width:min(620px,100%);padding:20px;border-radius:10px;max-height:80vh;overflow:auto;box-sizing:border-box}.work-search-dialog header{display:flex;justify-content:space-between;align-items:center;gap:10px}.work-search-results button{display:flex;flex-direction:column;align-items:flex-start;text-align:left;width:100%;background:#fff;border:1px solid #e3e8ee;border-radius:6px;padding:10px;margin:6px 0}.work-search-results .selected{background:#eef5ff;outline:2px solid #235d9b}.work-search-dialog small{color:#64748b}.work-page :focus-visible,.work-search-dialog :focus-visible{outline:2px solid #185a9d;outline-offset:2px}
@media(max-width:600px){.work-page{padding:12px}.work-form-grid{grid-template-columns:1fr}.work-wide{grid-column:auto}.work-toolbar>*{max-width:100%}.work-page button,.work-page a,.work-global-button,.work-search-dialog button{min-height:44px}.work-global-button>span:last-child{display:none}.work-chat-links a{min-height:32px;display:inline-flex;align-items:center}.work-search-backdrop{padding:12px}.work-search-dialog{max-height:calc(100dvh - 24px)}}

/* Operations use the same restrained controls as the rest of AiconChat. */
.work-page button:not(.primary-pill),.work-search-dialog header button{border:1px solid #ccd6e2;border-radius:7px;padding:8px 12px;background:var(--surface,#fff);color:inherit;font:inherit;font-weight:500;cursor:pointer}
.work-page button:disabled{opacity:.55;cursor:not-allowed}.work-page button:not(:disabled):hover{filter:brightness(.97)}
.work-page .work-actions{margin-top:12px}.work-page .work-card p{overflow-wrap:anywhere}.work-page .work-toolbar label:has(input[type=checkbox]){flex-direction:row;align-items:center}
@media(max-width:600px){.work-chat-links a{min-height:44px}.work-page .work-card header strong{overflow-wrap:anywhere;min-width:0}.work-page .work-toolbar{gap:8px}}

/* Search is mounted in the header: lift that stacking context only while the dialog is open. */
.topbar:has(.work-search-backdrop){z-index:4000}

/* Shared operator help: collapsed by default, keyboard and touch accessible. */
.work-feature-help{border:1px solid #dce3eb;border-radius:8px;background:#fff;margin:12px 0;color:var(--aicon-text,#183654)}.work-feature-help>summary{display:flex;align-items:center;gap:8px;min-height:44px;padding:8px 12px;cursor:pointer;font-weight:500;list-style:none}.work-feature-help .material-symbols-rounded{font-size:19px}.work-help-chevron{margin-left:auto}.work-feature-help[open] .work-help-chevron{transform:rotate(180deg)}.work-help-body{padding:0 16px 12px;line-height:1.6;font-size:13px}.work-help-body li{margin:6px 0}.work-feature-help summary:focus-visible{outline:2px solid #ff7900;outline-offset:2px}

.main-stage:has(.agenda-backdrop){z-index:5000;position:relative}.app-shell:has(.agenda-backdrop) .topbar,.app-shell:has(.agenda-backdrop) .sidebar{pointer-events:none}

/* Booking dialog includes nested case picker: keep native controls consistent. */
.agenda-modal .work-case-picker{display:grid;gap:10px;margin-bottom:16px}.agenda-modal .work-case-picker label{display:flex;flex-direction:column;gap:6px}.agenda-modal .work-case-picker input,.agenda-modal .work-case-picker select{box-sizing:border-box;width:100%;min-height:44px;padding:8px 10px;border:1px solid #ccd8e5;border-radius:6px;background:white;color:#183654}.agenda-modal button{min-height:44px;padding:8px 12px;border:1px solid #ccd8e5;border-radius:6px;background:white;color:#183654;cursor:pointer}.agenda-modal button.primary-pill{background:#ff7900;border-color:#ff7900;color:#172c44}.agenda-modal button:disabled{opacity:.5;cursor:default}.agenda-modal header{position:sticky;top:-24px;background:white;z-index:1;padding:10px 0}.agenda-modal footer{position:sticky;bottom:-24px;background:white;padding:12px 0;border-top:1px solid #e1e6ed}.agenda-modal .work-case-picker p{margin:0}.agenda-modal .work-case-picker small{line-height:1.5}@media(max-width:600px){.agenda-modal header{top:-16px}.agenda-modal footer{bottom:-16px}}

/* Scroll del menú y cabeceras de consultas de conversación. */
@media (hover: hover) and (pointer: fine) {
    .sidebar .nav-panel {
        scrollbar-color: #779bbc transparent;
        scrollbar-width: thin;
    }
}
.history-modal-panel .history-modal-header,
.conversation-preview-modal .history-modal-header {
    background: #f2f7fc;
    border-block-start: 3px solid #e78129;
    border-block-end: 1px solid #d0dfed;
    border-radius: 8px 8px 0 0;
}
.history-modal-panel .history-modal-title h2,
.conversation-preview-modal .history-modal-title h2 {
    color: #123e65;
}
