:root {
    color-scheme: light;
    --ink: #172033;
    --muted: #59657b;
    --paper: #fff;
    --background: #eef2f7;
    --line: #dce3eb;
    --nav: #151c2e;
    --nav-muted: #b2bed1;
    --accent: #ffb768;
    --accent-hover: #ffa94d;
    --link: #254c81;
    --focus: #1d5cab;
    --radius: 14px;
    --shadow: 0 2px 4px #17203307;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 100%;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--background); line-height: 1.5; }
a { color: var(--link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: clamp(1.8rem, 4vw, 2.65rem); line-height: 1.12; letter-spacing: -.045em; overflow-wrap: anywhere; }
h2 { font-size: 1.15rem; line-height: 1.3; letter-spacing: -.02em; }
h3 { font-size: 1rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .875rem; }
.preserve { white-space: pre-wrap; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.text-danger { color: #a4292b; }

.skip-link { position: fixed; inset: 10px auto auto 10px; z-index: 2; transform: translateY(-180%); padding: 10px 14px; background: #fff; border-radius: 8px; }
.skip-link:focus { transform: translateY(0); }

.workspace { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 35px;
    padding: 25px 16px 18px;
    background: var(--nav);
    color: white;
}
.sidebar :focus-visible, .login-aside :focus-visible { outline-color: var(--accent); }
.brand { display: inline-flex; align-items: center; gap: 12px; width: fit-content; color: #fff; text-decoration: none; font-size: 1.18rem; font-weight: 760; letter-spacing: -.035em; white-space: nowrap; }
.sidebar > .brand { margin-left: 6px; }
.brand-accent { color: var(--accent); }
.brand small { margin-left: 4px; font-size: .67rem; font-weight: 700; letter-spacing: .08em; color: var(--nav-muted); }
.brand-mark { display: flex; align-items: flex-end; justify-content: center; gap: 3px; width: 37px; height: 37px; padding-bottom: 9px; border-radius: 11px; background: var(--accent); }
.brand-mark i { width: 4px; background: var(--nav); border-radius: 2px; }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 13px; }
.brand-mark i:nth-child(3) { height: 19px; }

.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 9px; color: #d8e0ec; text-decoration: none; font-size: .93rem; font-weight: 580; }
.sidebar nav a:hover, .sidebar-profile:hover { background: #222d44; }
.sidebar nav a[aria-current], .sidebar-profile[aria-current] { color: var(--accent); background: #29334a; }
.nav-icon { width: 16px; height: 16px; position: relative; flex: 0 0 auto; }
.nav-dashboard { border: 1.5px solid currentColor; border-radius: 3px; }
.nav-dashboard::before, .nav-dashboard::after { position: absolute; content: ""; background: currentColor; }
.nav-dashboard::before { height: 1px; width: 100%; top: 5px; }
.nav-dashboard::after { width: 1px; height: 100%; left: 5px; }
.nav-companies { height: 13px; border: 1.5px solid currentColor; border-radius: 2px; margin-top: 2px; }
.nav-companies::before { position: absolute; content: ""; width: 7px; height: 3px; border: 1.5px solid currentColor; border-bottom: 0; border-radius: 2px 2px 0 0; top: -5px; left: 1px; }
.nav-orders { width: 13px; margin-inline: 1px 2px; border: 1.5px solid currentColor; border-radius: 2px; }
.nav-orders::before { position: absolute; content: ""; width: 6px; height: 1px; top: 4px; left: 2px; background: currentColor; box-shadow: 0 4px currentColor; }
.nav-team::before, .nav-team::after { position: absolute; content: ""; border: 1.5px solid currentColor; left: 50%; transform: translateX(-50%); }
.nav-team::before { width: 5px; height: 5px; top: 0; border-radius: 50%; }
.nav-team::after { width: 12px; height: 5px; bottom: 0; border-radius: 8px 8px 2px 2px; }

.sidebar-footer { margin-top: auto; border-top: 1px solid #354158; padding-top: 13px; }
.sidebar-profile { display: flex; align-items: center; gap: 9px; padding: 7px 6px; border-radius: 9px; color: #fff; text-decoration: none; }
.avatar { display: grid; place-items: center; width: 37px; height: 37px; flex: 0 0 auto; border-radius: 11px; color: #294476; background: #e7effe; font-size: .875rem; font-weight: 750; }
.sidebar .avatar { background: #34415b; color: #ffcd95; }
.identity { display: grid; min-width: 0; }
.identity strong { font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity small { color: var(--nav-muted); font-size: .8rem; }
.logout { margin: 4px 0 0; padding: 6px 10px; border: 0; background: none; color: var(--nav-muted); border-radius: 6px; font-size: .875rem; }
.logout:hover { background: #222d44; color: #fff; }

.main { min-width: 0; padding: 38px clamp(18px, 4vw, 54px) 48px; }
.main-inner { max-width: 1360px; margin-inline: auto; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px 24px; margin-bottom: 26px; }
.page-heading p { color: var(--muted); margin-top: 9px; }
.breadcrumb { display: inline-block; margin-bottom: 12px; font-size: .875rem; font-weight: 650; text-decoration: none; }
.breadcrumb:hover { text-decoration: underline; }

.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; padding: 9px 16px; border: 1px solid transparent; border-radius: 8px; background: var(--accent); color: #252018; font-size: .9rem; font-weight: 700; text-decoration: none; line-height: 1.35; text-align: center; flex: 0 0 auto; }
.button:hover { background: var(--accent-hover); }
.button.secondary { color: var(--ink); background: #fff; border-color: #c8d3e0; }
.button.secondary:hover { background: #edf3fa; border-color: #a8b9cc; }
.subtle-link { align-self: center; font-size: .875rem; }

.card { min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; min-height: 60px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.card-header a { font-size: .875rem; font-weight: 600; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric { display: grid; gap: 5px; min-height: 108px; padding: 14px 17px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: var(--shadow); color: var(--ink); text-decoration: none; }
.metric:first-child { background: #fff5e8; border-color: #f0d1aa; }
.metric:hover { border-color: #8b9db4; }
.metric span { color: #4e5c72; font-size: .875rem; font-weight: 620; }
.metric strong { font-size: 2rem; font-variant-numeric: tabular-nums; font-weight: 780; letter-spacing: -.045em; line-height: 1.2; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, .43fr); align-items: start; gap: 18px; }
.dashboard-grid > .card + .card { margin-top: 0; }
.status-chart { display: grid; gap: 14px; margin: 0; padding: 17px 20px 20px; list-style: none; }
.status-chart li { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: .875rem; }
.status-chart a { color: var(--ink); text-decoration: none; }
.status-chart a:hover { text-decoration: underline; }
.status-chart progress { appearance: none; width: 100%; height: 6px; grid-column: 1 / -1; border: 0; border-radius: 8px; background: #edf0f5; color: var(--bar, #6e809b); }
progress::-webkit-progress-bar { background: #edf0f5; border-radius: 8px; }
progress::-webkit-progress-value { background: var(--bar, #6e809b); border-radius: 8px; }
progress::-moz-progress-bar { background: var(--bar, #6e809b); border-radius: 8px; }
.bar-in_progress { --bar: #3a70af; }
.bar-waiting { --bar: #c88824; }
.bar-done { --bar: #41866c; }
.bar-cancelled { --bar: #a95056; }

.empty-state { min-height: 170px; display: grid; justify-items: center; align-content: center; gap: 7px; padding: 23px 18px; text-align: center; }
.empty-state p { color: var(--muted); font-size: .9rem; max-width: 330px; }
.empty-state .button { margin-top: 6px; }
.empty-icon { display: grid; gap: 4px; justify-items: start; align-content: center; width: 37px; height: 36px; padding-left: 9px; margin-bottom: 6px; border-radius: 9px; background: #e9eff9; }
.empty-icon i { border-radius: 2px; background: #5e7aa2; width: 18px; height: 2px; }
.empty-icon i:last-child { width: 11px; }

.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; }
th, td { padding: 12px 20px; vertical-align: top; font-size: .9rem; border-bottom: 1px solid var(--line); }
th { background: #f6f8fb; color: #48566e; font-weight: 670; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.table-link { color: #234673; font-weight: 700; overflow-wrap: anywhere; }
.table-sub { display: block; max-width: 350px; margin-top: 3px; color: var(--muted); font-size: .83rem; overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 6px; white-space: nowrap; font-size: .875rem; font-weight: 650; }
.status-new { color: #3f4d65; background: #e9edf3; }
.status-in_progress { color: #1f4c8b; background: #e2edfc; }
.status-waiting { color: #754405; background: #fff1d6; }
.status-done { color: #1b674e; background: #e0f3eb; }
.status-cancelled { color: #923438; background: #fbe9e9; }
.urgent-label { display: block; color: #a4292b; margin-top: 3px; font-size: .83rem; font-weight: 650; }

.filters { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; padding: 15px 19px; border-bottom: 1px solid var(--line); }
.filters .search-field { flex: 1 1 220px; max-width: 430px; }
.filters .field:not(.search-field) { flex: 0 1 155px; }
.filter-check { align-self: flex-end; min-height: 42px; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 9px 12px; padding: 12px 19px; border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.pagination .button { min-height: 35px; padding: 6px 12px; }

.form-card { max-width: 780px; padding: 22px; }
.form-card.narrow { max-width: 550px; }
.form-stack { display: grid; gap: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { display: grid; gap: 5px; min-width: 0; color: var(--ink); font-size: .9rem; font-weight: 640; }
.field input, .field select, .field textarea {
    width: 100%;
    min-height: 42px;
    padding: 8px 11px;
    border: 1px solid #b9c6d5;
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    font-weight: 470;
    font-size: 1rem;
}
.field input::placeholder { color: #657289; }
.field textarea { min-height: 96px; resize: vertical; }
.field select {
    appearance: none;
    padding-right: 34px;
    background-image: linear-gradient(45deg, transparent 49%, #536682 50%), linear-gradient(135deg, #536682 50%, transparent 51%);
    background-position: right 17px center, right 12px center;
    background-size: 5px 5px;
    background-repeat: no-repeat;
}
.check { display: flex; align-items: center; gap: 7px; font-size: .9rem; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--link); }
.form-stack .hint { margin-top: -8px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-top: 3px; }
.notice { margin-bottom: 16px; padding: 11px 14px; border: 1px solid #add7bf; border-radius: 8px; color: #1a5b41; background: #e5f4eb; }
.notice.error { color: #8a272a; background: #fdebec; border-color: #ecc5c9; }

.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 25px; padding: 17px 20px 21px; }
.detail-list div:last-child:nth-child(odd) { grid-column: 1 / -1; }
.detail-list dt { margin-bottom: 3px; color: var(--muted); font-size: .875rem; }
.detail-list dd { font-size: .95rem; overflow-wrap: anywhere; }
.order-summary { padding: 15px 20px; }
.order-company { font-weight: 720; overflow-wrap: anywhere; }
.order-summary p { margin-top: 7px; }
.order-details { border-top: 1px solid var(--line); }
.order-details summary { padding: 12px 20px; color: var(--link); cursor: pointer; font-size: .9rem; font-weight: 680; }
.order-details summary:hover { background: #f6f8fb; }
.order-details summary:focus-visible { outline-offset: -3px; }
.order-details[open] summary { background: #f6f8fb; border-bottom: 1px solid var(--line); }
.order-detail-actions { padding: 0 20px 18px; }
.order-work { scroll-margin-top: 14px; }
.order-tabs { display: flex; flex-wrap: wrap; gap: 0 18px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.order-tabs a { display: inline-flex; align-items: center; gap: 7px; min-height: 49px; padding: 9px 2px 7px; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 680; text-decoration: none; }
.order-tabs a:hover { color: var(--link); }
.order-tabs a[aria-current] { color: var(--ink); border-bottom-color: var(--accent-hover); }
.tab-count { min-width: 23px; padding: 0 5px; background: #edf2f8; color: #48566e; border-radius: 10px; font-size: .875rem; text-align: center; }
.document-table { table-layout: fixed; }
.document-table th { white-space: normal; }
.document-table th:first-child { width: 45%; }
.document-table td { overflow-wrap: anywhere; }
.note-form { padding: 17px 20px; }
.field .file { padding: 5px; background: #f7f9fc; font-size: .9rem; }
.file::file-selector-button { min-height: 31px; margin-right: 8px; padding: 4px 8px; border: 1px solid #bccbde; border-radius: 5px; background: #fff; color: var(--ink); cursor: pointer; }
.journal-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 20px; border-block: 1px solid var(--line); background: #f6f8fb; }
.journal-heading span { color: var(--muted); font-size: .82rem; }
.entries { list-style: none; padding: 0; margin: 0; }
.entry { display: flex; align-items: flex-start; gap: 10px; padding: 15px 20px; }
.entry + .entry { border-top: 1px solid var(--line); }
.entry.event > .avatar { color: #5b6473; background: #edf0f5; }
.entry-content { min-width: 0; flex: 1; }
.entry-content p { margin-top: 4px; font-size: .95rem; }
.entry-meta { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.entry-meta > strong { font-size: .9rem; overflow-wrap: anywhere; }
.event-time { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 7px; color: var(--muted); font-size: .875rem; }
.event-time strong { color: var(--ink); font-weight: 750; }
.event-time time { font-variant-numeric: tabular-nums; }
.entry-type { color: #536178; font-size: .82rem; font-weight: 640; }
.attachment { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; width: fit-content; max-width: 100%; margin-top: 7px; padding: 7px 9px; border: 1px solid #c8d7ec; border-radius: 7px; background: #f2f7ff; font-size: .875rem; font-weight: 640; overflow-wrap: anywhere; }
.attachment small { color: var(--muted); }
.reset-card summary { cursor: pointer; font-size: .95rem; font-weight: 690; }
.reset-card[open] summary { margin-bottom: 16px; }

.guest { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: #e6edf6; }
.login-grid { display: grid; grid-template-columns: 1fr 1fr; width: min(820px, 100%); min-height: 450px; border-radius: 20px; overflow: hidden; box-shadow: 0 16px 50px #24395420; }
.login-aside { display: grid; align-content: space-between; gap: 20px; padding: 30px; background: var(--nav); overflow: hidden; }
.login-art { display: grid; align-items: end; grid-template-columns: repeat(8, 1fr); gap: clamp(4px, 1.1vw, 12px); height: 220px; padding: 15px 4px 17px; border-bottom: 1px solid #3a4963; }
.login-art i { background: #354869; height: 21%; border-radius: 5px 5px 0 0; }
.login-art i:nth-child(2) { height: 31%; }
.login-art i:nth-child(3) { height: 46%; }
.login-art i:nth-child(4) { height: 40%; background: #42638c; }
.login-art i:nth-child(5) { height: 58%; background: #4d75a3; }
.login-art i:nth-child(6) { height: 71%; background: #638cbb; }
.login-art i:nth-child(7) { height: 65%; background: #cf915d; }
.login-art i:nth-child(8) { height: 93%; background: var(--accent); }
.guest-panel { display: grid; align-content: center; padding: clamp(25px, 5vw, 44px); background: #fff; }
.login-panel h1 { margin-bottom: 8px; }
.login-panel .form-stack { margin-top: 24px; }
.login-panel .notice { margin-top: 14px; margin-bottom: 0; }
.login-panel button { margin-top: 4px; }
.error-panel { width: min(550px, 100%); gap: 17px; border-radius: var(--radius); }
.error-panel > .brand { color: var(--ink); }
.error-panel .brand-accent { color: #975212; }
.error-panel .brand small { color: var(--muted); }
.error-panel .button { justify-self: start; }

@media (max-width: 1100px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .workspace { grid-template-columns: 180px minmax(0, 1fr); }
    .sidebar { padding-inline: 12px; }
    th, td { padding-inline: 13px; }
}
@media (max-width: 690px) {
    .workspace { display: block; }
    .sidebar { position: static; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 11px 8px; height: auto; padding: 11px 13px; }
    .sidebar > .brand { margin-left: 0; }
    .sidebar nav { grid-row: 2; grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
    .sidebar nav a { gap: 6px; padding: 7px 8px; font-size: .875rem; }
    .sidebar nav .nav-icon { display: none; }
    .sidebar-footer { display: flex; align-items: center; grid-column: 2; grid-row: 1; gap: 3px; padding-top: 0; border: 0; margin-top: 0; }
    .sidebar-profile { padding: 4px; }
    .sidebar-profile .identity { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
    .sidebar .avatar { width: 34px; height: 34px; }
    .logout { margin: 0; }
    .main { padding: 22px 13px 36px; }
    .page-heading { align-items: flex-start; flex-direction: column; margin-bottom: 17px; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .metric { min-height: 84px; padding: 10px 12px; }
    .metric strong { font-size: 1.65rem; }
    .form-card { padding: 15px; }
    .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 530px) {
    .login-grid { grid-template-columns: minmax(0, 1fr); min-height: auto; max-width: 410px; }
    .login-aside { padding: 16px 24px; }
    .login-art { display: none; }
    .detail-list { grid-template-columns: 1fr; }
    .document-table th, .document-table td { padding-inline: 8px; }
    .document-table th:first-child { width: 40%; }
}

[hidden] { display: none !important; }
.nav-chats { height: 13px; margin-bottom: 2px; border: 1.5px solid currentColor; border-radius: 4px; }
.nav-chats::after { position: absolute; content: ""; left: 2px; bottom: -3px; width: 4px; height: 4px; border-left: 1.5px solid currentColor; transform: skewY(-34deg); }
.chat-unread { min-width: 22px; margin-left: auto; padding: 1px 5px; color: #30251a; background: var(--accent); text-align: center; border-radius: 12px; font-size: .8rem; font-weight: 750; }
.chat-toast { position: fixed; right: 20px; bottom: 20px; z-index: 3; max-width: calc(100% - 40px); padding: 13px 16px; border: 1px solid #c7d5e8; border-radius: 9px; background: #fff; box-shadow: 0 4px 24px #202a4430; }
.chat-toast a { font-weight: 680; }
.chat-notify-settings { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chat-rooms { list-style: none; margin: 0; padding: 0; }
.chat-rooms li + li { border-top: 1px solid var(--line); }
.chat-rooms a { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 20px; text-decoration: none; }
.chat-rooms a:hover { background: #f6f8fb; }
.chat-rooms strong, .chat-rooms small { display: block; overflow-wrap: anywhere; }
.chat-rooms small { font-size: .875rem; color: var(--muted); }

.order-chat {
    --chat-line: #d4e0e7;
    --chat-control: #4e6674;
    --chat-control-hover: #e7f2ee;
    --chat-accent: #08705a;
    --chat-accent-hover: #065844;
}
.chat-icon { width: 21px; height: 21px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 10px 18px; padding: 13px 20px; border-bottom: 1px solid var(--chat-line); }
.chat-title { display: flex; align-items: center; gap: 11px; }
.chat-title .hint { display: block; font-size: .8rem; }
.chat-header-icon { display: grid; place-items: center; flex: none; width: 39px; height: 39px; border-radius: 13px; background: #e2f2ed; color: var(--chat-accent); }
.chat-header .chat-people { align-self: center; }
.chat-header .chat-people[open] { flex-basis: 100%; }
.chat-revoked { margin: 12px 20px; }
.chat-people { font-size: .9rem; }
.chat-people summary { color: var(--link); cursor: pointer; font-weight: 650; }
.chat-people ul { display: grid; gap: 5px; padding: 0; margin: 9px 0; list-style: none; }
.chat-people li { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 9px; overflow-wrap: anywhere; }
.chat-people small { color: var(--muted); font-size: .82rem; }
.chat-invite { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 8px; max-width: 500px; }
.chat-invite .field { flex: 1 1 170px; }
.chat-link { padding: 0; border: 0; color: var(--link); background: none; text-decoration: underline; font-size: .875rem; }
.chat-stream { min-height: 260px; max-height: min(54dvh, 600px); overflow: auto; overscroll-behavior: contain; padding: 16px 20px; background: linear-gradient(155deg, #edf5f6 0%, #f6f8fa 65%, #edf3f5 100%); }
.chat-older { display: block; width: fit-content; margin: 0 auto 12px; font-size: .875rem; font-weight: 650; }
.chat-older:last-child { margin: 12px auto 0; }
.chat-empty { padding: 45px 0; text-align: center; }
.chat-messages { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin: 0; padding: 0; list-style: none; }
.chat-message { width: fit-content; max-width: min(84%, 680px); padding: 9px 12px; border: 1px solid var(--chat-line); border-radius: 6px 15px 15px 15px; background: #fff; box-shadow: 0 2px 5px #263e4810; overflow-wrap: anywhere; }
.chat-message.is-own { align-self: flex-end; border-color: #bcded3; border-radius: 15px 6px 15px 15px; background: #e1f4ed; }
.chat-message > p { margin-top: 4px; }
.chat-image { display: block; width: fit-content; max-width: 100%; margin-top: 8px; border: 1px solid #c8d8e8; border-radius: 9px; overflow: hidden; cursor: zoom-in; }
.chat-image img { display: block; max-width: 100%; max-height: 245px; object-fit: contain; }
.chat-composer { display: grid; gap: 8px; padding: 11px 16px; border-top: 1px solid var(--chat-line); background: #fff; border-radius: 0 0 var(--radius) var(--radius); }
.chat-composer-row { position: relative; display: flex; align-items: flex-end; gap: 6px; min-width: 0; }
.chat-native-file { width: min(100%, 380px); }
.chat-attach-wrap, .chat-composer.is-enhanced .chat-native-file { display: none; }
.chat-composer.is-enhanced .chat-attach-wrap { display: block; position: relative; }
.chat-composer-input {
    flex: 1 1 0; width: 100%; min-width: 0; min-height: 44px; max-height: 144px; padding: 10px 13px; resize: none;
    border: 1px solid var(--chat-line); border-radius: 16px; background: #f6f9fa; color: var(--ink); line-height: 22px;
}
.chat-composer-input::placeholder { color: #5e7280; }
.chat-composer-input:focus { border-color: #6fac9c; background: #fff; outline: 2px solid #12816936; outline-offset: 0; }
.chat-composer-icon, .chat-composer-send {
    position: relative; display: inline-grid; place-items: center; flex: none; min-width: 44px; min-height: 44px;
    padding: 0; border: 1px solid transparent; border-radius: 14px; background: transparent; color: var(--chat-control);
}
.chat-composer-icon:not(:disabled):hover, .chat-composer-icon[aria-expanded="true"] { background: var(--chat-control-hover); color: var(--chat-accent); }
.chat-composer-send {
    display: inline-flex; justify-content: center; align-items: center; gap: 7px; padding: 0 13px;
    border-color: #08644f; background: var(--chat-accent); color: #fff; font-size: .875rem; font-weight: 700;
}
.chat-composer-send:not(:disabled):hover { background: var(--chat-accent-hover); }
.chat-composer-send .chat-icon { width: 19px; height: 19px; transform: translateX(1px); }
.chat-composer-send[aria-busy="true"]::before { position: absolute; left: 14px; width: 16px; height: 16px; border: 2px solid #fff6; border-top-color: #fff; border-radius: 50%; content: ""; animation: chat-sending .8s linear infinite; }
.chat-composer-send[aria-busy="true"] .chat-icon { visibility: hidden; }
@keyframes chat-sending { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .chat-composer-send[aria-busy="true"]::before { animation: none; } }
.chat-attach-popover {
    position: absolute; z-index: 2; bottom: calc(100% + 8px); left: 0; width: 192px; display: grid; gap: 2px; padding: 6px;
    border: 1px solid var(--chat-line); border-radius: 14px; background: #fff; box-shadow: 0 12px 30px #223e5230;
}
.chat-attach-limit { padding: 4px 7px; color: var(--muted); font-size: .8rem; }
.chat-attach-popover button { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 8px; border: 0; border-radius: 8px; background: none; color: var(--ink); text-align: left; }
.chat-attach-popover button .chat-icon { width: 18px; height: 18px; color: var(--chat-accent); }
.chat-attach-popover button:hover { background: var(--chat-control-hover); }
.chat-file-draft { display: flex; align-items: center; gap: 9px; width: fit-content; max-width: 100%; padding: 4px 6px 4px 8px; border: 1px solid var(--chat-line); border-radius: 12px; background: #f6f9fa; }
.chat-file-draft.is-invalid { border-color: #d18787; background: #fff5f5; }
.chat-draft-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 9px; background: #e2f2ed; color: var(--chat-accent); }
.chat-file-copy { display: grid; min-width: 0; line-height: 1.3; font-size: .875rem; }
.chat-file-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-file-copy small { color: var(--muted); }
.chat-file-draft.is-invalid small { color: #a4292b; }
.chat-draft-remove { min-width: 38px; min-height: 38px; }
.chat-composer button:disabled { opacity: .6; cursor: wait; }
.chat-jump { display: flex; gap: 6px; width: fit-content; min-height: 36px; margin: 6px auto; border-radius: 999px; }
.chat-jump .chat-icon { width: 16px; height: 16px; }

.voice-recorder {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px 16px;
    align-items: center;
    max-width: 760px;
    padding: 13px 15px;
    border: 1px solid #2c435c;
    border-radius: 12px;
    background: linear-gradient(120deg, #182536, #253c55);
    color: #f7faff;
}
.voice-recorder :focus-visible { outline-color: #ffcf92; }
.voice-recorder-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.voice-recorder-label { display: grid; min-width: 0; gap: 1px; line-height: 1.3; }
.voice-recorder-label strong { font-size: .9375rem; font-weight: 690; overflow-wrap: anywhere; }
.voice-recorder-label span { color: #c0d6ed; font-size: .875rem; }
.voice-recorder[data-state="recording"] [data-record-status]::before { content: ""; display: inline-block; width: 7px; height: 7px; margin: 0 6px 1px 0; border-radius: 50%; background: #ffab85; }
.voice-mic { position: relative; display: grid; place-items: center; flex: 0 0 38px; height: 38px; border: 1px solid #44617b; border-radius: 10px; background: #2b425d; }
.voice-mic i { position: relative; display: block; width: 6px; height: 11px; margin-top: -5px; border-radius: 5px; background: #d9ecff; }
.voice-mic i::before { position: absolute; inset: 4px -4px -4px; content: ""; border: 1.5px solid #d9ecff; border-top: 0; border-radius: 0 0 8px 8px; }
.voice-mic i::after { position: absolute; left: 2px; top: 14px; width: 2px; height: 4px; border-radius: 1px; background: #d9ecff; content: ""; }
.voice-timer { flex: 0 0 auto; margin-left: auto; padding: 3px 7px; border: 1px solid #4b6681; border-radius: 6px; background: #172b40; font-size: .875rem; font-variant-numeric: tabular-nums; font-weight: 680; }
.voice-record-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.voice-control { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 39px; padding: 7px 11px; border: 1px solid #52718d; border-radius: 8px; background: #304b65; color: #fff; font-size: .875rem; font-weight: 680; }
.voice-control:hover { background: #3d5973; }
.voice-record-button { border-color: var(--accent); background: var(--accent); color: #2c2119; }
.voice-record-button:hover { background: var(--accent-hover); }
.voice-stop-button { border-color: #9c6c64; background: #4e3944; color: #ffe4e1; }
.voice-stop-button:hover { background: #664653; }
.voice-icon { position: relative; display: inline-block; width: 12px; height: 12px; flex: 0 0 12px; }
.voice-icon::before { position: absolute; content: ""; }
.voice-icon[data-icon="record"]::before { inset: 1px; border-radius: 50%; background: #7a3023; }
.voice-icon[data-icon="pause"]::before { inset: 0 2px; border-inline: 3px solid currentColor; }
.voice-icon[data-icon="play"]::before { top: 0; left: 2px; border-block: 6px solid transparent; border-left: 9px solid currentColor; }
.voice-icon[data-icon="stop"]::before { inset: 1px; border-radius: 2px; background: currentColor; }
.voice-wave { display: block; grid-column: 1 / -1; width: 100%; height: 38px; padding: 2px 8px; border: 1px solid #3b5672; border-radius: 8px; background: #192e45; }
.voice-preview { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.voice-preview .voice-player { flex: 1 1 260px; margin: 0; }
.voice-discard { flex: 0 0 auto; }
.voice-error { grid-column: 1 / -1; font-size: .875rem; color: #ffd1bb; }

.voice-player { display: grid; gap: 5px; width: min(100%, 370px); margin-top: 8px; }
.voice-player audio { max-width: 100%; }
.voice-player-controls {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 7px 8px;
    border: 1px solid #c4d5e7;
    border-radius: 10px;
    background: #f4f8fd;
    color: #283f58;
}
.voice-play { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: #284e73; color: #fff; }
.voice-play:hover { background: #1e4066; }
.voice-track { display: grid; gap: 1px; min-width: 0; }
.voice-scrub { --rail: #cedceb; --thumb: #345d87; appearance: none; width: 100%; height: 16px; margin: 0; background: transparent; cursor: pointer; }
.voice-scrub:disabled { opacity: .55; }
.voice-scrub::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--rail); }
.voice-scrub::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; margin-top: -4px; border-radius: 50%; background: var(--thumb); }
.voice-scrub::-moz-range-track { height: 4px; border-radius: 4px; background: var(--rail); }
.voice-scrub::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--thumb); }
.voice-player-time { display: flex; flex-wrap: wrap; gap: 0 4px; color: #486079; font-size: .8125rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.voice-speed {
    --chevron: #486079;
    appearance: none;
    max-width: 82px;
    min-height: 34px;
    padding: 3px 20px 3px 7px;
    border: 1px solid #bccde2;
    border-radius: 7px;
    background-color: #fff;
    background-image: linear-gradient(45deg, transparent 49%, var(--chevron) 50%), linear-gradient(135deg, var(--chevron) 50%, transparent 51%);
    background-position: right 11px center, right 7px center;
    background-size: 4px 4px;
    background-repeat: no-repeat;
    color: #283f58;
    font-size: .875rem;
    font-weight: 690;
    cursor: pointer;
}
.voice-player-error { color: #a42f26; font-size: .875rem; }
.voice-preview .voice-player-controls { border-color: #55718b; background: #21374f; color: #fff; }
.voice-preview .voice-player-time { color: #d1e1f4; }
.voice-preview .voice-play { background: #a8d1f7; color: #14314d; }
.voice-preview .voice-play:hover { background: #c4e1fb; }
.voice-preview .voice-speed { --chevron: #d1e1f4; border-color: #6483a1; background-color: #2b4661; color: #f3f9ff; }
.voice-preview .voice-scrub { --rail: #526984; --thumb: #a8d1f7; }
.voice-preview .voice-player-error { color: #ffd1bb; }

.preview-page { min-height: 100vh; }
.preview-layout { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: 100vh; height: 100dvh; }
.preview-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 18px; padding: 13px clamp(12px, 3vw, 30px); border-bottom: 1px solid var(--line); background: #fff; }
.preview-name { flex: 1 1 235px; min-width: 0; }
.preview-name a { font-size: .875rem; font-weight: 650; }
.preview-name h1 { margin-top: 3px; font-size: clamp(1.15rem, 2.3vw, 1.6rem); line-height: 1.2; letter-spacing: -.02em; }
.preview-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.preview-actions .button { min-height: 38px; padding: 7px 10px; }
.preview-viewer { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.preview-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 7px clamp(12px, 3vw, 24px); padding: 8px 12px; border-bottom: 1px solid var(--line); background: #f7f9fc; }
.preview-navigation, .preview-page-picker, .preview-zoom { display: flex; align-items: center; gap: 7px; }
.preview-navigation { flex-wrap: wrap; justify-content: center; }
.preview-page-picker, .preview-zoom { font-size: .875rem; font-weight: 650; }
.preview-toolbar .button { padding-inline: 9px; min-height: 34px; }
.preview-toolbar button:disabled { opacity: .48; cursor: default; }
.preview-toolbar input, .preview-toolbar select { min-height: 34px; padding: 3px 6px; border: 1px solid #bcc9db; border-radius: 6px; background: #fff; color: var(--ink); }
.preview-toolbar input { width: 52px; font-variant-numeric: tabular-nums; }
.preview-status { margin: 12px auto; padding-inline: 12px; color: var(--muted); text-align: center; }
.preview-scroll { flex: 1 1 0; min-width: 0; min-height: 0; overflow: auto; background: #dce4ee; }
.preview-sheet { display: grid; justify-items: center; width: max-content; min-width: 100%; padding: 16px 12px 24px; }
.preview-sheet canvas { display: block; background: white; box-shadow: 0 1px 9px #17203330; }
.preview-viewer noscript { flex: 1 1 0; min-height: 0; }
.preview-frame { display: block; width: 100%; height: 100%; border: 0; background: #f6f8fb; }

body:has(.chat-gallery[open], .chat-image-editor[open]) { overflow: hidden; }
.chat-gallery {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    padding: 0;
    margin: 0;
    border: 0;
    background: #101a2a;
    color: #f5f8ff;
}
.chat-gallery[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.chat-gallery-header, .chat-gallery-footer { display: flex; align-items: center; gap: 7px 12px; padding: 12px clamp(12px, 3vw, 25px); background: #182437; }
.chat-gallery-header { justify-content: space-between; border-bottom: 1px solid #33445c; }
.chat-gallery-header > div { min-width: 0; }
.chat-gallery-header h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-gallery-header p { color: #bed0e5; font-size: .875rem; }
.chat-gallery-footer { flex-wrap: wrap; justify-content: center; border-top: 1px solid #33445c; }
.chat-gallery-stage { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; padding: 10px; touch-action: pan-y pinch-zoom; }
.chat-gallery-stage img { position: absolute; inset: 10px; display: block; width: calc(100% - 20px); height: calc(100% - 20px); object-fit: contain; }
.chat-gallery-status { color: #d8e6f4; text-align: center; }
.chat-gallery-status:empty { display: none; }
.gallery-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 7px 13px; border: 1px solid #55708c; border-radius: 8px; background: #293e57; color: #fff; text-decoration: none; font-size: .875rem; font-weight: 690; }
.gallery-button:hover { background: #37516d; }
.gallery-button:disabled { opacity: .43; cursor: default; }
.gallery-download { background: transparent; }
.chat-gallery :focus-visible { outline-color: #ffcf92; }

.chat-image-editor { width: min(1100px, calc(100% - 28px)); height: min(760px, calc(100dvh - 34px)); max-height: none; padding: 0; border: 1px solid #d0dcec; border-radius: 14px; background: #fff; color: var(--ink); }
.chat-image-editor[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.chat-image-editor::backdrop { background: #142236b8; }
.chat-image-editor-header, .chat-image-editor-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 12px 15px; }
.chat-image-editor-header { border-bottom: 1px solid var(--line); }
.chat-image-editor-header > div { flex: 1 1 180px; min-width: 0; }
.chat-image-editor-header p { margin-top: 3px; font-size: .875rem; overflow-wrap: anywhere; }
.chat-image-editor-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(225px, 285px); min-height: 0; overflow-y: auto; }
.chat-image-editor-stage { display: grid; place-items: center; min-height: 190px; padding: 12px; background: #e5ecf4; }
.chat-image-source { position: relative; max-width: 100%; }
.chat-image-source img { display: block; width: auto; height: auto; max-width: 100%; max-height: min(65dvh, 585px); border-radius: 3px; box-shadow: 0 1px 8px #17203325; }
.chat-image-source canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; pointer-events: none; }
.chat-image-source canvas[data-drawing="true"] { pointer-events: auto; cursor: crosshair; touch-action: none; }
.chat-image-editor-options { display: grid; align-content: start; gap: 16px; padding: 13px; }
.chat-drawing, .chat-drawing-tools { display: grid; gap: 8px; justify-items: start; }
.chat-drawing .button, .chat-image-editor-footer .button { min-height: 38px; }
.chat-colors { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-colors button { width: 32px; height: 32px; padding: 4px; border: 2px solid #c3d0df; border-radius: 8px; background: #fff; }
.chat-colors button::before { display: block; width: 100%; height: 100%; border: 1px solid #a8bacd; border-radius: 4px; background: var(--mark); content: ""; }
.chat-colors button[aria-pressed="true"] { border-color: #244c82; }
.chat-colors button[data-draw-color="red"] { --mark: #da302c; }
.chat-colors button[data-draw-color="blue"] { --mark: #1264f0; }
.chat-colors button[data-draw-color="yellow"] { --mark: #ffd825; }
.chat-colors button[data-draw-color="white"] { --mark: #fff; }
.chat-drawing-tools .chat-link:disabled { opacity: .42; cursor: default; }
.chat-image-options { display: grid; min-width: 0; gap: 7px; margin: 0; padding: 0; border: 0; }
.chat-image-options legend { margin-bottom: 6px; font-weight: 680; }
.image-format { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border: 1px solid #c9d5e3; border-radius: 8px; cursor: pointer; }
.image-format:has(input:checked) { border-color: #5d83ae; background: #edf4fb; }
.image-format input { flex: 0 0 auto; margin: 0; accent-color: #254c81; }
.image-format span { display: grid; gap: 1px; min-width: 0; }
.image-format strong { font-size: .9rem; }
.image-format small { color: var(--muted); font-size: .8125rem; }
.chat-image-editor-footer { justify-content: flex-end; border-top: 1px solid var(--line); }
.chat-image-editor-footer p { flex: 1 1 min(300px, 100%); font-size: .875rem; }
.chat-image-editor-footer .button:disabled { opacity: .5; cursor: default; }
.chat-image-draft { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; width: fit-content; max-width: 100%; padding: 7px 10px; border: 1px solid #c6d7eb; border-radius: 9px; background: #f4f8fd; }
.chat-image-draft img { width: 47px; height: 47px; object-fit: cover; border-radius: 6px; }
.chat-image-draft-info { display: grid; gap: 1px; min-width: 0; max-width: 100%; font-size: .875rem; overflow-wrap: anywhere; }
.chat-image-draft-info span { color: var(--muted); }
.chat-image-draft-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.chat-image-draft-actions .button { min-height: 34px; padding: 5px 8px; }

@media (max-width: 690px) {
    .chat-unread { margin-left: 0; }
    .chat-header, .chat-composer, .chat-stream { padding-inline: 12px; }
    .chat-stream { max-height: min(53vh, 420px); }
    .chat-message { max-width: 95%; }
    .chat-toast { bottom: 12px; right: 12px; }
    .voice-recorder { grid-template-columns: minmax(0, 1fr); padding: 11px; }
    .voice-record-controls { justify-content: flex-start; }
    .chat-image-editor { width: calc(100% - 14px); height: calc(100dvh - 14px); }
    .chat-image-editor-body { grid-template-columns: minmax(0, 1fr); }
    .chat-image-source img { max-height: min(45dvh, 450px); }
}

@media (max-width: 560px) {
    .chat-composer-row { gap: 4px; }
    .chat-composer-send { width: 44px; padding: 0; }
    .chat-composer-send [data-send-label] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
