:root {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #202b38;
    background: #f5f6f8;
    line-height: 1.5;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.site-header { background: #fff; border-bottom: 1px solid #e3e7ec; color: #202b38; }
.nav, .nav nav { display: flex; align-items: center; justify-content: space-between; gap: 22px; flex-wrap: wrap; }
.nav { min-height: 66px; }
.nav nav { gap: 20px; }
.brand { color: #202b38; font-size: 1.12rem; font-weight: 720; text-decoration: none; }
.brand small { display: block; color: #798391; font-size: .7rem; font-weight: 450; }
.site-header a, .link { color: #455263; text-decoration: none; }
.site-header nav a, .link { font-size: .9rem; }
.link { background: transparent; border: 0; padding: 0; font: inherit; cursor: pointer; }
main { padding-top: 28px !important; padding-bottom: 60px !important; }
h1 { font-size: 1.8rem; margin: 0 0 10px; letter-spacing: -.035em; }
h2 { font-size: 1.22rem; margin: 0 0 14px; letter-spacing: -.02em; }

.main-home { max-width: 1600px; padding-top: 30px !important; padding-bottom: 24px !important; }
.workspace-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin: 0 0 20px; }
.workspace-heading h1 { font-size: 1.58rem; margin: 4px 0 0; }
.workspace-heading > p { color: #75808d; font-size: .86rem; margin: 0 0 3px; }
.eyebrow { display: block; color: #89929e; font-size: .65rem; font-weight: 760; letter-spacing: .11em; }
.notebook-layout { display: grid; grid-template-columns: minmax(260px, 310px) minmax(380px, 1fr) minmax(255px, 290px); gap: 16px; height: calc(100vh - 205px); min-height: 520px; align-items: stretch; }
.notebook-sidebar, .chat-workspace, .history-sidebar { background: #fff; border: 1px solid #e1e5ea; border-radius: 13px; box-shadow: 0 2px 8px #17263b08; }
.notebook-sidebar, .history-sidebar { min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.notebook-sidebar { align-self: stretch; }
.sidebar-section { padding: 18px; border-bottom: 1px solid #edf0f3; }
.sidebar-section:last-child { border-bottom: 0; }
.sidebar-section h2 { font-size: 1rem; margin: 4px 0 12px; }
.source-picker select { width: 100%; min-width: 0; border: 1px solid #dce2e9; border-radius: 7px; background: #fff; color: #263343; font: inherit; font-size: .83rem; padding: 10px 9px; }
.source-picker .button-secondary { width: 100%; margin-top: 9px; }
.selected-source { color: #75808d; font-size: .77rem; margin-top: 10px; }
.button-secondary, button.button-secondary:not(.link) { background: #f2f4f7; color: #364353; border: 1px solid #e5e8ed; font-size: .82rem; }
.quick-actions form + form { margin-top: 5px; }
.quick-button, button.quick-button:not(.link) { width: 100%; display: grid; grid-template-columns: 34px minmax(0, 1fr) 16px; align-items: center; gap: 10px; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 9px 7px; color: #354153; text-align: left; }
.quick-button:not(:disabled):hover { background: #f7f8fa; border-color: #eceff3; filter: none; }
.quick-button:disabled { cursor: not-allowed; opacity: .48; }
.quick-button strong, .quick-button small { display: block; }
.quick-button strong { font-size: .84rem; font-weight: 650; }
.quick-button small { color: #808a97; font-size: .7rem; font-weight: 400; line-height: 1.4; margin-top: 2px; }
.quick-icon { width: 31px; height: 31px; display: grid; place-items: center; background: #f1f3f6; border-radius: 8px; color: #505c6b; font-size: .85rem; font-weight: 700; }
.quick-arrow { color: #9aa3ad; font-size: 1.2rem; text-align: right; }
.sidebar-hint { display: block; color: #828c99; font-size: .72rem; margin: 8px 5px 0; }
.sidebar-title { display: flex; justify-content: space-between; align-items: center; }
.sidebar-title h2 { margin-bottom: 0; }
.source-count { display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 20px; background: #f1f3f6; color: #687483; font-size: .73rem; }
.upload-form { margin: 13px 0 6px; }
.upload-form input[type=file] { width: 100%; margin-bottom: 8px; color: #707b88; font-size: .74rem; }
.upload-form .button-secondary { width: 100%; }
.empty-sources { margin: 12px 0 2px; color: #828c99; font-size: .78rem; }
.source-item { display: grid; grid-template-columns: 31px minmax(0, 1fr); gap: 10px; border-top: 1px solid #eff1f4; padding: 13px 0 4px; margin-top: 11px; }
.source-file-icon { display: grid; place-items: center; width: 30px; height: 34px; border: 1px solid #e5d9d7; border-radius: 5px; background: #fff9f8; color: #a55a53; font-size: .56rem; font-weight: 800; letter-spacing: .03em; }
.source-details { min-width: 0; }
.source-details > strong { display: block; overflow: hidden; color: #364252; font-size: .77rem; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.source-details > small { display: flex; align-items: center; gap: 6px; color: #808a97; font-size: .69rem; margin-top: 3px; }
.source-details .error-text { display: block; color: #a33232; overflow-wrap: anywhere; }
.status-dot { display: inline-block; flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: #c4cbd3; }
.status-ready { background: #43a278; }
.status-pending { background: #daa441; }
.status-failed { background: #cb5b55; }
.source-actions { display: flex; gap: 12px; margin-top: 5px; }
.source-actions form { margin: 0; }
.text-button, button.text-button:not(.link) { background: transparent; color: #637286; border: 0; border-radius: 0; padding: 2px 0; font-size: .7rem; }
.text-button:hover { color: #1e5da7; filter: none; text-decoration: underline; }
.text-button.text-danger { color: #a25555; }

.chat-workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.chat-heading { display: flex; flex: 0 0 auto; align-items: center; gap: 12px; min-height: 73px; padding: 15px 22px; border-bottom: 1px solid #eceff2; }
.chat-heading h2 { overflow: hidden; color: #344152; font-size: .91rem; font-weight: 640; margin: 3px 0 0; text-overflow: ellipsis; white-space: nowrap; }
.assistant-mark { display: grid; flex: 0 0 37px; width: 37px; height: 37px; place-items: center; border: 1px solid #dce6f1; border-radius: 11px; background: #f1f6fc; color: #4979ac; font-size: .95rem; font-weight: 760; }
.chat-heading > div:nth-child(2), .chat-heading .chat-title { min-width: 0; }
.grounding-badge { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; margin-left: auto; padding: 6px 9px; border: 1px solid #e8ecef; border-radius: 20px; color: #76818d; font-size: .7rem; }
.chat-workspace > .alert { margin: 14px 22px 0; }
.chat-content { position: relative; display: flex; flex: 1 1 auto; flex-direction: column; justify-content: center; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; scrollbar-width: thin; padding: 26px max(clamp(18px, 4vw, 48px), calc((100% - 850px) / 2)); }
.chat-content.has-history { justify-content: flex-start; }
.welcome-card { max-width: 560px; margin: auto; text-align: center; }
.welcome-icon { display: grid; width: 55px; height: 55px; place-items: center; margin: 0 auto 18px; border: 1px solid #e2e9f1; border-radius: 17px; background: #f6f9fc; color: #6384a8; font-size: 1.5rem; }
.welcome-card h2 { color: #344152; font-size: 1.36rem; }
.welcome-card p { color: #788390; font-size: .88rem; }
.welcome-card .welcome-note { color: #a17734; font-size: .79rem; }
.response-card { width: 100%; margin: auto 0; }
.response-author { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.small-mark { flex-basis: 31px; width: 31px; height: 31px; border-radius: 9px; font-size: .78rem; }
.response-author strong, .response-author small { display: block; }
.response-author strong { color: #465365; font-size: .82rem; }
.response-author small { color: #89929e; font-size: .7rem; margin-top: 2px; }
.answer-text { color: #354153; font-size: .92rem; line-height: 1.7; overflow-wrap: anywhere; }
.answer-text > :first-child { margin-top: 0; }
.answer-text > :last-child { margin-bottom: 0; }
.answer-text p { margin: 0 0 12px; }
.answer-text h2, .answer-text h3, .answer-text h4, .answer-text h5 { margin: 20px 0 8px; color: #2b3746; line-height: 1.35; letter-spacing: -.01em; }
.answer-text h2 { font-size: 1.12rem; }
.answer-text h3 { font-size: 1.05rem; }
.answer-text h4 { font-size: .97rem; }
.answer-text h5 { font-size: .92rem; }
.answer-text ul, .answer-text ol { margin: 0 0 12px; padding-left: 22px; }
.answer-text li { margin: 3px 0; }
.answer-text li.nested { margin-left: 20px; list-style-type: circle; }
.answer-text strong { color: #273342; font-weight: 650; }
.answer-text code { padding: 1px 5px; border-radius: 4px; background: #f2f4f7; font-size: .85em; }
.answer-text hr { margin: 18px 0; border: 0; border-top: 1px solid #edf0f3; }
.table-scroll { max-width: 100%; margin: 0 0 14px; overflow-x: auto; border: 1px solid #e3e7ec; border-radius: 8px; }
.answer-text table { width: 100%; border-collapse: collapse; font-size: .84rem; line-height: 1.45; }
.answer-text th, .answer-text td { padding: 7px 10px; border-bottom: 1px solid #edf0f3; text-align: left; vertical-align: top; overflow-wrap: normal; }
.answer-text th { background: #f4f6f9; color: #2b3746; font-weight: 650; white-space: nowrap; }
.answer-text tr:last-child td { border-bottom: 0; }
.citation-list { margin-top: 18px; padding-top: 12px; border-top: 1px solid #edf0f3; }
.citation-list > summary { display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px 5px 6px; border: 1px solid #e5e9ee; border-radius: 20px; color: #5d6a7a; font-size: .74rem; font-weight: 600; cursor: pointer; list-style: none; user-select: none; }
.citation-list > summary::-webkit-details-marker, .citation > summary::-webkit-details-marker { display: none; }
.citation-list > summary::after { content: "▾"; color: #9aa3ad; font-size: .7rem; transition: transform .15s; }
.citation-list[open] > summary::after { transform: rotate(180deg); }
.citation-list > summary:hover { background: #f6f8fa; }
.citation { margin-top: 8px; padding: 8px 11px; border: 1px solid #eef1f4; border-radius: 8px; background: #fafbfc; color: #667384; font-size: .74rem; overflow-wrap: anywhere; }
.citation > summary { color: #4f5d6e; font-weight: 560; cursor: pointer; list-style: none; }
.citation > summary::before { content: "›"; display: inline-block; width: 12px; color: #9aa3ad; transition: transform .15s; }
.citation[open] > summary::before { transform: rotate(90deg); }
.citation p { max-height: 220px; overflow-y: auto; margin: 7px 0 0 12px; line-height: 1.55; white-space: pre-wrap; }
.small-file { flex: 0 0 24px; width: 24px; height: 27px; font-size: .48rem; }
.history-day-heading { display: flex; align-items: baseline; gap: 9px; margin: 0 0 16px; }
.history-day-heading .eyebrow { margin-right: auto; }
.history-day-heading > strong { color: #5d6877; font-size: .78rem; }
.history-day-heading > small { color: #89929e; font-size: .69rem; }
.history-entry { padding: 18px 0 22px; border-bottom: 1px solid #edf0f3; }
.history-entry:last-child { border-bottom: 0; }
.user-question { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; margin: 0 0 18px 15%; }
.user-bubble { max-width: 100%; padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: #eaf1f9; color: #2b4560; }
.user-bubble strong { display: block; font-size: .86rem; font-weight: 560; white-space: pre-wrap; overflow-wrap: anywhere; }
.user-question > small { color: #9aa2ac; font-size: .66rem; }
.saved-question { margin-top: 6px; color: #5d7590; font-size: .72rem; line-height: 1.5; }
.saved-question summary { cursor: pointer; color: #61809f; }
.saved-question[open] summary { margin-bottom: 4px; }
.section-link { color: #3d6b9a; font-size: .72rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.section-link:hover { text-decoration: underline; }
.quick-actions .sidebar-title { margin-bottom: 10px; }
.pinned-link { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: start; margin-top: 6px; padding: 8px 7px; border: 1px solid transparent; border-radius: 8px; color: #354153; text-decoration: none; }
.pinned-link:hover { background: #f7f8fa; border-color: #eceff3; }
.pinned-link.active { background: #eef4fa; border-color: #d9e5f1; }
.pinned-link strong { display: block; overflow: hidden; font-size: .8rem; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.pinned-link small { display: block; color: #8a939e; font-size: .67rem; }
.pin-icon { font-size: .8rem; line-height: 1.6; }
.pinned-heading a { color: #3d6b9a; font-size: .72rem; text-decoration: none; }
.pinned-heading a:hover { text-decoration: underline; }
.answer-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; margin-top: 12px; }
.excel-download { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border: 1px solid #b8dbc6; border-radius: 7px; background: #eaf6ef; color: #1d6b40; font-size: .8rem; font-weight: 600; text-decoration: none; }
.excel-download:hover { background: #dcf0e4; }
.excel-missing { color: #8a5a12; font-size: .78rem; }
.pin-control > summary { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border: 1px solid #e5e9ee; border-radius: 20px; color: #5d6a7a; font-size: .72rem; cursor: pointer; list-style: none; user-select: none; }
.pin-control > summary::-webkit-details-marker { display: none; }
.pin-control > summary:hover { background: #f6f8fa; }
.pin-control > summary.is-pinned { border-color: #f0dca8; background: #fffaf0; color: #8a6418; }
.pin-form { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.pin-form input[name=pin_name] { flex: 1; max-width: 360px; margin: 0; padding: 6px 9px; font-size: .8rem; }
.pin-form button:not(.text-button) { padding: 6px 12px; font-size: .76rem; }
.back-link { color: #3d6b9a; font-size: .85rem; text-decoration: none; }
.category-row { display: flex; align-items: flex-end; gap: 12px; padding: 16px 0; border-top: 1px solid #e6ebf2; }
.category-edit { flex: 1; }
.category-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 12px; }
.category-row label { margin-bottom: 10px; font-size: .85rem; }
.typing-dots { display: flex; gap: 5px; padding: 6px 0 4px 41px; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: #9fb3c8; animation: typing 1.2s infinite ease-in-out; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.history-panel { padding: 18px 15px; }
.history-panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 17px; }
.history-panel-heading h2 { margin: 4px 0 0; font-size: 1rem; }
.calendar-icon { display: grid; width: 31px; height: 31px; place-items: center; border-radius: 8px; background: #f2f5f8; color: #687b90; font-size: 1rem; }
.calendar-heading { display: grid; grid-template-columns: 30px 1fr 30px; align-items: center; margin-bottom: 12px; text-align: center; }
.calendar-heading strong { color: #465365; font-size: .82rem; font-weight: 680; }
.calendar-heading a { display: grid; width: 27px; height: 27px; place-items: center; border-radius: 7px; color: #657283; font-size: 1.25rem; text-decoration: none; }
.calendar-heading a:hover { background: #f1f3f6; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px 2px; }
.calendar-weekday { display: grid; height: 27px; place-items: center; color: #929aa4; font-size: .65rem; font-weight: 650; }
.calendar-day { position: relative; display: grid; min-height: 35px; place-items: center; border: 1px solid transparent; border-radius: 8px; color: #4d5968; font-size: .73rem; text-decoration: none; }
.calendar-day:hover { background: #f3f5f7; }
.calendar-day.outside-month { color: #bdc3cb; }
.calendar-day.today { border-color: #d9e4ef; color: #326595; font-weight: 700; }
.calendar-day.selected-day { background: #eaf1f8; color: #255f96; font-weight: 740; }
.calendar-day.has-history:not(.selected-day) { color: #315f48; font-weight: 700; }
.calendar-day i, .calendar-legend i { display: block; width: 4px; height: 4px; border-radius: 50%; background: #5b9a76; }
.calendar-day i { position: absolute; bottom: 3px; left: calc(50% - 2px); }
.calendar-day.selected-day i { background: #3275ae; }
.calendar-legend { display: flex; align-items: center; gap: 7px; margin-top: 13px; color: #84909c; font-size: .67rem; }
.calendar-legend i { width: 6px; height: 6px; }
.history-date-label { display: flex; align-items: center; justify-content: space-between; margin-top: 15px; padding-top: 12px; border-top: 1px solid #edf0f3; color: #596575; font-size: .75rem; }
.history-date-label strong { color: #8a939e; font-size: .67rem; font-weight: 550; }
.empty-history { color: #828c99; font-size: .78rem; line-height: 1.6; }
.chat-composer { flex: 0 0 auto; width: min(100% - 36px, 850px); margin: 12px auto 18px; padding: 10px 14px 9px; border: 1px solid #dfe4ea; border-radius: 14px; background: #fff; box-shadow: 0 3px 12px #17263b0a; }
.chat-composer:focus-within { border-color: #b9cde2; box-shadow: 0 3px 14px #205ba514; }
.chat-composer textarea { display: block; width: 100%; min-height: 44px; max-height: 180px; resize: none; border: 0; outline: 0; padding: 5px 2px; color: #354153; font: inherit; font-size: .88rem; }
.chat-composer textarea:focus { outline: none; }
.chat-composer textarea::placeholder { color: #a0a8b2; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid #f0f2f5; padding-top: 9px; }
.composer-footer small { color: #8a939e; font-size: .68rem; }
.composer-footer button { padding: 7px 12px !important; border-radius: 7px !important; font-size: .78rem !important; }
.composer-footer button:disabled { cursor: not-allowed; opacity: .48; }

.columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin: 20px 0; }
.card { margin: 20px 0; padding: 22px; border: 1px solid #dce3ed; border-radius: 10px; background: #fff; box-shadow: 0 2px 10px #15365c09; }
.columns .card { margin: 0; }
.narrow { max-width: 460px; margin: 60px auto; }
label { display: block; margin-bottom: 14px; font-weight: 600; }
input:not([type=checkbox]):not([type=hidden]), select, textarea { display: block; width: 100%; margin-top: 5px; padding: 9px; border: 1px solid #aab8c9; border-radius: 5px; background: #fff; color: inherit; font: inherit; }
textarea { resize: vertical; }
button:not(.link) { padding: 9px 16px; border: 0; border-radius: 5px; background: #205ba5; color: #fff; font: inherit; cursor: pointer; }
button.secondary { background: #e4ecf7; color: #173c70; font-size: .85rem; }
button.danger { background: #a33232; color: #fff; font-size: .85rem; }
button:hover { filter: brightness(.93); }
.inline { display: inline; }
.row { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid #e6ebf2; }
.row > * { flex: 1; }
.row > strong, .row > span, .row > .check, .row > button { flex: 0 0 auto; }
.row > label { margin: 0; }
.row > button { white-space: nowrap; }
.subrow { padding-left: 25px; }
.check { font-weight: 400; }
.check input { margin-right: 4px; }
.alert { margin: 15px 0; padding: 12px 15px; border-radius: 5px; background: #e8f1fc; }
.alert.error { background: #ffe6e3; color: #8b1c17; }
.alert.success { background: #e2f4e9; color: #195a34; }
.document { padding: 12px 0; border-top: 1px solid #e6ebf2; }
.document small { display: block; color: #5c6776; }
.document form { display: inline-block; margin: 8px 8px 0 0; }
.document .error-text { color: #9b2929; }
.answer { margin-top: 22px; padding-top: 10px; border-top: 1px solid #dce3ed; overflow-wrap: anywhere; }
.answer p { white-space: normal; }
.user-row { padding: 12px 0; border-top: 1px solid #edf0f3; }
.user-row > strong, .user-row > small { display: block; }
.user-row > small { margin-top: 3px; }
.permission-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.permission { padding: 3px 7px; border-radius: 20px; background: #f1f3f6; color: #7b8591; font-size: .68rem; }
.permission-on { background: #e8f4ed; color: #31704f; }
small { color: #657287; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }

.drawer-bar, .drawer-toggle, .drawer-backdrop { display: none; }

@media (max-width: 1180px) and (min-width: 901px) {
    .notebook-layout { grid-template-columns: minmax(235px, 280px) minmax(340px, 1fr); height: auto; }
    .notebook-layout > .notebook-sidebar, .notebook-layout > .chat-workspace { height: calc(100vh - 205px); min-height: 520px; }
    .history-sidebar { grid-column: 1 / -1; overflow: visible; }
    .history-panel { position: static; }
    .calendar-grid { max-width: 460px; }
}

@media (max-width: 900px) {
    body.page-home { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
    body.page-home .site-header { flex: 0 0 auto; }
    body.page-home .nav { min-height: 52px; padding-top: 6px; padding-bottom: 6px; flex-wrap: nowrap; }
    body.page-home .nav nav { gap: 12px; flex-wrap: nowrap; }
    body.page-home .brand { font-size: 1rem; white-space: nowrap; }
    body.page-home .brand small { display: none; }
    body.page-home main.main-home { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; padding: 8px 8px max(8px, env(safe-area-inset-bottom)) !important; }
    .main-home > .alert { flex: 0 0 auto; margin: 0 0 8px; }
    .main-home .workspace-heading { display: none; }
    .notebook-layout { display: block; flex: 1 1 auto; height: auto; min-height: 0; }
    .notebook-layout > .chat-workspace { height: 100%; min-height: 0; }
    .chat-heading { gap: 9px; min-height: 58px; padding: 9px 10px; }
    .chat-heading .assistant-mark { display: none; }
    .chat-heading .eyebrow { display: none; }
    .chat-heading h2 { margin: 0; font-size: .86rem; }
    .chat-heading .chat-title { flex: 1 1 auto; }
    .grounding-badge { display: none; }
    .drawer-toggle { display: inline-grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; padding: 0; border: 1px solid #e1e5ea; border-radius: 9px; background: #f7f8fa; color: #344152; font-size: 1.05rem; cursor: pointer; }
    .drawer-toggle-history { margin-left: auto; }
    .chat-content { padding: 16px 12px; }

    .drawer { position: fixed; top: 0; bottom: 0; z-index: 60; width: min(86vw, 340px); height: 100%; border-radius: 0; box-shadow: 0 0 30px #0f1b2b33; overflow-y: auto; overscroll-behavior: contain; visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; animation: none !important; }
    .drawer-left { left: 0; transform: translateX(-102%); }
    .drawer-right { right: 0; transform: translateX(102%); }
    .drawer.is-open { visibility: visible; transform: translateX(0); transition: transform .25s ease, visibility 0s; }
    .drawer-bar { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid #edf0f3; background: #fff; }
    .drawer-close { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px; background: #f1f3f6; color: #455263; font-size: .95rem; cursor: pointer; }
    .drawer-backdrop { position: fixed; inset: 0; z-index: 55; display: block; background: #0f1b2b66; }
    .drawer-backdrop[hidden] { display: none; }
    .history-panel { position: static; }
    .sidebar-section { padding: 14px; }
}

@media (max-width: 480px) {
    body.page-home .brand { font-size: .92rem; }
}

.nav-toggle { display: none; }
.site-header nav a[aria-current="page"] { color: var(--gempe-ocre); }
.login-log { margin-top: 22px; }
.login-log table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.login-log th, .login-log td { padding: 7px 10px; border-bottom: 1px solid #edf0f3; text-align: left; white-space: nowrap; }
.login-log th { background: #f4f6f9; font-weight: 650; }
.login-log tr:last-child td { border-bottom: 0; }
.login-agent { max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: #62666d; }
.login-result { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: .75rem; font-weight: 600; }
.login-ok { background: #e3f4e8; color: #1d6b36; }
.login-fail { background: #fde4e2; color: #ba1a1a; }

@media (max-width: 680px) {
    .site-header .nav { position: relative; flex-wrap: nowrap; align-items: center; }
    .nav-toggle { display: inline-grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; margin-left: auto; padding: 0; border: 1px solid #ffffff40; border-radius: 9px; background: transparent; color: #fff; font-size: 1.1rem; cursor: pointer; }
    .nav-toggle[aria-expanded="true"] { background: var(--gempe-ocre); border-color: var(--gempe-ocre); color: var(--gempe-gris); }
    .site-header nav#site-nav { position: absolute; top: 100%; right: 12px; left: 12px; z-index: 70; display: none; flex-direction: column; align-items: stretch; gap: 0; margin-top: 3px; padding: 6px; border-radius: 0 0 12px 12px; background: var(--gempe-gris); box-shadow: 0 12px 28px #0f1b2b55; }
    .site-header nav#site-nav.is-open { display: flex; }
    .site-header nav#site-nav a, .site-header nav#site-nav .link { display: block; width: 100%; padding: 12px 14px; border-radius: 8px; font-size: .95rem; text-align: left; }
    .site-header nav#site-nav a:hover, .site-header nav#site-nav .link:hover { background: #ffffff14; }
    .site-header nav#site-nav form { border-top: 1px solid #ffffff22; margin-top: 4px; padding-top: 4px; }
}

@media (max-width: 680px) {
    .wrap { padding-right: 16px; padding-left: 16px; }
    .main-home { padding-top: 20px !important; }
    .workspace-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
    .workspace-heading h1 { font-size: 1.35rem; }
    .columns { grid-template-columns: 1fr; }
    .nav { align-items: flex-start; padding-top: 10px; padding-bottom: 10px; }
    .nav nav { gap: 12px; }
    .row { align-items: stretch; }
    .row > strong, .row > span, .row > .check, .row > button { flex: auto; }
    .subrow { padding-left: 10px; }
    .category-row { flex-direction: column; align-items: stretch; }
    .category-fields { grid-template-columns: 1fr; }
    .composer-footer { align-items: flex-end; }
}

@media (prefers-reduced-motion: no-preference) {
    .notebook-sidebar, .chat-workspace { animation: panel-in .24s ease-out both; }
    .chat-workspace { animation-delay: .04s; }
    @keyframes panel-in { from { opacity: .65; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
}

/* ===== Tema GEMPE (paleta gempeV200) ===== */
:root {
    --gempe-bg: #eef1f3; --gempe-surface: #ffffff; --gempe-subtle: #f7f7f8;
    --gempe-text: #202124; --gempe-muted: #62666d; --gempe-gris: #383838;
    --gempe-grisclaro: #9FA3A6; --gempe-ocre: #F2B705; --gempe-ocre-dark: #8a6a00;
    --gempe-amarilloclaro: #F2E8B3; --gempe-amarilloscuro: #F2D479; --gempe-rojo: #ba1a1a;
    --gempe-border: #dfe2e5;
    color: var(--gempe-text); background: var(--gempe-bg);
}
body { background: var(--gempe-bg); }
:focus-visible { outline: 2px solid var(--gempe-ocre); outline-offset: 2px; }
.site-header { background: var(--gempe-gris); border-bottom: 3px solid var(--gempe-ocre); color: #fff; }
.brand, .site-header a, .site-header .link { color: #fff; }
.brand small { color: var(--gempe-grisclaro); }
.site-header nav a:hover, .site-header .link:hover { color: var(--gempe-ocre); }
.notebook-sidebar, .chat-workspace, .history-sidebar, .card { border-color: var(--gempe-border); }
button:not(.link) { background: var(--gempe-ocre); color: var(--gempe-gris); font-weight: 600; }
button:not(.link):hover { background: var(--gempe-amarilloscuro); filter: none; }
button.secondary, .button-secondary, button.button-secondary:not(.link) { background: var(--gempe-surface); color: var(--gempe-gris); border: 1px solid var(--gempe-border); }
button.secondary:hover, .button-secondary:hover, button.button-secondary:not(.link):hover { background: var(--gempe-ocre); border-color: var(--gempe-ocre); }
.quick-button, button.quick-button:not(.link) { background: transparent; color: var(--gempe-text); font-weight: inherit; }
.quick-button:not(:disabled):hover { background: var(--gempe-amarilloclaro); border-color: var(--gempe-amarilloscuro); }
.quick-icon { background: var(--gempe-amarilloclaro); color: var(--gempe-gris); }
.assistant-mark { background: var(--gempe-gris); border-color: var(--gempe-gris); color: var(--gempe-ocre); }
.welcome-icon { background: var(--gempe-amarilloclaro); border-color: var(--gempe-amarilloscuro); color: var(--gempe-gris); }
.welcome-card .welcome-note { color: var(--gempe-ocre-dark); }
.user-bubble { background: var(--gempe-gris); color: #fff; }
.saved-question, .saved-question summary { color: var(--gempe-muted); }
.section-link, .pinned-heading a, .back-link, .text-button:hover { color: var(--gempe-ocre-dark); }
.pinned-link.active { background: var(--gempe-amarilloclaro); border-color: var(--gempe-ocre); box-shadow: inset 3px 0 0 var(--gempe-ocre); }
.pin-control > summary.is-pinned { background: var(--gempe-amarilloclaro); border-color: var(--gempe-ocre); color: var(--gempe-gris); }
.typing-dots span { background: var(--gempe-ocre); }
.calendar-icon { background: var(--gempe-amarilloclaro); color: var(--gempe-gris); }
.calendar-day.today { border-color: var(--gempe-ocre); color: var(--gempe-gris); }
.calendar-day.selected-day { background: var(--gempe-ocre); color: var(--gempe-gris); }
.calendar-day.selected-day i { background: var(--gempe-gris); }
.chat-composer:focus-within { border-color: var(--gempe-ocre); box-shadow: 0 0 0 3px rgba(242, 183, 5, .24); }
input:not([type=checkbox]):not([type=hidden]):focus, select:focus, textarea:focus { border-color: var(--gempe-ocre); outline: none; box-shadow: 0 0 0 3px rgba(242, 183, 5, .24); }
.chat-composer textarea:focus { box-shadow: none; }
.alert:not(.error):not(.success) { background: var(--gempe-amarilloclaro); border-left: 3px solid var(--gempe-ocre); }
.status-pending { background: var(--gempe-ocre); }
.answer-text th { background: var(--gempe-gris); color: #fff; }
@media (max-width: 900px) {
    .drawer-toggle { background: var(--gempe-surface); border-color: var(--gempe-border); color: var(--gempe-gris); }
    .drawer-toggle:hover { background: var(--gempe-ocre); border-color: var(--gempe-ocre); }
}

.nextcloud-sync-form { margin-top: 8px; }
.nextcloud-sync-form .button-secondary { width: 100%; }

select[data-searchable-select][hidden] { display: none; }
.searchable-select { position: relative; min-width: 0; }
.searchable-select button.searchable-select-trigger {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid #c7c9cc;
    border-radius: 6px; background: #fff; color: #34383d; font: inherit;
    font-size: .83rem; text-align: left; overflow-wrap: anywhere;
}
.searchable-select button.searchable-select-trigger:hover { background: #fff; border-color: #9fa3a6; }
.searchable-select-trigger::after { content: "⌄"; flex: 0 0 auto; color: #687c99; }
.searchable-select-trigger[aria-expanded=true] { border-color: var(--gempe-ocre); }
.searchable-select-dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 10;
    padding: 6px; border: 1px solid #c7c9cc; border-radius: 6px;
    background: #fff; box-shadow: 0 4px 12px #17263b26;
}
.searchable-select input.searchable-select-search {
    display: block; width: 100%; min-width: 0; margin: 0 0 6px; padding: 8px 9px;
    border: 1px solid #c7c9cc; border-radius: 6px; background: #fff;
    color: #34383d; font: inherit; font-size: .83rem;
}
.searchable-select-options { max-height: 230px; overflow-y: auto; overscroll-behavior: contain; }
.searchable-select-option { margin-bottom: 4px; padding: 7px 8px; border-radius: 5px; color: #34383d; font-size: .83rem; cursor: pointer; overflow-wrap: anywhere; }
.searchable-select-option:hover, .searchable-select-option.is-active,
.searchable-select-option[aria-selected=true] { background: #e5ecff; }
.searchable-select-empty { padding: 8px; color: var(--gempe-muted); font-size: .8rem; }
.searchable-select [hidden] { display: none; }

.report-download { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border: 1px solid var(--gempe-ocre); border-radius: 6px; background: var(--gempe-amarilloclaro); color: var(--gempe-gris); font-size: .8rem; font-weight: 650; text-decoration: none; }
.report-download:hover { background: var(--gempe-ocre); }

.dashboard-filters, .admin-actions { display: flex; align-items: end; gap: 14px; flex-wrap: wrap; }
.dashboard-filters label { flex: 1 1 180px; margin-bottom: 0; }
.dashboard-note { color: var(--gempe-muted); font-size: .85rem; }
.dashboard-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.dashboard-metrics .card { margin: 12px 0; }
.metric h2 { color: var(--gempe-muted); font-size: .85rem; font-weight: 600; }
.metric > strong { display: block; font-size: 2rem; }
.metric > small { display: block; }
.dashboard-rankings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.dashboard-rankings .card { margin: 0; min-width: 0; }
.dashboard-rankings h2 { font-size: 1.05rem; }
.dashboard-bars { list-style: none; padding: 0; margin: 16px 0 0; }
.dashboard-bars li { margin: 0 0 16px; }
.dashboard-bars li > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: .8rem; }
.dashboard-bars span { overflow-wrap: anywhere; min-width: 0; }
.dashboard-bars meter { display: block; width: 100%; height: 14px; margin-top: 4px; accent-color: var(--gempe-ocre); }
.dashboard-bars meter::-webkit-meter-bar { background: var(--gempe-bg); border: 0; }
.dashboard-bars meter::-webkit-meter-optimum-value { background: var(--gempe-ocre); }
.dashboard-bars meter::-moz-meter-bar { background: var(--gempe-ocre); }
.dashboard-trend { display: block; width: 100%; min-height: 150px; }
.dashboard-trend text { fill: var(--gempe-muted); font-size: 13px; }
.chart-axis { stroke: var(--gempe-muted); }
.chart-grid { stroke: var(--gempe-border); stroke-dasharray: 5 5; }
.chart-line { fill: none; stroke: var(--gempe-ocre-dark); stroke-width: 3; stroke-linejoin: round; }
.chart-dot { fill: var(--gempe-ocre-dark); }
.trend-details { max-height: 300px; overflow-y: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.admin-table th, .admin-table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--gempe-border); vertical-align: top; }
.admin-table th { background: var(--gempe-subtle); }
.admin-table td:first-child { overflow-wrap: anywhere; }
.admin-actions { align-items: center; gap: 10px; }
.admin-actions form { margin: 0; }
.admin-actions button:not(.link) { font-size: .8rem; }
.admin-actions button.danger { background: var(--gempe-rojo); color: #fff; }
.user-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.user-permissions { border: 1px solid var(--gempe-border); border-radius: 6px; margin: 14px 0 20px; }
.user-permissions .check { margin: 8px 0; }
.site-header nav a[aria-current=page] { color: var(--gempe-ocre); }
.dashboard-tabs { display: flex; flex-wrap: wrap; gap: 8px; border-bottom: 1px solid var(--gempe-border); margin-bottom: 24px; }
.dashboard-tabs a { padding: 12px 16px; color: var(--gempe-muted); text-decoration: none; border-bottom: 3px solid transparent; }
.dashboard-tabs a[aria-current=page] { color: var(--gempe-gris); border-color: var(--gempe-ocre); font-weight: 700; }
.group-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px; }
.group-heading h2, .group-heading h3 { margin: 0; overflow-wrap: anywhere; }
.group-heading h3 { font-size: 1rem; }
.group-controls, .group-edit { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.group-edit { flex: 1 1 320px; }
.group-edit label { flex: 1 1 180px; margin: 0; }
.group-controls button:not(.link) { font-size: .82rem; }
.group-controls button.danger { background: var(--gempe-rojo); color: #fff; }
.group-subgroup { border-top: 1px solid var(--gempe-border); margin-top: 20px; padding-top: 18px; padding-left: 18px; }
@media (max-width: 900px) {
    .dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-rankings { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .dashboard-metrics, .user-fields { grid-template-columns: 1fr; }
    .dashboard-metrics .card { margin: 0; }
    .user-fields { gap: 0; }
    .dashboard-filters { align-items: stretch; }
}
