:root {
    --ink: #1e2024;
    --muted: #68707d;
    --line: #e1e5eb;
    --line-strong: #cbd1da;
    --canvas: #f7f8fa;
    --surface: #ffffff;
    --surface-soft: #f1f3f6;
    --cobalt: #1e5eff;
    --cobalt-dark: #164bd4;
    --cobalt-soft: #eaf0ff;
    --mint: #22b991;
    --mint-soft: #e7f8f2;
    --amber: #e7a51a;
    --amber-soft: #fff5dc;
    --coral: #ec6554;
    --danger: #b94437;
    --rail: 212px;
    --shadow-sm: 0 1px 2px rgba(22, 29, 37, .06), 0 4px 14px rgba(22, 29, 37, .04);
    --shadow-lg: 0 24px 70px rgba(22, 29, 37, .16);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body, button, input, textarea, select { font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: 0; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
button, a { color: inherit; }
button { cursor: pointer; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: 0 0 auto; }
.brand-tile { fill: var(--cobalt); }
.brand-glyph { fill: white; }
.brand-name { font-size: 24px; line-height: 1; font-weight: 750; }

.button { min-height: 44px; padding: 0 18px; border: 1px solid transparent; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 700; text-decoration: none; transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease; }
.button:hover { transform: translateY(-1px); }
.button svg { width: 17px; }
.button.full { width: 100%; }
.icon-button { width: 40px; height: 40px; padding: 0; border: 0; border-radius: 7px; display: inline-grid; place-items: center; background: transparent; }
.icon-button:hover { background: var(--surface-soft); }
.icon-button svg { width: 18px; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: 28px; max-width: min(440px, calc(100% - 30px)); padding: 12px 16px; border-radius: 7px; transform: translate(-50%, 16px); opacity: 0; background: var(--ink); color: white; font-size: 12px; pointer-events: none; transition: .22s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Signed-in app */
.app-page { height: 100dvh; overflow: hidden; background: var(--canvas); }
.app-shell { height: 100%; display: grid; grid-template-columns: var(--rail) 1fr; }
.app-rail { height: 100%; padding: 24px 14px 16px; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--surface); }
.rail-brand { padding: 0 10px 25px; }
.rail-context { height: 42px; padding: 0 11px; border-radius: 6px; display: flex; align-items: center; gap: 10px; color: var(--cobalt-dark); background: var(--cobalt-soft); font-size: 13px; font-weight: 700; }
.rail-context svg { width: 18px; }
.rail-help { margin: auto 2px 18px; padding: 13px 11px; border: 1px solid var(--line); border-radius: 8px; display: grid; grid-template-columns: 28px 1fr; gap: 8px; background: #fbfcfd; }
.rail-help > span { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--mint-soft); color: var(--mint); }
.rail-help svg { width: 14px; }
.rail-help strong, .rail-help small { display: block; }
.rail-help strong { font-size: 10px; }
.rail-help small { margin-top: 4px; color: var(--muted); font-size: 8px; line-height: 1.45; }
.profile-trigger { width: 100%; min-height: 58px; padding: 7px 9px; border: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 36px minmax(0, 1fr) 16px; gap: 9px; align-items: center; background: transparent; text-align: left; }
.profile-trigger:hover { background: var(--surface-soft); }
.profile-trigger > span:nth-child(2) { min-width: 0; }
.profile-trigger strong, .profile-trigger small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-trigger strong { font-size: 11px; }
.profile-trigger small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.profile-trigger > svg { width: 15px; color: #9299a3; }
.profile-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--cobalt-soft); color: var(--cobalt-dark); font-size: 12px; font-weight: 800; }

.app-main { min-width: 0; height: 100%; overflow: auto; background: var(--canvas); }
.app-header { position: sticky; z-index: 20; top: 0; height: 74px; padding: 0 42px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px); }
.desktop-heading p { margin: 0 0 3px; color: var(--cobalt); font-size: 8px; font-weight: 800; }
.desktop-heading h1 { margin: 0; font-size: 20px; line-height: 1; }
.mobile-brand, .header-actions { display: none; }

.documents-view { width: min(1180px, calc(100% - 64px)); margin: 0 auto; padding: 34px 0 110px; }
.documents-heading { min-height: 58px; margin-bottom: 26px; display: flex; align-items: flex-start; justify-content: space-between; }
.documents-heading p { margin: 0 0 7px; color: var(--cobalt); font-size: 11px; font-weight: 800; }
.documents-heading h2 { margin: 0; font-size: 28px; line-height: 1.1; }
.desktop-add { min-height: 40px; background: var(--cobalt); color: white; }
.desktop-add:hover { background: var(--cobalt-dark); }
.document-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
.document-search { height: 52px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 8px; display: grid; grid-template-columns: 21px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; background: var(--surface); box-shadow: var(--shadow-sm); }
.document-search:focus-within { border-color: var(--cobalt); box-shadow: 0 0 0 3px rgba(30, 94, 255, .1); }
.document-search > svg { width: 18px; color: var(--cobalt); }
.document-search input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; }
.document-search input::placeholder { color: #8c939d; }
.document-search kbd { padding: 3px 7px; border: 1px solid var(--line); border-radius: 4px; color: #7d8590; background: #fafbfc; font: 10px ui-monospace, monospace; }
.document-search button { width: 27px; height: 27px; padding: 0; border: 0; display: grid; place-items: center; background: transparent; }
.document-search button svg { width: 14px; }
.filter-button { position: relative; height: 52px; padding: 0 15px; border: 1px solid var(--line-strong); border-radius: 8px; display: flex; align-items: center; gap: 8px; background: var(--surface); color: #515966; font-size: 11px; font-weight: 700; box-shadow: var(--shadow-sm); }
.filter-button svg { width: 17px; color: var(--cobalt); }
.filter-button b { min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; background: var(--cobalt); color: white; font-size: 8px; }
.date-filter-panel { margin-top: 8px; padding: 13px; border: 1px solid var(--line); border-radius: 8px; display: flex; justify-content: flex-end; align-items: end; gap: 9px; background: var(--surface); box-shadow: var(--shadow-sm); }
.date-filter-panel label { display: grid; gap: 5px; }
.date-filter-panel label span { color: var(--muted); font-size: 9px; font-weight: 700; }
.date-filter-panel input { height: 37px; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.text-button { height: 37px; padding: 0 12px; border: 0; background: transparent; color: var(--cobalt); font-size: 10px; font-weight: 700; }
.apply-button { min-height: 37px; height: 37px; background: var(--ink); color: white; font-size: 10px; }
.result-context { min-height: 60px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.result-context p { margin: 0; color: var(--muted); font-size: 12px; }
.document-day { margin-top: 20px; }
.document-day > h2 { margin: 0 0 8px; color: #68717d; font-size: 11px; font-weight: 750; text-transform: uppercase; }
.document-group { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); }
.document-row { min-height: 50px; padding: 6px 6px 6px 10px; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto 34px; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); transition: background .16s ease; }
.document-row:last-child { border-bottom: 0; }
.document-row:hover { background: #f8faff; }
.file-icon { width: 28px; height: 32px; border-radius: 4px; display: grid; place-items: center; background: var(--cobalt-soft); color: var(--cobalt); }
.file-icon svg { width: 15px; }
.document-copy { min-width: 0; display: flex; align-items: baseline; gap: 9px; white-space: nowrap; }
.document-copy strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.document-copy small { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.source-channel { display: inline-flex; align-items: center; gap: 4px; color: #4f5966; }
.source-channel svg { width: 13px; height: 13px; color: var(--cobalt); }
.meta-separator { color: #a2a9b2; }
.shared-label { color: var(--cobalt-dark); font-weight: 650; }
.document-time { color: #7b838e; font-size: 11px; white-space: nowrap; }
.download-button { width: 36px; height: 36px; padding: 0; border: 0; border-radius: 7px; display: grid; place-items: center; background: transparent; color: var(--cobalt); }
.download-button:hover { background: var(--cobalt-soft); }
.download-button svg { width: 16px; }
.empty-documents { padding: 76px 20px; text-align: center; }
.empty-documents > span { width: 54px; height: 54px; margin: 0 auto 18px; border-radius: 12px; display: grid; place-items: center; background: var(--cobalt-soft); color: var(--cobalt); }
.empty-documents svg { width: 23px; }
.empty-documents h2 { margin: 0; font-size: 20px; }
.empty-documents p { max-width: 390px; margin: 8px auto 20px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.empty-documents a { background: var(--cobalt); color: white; }
.scroll-sentinel { height: 45px; display: grid; place-items: center; }
.scroll-sentinel.loading span { width: 19px; height: 19px; border: 2px solid var(--line); border-top-color: var(--cobalt); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chat-scrim { position: fixed; z-index: 39; inset: 0; border: 0; background: rgba(24, 30, 38, .18); backdrop-filter: blur(1px); }
.chat-view { position: fixed; z-index: 40; right: 24px; bottom: 88px; width: min(430px, calc(100% - 32px)); height: min(650px, calc(100dvh - 112px)); overflow: hidden; border: 1px solid var(--line-strong); border-radius: 8px; display: grid; grid-template-rows: 58px minmax(0, 1fr) auto; background: var(--surface); box-shadow: 0 24px 70px rgba(22, 29, 37, .24); }
.chat-panel-header { padding: 0 10px 0 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.chat-panel-header > div { display: flex; align-items: center; gap: 10px; }
.chat-panel-header > div > span:last-child { display: grid; gap: 2px; }
.chat-panel-header small { color: var(--cobalt); font-size: 9px; font-weight: 800; }
.chat-panel-header strong { font-size: 14px; }
.chat-panel-mark { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; color: white; background: var(--cobalt); font-size: 16px; font-weight: 800; }
.chat-thread { width: auto; margin: 0; padding: 18px; overflow: auto; }
.chat-welcome { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.chat-logo { width: 54px; height: 54px; display: block; }
.chat-logo svg { width: 100%; color: var(--cobalt); }
.chat-logo rect { fill: currentColor; }
.chat-logo path { fill: white; }
.chat-welcome > p { margin: 15px 0 7px; color: var(--cobalt); font-size: 10px; font-weight: 800; }
.chat-welcome h2 { margin: 0; font-size: 24px; }
.chat-subtitle { margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.chat-prompts { width: min(520px, 100%); margin-top: 25px; display: grid; gap: 7px; }
.chat-prompts button { min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; display: grid; grid-template-columns: 24px minmax(0, 1fr) 16px; gap: 9px; align-items: center; background: var(--surface); color: #505865; text-align: left; font-size: 12px; }
.chat-prompts button:hover { border-color: #aab9df; color: var(--ink); }
.chat-prompts svg { width: 16px; color: var(--cobalt); }
.chat-prompts svg:last-child { width: 14px; color: #8e96a1; }
.chat-message { max-width: 75%; margin: 9px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 12px; line-height: 1.5; }
.chat-message.user { margin-left: auto; border-color: var(--cobalt); background: var(--cobalt); color: white; }
.chat-message.system { color: var(--muted); }
.chat-composer { position: relative; width: auto; margin: 0 14px 14px; }
.chat-composer textarea { width: 100%; min-height: 58px; max-height: 140px; padding: 18px 60px 18px 16px; resize: none; border: 1px solid var(--line-strong); border-radius: 9px; outline: 0; background: var(--surface); box-shadow: 0 12px 35px rgba(22, 29, 37, .08); }
.chat-composer textarea:focus { border-color: var(--cobalt); box-shadow: 0 0 0 3px rgba(30, 94, 255, .1); }
.chat-composer > button { position: absolute; right: 9px; top: 9px; width: 40px; height: 40px; border: 0; border-radius: 7px; display: grid; place-items: center; background: var(--cobalt); color: white; }
.chat-composer > button svg { width: 17px; }
.chat-composer small { display: block; margin-top: 7px; color: #8b929c; text-align: center; font-size: 8px; }
.mobile-nav { display: none; }
.floating-actions { position: fixed; z-index: 38; right: 24px; bottom: 24px; display: flex; gap: 10px; }
.chat-open .floating-actions { opacity: 0; pointer-events: none; transform: translateY(8px); }
.floating-action { position: relative; width: 52px; height: 52px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; color: white; text-decoration: none; box-shadow: 0 12px 28px rgba(22, 29, 37, .2); transition: transform .18s ease, box-shadow .18s ease; }
.floating-action:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(22, 29, 37, .25); }
.floating-action svg { width: 22px; }
.whatsapp-action { background: #1ba76f; }
.chat-action { background: var(--cobalt); }
.chat-action > svg { position: absolute; right: 7px; bottom: 6px; width: 13px; }
.floating-n { font-size: 20px; font-weight: 800; }

/* Dialogs */
dialog { border: 0; border-radius: 12px; color: var(--ink); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(20, 25, 32, .62); backdrop-filter: blur(4px); }
.dialog-close { position: absolute; right: 11px; top: 11px; }
.download-dialog, .profile-dialog { width: min(460px, calc(100% - 26px)); padding: 34px; }
.dialog-icon { width: 42px; height: 42px; margin-bottom: 18px; border-radius: 10px; display: grid; place-items: center; background: var(--cobalt-soft); color: var(--cobalt); }
.dialog-icon svg { width: 19px; }
.dialog-kicker, .profile-heading p { margin: 0 0 7px; color: var(--cobalt); font-size: 8px; font-weight: 800; }
.download-dialog h2 { margin: 0 40px 22px 0; font-size: 22px; }
.download-list { display: grid; gap: 7px; }
.download-list a { min-height: 58px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; display: grid; grid-template-columns: 34px minmax(0, 1fr) 18px; gap: 9px; align-items: center; text-decoration: none; }
.download-list a:hover { border-color: var(--cobalt); background: #f9fbff; }
.download-list a > span:first-child { width: 32px; height: 36px; border-radius: 5px; display: grid; place-items: center; background: var(--cobalt-soft); color: var(--cobalt); }
.download-list svg { width: 15px; }
.download-list strong, .download-list small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.download-list strong { font-size: 10px; }
.download-list small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.profile-heading { margin-bottom: 24px; display: grid; grid-template-columns: 52px 1fr; gap: 13px; align-items: center; }
.profile-avatar.large { width: 52px; height: 52px; font-size: 17px; }
.profile-heading p { margin-bottom: 4px; }
.profile-heading h2 { margin: 0; font-size: 22px; }
.profile-form { margin-bottom: 12px; }
.profile-form label > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 9px; font-weight: 700; }
.profile-form label > div { height: 44px; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; display: grid; grid-template-columns: 1fr auto; }
.profile-form input { min-width: 0; padding: 0 11px; border: 0; outline: 0; }
.profile-form button { padding: 0 14px; border: 0; border-left: 1px solid var(--line); background: var(--surface-soft); color: var(--cobalt); font-size: 9px; font-weight: 800; }
.profile-contact { min-height: 58px; padding: 9px 3px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 27px minmax(0, 1fr) 20px; gap: 8px; align-items: center; }
.profile-contact > svg:first-child { width: 17px; color: #707985; }
.profile-contact small, .profile-contact strong { display: block; }
.profile-contact small { color: var(--muted); font-size: 8px; }
.profile-contact strong { margin-top: 3px; overflow: hidden; text-overflow: ellipsis; font-size: 10px; }
.verified-icon { width: 16px; color: var(--mint); }
.profile-note { margin: 13px 0 24px; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; }
.profile-note svg { width: 14px; color: var(--mint); }
.signout-button { width: 100%; height: 42px; border: 1px solid #efc7c1; border-radius: 7px; display: flex; align-items: center; justify-content: center; gap: 8px; background: #fff8f7; color: var(--danger); font-size: 10px; font-weight: 700; }
.signout-button svg { width: 15px; }

/* Legal pages */
.legal-page { min-height: 100vh; background: var(--surface); }
.legal-page .public-header { position: static; height: 72px; padding: 0 5vw; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.legal-page main { width: min(760px, calc(100% - 40px)); margin: 0 auto; padding: 100px 0; }
.legal-page main .eyebrow { color: var(--cobalt); font-size: 9px; font-weight: 800; }
.legal-page main h1 { margin: 14px 0 24px; font-size: 48px; line-height: 1.05; }
.legal-page main > p:last-child { color: var(--muted); font-size: 16px; line-height: 1.8; }

@media (max-width: 760px) {
    .app-shell { display: block; }
    .app-rail { display: none; }
    .app-main { height: 100dvh; }
    .app-header { height: 68px; padding: 0 14px; }
    .desktop-heading { display: none; }
    .mobile-brand { display: block; }
    .mobile-brand .brand-name { font-size: 21px; }
    .mobile-brand .brand-mark { width: 31px; height: 31px; }
    .header-actions { display: flex; align-items: center; gap: 4px; }
    .profile-avatar-button { border: 0; }
    .documents-view { width: auto; padding: 22px 12px 105px; }
    .documents-heading { min-height: 45px; margin-bottom: 16px; }
    .documents-heading p { font-size: 8px; }
    .documents-heading h2 { font-size: 23px; }
    .desktop-add { display: none; }
    .document-tools { grid-template-columns: minmax(0, 1fr) auto; }
    .document-search { height: 48px; padding: 0 11px; grid-template-columns: 19px minmax(0, 1fr) auto; }
    .document-search input { font-size: 11px; }
    .document-search kbd { display: none; }
    .filter-button { width: 48px; height: 48px; padding: 0; justify-content: center; }
    .filter-button span { display: none; }
    .filter-button b { position: absolute; top: -5px; right: -5px; }
    .date-filter-panel { padding: 11px; display: grid; grid-template-columns: 1fr 1fr; }
    .date-filter-panel input { width: 100%; }
    .date-filter-panel .text-button, .date-filter-panel .apply-button { width: 100%; }
    .result-context { min-height: 48px; }
    .document-day { margin-top: 17px; }
    .document-row { min-height: 50px; padding: 5px 4px 5px 8px; grid-template-columns: 28px minmax(0, 1fr) 32px; gap: 8px; }
    .file-icon { width: 27px; height: 31px; }
    .file-icon svg { width: 14px; }
    .document-copy { gap: 6px; }
    .document-copy strong { font-size: 12px; }
    .document-copy small { font-size: 10px; }
    .file-count, .source-channel + .meta-separator { display: none; }
    .document-time { display: none; }
    .download-button { width: 32px; height: 32px; }
    .chat-view { left: 8px; right: 8px; bottom: 80px; width: auto; height: min(650px, calc(100dvh - 96px)); }
    .chat-thread { width: auto; padding: 16px; }
    .chat-welcome { justify-content: flex-start; padding-top: 4vh; }
    .chat-welcome h2 { font-size: 24px; }
    .chat-subtitle { max-width: 310px; font-size: 11px; line-height: 1.5; }
    .chat-prompts { margin-top: 22px; }
    .chat-composer { width: auto; margin: 0 10px 10px; }
    .chat-composer small { display: none; }
    .floating-actions { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); }
    .floating-action { width: 50px; height: 50px; }
    dialog { margin: auto 12px; width: calc(100% - 24px); padding: 27px 20px; }
    .toast { bottom: 78px; }
    .legal-page main { padding: 70px 0; }
    .legal-page main h1 { font-size: 36px; }
}

@media (max-width: 390px) {
    .document-search input { font-size: 10px; }
    .profile-dialog, .download-dialog { padding: 26px 18px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
