:root {
    font-family: "Segoe UI", Arial, sans-serif;
    color: #243248;
    background: #f3f5f9;
    font-synthesis: none;
    --blue: #3375ec;
    --muted: #8591a4;
    --border: #e7ecf3;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, label.dropzone { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
button:focus-visible, a:focus-visible { outline: 3px solid #93b7fb; outline-offset: 3px; }
[hidden] { display: none !important; }
svg { display: block; width: 24px; height: 24px; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 242px; flex-shrink: 0; background: #16243b; color: #fff; padding: 34px 18px 22px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; margin: 0 12px 47px; text-decoration: none; color: #fff; font-size: 21px; font-weight: 650; line-height: 1.2; }
.brand-icon { display: block; width: 52px; height: 52px; flex-shrink: 0; object-fit: contain; border-radius: 12px; }
.brand-subtitle { display: block; font-size: 17px; font-weight: 400; color: #b9c6d9; }
.nav-label { color: #8494ae; font-size: 10px; letter-spacing: 1.6px; font-weight: 600; margin: 0 15px 14px; }
.main-nav { display: grid; gap: 9px; }
.nav-button { width: 100%; text-align: left; border: 0; background: none; color: #bfc9d9; border-radius: 9px; padding: 15px 14px; line-height: 1.45; font-size: 13px; transition: background .15s, color .15s; }
.nav-button:hover { background: #23344e; color: #fff; }
.nav-button.active { background: #3375ec; color: #fff; box-shadow: 0 5px 18px #0d193444; }
.sidebar-note { margin: auto 9px 28px; padding-top: 65px; font-size: 12px; }
.sidebar-note-icon { color: #8db3fa; font-size: 24px; display: block; margin-bottom: 12px; }
.sidebar-note strong { font-weight: 500; }
.sidebar-note p { color: #8293ae; font-size: 12px; line-height: 1.65; max-width: 162px; }
.sidebar-footer { display: flex; gap: 8px; align-items: center; color: #9eacc2; border-top: 1px solid #ffffff12; padding: 20px 7px 0; font-size: 10px; }
.status-dot { flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%; background: #49ad8b; display: inline-block; }
.main-area { flex: 1; min-width: 0; }
.topbar { min-height: 78px; padding: 18px 32px; background: white; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.topbar-label { color: #8c98aa; font-size: 12px; }
.topbar-label span { margin: 0 12px; color: #c7d0dc; }
.profile { position: relative; }
.profile-button { display: flex; align-items: center; gap: 13px; background: none; border: none; padding: 0; font-size: 12px; color: #51617a; }
#profile-name { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: #edf2fa; color: #91a0b6; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-popover { position: absolute; top: 50px; right: 0; width: 250px; background: white; border: 1px solid var(--border); box-shadow: 0 12px 30px #2639551a; padding: 19px; border-radius: 12px; z-index: 5; }
.profile-popover span { display: block; font-size: 11px; color: var(--muted); }
.profile-popover strong { display: block; font-size: 13px; font-weight: 500; overflow-wrap: anywhere; margin: 7px 0 18px; }
.profile-popover button { width: 100%; background: #f1f4f8; border: none; border-radius: 7px; padding: 9px; color: #4d5f79; }
.content { max-width: 1590px; margin: 0 auto; padding: 29px 32px 18px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 27px; }
.eyebrow { font-size: 10px; letter-spacing: 1.65px; color: #8b98ac; font-weight: 600; }
h1 { font-size: 25px; font-weight: 650; letter-spacing: -.6px; margin: 9px 0 8px; line-height: 1.3; }
.page-heading p { color: #8995a7; font-size: 12px; margin: 0; line-height: 1.7; }
.page-badge { display: flex; align-items: center; gap: 7px; flex-shrink: 0; font-size: 10px; color: #749587; background: #eaf3ef; padding: 8px 11px; border-radius: 6px; }
.workspace { display: grid; grid-template-columns: minmax(235px, .86fr) minmax(275px, 1.08fr) minmax(295px, 1.06fr); gap: 19px; align-items: start; }
.workspace.is-question { grid-template-columns: minmax(300px, .94fr) minmax(360px, 1.2fr); }
.card { border: 1px solid #e3e8f0; background: white; border-radius: 12px; box-shadow: 0 3px 9px #25385704; overflow: hidden; }
.card-heading { min-height: 66px; padding: 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 9px; }
.card-heading h2 { font-size: 12px; font-weight: 600; margin: 0; white-space: nowrap; }
.step-number { color: #8b9dbb; font-size: 9px; background: #eff3f9; border-radius: 5px; min-width: 23px; height: 23px; display: grid; place-items: center; }
#request-form { padding: 21px 19px 18px; }
.field { margin-bottom: 21px; }
.field > label, .field-label, .login-card label { display: block; margin-bottom: 9px; font-size: 11px; font-weight: 550; color: #586880; }
select, textarea, .login-card input { width: 100%; border: 1px solid #e0e6ef; border-radius: 7px; padding: 12px; color: #50617b; background: #fbfcfe; font-size: 12px; outline: none; }
select { padding: 11px 30px 11px 10px; text-overflow: ellipsis; }
textarea { resize: vertical; min-height: 128px; line-height: 1.65; }
textarea::placeholder { color: #a4aebd; }
select:focus, textarea:focus, .login-card input:focus { border-color: #75a2f5; box-shadow: 0 0 0 3px #3375ec0f; }
.field .dropzone { border: 1.5px dashed #ccdbf1; border-radius: 9px; padding: 22px 10px 19px; margin: 0; background: #f8faff; text-align: center; display: flex; flex-direction: column; align-items: center; cursor: pointer; transition: background .15s, border-color .15s; }
.dropzone:hover, .dropzone.dragging, .dropzone:focus-within { background: #eef4ff; border-color: var(--blue); }
.upload-icon { display: grid; place-items: center; width: 45px; height: 45px; border-radius: 12px; background: #eaf1ff; color: #4b82e9; margin-bottom: 15px; }
.dropzone strong { font-size: 11px; font-weight: 500; overflow-wrap: anywhere; max-width: 100%; margin-bottom: 6px; }
.dropzone > span:not(.upload-icon) { font-size: 10px; font-weight: 400; color: #8a99af; }
.dropzone .file-formats { margin-top: 14px; color: #a1adc0 !important; font-size: 9px !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.text-button { background: none; border: none; color: #73849f; padding: 0; font-size: 10px; }
.remove-file { display: block; margin-top: 10px; margin-left: auto; }
.primary-button { border: 0; background: var(--blue); color: white; width: 100%; padding: 12px 15px; border-radius: 7px; font-size: 12px; font-weight: 500; transition: background .15s; }
.primary-button:hover { background: #2465d8; }
.form-hint { font-size: 10px; color: #94a1b5; line-height: 1.65; text-align: center; margin: 12px 4px 0; }
.form-error { font-size: 11px; line-height: 1.6; color: #c4494d; padding: 10px 12px; background: #fff2f2; border-radius: 6px; }
.request-tip { border-top: 1px solid var(--border); padding: 15px 18px; display: flex; gap: 10px; align-items: start; background: #fcfdff; }
.request-tip > span { font-size: 15px; }
.request-tip p { color: #91a0b4; font-size: 10px; line-height: 1.7; margin: 0; }
.zoom-controls { margin-left: auto; display: flex; align-items: center; gap: 6px; color: #99a5b7; font-size: 9px; }
.zoom-controls button { width: 23px; height: 23px; border: 1px solid #e4eaf2; border-radius: 4px; background: white; color: #70829e; font-size: 14px; padding: 0; }
.document-preview { margin: 15px; background: #f2f4f8; border: 1px solid #e9edf3; border-radius: 7px; height: 330px; overflow: auto; display: flex; align-items: safe center; justify-content: safe center; }
.preview-empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 24px; color: #c7d1e0; }
.preview-empty svg { width: 55px; height: 62px; margin-bottom: 24px; }
.preview-empty strong { font-size: 11px; font-weight: 500; color: #94a3b9; margin-bottom: 9px; }
.preview-empty span { color: #a7b2c3; font-size: 10px; line-height: 1.65; max-width: 180px; }
.preview-stage { position: relative; flex-shrink: 0; line-height: 0; }
#preview-image { display: block; width: 100%; height: auto; padding: 0; }
#visual-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.document-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 0 15px 12px; font-size: 11px; color: #586880; }
.document-tools label { display: flex; align-items: center; gap: 4px; }
.document-tools select { width: auto; padding: 4px; }
.document-tools a { color: var(--blue); }
.visual-results { border-top: 1px solid var(--border); padding: 12px 18px; font-size: 11px; line-height: 1.7; color: #586880; }
.visual-results ul { margin: 5px 0; padding-left: 18px; }
.visual-results p { margin: 5px 0; }
.visual-legend { display: flex; flex-wrap: wrap; gap: 10px; }
.visual-legend .stamp { color: #16843c; }
.visual-legend .signature { color: #2465d8; }
.visual-legend .uncertain { color: #8c6700; }
.recognition { border-top: 1px solid var(--border); padding: 17px 18px 20px; }
.recognition-heading { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.recognition-heading h3 { font-size: 11px; font-weight: 600; margin: 0; }
.recognition-heading span { color: #90a0b7; font-size: 8px; border: 1px solid #e3eaf4; border-radius: 4px; padding: 4px 6px; }
#recognized-text { white-space: pre-wrap; overflow-wrap: anywhere; font: 10px/1.8 "Segoe UI", Arial, sans-serif; color: #91a0b4; max-height: 158px; overflow: auto; margin: 13px 0 0; }
#recognized-text.has-text { color: #586a83; }
.chat-card { display: flex; flex-direction: column; }
.chat-badge { margin-left: auto; color: #739789; background: #eef7f2; font-size: 8px; padding: 5px 7px; border-radius: 4px; white-space: nowrap; }
.chat-messages { height: 439px; padding: 19px 16px; overflow: auto; overscroll-behavior: contain; }
.is-question .chat-messages { height: 415px; }
.chat-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; }
.chat-empty-icon { display: grid; place-items: center; color: #9bb6e4; background: #f0f5fd; width: 60px; height: 60px; border-radius: 18px; margin-bottom: 16px; }
.chat-empty-icon svg { width: 31px; height: 31px; }
.chat-empty h3 { font-size: 12px; color: #7b8ea9; font-weight: 500; margin: 0 0 9px; }
.chat-empty p { font-size: 10px; color: #a1aec0; line-height: 1.9; margin: 0; }
.chat-message { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 18px; gap: 5px; }
.chat-message.student { align-items: flex-end; }
.message-author { color: #8c9ab0; font-size: 9px; margin: 0 4px; }
.message-body { max-width: 100%; padding: 12px 14px; border-radius: 9px 9px 9px 2px; color: #627590; background: #f2f5f9; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; line-height: 1.7; }
.student .message-body { background: #eaf2ff; color: #4e74a8; border-radius: 9px 9px 2px 9px; }
.dean .message-body { background: #edf6f1; color: #4f7b68; }
.message-time { font-size: 8px; color: #a6b2c3; padding: 0 4px; }
.message-photo { display: block; margin-bottom: 8px; padding: 0; border: none; background: none; }
.message-photo img { display: block; width: 116px; max-height: 135px; object-fit: cover; border-radius: 5px; }
.chat-footer { display: flex; align-items: center; gap: 7px; font-size: 9px; color: #92a1b6; padding: 15px 18px; border-top: 1px solid var(--border); background: #fcfdff; }
.page-footer { text-align: center; margin: 24px 0 0; color: #a8b3c4; font-size: 9px; }
.page-footer span { margin: 0 8px; }
dialog { border: none; border-radius: 12px; padding: 32px 18px 18px; max-width: 90vw; max-height: 90vh; }
dialog::backdrop { background: #15233bb3; }
#dialog-photo { display: block; max-width: 80vw; max-height: 78vh; object-fit: contain; }
.dialog-close { position: absolute; right: 9px; top: 3px; background: none; border: none; color: #7889a1; font-size: 26px; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 25px; background: linear-gradient(140deg, #edf3fc, #f9fafc); }
.login-card { width: 100%; max-width: 430px; background: white; padding: 38px; border: 1px solid #e5ebf5; border-radius: 20px; box-shadow: 0 18px 60px #253b5b0a; }
.login-icon { display: block; width: 112px; height: 112px; object-fit: contain; border-radius: 14px; margin-bottom: 26px; }
.login-card h1 { margin-top: 10px; }
.login-card > p { color: #91a0b5; font-size: 12px; line-height: 1.9; margin: 14px 0 28px; }
.login-card > p strong { font-weight: 600; color: #7186a5; }
.telegram-bot-link { color: var(--blue); text-decoration: underline; text-decoration-color: #a8c5fa; text-underline-offset: 3px; }
.telegram-bot-link:hover { color: #2465d8; text-decoration-color: currentColor; }
.document-type-result { padding: 10px 18px; font-size: 11px; color: #586880; border-top: 1px solid var(--border); }
.type-notice { margin: 12px 15px; padding: 12px; border: 1px solid #e8c45d; background: #fff8df; color: #775a14; border-radius: 7px; font-size: 12px; line-height: 1.6; }
.type-notice p { margin: 0 0 9px; }
.warning-button { display: block; width: 100%; padding: 12px; margin-bottom: 8px; border: 1px solid #c99d28; border-radius: 7px; background: #f4cd61; color: #513c09; font: inherit; font-weight: 600; cursor: pointer; }
.warning-button:disabled { opacity: .6; cursor: wait; }
.type-notice .text-button { color: #715315; text-decoration: underline; font-size: 12px; }
.type-notice.neutral { border-color: #dbe3ee; background: #f3f6fa; color: #586880; }
.review-actions { padding: 0 15px 15px; font-size: 11px; line-height: 1.6; color: #586880; }
.review-actions button + button { margin-top: 8px; }
.field-card, .ai-panel { margin: 12px 15px; font-size: 12px; line-height: 1.6; }
.field-card summary { cursor: pointer; font-weight: 600; }
.field-card dt { font-weight: 600; margin-top: 8px; }
.field-card dd { margin-left: 0; overflow-wrap: anywhere; }
.ai-panel textarea { display: block; width: 100%; margin: 8px 0; padding: 8px; border: 1px solid #dbe3ee; border-radius: 6px; resize: vertical; font: inherit; }
#ai-answer { white-space: pre-wrap; overflow-wrap: anywhere; }
.validation-result { margin: 12px 15px; padding: 12px; border-radius: 7px; background: #fff8df; color: #775a14; font-size: 12px; line-height: 1.6; }
.validation-result[data-status="document_ok"] { background: #edf8f0; color: #23713c; }
.validation-result h3 { margin: 0 0 8px; }
.login-card input { margin-bottom: 14px; }
.login-footer { display: block; margin-top: 26px; color: #acb7c7; font-size: 10px; line-height: 1.7; }
@media (min-width: 1500px) {
    .content { padding-top: 37px; }
    .document-preview { height: 400px; }
    .chat-messages { height: 509px; }
}
@media (max-width: 1250px) {
    .sidebar { width: 215px; padding-inline: 12px; }
    .content { padding: 25px 22px 18px; }
    .topbar { padding-inline: 22px; }
    .workspace { grid-template-columns: minmax(240px, 1fr) minmax(275px, 1.1fr); }
    .chat-card { grid-column: 1 / -1; }
    .chat-messages { height: 300px; }
    .workspace.is-question .chat-card { grid-column: auto; }
    .workspace.is-question { grid-template-columns: minmax(270px, 1fr) minmax(290px, 1.1fr); }
    .page-badge { display: none; }
}
@media (max-width: 820px) {
    .app-shell { display: block; }
    .sidebar { width: 100%; padding: 20px 18px 16px; }
    .brand { font-size: 18px; margin: 0 0 18px; }
    .brand-subtitle { display: inline; margin-left: 5px; font-size: 18px; }
    .brand-icon { width: 44px; height: 44px; border-radius: 9px; }
    .nav-label, .sidebar-note, .sidebar-footer { display: none; }
    .main-nav { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .nav-button { font-size: 10px; padding: 11px 10px; }
    .topbar { min-height: 67px; padding: 14px 20px; }
    .content { padding: 22px 18px 18px; }
    h1 { font-size: 23px; }
    .workspace.is-question { grid-template-columns: 1fr; }
    .workspace.is-question .chat-messages { height: 330px; }
}
@media (max-width: 560px) {
    .main-nav { grid-template-columns: 1fr; gap: 4px; }
    .nav-button { font-size: 11px; padding: 9px 12px; }
    .brand { margin-bottom: 12px; }
    .topbar-label { font-size: 10px; }
    .topbar-label span { margin-inline: 6px; }
    #profile-name { max-width: 110px; font-size: 10px; }
    .profile-button { gap: 8px; }
    .avatar { width: 33px; height: 33px; }
    .workspace { grid-template-columns: 1fr; gap: 16px; }
    .chat-card { grid-column: auto; }
    .page-heading { margin-bottom: 20px; }
    .page-heading p { font-size: 11px; }
    .content { padding-inline: 13px; }
    .document-preview { height: 340px; }
    .login-card { padding: 28px; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
}
