:root {
    --ink: #17202a;
    --muted: #647184;
    --line: #d8dee8;
    --paper: #ffffff;
    --soft: #f4f6f8;
    --brand: #185c57;
    --brand-strong: #0d403c;
    --accent: #b88a44;
    --danger: #a83232;
    --ok: #1d7a4d;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Mobile client panel */
@media screen and (max-width: 760px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .client-topbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px;
        min-height: 0;
        padding: 10px 14px;
        align-items: center;
    }

    .client-topbar .brand {
        min-width: 0;
    }

    .client-topbar .brand span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .client-menu-toggle {
        display: inline-flex;
        min-height: 42px;
        padding: 8px 12px;
        font-size: 14px;
    }

    .client-topbar .client-nav {
        display: none;
        grid-column: 1 / -1;
        order: initial;
        width: 100%;
        padding: 6px;
        border: 1px solid var(--line);
        border-radius: 10px;
        background: #f7f9fb;
        overflow: visible;
    }

    .client-topbar .client-nav.is-open {
        display: grid;
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .client-topbar .client-nav a {
        width: 100%;
        min-height: 44px;
        padding: 10px 12px;
        border: 0;
        border-radius: 8px;
        justify-content: flex-start;
    }

    .client-topbar .client-nav a.active {
        background: #e5f1f0;
        box-shadow: inset 3px 0 0 var(--brand);
    }

    .client-topbar .user-strip {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-column: 1 / -1;
        width: 100%;
        gap: 6px;
    }

    .client-topbar .user-strip .button {
        min-width: 0;
        min-height: 38px;
        padding: 7px 6px;
        font-size: 12px;
        white-space: nowrap;
    }

    .client-case-strip {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        gap: 6px 8px;
        padding: 9px 14px;
        font-size: 12px;
    }

    .client-case-strip strong {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body:has(.client-topbar) .page {
        width: 100%;
        padding: 16px 12px 88px;
    }

    body:has(.client-topbar) .page h1 {
        font-size: 24px;
        overflow-wrap: anywhere;
    }

    body:has(.client-topbar) .card {
        padding: 16px;
        border-radius: 10px;
    }

    .case-file-heading {
        gap: 8px;
        margin-bottom: 14px;
    }

    .case-file-heading p {
        margin-bottom: 0;
    }

    .client-timeline-filter,
    .document-filter-advanced {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .client-timeline-filter select,
    .client-timeline-filter button {
        width: 100%;
        margin: 0;
    }

    .timeline-toolbar-right {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
        gap: 6px;
    }

    .timeline-toolbar-right .button {
        width: 100%;
        margin: 0;
    }

    .timeline-tree {
        width: 100%;
        margin: 0;
    }

    .timeline-node {
        grid-template-columns: 0 30px minmax(0, 1fr);
        gap: 7px;
        width: 100%;
    }

    .timeline-node-select {
        width: 0;
        overflow: visible;
        transform: translateX(2px);
        z-index: 2;
    }

    .timeline-node-dot {
        width: 30px;
        height: 30px;
        font-size: 11px;
    }

    .timeline-node-card {
        min-width: 0;
        padding: 13px;
        overflow-wrap: anywhere;
    }

    .timeline-node-card h3 {
        font-size: 16px;
        overflow-wrap: anywhere;
    }

    .timeline-node-badges,
    .tag-row,
    .document-people,
    .evidence-group-row {
        gap: 5px;
    }

    .timeline-node-meta {
        grid-template-columns: 1fr;
    }

    .document-files,
    .document-file,
    .document-file-head,
    .pdf-preview-trigger {
        min-width: 0;
        max-width: 100%;
    }

    .document-file-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .pdf-preview-trigger a {
        overflow-wrap: anywhere;
    }

    .preview-popup {
        display: none !important;
    }

    .upload-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .document-upload-form input,
    .document-upload-form select,
    .document-upload-form textarea,
    .document-upload-form button {
        max-width: 100%;
    }

    .document-upload-form input[type="file"] {
        padding: 10px;
        font-size: 13px;
    }

    .person-picker label {
        align-items: flex-start;
    }

    .client-people-layout {
        display: block;
    }

    .client-person-editor {
        position: static;
        margin-bottom: 14px;
    }

    .client-person-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 14px 0;
    }

    .client-person-edit-form {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .client-person-edit-form input,
    .client-person-edit-form select,
    .client-person-edit-form button,
    .client-person-row > form,
    .client-person-row > form .button {
        width: 100%;
    }

    .chat-shell {
        width: 100%;
        padding: 12px !important;
    }

    .chat-messages {
        min-height: 260px;
        max-height: 52vh;
        padding: 9px;
    }

    .chat-message {
        width: 92%;
        padding: 10px 11px;
    }

    .chat-message-meta {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }

    .chat-compose textarea,
    .chat-compose button {
        width: 100%;
    }

    .help-launcher {
        right: 12px;
        bottom: 12px;
    }
}

@media screen and (max-width: 420px) {
    .client-topbar {
        padding-inline: 10px;
    }

    .client-topbar .brand .mark {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }

    .client-topbar .brand span {
        font-size: 14px;
    }

    .client-menu-toggle {
        min-height: 38px;
        padding: 7px 9px;
    }

    .client-topbar .user-strip .button {
        font-size: 11px;
        padding-inline: 4px;
    }

    .client-case-strip {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .client-case-strip > span:first-child {
        display: none;
    }

    body:has(.client-topbar) .page {
        padding-inline: 9px;
    }

    body:has(.client-topbar) .card {
        padding: 13px;
    }

    .timeline-node {
        grid-template-columns: 0 26px minmax(0, 1fr);
        gap: 5px;
    }

    .timeline-node-dot {
        width: 26px;
        height: 26px;
    }

    .timeline-node-card {
        padding: 11px;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--soft);
}

body.modal-open {
    overflow: hidden;
}

a {
    color: var(--brand);
}

.layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
}

.home {
    padding: 54px clamp(28px, 7vw, 96px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 40px;
    background:
        linear-gradient(180deg, rgba(255,255,255,.88), rgba(255,255,255,.94)),
        url("https://images.unsplash.com/photo-1589829545856-d10d557cf95f?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    letter-spacing: 0;
}

.mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-weight: 900;
}

.hero {
    max-width: 780px;
}

.hero h1 {
    margin: 0 0 20px;
    font-size: clamp(42px, 6vw, 78px);
    line-height: .98;
    letter-spacing: 0;
}

.hero p {
    max-width: 680px;
    color: #334154;
    font-size: 19px;
    line-height: 1.65;
}

.quick {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    max-width: 900px;
}

.quick-item {
    border-left: 4px solid var(--accent);
    background: rgba(255,255,255,.76);
    padding: 18px;
    min-height: 118px;
}

.quick-item strong {
    display: block;
    margin-bottom: 8px;
}

.quick-item span {
    color: var(--muted);
    line-height: 1.45;
}

.side {
    background: var(--paper);
    border-left: 1px solid var(--line);
    padding: 34px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.panel {
    width: 100%;
}

.panel h2,
.page h1 {
    margin: 0 0 8px;
    font-size: 27px;
    letter-spacing: 0;
}

.panel p,
.muted {
    color: var(--muted);
    line-height: 1.55;
}

label {
    display: block;
    margin: 18px 0 7px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px 14px;
    font: inherit;
    background: #fff;
}

input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(24, 92, 87, .16);
    border-color: var(--brand);
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 8px;
    padding: 13px 16px;
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.button:hover {
    background: var(--brand-strong);
}

.button.secondary {
    background: #e7ecef;
    color: var(--ink);
}

.button.danger {
    background: var(--danger);
}

.full {
    width: 100%;
    margin-top: 22px;
}

.alert {
    border-radius: 8px;
    padding: 12px 14px;
    margin: 16px 0;
    background: #fff3d7;
    color: #654410;
    border: 1px solid #efd08e;
}

.alert.error {
    background: #fdeaea;
    color: #742323;
    border-color: #efb4b4;
}

.alert.ok {
    background: #e9f7ef;
    color: #185839;
    border-color: #afd9c3;
}

.generated-password-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 12px 0;
}

.generated-password-row input {
    width: min(100%, 360px);
    margin: 0;
    background: #fff;
    color: #17202a;
    font: 700 18px ui-monospace, SFMono-Regular, Consolas, monospace;
    letter-spacing: .04em;
}

.accounts-panel {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.account-table {
    margin: 0;
    min-width: 980px;
    font-size: 13px;
}

.account-table th {
    padding: 11px 12px;
    font-size: 12px;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.account-table td {
    padding: 9px 10px;
    vertical-align: middle;
}

.account-table input {
    width: 100%;
    min-width: 150px;
    margin: 0;
    padding: 7px 8px;
    font-size: 13px;
}

.account-table td:first-child {
    width: 20%;
}

.account-table td:nth-child(2) {
    width: 24%;
}

.account-table td:nth-child(3),
.account-table td:nth-child(4),
.account-table td:nth-child(5) {
    white-space: nowrap;
}

.account-table .badge {
    font-size: 11px;
}

.account-identifier,
.account-password-state small {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    color: var(--muted);
}

.account-actions {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.account-actions form {
    display: inline-flex;
    flex: 0 0 auto;
    margin: 0;
}

.account-actions .button,
.account-actions button {
    width: auto;
    margin: 0;
    padding: 7px 9px;
    font-size: 11px;
    white-space: nowrap;
}

.account-actions .account-unlocked:disabled {
    opacity: .55;
    cursor: default;
}

.account-status {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    margin: 0;
    font-size: 12px;
    font-weight: 600;
}

.account-status input {
    width: auto;
    min-width: 0;
}

.account-password-state {
    font-size: 12px;
}

.state-ok {
    color: #187348;
    font-weight: 700;
}

.state-missing {
    color: var(--danger);
    font-weight: 700;
}

@media (max-width: 720px) {
    .account-table {
        min-width: 980px;
    }
}

.topbar {
    min-height: 72px;
    padding: 0 clamp(22px, 5vw, 64px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.lawyer-topbar {
    gap: 22px;
    align-items: stretch;
}

.client-topbar {
    gap: 20px;
}

.client-nav {
    flex: 1 1 auto;
    justify-content: center;
}

.client-menu-toggle {
    display: none;
}

.client-mobile-links {
    display: none;
}

.client-case-strip {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px clamp(22px, 5vw, 64px);
    border-bottom: 1px solid var(--line);
    background: #f7f9fc;
    font-size: 13px;
}

.client-people-layout {
    display: grid;
    grid-template-columns: minmax(280px, .7fr) minmax(520px, 1.3fr);
    gap: 20px;
    align-items: start;
}

.client-person-editor {
    position: sticky;
    top: 18px;
}

.section-heading-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.client-person-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid var(--line);
}

.client-person-edit-form {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) 160px minmax(180px, 1.2fr) auto;
    gap: 8px;
    align-items: center;
    flex: 1 1 auto;
}

.client-person-edit-form input,
.client-person-edit-form select,
.client-person-edit-form button,
.client-person-row form,
.client-person-row .button {
    margin: 0;
}

.chat-shell {
    max-width: 980px;
    margin-inline: auto;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 180px;
    max-height: 520px;
    overflow-y: auto;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f6f8fb;
}

.chat-message {
    width: min(78%, 620px);
    padding: 11px 13px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
}

.chat-message.mine {
    align-self: flex-end;
    border-color: #9fc4e8;
    background: #eaf4ff;
}

.chat-message.theirs {
    align-self: flex-start;
}

.chat-message-meta {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 5px;
    font-size: 11px;
    color: var(--muted);
}

.chat-message p {
    margin: 0;
}

.chat-compose {
    margin-top: 14px;
}

.chat-compose textarea {
    margin-bottom: 10px;
}

.message-case-picker {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto;
    gap: 10px;
    align-items: end;
}

.message-case-picker label {
    grid-column: 1 / -1;
}

@media (max-width: 1050px) {
    .client-topbar {
        align-items: center;
        flex-wrap: wrap;
        padding-block: 12px;
    }

    .client-nav {
        order: 3;
        width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
    }

    .client-people-layout {
        grid-template-columns: 1fr;
    }

    .client-person-editor {
        position: static;
    }
}

@media (max-width: 760px) {
    .client-person-row {
        align-items: stretch;
        flex-direction: column;
    }

    .client-person-edit-form {
        grid-template-columns: 1fr;
    }

    .chat-message {
        width: 92%;
    }
}

.lawyer-topbar .brand,
.user-strip {
    flex: 0 0 auto;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 auto;
    overflow-x: auto;
}

.main-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 72px;
    padding: 0 12px;
    border-bottom: 3px solid transparent;
    color: var(--muted);
    text-decoration: none;
    font-weight: 800;
    white-space: nowrap;
}

.main-nav a:hover,
.main-nav a.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
}

.user-strip {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 14px;
}

.page {
    padding: 36px clamp(22px, 5vw, 64px);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 26px;
    background: rgba(23, 32, 42, .58);
}

.modal-backdrop[hidden] {
    display: none !important;
}

.modal-window {
    width: min(1180px, 96vw);
    height: min(820px, 92vh);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 22px 70px rgba(0, 0, 0, .28);
    overflow: hidden;
}

.modal-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-window iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: var(--soft);
}

body:has(.topbar) .modal-window iframe {
    background: #fff;
}

body .topbar + .page,
body > .page {
    min-width: 0;
}

body:not(:has(.topbar)) .page {
    padding: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 8px;
}

.stat-card strong {
    font-size: 36px;
    line-height: 1;
}

.stat-card .small-stat {
    font-size: 18px;
}

.audit-issue {
    border-top: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    padding: 16px;
}

.audit-issue:first-of-type {
    border-top: 0;
}

.audit-issue.critical {
    border-left-color: var(--danger);
    background: #fdeaea;
}

.audit-issue.warning {
    background: #fff9ec;
}

.slot-meter {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    gap: 22px;
    align-items: center;
    margin: 20px 0;
}

.slot-circle {
    width: 132px;
    height: 132px;
    display: grid;
    place-content: center;
    text-align: center;
    border: 10px solid #dceae7;
    border-top-color: var(--brand);
    border-radius: 50%;
    background: #fff;
}

.slot-circle strong {
    font-size: 38px;
    line-height: 1;
}

.slot-circle span {
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.slot-details p {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    margin: 8px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}

.slot-details span {
    color: var(--muted);
}

.slot-progress {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e7ecef;
}

.slot-progress span {
    display: block;
    height: 100%;
    background: var(--brand);
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.month-switcher {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.section-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 22px 0;
    border-bottom: 1px solid var(--line);
}

.section-tabs a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 14px;
    border-bottom: 3px solid transparent;
    color: var(--muted);
    text-decoration: none;
    font-weight: 900;
}

.section-tabs a.active,
.section-tabs a:hover {
    color: var(--brand);
    border-bottom-color: var(--brand);
}

.section-tabs span {
    border-radius: 999px;
    padding: 3px 7px;
    background: #e7ecef;
    color: var(--ink);
    font-size: 12px;
}

.case-menu-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.module-tile {
    display: block;
    min-height: 156px;
    padding: 22px;
    background: #fff;
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    border-radius: 8px;
    color: var(--ink);
    text-decoration: none;
}

.module-tile:hover {
    border-color: var(--brand);
    background: #f8fbfa;
}

.module-tile strong {
    display: block;
    margin-bottom: 10px;
    font-size: 20px;
}

.module-tile span {
    color: var(--muted);
    line-height: 1.5;
}

.calendar-layout {
    display: grid;
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.notebook-layout {
    display: grid;
    grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.note-card {
    border-top: 1px solid var(--line);
    padding: 20px 0;
}

.note-card:first-of-type {
    border-top: 0;
}

.note-card.pinned {
    background: #fffdf5;
    margin: 0 -12px;
    padding: 20px 12px;
    border-radius: 8px;
}

.note-head,
.court-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

.tag-row span {
    display: inline-flex;
    border-radius: 999px;
    padding: 5px 9px;
    background: #edf1f3;
    color: #334154;
    font-size: 13px;
    font-weight: 800;
}

.ai-panel {
    border: 1px solid #c8d8d5;
    border-left: 4px solid var(--brand);
    border-radius: 8px;
    background: #f3faf8;
    padding: 14px;
    margin: 14px 0;
}

.checklist {
    margin: 10px 0 0;
    padding-left: 20px;
}

.inline-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.court-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px auto;
    gap: 12px;
    align-items: end;
}

.court-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.court-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
}

.contact-list {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 8px 14px;
    margin: 16px 0;
}

.contact-list dt {
    color: var(--muted);
    font-weight: 800;
}

.contact-list dd {
    margin: 0;
}

.calendar-main {
    min-width: 0;
}

.calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-bar select {
    min-width: 150px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(92px, 1fr));
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
    overflow-x: auto;
}

.calendar-day-name {
    padding: 10px;
    background: #edf1f3;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-weight: 900;
    font-size: 13px;
}

.calendar-day {
    min-height: 132px;
    padding: 9px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.calendar-day.muted-day {
    background: #f7f8fa;
    color: #9aa4b2;
}

.calendar-day.today {
    box-shadow: inset 0 0 0 2px var(--brand);
}

.day-number {
    font-weight: 900;
    margin-bottom: 8px;
}

.event-pill {
    display: block;
    margin: 5px 0;
    padding: 6px 7px;
    border-radius: 7px;
    color: #17202a;
    font-size: 12px;
    line-height: 1.25;
    background: #edf1f3;
    border-left: 4px solid var(--muted);
}

.event-pill span {
    display: block;
    font-weight: 900;
}

.event-pill.hearing,
.deadline-row.critical,
.agenda-item.critical {
    border-left-color: var(--danger);
    background: #fdeaea;
}

.event-pill.deadline,
.deadline-row.high,
.agenda-item.high {
    border-left-color: var(--accent);
    background: #fff3d7;
}

.event-pill.meeting,
.event-pill.call {
    border-left-color: var(--brand);
    background: #e9f3f1;
}

.event-pill.task,
.event-pill.document {
    border-left-color: #4f6fb2;
    background: #edf2ff;
}

.event-pill.payment {
    border-left-color: var(--ok);
    background: #e9f7ef;
}

.more-events {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.agenda-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    border-left: 4px solid var(--line);
    border-top: 1px solid var(--line);
    padding: 16px 0 16px 14px;
}

.agenda-item:first-of-type {
    border-top: 0;
}

.agenda-item form {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex-wrap: wrap;
}

.deadline-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px 12px;
    align-items: center;
    border-left: 4px solid var(--line);
    border-top: 1px solid var(--line);
    padding: 14px 0 14px 14px;
}

.deadline-row:first-of-type {
    border-top: 0;
}

.deadline-row small {
    grid-column: 2;
    color: var(--muted);
}

.card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
}

.case-block {
    border-top: 1px solid var(--line);
    padding: 20px 0;
}

.case-block:first-of-type {
    border-top: 0;
}

.case-title-row,
.inline-action {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.inline-action {
    align-items: center;
    margin: 10px 0;
    flex-wrap: wrap;
}

.case-assign-form {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--line);
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    background: #fff;
}

.table th,
.table td {
    text-align: left;
    border-bottom: 1px solid var(--line);
    padding: 12px;
    vertical-align: top;
}

.table-scroll {
    overflow-x: auto;
}

.case-table {
    min-width: 1180px;
}

.case-table th {
    white-space: nowrap;
}

.case-file-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.case-file-heading h1 {
    margin-top: 10px;
}

.case-file-date {
    text-align: right;
}

.case-file-date span,
.case-file-summary span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.case-file-date strong {
    display: block;
    margin-top: 5px;
    font-size: 20px;
}

.case-file-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    margin-bottom: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--line);
}

.case-file-summary section {
    padding: 16px;
    background: #fff;
}

.case-file-summary strong,
.case-file-summary small {
    display: block;
    margin-top: 5px;
}

.case-file-summary small {
    color: var(--muted);
}

.case-file-layout {
    display: grid;
    grid-template-columns: minmax(280px, .8fr) minmax(380px, 1.2fr);
    gap: 20px;
    align-items: start;
}

.documents-layout {
    max-width: 980px;
}

.documents-layout > div {
    display: grid;
    gap: 20px;
}

.case-file-layout > div {
    display: grid;
    gap: 20px;
}

.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.file-row:first-of-type {
    border-top: 0;
}

.file-row strong,
.file-row small {
    display: block;
}

.file-row small {
    margin-top: 4px;
    color: var(--muted);
}

.document-upload-form {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.document-card {
    position: relative;
    border-top: 1px solid var(--line);
    padding: 18px 0;
}

.document-card:first-of-type {
    border-top: 0;
}

.document-filter {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) 150px 170px auto;
    gap: 8px;
    align-items: center;
}

.document-filter input,
.document-filter select {
    padding: 9px 10px;
}

.document-period {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 28px 0 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--brand);
}

.document-period strong {
    font-size: 20px;
}

.document-period span {
    color: var(--muted);
    font-weight: 800;
}

.document-chronology-item {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 14px;
    padding: 18px;
    border: 1px solid var(--line);
    border-left: 5px solid var(--accent);
    border-radius: 8px;
    background: #fff;
}

.document-chronology-item.reviewed {
    border-left-color: var(--ok);
}

.document-date-block {
    min-height: 86px;
    display: grid;
    align-content: center;
    justify-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7f9fa;
    text-align: center;
}

.document-date-block strong {
    font-size: 32px;
    line-height: 1;
}

.document-date-block span {
    margin-top: 5px;
    color: var(--brand);
    font-size: 13px;
    font-weight: 900;
}

.document-date-block small {
    color: var(--muted);
}

.document-content {
    min-width: 0;
}

.document-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.document-head h3 {
    margin: 0;
    font-size: 18px;
}

.document-status {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.review-state {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 900;
}

.review-state.reviewed {
    background: #e9f7ef;
    color: #185839;
}

.review-state.pending {
    background: #fff3d7;
    color: #654410;
}

.document-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 16px;
    margin: 12px 0;
    color: var(--muted);
    font-size: 13px;
}

.document-description {
    margin: 12px 0;
    padding: 12px;
    background: #f7f9fa;
    border-radius: 8px;
}

.document-description p {
    margin: 5px 0 0;
}

.review-meta {
    color: var(--muted);
    font-size: 12px;
}

.pdf-hover {
    position: relative;
}

.pdf-hover iframe {
    display: none;
    position: fixed;
    z-index: 1200;
    top: 10vh;
    right: 4vw;
    width: min(520px, 44vw);
    height: 76vh;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 60px rgba(0, 0, 0, .28);
    pointer-events: none;
}

.pdf-hover:hover iframe,
.pdf-hover:focus-within iframe {
    display: block;
}

.document-opinion {
    margin: 12px 0;
    padding: 12px;
    border-left: 4px solid var(--brand);
    background: #f3faf8;
}

.document-opinion p {
    margin-bottom: 0;
}

.document-note {
    margin: 8px 0;
    padding: 10px 12px;
    border-left: 3px solid #4f6fb2;
    background: #edf2ff;
}

.review-panel {
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.pdf-page-editor {
    margin-top: 14px;
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.pdf-page-editor summary {
    cursor: pointer;
    color: #8a2f2f;
    font-weight: 800;
}

.pdf-page-editor form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto;
    gap: 8px;
    align-items: end;
}

.pdf-page-editor label {
    grid-column: 1 / -1;
}

.document-version-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
    padding: 10px 12px;
    margin: 12px 0;
    border-left: 3px solid #6d58a8;
    background: #f5f1ff;
    font-size: 13px;
}

.document-files {
    display: grid;
    gap: 10px;
    margin: 14px 0;
}

.document-file {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fafbfc;
}

.document-file.corrected {
    border-color: #b8d7c7;
    background: #f1faf5;
}

.document-file-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.page-selector-button {
    margin-top: 10px;
}

.pdf-page-selector-dialog {
    width: min(1180px, 96vw);
    max-width: none;
    max-height: 94vh;
    padding: 0;
    border: 0;
    border-radius: 12px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
}

.pdf-page-selector-dialog::backdrop {
    background: rgba(14, 28, 34, .68);
}

.pdf-page-selector-shell {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    max-height: 94vh;
    padding: 18px;
}

.pdf-page-selector-head,
.pdf-page-selector-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.help-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.help-navigation {
    position: sticky;
    top: 18px;
    max-height: calc(100vh - 36px);
    overflow: auto;
}

.help-navigation nav {
    display: grid;
    gap: 3px;
}

.help-navigation a {
    padding: 8px 10px;
    border-radius: 7px;
    color: var(--ink);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
}

.help-navigation a:hover,
.help-navigation a:focus {
    background: #edf5f4;
    color: var(--brand-strong);
}

.help-content {
    min-width: 0;
}

.help-section {
    scroll-margin-top: 20px;
}

.help-section h2 {
    color: var(--brand-strong);
}

.help-section h3 {
    margin: 22px 0 8px;
}

.help-section li {
    margin-bottom: 7px;
}

.help-steps li::marker {
    color: var(--brand);
    font-weight: 900;
}

.help-note,
.help-warning {
    margin: 16px 0;
    padding: 13px 15px;
    border-radius: 8px;
}

.help-note {
    border-left: 4px solid var(--brand);
    background: #edf7f5;
}

.help-warning {
    border-left: 4px solid #bd7a22;
    background: #fff7e8;
}

.help-status-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.help-status-grid > div {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.help-status-grid .badge {
    margin-left: 8px;
}

.help-faq dt {
    margin-top: 16px;
    font-weight: 900;
    color: var(--ink);
}

.help-faq dd {
    margin: 5px 0 0;
    color: var(--muted);
}

.help-footer {
    text-align: center;
}

.pdf-page-selector-head p {
    margin: 4px 0 0;
}

.pdf-page-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
    overflow: auto;
    padding: 16px 2px;
}

.pdf-page-choice {
    position: relative;
    display: grid;
    grid-template-rows: 260px auto;
    margin: 0;
    border: 3px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    background: #edf1f3;
    cursor: pointer;
}

.pdf-page-choice.selected {
    border-color: #b43737;
    background: #fff0f0;
    box-shadow: 0 0 0 3px rgba(180, 55, 55, .14);
}

.pdf-page-choice input {
    position: absolute;
    z-index: 2;
    top: 10px;
    left: 10px;
    width: 22px;
    height: 22px;
}

.pdf-page-choice iframe {
    width: 100%;
    height: 260px;
    border: 0;
    background: #fff;
    pointer-events: none;
}

.pdf-page-choice span {
    padding: 9px;
    text-align: center;
    font-weight: 800;
}

.pdf-page-selector-actions {
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.file-version-badge {
    flex: 0 0 auto;
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 800;
}

.file-version-badge.original {
    background: #edf1f3;
    color: #37474f;
}

.file-version-badge.corrected {
    background: #dff3e7;
    color: #185839;
}

.file-version-reason {
    margin: 7px 0 0;
    color: #28553e;
    font-size: 13px;
    font-weight: 700;
}

.review-panel summary {
    cursor: pointer;
    color: var(--brand);
    font-weight: 900;
}

.review-tags {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
}

.review-tags label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 13px;
}

.review-tags input {
    width: auto;
    margin: 0;
}

.timeline-item.review .timeline-dot,
.timeline-item.document .timeline-dot {
    background: #4f6fb2;
    border-color: #dce5f8;
}

.timeline-card {
    min-width: 0;
}

.timeline-item {
    position: relative;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 12px;
    padding-bottom: 22px;
}

.timeline-item::before {
    content: "";
    position: absolute;
    top: 14px;
    bottom: 0;
    left: 7px;
    width: 2px;
    background: var(--line);
}

.timeline-item:last-child::before {
    display: none;
}

.timeline-dot {
    position: relative;
    z-index: 1;
    width: 16px;
    height: 16px;
    margin-top: 3px;
    border: 4px solid #dceae7;
    border-radius: 50%;
    background: var(--brand);
}

.timeline-item.closed .timeline-dot {
    background: var(--danger);
    border-color: #f3caca;
}

.timeline-item.reopened .timeline-dot,
.timeline-item.calendar .timeline-dot {
    background: var(--accent);
    border-color: #f2dfbd;
}

.timeline-item.note .timeline-dot {
    background: #4f6fb2;
    border-color: #dce5f8;
}

.timeline-item h3 {
    margin: 3px 0 5px;
    font-size: 16px;
}

.timeline-item p {
    margin: 0 0 5px;
}

.timeline-item time,
.timeline-item small {
    color: var(--muted);
    font-size: 12px;
}

.count-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--brand);
    font-weight: 900;
    text-decoration: none;
    white-space: nowrap;
}

.count-link span {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 12px;
}

.button.compact,
button.compact {
    padding: 8px 10px;
    font-size: 13px;
}

.mini-form {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.mini-form select {
    padding: 8px 10px;
    min-width: 150px;
}

.badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 9px;
    background: #e7ecef;
    font-size: 13px;
    font-weight: 800;
}

.token {
    width: 100%;
    min-height: 84px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    font: 14px ui-monospace, SFMono-Regular, Consolas, monospace;
}

@media (max-width: 920px) {
    .help-layout {
        grid-template-columns: 1fr;
    }

    .help-navigation {
        position: static;
        max-height: none;
    }

    .help-navigation nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .layout {
        grid-template-columns: 1fr;
    }

    .side {
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    .quick,
    .grid,
    .case-menu-grid,
    .stats-grid,
    .calendar-layout,
    .notebook-layout,
    .court-grid,
    .court-search,
    .case-file-layout,
    .case-file-summary {
        grid-template-columns: 1fr;
    }

    .page-heading,
    .calendar-toolbar,
    .filter-bar,
    .agenda-item {
        align-items: stretch;
        flex-direction: column;
        display: flex;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .slot-meter {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .note-head,
    .court-head,
    .case-title-row,
    .inline-action,
    .case-file-heading {
        flex-direction: column;
    }

    .case-file-date {
        text-align: left;
    }

    .review-tags {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .document-filter-advanced,
    .document-chronology-item {
        grid-template-columns: 1fr;
    }

    .timeline-tree {
        margin-left: 0;
    }

    .timeline-node {
        grid-template-columns: 20px 38px minmax(0, 1fr);
        gap: 10px;
    }

    .timeline-toolbar {
        flex-direction: column;
        gap: 10px;
    }

    .upload-row {
        grid-template-columns: 1fr;
    }

    .review-form-grid {
        grid-template-columns: 1fr;
    }

    .meta-item strong,
    .meta-item span {
        font-size: 12px;
    }

    .timeline-node-meta {
        grid-template-columns: 1fr;
    }

    .timeline-node-head {
        flex-direction: column;
    }

    .preview-popup {
        width: 92vw !important;
        left: 0 !important;
    }

    .preview-popup iframe {
        height: 50vh;
    }

    .document-filter-advanced .button.secondary {
        grid-column: 1 / -1;
    }

    .document-date-block {
        min-height: auto;
        grid-template-columns: auto auto auto;
        justify-content: start;
        gap: 8px;
    }

    .document-date-block strong {
        font-size: 22px;
    }

    .document-head {
        flex-direction: column;
    }

    .document-status {
        justify-content: flex-start;
    }

    .pdf-hover iframe {
        top: 8vh;
        right: 4vw;
        width: 92vw;
        height: 80vh;
    }

    .lawyer-topbar {
        flex-wrap: wrap;
        padding-top: 14px;
        padding-bottom: 14px;
    }

    .main-nav {
        order: 3;
        width: 100%;
        flex-basis: 100%;
    }

    .main-nav a {
        min-height: 44px;
    }

    .modal-backdrop {
        padding: 10px;
    }

    .modal-window {
        width: 100%;
        height: 96vh;
    }

    .modal-bar {
        align-items: stretch;
        flex-direction: column;
    }
}

/* ============== ENHANCED TIMELINE ============== */

.timeline-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.timeline-toolbar-left h2 {
    margin-bottom: 4px;
}

.timeline-toolbar-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filtered-indicator {
    color: var(--brand);
    font-weight: 800;
    font-size: 13px;
}

.document-filter-advanced {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 6px;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.client-timeline-filter {
    grid-template-columns: minmax(220px, 1fr) minmax(180px, 1fr) auto;
}

.document-filter-advanced input,
.document-filter-advanced select {
    padding: 9px 8px;
    font-size: 13px;
}

.document-filter-advanced button,
.document-filter-advanced .button {
    padding: 9px 12px;
    font-size: 13px;
    white-space: nowrap;
}

.upload-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.upload-field label {
    margin-top: 0;
}

.empty-timeline {
    padding: 32px 0;
    text-align: center;
}

/* Timeline tree */
.timeline-tree {
    position: relative;
    margin-left: 4px;
}

.timeline-period {
    display: grid;
    grid-template-columns: 24px 44px minmax(0, 1fr);
    gap: 14px;
    margin: 24px 0 14px;
    align-items: center;
}

.timeline-period-dot {
    grid-column: 2;
    justify-self: center;
    position: relative;
    z-index: 1;
    width: 18px;
    height: 18px;
    border: 3px solid var(--brand);
    border-radius: 50%;
    background: #fff;
}

.timeline-period-content {
    grid-column: 3;
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.timeline-period-content strong {
    font-size: 20px;
    color: var(--brand-strong);
}

.timeline-period-content span {
    color: var(--muted);
    font-weight: 800;
    font-size: 15px;
}

/* Timeline nodes */
.timeline-node {
    display: grid;
    grid-template-columns: 24px 44px minmax(0, 1fr);
    gap: 14px;
    position: relative;
    padding-bottom: 4px;
}

.timeline-node::before {
    content: "";
    position: absolute;
    top: 24px;
    bottom: 0;
    left: 59px;
    width: 2px;
    background: var(--line);
    z-index: 0;
}

.timeline-node.last::before {
    display: none;
}

.timeline-node-select {
    display: flex;
    align-items: flex-start;
    padding-top: 12px;
}

.timeline-node-select input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--brand);
}

.timeline-node-dot {
    position: relative;
    z-index: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 20px;
    border: 3px solid var(--line);
    background: #fff;
    margin-top: 4px;
}

.timeline-node-dot.reviewed {
    border-color: #afd9c3;
    background: #e9f7ef;
}

.timeline-node-dot.pending {
    border-color: #efd08e;
    background: #fff3d7;
}

.timeline-node-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 12px;
    transition: box-shadow 0.15s;
}

.timeline-node-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, .08);
}

.timeline-node-card.reviewed {
    border-left: 4px solid var(--ok);
}

.timeline-node-card.pending {
    border-left: 4px solid var(--accent);
}

.timeline-node-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.timeline-node-head h3 {
    margin: 0;
    font-size: 17px;
    color: var(--ink);
}

.timeline-node-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.doc-type-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 800;
    background: #edf1f3;
    color: var(--ink);
}

.doc-type-badge.umowa { background: #e3f2fd; color: #0d47a1; }
.doc-type-badge.pozew { background: #fce4ec; color: #880e4f; }
.doc-type-badge.pismo_procesowe { background: #ede7f6; color: #311b92; }
.doc-type-badge.dowod { background: #fff8e1; color: #e65100; }
.doc-type-badge.ekspertyza { background: #e0f2f1; color: #004d40; }
.doc-type-badge.faktura { background: #f3e5f5; color: #6a1b9a; }
.doc-type-badge.korespondencja { background: #e8eaf6; color: #1a237e; }
.doc-type-badge.orzeczenie { background: #ffebee; color: #b71c1c; }
.doc-type-badge.pelnomocnictwo { background: #efebe9; color: #3e2723; }
.doc-type-badge.notatka { background: #f5f5f5; color: #37474f; }
.doc-type-badge.zdjecie { background: #e8f5e9; color: #1b5e20; }
.doc-type-badge.inny { background: #eceff1; color: #37474f; }

.review-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 800;
}

.review-badge.reviewed {
    background: #e9f7ef;
    color: #185839;
}

.review-badge.pending {
    background: #fff3d7;
    color: #654410;
}

.timeline-node-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 14px 0;
    padding: 12px;
    background: #f7f9fa;
    border-radius: 8px;
}

.meta-item {
    min-width: 0;
}

.meta-label {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 3px;
}

.meta-item strong {
    display: block;
    font-size: 14px;
}

.meta-item span {
    font-size: 13px;
    color: var(--ink);
}

.meta-item time {
    color: var(--ink);
}

.problem-tag {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 800;
    border: 1px solid transparent;
}

.problem-tag.dyskryminacja { background: #fce4ec; color: #880e4f; border-color: #f8bbd0; }
.problem-tag.wypadek_przy_pracy { background: #fff3e0; color: #bf360c; border-color: #ffcc80; }
.problem-tag.mobbing { background: #f3e5f5; color: #6a1b9a; border-color: #ce93d8; }
.problem-tag.wynagrodzenie { background: #e8f5e9; color: #1b5e20; border-color: #a5d6a7; }
.problem-tag.umowa { background: #e3f2fd; color: #0d47a1; border-color: #90caf9; }
.problem-tag.dowod { background: #fff8e1; color: #e65100; border-color: #ffe082; }
.problem-tag.medyczne { background: #e0f2f1; color: #004d40; border-color: #80cbc4; }
.problem-tag.korespondencja { background: #ede7f6; color: #311b92; border-color: #b39ddb; }
.problem-tag.pilne { background: #ffebee; color: #b71c1c; border-color: #ef9a9a; }
.problem-tag.naruszenie_danych { background: #fce4ec; color: #880e4f; border-color: #f8bbd0; }
.problem-tag.odszkodowanie { background: #e8eaf6; color: #1a237e; border-color: #9fa8da; }
.problem-tag.rozwiazanie_umowy { background: #efebe9; color: #3e2723; border-color: #bcaaa4; }
.problem-tag.dane_osobowe { background: #e1f5fe; color: #01579b; border-color: #81d4fa; }
.problem-tag.renta { background: #f1f8e9; color: #33691e; border-color: #aed581; }
.problem-tag.zasilek { background: #fff3e0; color: #e65100; border-color: #ffb74d; }

.review-form-grid {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.review-groups,
.evidence-group-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin: 12px 0;
}

.review-groups label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 0;
}

.evidence-group-badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 999px;
    background: #e8f0ff;
    color: #173f78;
    border: 1px solid #b7cae8;
    font-size: 12px;
    font-weight: 800;
}

.person-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(160px, .6fr) minmax(220px, 1.2fr) auto;
    gap: 10px;
    align-items: end;
}

.person-form label {
    margin-top: 0;
}

.people-directory {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 10px;
    margin-top: 18px;
}

.person-card {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafb;
}

.person-role {
    color: var(--brand);
    font-size: 12px;
    font-weight: 800;
}

.person-picker {
    margin: 14px 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.person-picker legend {
    padding: 0 6px;
    font-weight: 800;
}

.person-picker label {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: flex-start;
    gap: 10px;
    margin: 8px 0 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafb;
    line-height: 1.35;
    cursor: pointer;
}

.person-picker label:hover {
    border-color: #aeb9c7;
    background: #fff;
}

.person-picker label input[type="checkbox"] {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
}

.person-picker label span {
    display: block;
    min-width: 0;
    font-size: 0;
    overflow-wrap: anywhere;
}

.person-picker label strong {
    display: block;
    color: var(--ink);
    font-size: 14px;
}

.person-picker label::after {
    grid-column: 2;
    margin-top: -6px;
    color: var(--brand);
    content: attr(data-person-role);
    font-size: 12px;
    font-weight: 800;
}

.person-picker label strong + br,
.person-picker label small {
    color: var(--muted);
}

.document-people {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    margin: 12px 0;
}

.document-people-editor {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.document-people-editor summary {
    cursor: pointer;
    color: var(--brand);
    font-weight: 800;
}

.person-picker.compact {
    margin: 10px 0;
    padding: 10px;
}

.document-people-editor form {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.document-type-lock {
    margin: 12px 0 0;
}

.person-badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f2eafa;
    color: #5d287d;
    border: 1px solid #d5bce5;
    font-size: 12px;
    font-weight: 800;
}

.final-source-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.final-source-row {
    display: grid;
    grid-template-columns: minmax(260px, 1.5fr) 110px minmax(180px, .8fr) auto;
    gap: 10px;
    align-items: end;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f8fafb;
}

.final-source-row label {
    margin-top: 0;
}

.final-source-check {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    margin: 0;
    cursor: pointer;
}

.final-source-check input {
    width: 18px;
    height: 18px;
    margin: 3px 0 0;
}

.final-source-check span,
.final-source-check strong,
.final-source-check small {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
}

.final-source-check small {
    margin-top: 3px;
    color: var(--muted);
    font-weight: 400;
}

@media (max-width: 820px) {
    .final-source-row {
        grid-template-columns: 1fr 100px;
    }

    .final-source-check {
        grid-column: 1 / -1;
    }
}

@media (max-width: 520px) {
    .final-source-row {
        grid-template-columns: 1fr;
    }

    .final-source-check {
        grid-column: auto;
    }

    .final-source-row .button {
        width: 100%;
    }
}

/* Contextual help */
.help-launcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1250;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    width: auto;
    min-height: 48px;
    padding: 9px 16px 9px 10px;
    border: 0;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    box-shadow: 0 10px 30px rgba(22, 55, 88, .28);
}

.help-launcher span {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    font-size: 19px;
    font-weight: 900;
}

.help-launcher:hover,
.help-launcher:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 14px 34px rgba(22, 55, 88, .35);
}

.context-help-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1270;
    background: rgba(11, 24, 36, .38);
}

.context-help {
    position: fixed;
    z-index: 1280;
    top: 0;
    right: 0;
    width: min(430px, 100%);
    height: 100dvh;
    overflow-y: auto;
    background: #fff;
    box-shadow: -16px 0 50px rgba(0, 0, 0, .22);
    transform: translateX(105%);
    transition: transform .22s ease;
}

.context-help.open {
    transform: translateX(0);
}

body.context-help-open {
    overflow: hidden;
}

.context-help-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 24px;
    border-bottom: 1px solid var(--line);
    background: #f7fafc;
}

.context-help-head h2 {
    margin: 4px 0 0;
}

.context-help-kicker {
    color: var(--brand);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.context-help-close {
    display: grid;
    place-items: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    background: #e8eef3;
    color: var(--ink);
    font-size: 26px;
    line-height: 1;
}

.context-help-body {
    padding: 24px;
}

.context-help-body > p {
    margin-top: 0;
    color: var(--muted);
    line-height: 1.6;
}

.context-help-body h3 {
    margin: 24px 0 10px;
}

.context-help-body ol {
    display: grid;
    gap: 12px;
    padding-left: 24px;
    line-height: 1.55;
}

.context-help-tip {
    margin: 24px 0;
    padding: 16px;
    border-left: 4px solid #d39d28;
    border-radius: 8px;
    background: #fff8e5;
}

.context-help-tip p {
    margin: 6px 0 0;
}

.help-search-card {
    margin-bottom: 18px;
}

.help-search-card label {
    margin-top: 0;
}

.help-search-card input {
    font-size: 16px;
}

.help-empty {
    padding: 24px;
    text-align: center;
}

.court-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 16px;
}

.court-form-wide {
    grid-column: 1 / -1;
}

/* Browser legal document editor */
.word-page {
    max-width: 1700px;
}

.word-layout {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.word-sidebar {
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 112px);
    overflow-y: auto;
}

.word-new-form label:first-of-type {
    margin-top: 8px;
}

.word-template-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.word-template-section h3 {
    margin: 0 0 8px;
}

.word-template-list {
    margin-top: 12px;
}

.word-template-list summary {
    cursor: pointer;
    color: var(--brand);
    font-weight: 800;
}

.word-template-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.word-template-row > div {
    display: grid;
    gap: 3px;
}

.word-template-row small {
    color: var(--muted);
}

.word-document-list {
    display: grid;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.word-document-link {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    text-decoration: none;
    background: #fff;
}

.word-document-link:hover,
.word-document-link.active {
    border-color: var(--brand);
    background: #eef7f5;
}

.word-document-link span,
.word-document-link small {
    color: var(--muted);
}

.word-workspace {
    min-width: 0;
}

.word-editor-tools-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 20px;
    align-items: start;
}

.word-empty-state {
    min-height: 420px;
    display: grid;
    place-content: center;
    text-align: center;
}

.word-editor-shell {
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: #dfe3e8;
    box-shadow: 0 8px 28px rgba(20, 32, 45, .1);
}

.word-document-settings {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(220px, .8fr) auto;
    gap: 14px;
    align-items: end;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.word-document-settings label {
    margin-top: 0;
}

.word-save-state {
    display: grid;
    justify-items: end;
    gap: 3px;
    padding-bottom: 10px;
    color: var(--brand);
    font-weight: 800;
}

.word-save-state small {
    color: var(--muted);
    font-weight: 600;
}

.word-toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 10px 14px;
    border-bottom: 1px solid #c7ccd2;
    background: #f7f8fa;
}

.word-toolbar button {
    width: auto;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid #ccd2d9;
    background: #fff;
    color: var(--ink);
    font-size: 13px;
}

.word-toolbar button:hover {
    border-color: var(--brand);
    background: #edf6f4;
}

.word-toolbar-separator {
    width: 1px;
    margin: 3px 4px;
    background: #cbd1d8;
}

.word-paper-wrap {
    overflow: auto;
    padding: 28px;
}

.word-paper {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    padding: 22mm 20mm 22mm 25mm;
    outline: none;
    background: #fff;
    color: #111;
    box-shadow: 0 5px 22px rgba(0, 0, 0, .18);
    font: 12pt/1.55 Georgia, "Times New Roman", serif;
}

.word-paper:focus {
    box-shadow: 0 5px 25px rgba(24, 92, 87, .25);
}

.word-paper h1 { font-size: 20pt; }
.word-paper h2 { font-size: 16pt; }
.word-paper h3 { font-size: 13pt; }
.word-paper table { width: 100%; border-collapse: collapse; }
.word-paper th,
.word-paper td { border: 1px solid #555; padding: 6px; }
.word-paper blockquote { margin-left: 20px; padding-left: 14px; border-left: 3px solid #888; }

.word-editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    border-top: 1px solid #c7ccd2;
    background: #fff;
}

.word-editor-footer > div {
    display: flex;
    gap: 8px;
}

.word-editor-status {
    display: grid !important;
    gap: 3px !important;
}

.word-editor-status small {
    color: var(--muted);
}

.word-history {
    margin-top: 20px;
}

.word-revision-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.word-revision-row > div {
    display: grid;
    gap: 3px;
}

.word-revision-row span,
.word-revision-row small {
    color: var(--muted);
}

.word-context-panel {
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 112px);
    overflow-y: auto;
}

.word-context-head {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.word-context-head h2 {
    margin: 0;
}

.word-context-head p {
    margin: 4px 0 0;
}

.word-note-list {
    display: grid;
    gap: 10px;
}

.word-note-item {
    display: grid;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafb;
}

.word-note-item small {
    color: var(--brand);
    font-weight: 700;
}

.word-note-item p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.word-save-template-form {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.word-save-template-form h3 {
    margin: 0;
}

.word-save-template-form small {
    display: block;
    margin-top: 8px;
    line-height: 1.4;
}

/* PDF preview popup on hover */
.pdf-preview-area {
    flex: 1;
    min-width: 0;
}

.pdf-preview-trigger {
    position: relative;
    display: inline-block;
}

.preview-popup {
    display: none;
    position: absolute;
    z-index: 1100;
    top: 100%;
    left: 0;
    margin-top: 8px;
    width: 480px;
    border-radius: 10px;
    box-shadow: 0 14px 50px rgba(0, 0, 0, .22);
    background: #fff;
    overflow: hidden;
    border: 1px solid var(--line);
}

.pdf-preview-trigger:hover .preview-popup,
.pdf-preview-trigger:focus-within .preview-popup {
    display: block;
}

.preview-popup-inner {
    display: grid;
    grid-template-rows: minmax(320px, 1fr) auto;
}

.preview-popup iframe {
    width: 100%;
    height: 360px;
    border: 0;
    background: #fff;
}

.preview-popup-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: #f7f9fa;
    border-top: 1px solid var(--line);
    font-size: 13px;
    font-weight: 800;
    color: var(--ink);
}

/* Print styles */
@media print {
    body {
        background: #fff !important;
    }

    .topbar,
    .main-nav,
    .user-strip,
    .button,
    form,
    .document-filter-advanced,
    .timeline-toolbar-right,
    .timeline-node-select,
    .review-panel,
    .preview-popup,
    .doc-select {
        display: none !important;
    }

    .help-launcher,
    .context-help,
    .context-help-backdrop {
        display: none !important;
    }

    .page {
        padding: 0 !important;
        margin: 0 !important;
    }

    .case-file-page {
        max-width: 100% !important;
    }

    .card {
        border: 0 !important;
        box-shadow: none !important;
        padding: 10px 0 !important;
    }

    .timeline-tree {
        margin-left: 0 !important;
    }

    .timeline-node {
        grid-template-columns: 44px minmax(0, 1fr) !important;
        break-inside: avoid;
    }

    .timeline-node::before {
        display: none;
    }

    .timeline-node-card {
        border: 0 !important;
        border-bottom: 1px solid #ccc !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        margin-bottom: 6px !important;
        padding: 12px 0 !important;
    }

    .timeline-node-card.reviewed,
    .timeline-node-card.pending {
        border-left: 0 !important;
    }

    .timeline-node-dot {
        border: 2px solid #999 !important;
        background: #fff !important;
    }

    .timeline-node-meta {
        background: #f9f9f9 !important;
        border: 1px solid #ddd !important;
    }

    .tag-row span,
    .doc-type-badge,
    .review-badge {
        border: 1px solid #bbb !important;
    }
}

/* Print mode active */
body.print-mode .topbar,
body.print-mode .case-file-summary,
body.print-mode .document-filter-advanced,
body.print-mode .document-upload-form,
body.print-mode .timeline-toolbar,
body.print-mode .timeline-node-select,
body.print-mode .review-panel,
body.print-mode .pdf-preview-trigger .preview-popup {
    display: none !important;
}

body.print-mode .document-description {
    background: #fafafa;
}

body.print-mode .timeline-node-meta {
    background: #fafafa;
    border: 1px solid #ddd;
}

.taxonomy-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}

.taxonomy-row,
.taxonomy-add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.taxonomy-add {
    grid-template-columns: minmax(0, 1fr) auto;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

@media (max-width: 920px) {
    .word-layout {
        grid-template-columns: 1fr;
    }

    .word-sidebar {
        position: static;
        max-height: none;
    }

    .word-document-settings {
        grid-template-columns: 1fr;
    }

    .word-save-state {
        justify-items: start;
    }

    .word-editor-tools-layout {
        grid-template-columns: 1fr;
    }

    .word-context-panel {
        display: none;
        position: static;
        max-height: none;
    }

    .word-context-panel.open {
        display: block;
    }

    .document-filter-advanced {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .document-filter-advanced input[type="search"] {
        grid-column: 1 / -1;
    }

    .timeline-toolbar {
        align-items: stretch;
    }

    .timeline-toolbar-right {
        flex-wrap: wrap;
    }

    .timeline-period {
        grid-template-columns: 20px 38px minmax(0, 1fr);
        gap: 10px;
    }

    .timeline-node {
        grid-template-columns: 20px 38px minmax(0, 1fr);
        gap: 10px;
    }

    .timeline-node::before {
        left: 48px;
    }

    .timeline-node-dot {
        width: 38px;
        height: 38px;
        font-size: 17px;
    }
}

@media (max-width: 620px) {
    .word-paper-wrap {
        padding: 12px;
    }

    .word-paper {
        width: 100%;
        min-height: 70vh;
        padding: 22px 18px;
    }

    .word-editor-footer,
    .word-revision-row {
        align-items: stretch;
        flex-direction: column;
    }

    .word-editor-footer > div {
        flex-direction: column;
    }

    .court-form {
        grid-template-columns: 1fr;
    }

    .court-form-wide {
        grid-column: auto;
    }

    .help-launcher {
        right: 14px;
        bottom: 14px;
    }

    .help-launcher strong {
        display: none;
    }

    .help-launcher {
        width: 50px;
        height: 50px;
        padding: 10px;
    }

    .help-navigation nav,
    .help-status-grid {
        grid-template-columns: 1fr;
    }
    .pdf-page-editor form {
        grid-template-columns: 1fr;
    }
    .person-form {
        grid-template-columns: 1fr;
    }
    .taxonomy-grid {
        grid-template-columns: 1fr;
    }
    .document-filter-advanced {
        grid-template-columns: 1fr;
    }

    .document-filter-advanced input[type="search"],
    .document-filter-advanced .button.secondary {
        grid-column: auto;
    }

    .timeline-toolbar-right .button {
        flex: 1 1 170px;
    }

    .timeline-period {
        grid-template-columns: 34px minmax(0, 1fr);
        gap: 10px;
    }

    .timeline-period-dot {
        grid-column: 1;
    }

    .timeline-period-content {
        grid-column: 2;
    }

    .timeline-node {
        grid-template-columns: 34px minmax(0, 1fr);
        gap: 10px;
    }

    .timeline-node-select {
        position: absolute;
        z-index: 3;
        left: 8px;
        top: 42px;
        padding: 0;
    }

    .timeline-node-dot {
        grid-column: 1;
        width: 34px;
        height: 34px;
        font-size: 15px;
    }

    .timeline-node-card {
        grid-column: 2;
        padding: 15px;
    }

    .timeline-node::before {
        left: 16px;
    }

    .timeline-node-meta {
        grid-template-columns: 1fr;
    }

    .preview-popup {
        display: none !important;
    }
}

/* Final mobile overrides for the client panel */
@media screen and (max-width: 760px) {
    body:has(.client-topbar) {
        min-width: 0;
        overflow-x: hidden;
    }

    .client-topbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 10px;
        min-height: 0;
        padding: 10px 14px;
    }

    .client-topbar .brand {
        min-width: 0;
    }

    .client-topbar .brand span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .client-menu-toggle {
        display: inline-flex;
        min-height: 42px;
        padding: 8px 12px;
        font-size: 14px;
    }

    .client-topbar .client-nav {
        display: none;
        grid-column: 1 / -1;
        order: initial;
        width: 100%;
        padding: 6px;
        border: 1px solid var(--line);
        border-radius: 10px;
        background: #f7f9fb;
        overflow: visible;
    }

    .client-topbar .client-nav.is-open {
        display: grid;
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .client-topbar .client-nav a {
        justify-content: flex-start;
        width: 100%;
        min-height: 44px;
        padding: 10px 12px;
        border: 0;
        border-radius: 8px;
    }

    .client-topbar .client-nav a.active {
        border: 0;
        background: #e5f1f0;
        box-shadow: inset 3px 0 0 var(--brand);
    }

    .client-topbar .user-strip {
        display: none;
    }

    .client-mobile-links {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 5px;
        margin-top: 5px;
        padding-top: 5px;
        border-top: 1px solid var(--line);
    }

    .client-topbar .client-nav .client-mobile-links a {
        justify-content: center;
        min-width: 0;
        min-height: 40px;
        padding: 8px 4px;
        background: #e7ecef;
        color: var(--ink);
        font-size: 12px;
        text-align: center;
    }

    .client-topbar .client-nav .client-mobile-links .client-mobile-logout {
        background: #f5dddd;
        color: #7b2525;
    }

    .client-case-strip {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        padding: 9px 14px;
        gap: 6px 8px;
        font-size: 12px;
    }

    .client-case-strip strong {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body:has(.client-topbar) .page {
        width: 100%;
        max-width: 100%;
        padding: 16px 12px 88px;
        overflow: hidden;
    }

    body:has(.client-topbar) .page h1 {
        font-size: 24px;
        overflow-wrap: anywhere;
    }

    body:has(.client-topbar) .card {
        min-width: 0;
        padding: 16px;
        border-radius: 10px;
    }

    .case-file-heading {
        display: block;
        margin-bottom: 14px;
    }

    .client-timeline-filter,
    .document-filter-advanced,
    .upload-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .client-timeline-filter > *,
    .document-upload-form input,
    .document-upload-form select,
    .document-upload-form textarea,
    .document-upload-form button {
        width: 100%;
        max-width: 100%;
        margin-inline: 0;
    }

    .timeline-toolbar {
        align-items: stretch;
    }

    .timeline-toolbar-right {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
        gap: 6px;
    }

    .timeline-toolbar-right .button {
        width: 100%;
        margin: 0;
    }

    .timeline-tree {
        width: 100%;
        margin: 0;
    }

    .timeline-node {
        grid-template-columns: 30px minmax(0, 1fr);
        gap: 7px;
        width: 100%;
    }

    .timeline-node-select {
        position: absolute;
        left: 7px;
        top: 37px;
        z-index: 3;
    }

    .timeline-node-dot {
        grid-column: 1;
        width: 30px;
        height: 30px;
        font-size: 11px;
    }

    .timeline-node-card {
        grid-column: 2;
        min-width: 0;
        padding: 13px;
        overflow-wrap: anywhere;
    }

    .timeline-node::before {
        left: 14px;
    }

    .timeline-node-card h3 {
        font-size: 16px;
        overflow-wrap: anywhere;
    }

    .timeline-node-meta {
        grid-template-columns: 1fr;
    }

    .document-files,
    .document-file,
    .document-file-head,
    .pdf-preview-trigger {
        min-width: 0;
        max-width: 100%;
    }

    .document-file-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .pdf-preview-trigger a {
        overflow-wrap: anywhere;
    }

    .preview-popup {
        display: none !important;
    }

    .document-upload-form input[type="file"] {
        padding: 10px;
        font-size: 13px;
    }

    .client-people-layout {
        display: block;
    }

    .client-person-editor {
        position: static;
        margin-bottom: 14px;
    }

    .client-person-row,
    .client-person-edit-form {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .client-person-row {
        padding: 14px 0;
    }

    .client-person-edit-form > *,
    .client-person-row > form,
    .client-person-row > form .button {
        width: 100%;
        max-width: 100%;
    }

    .chat-shell {
        width: 100%;
        max-width: 100%;
        padding: 12px !important;
    }

    .chat-messages {
        min-height: 260px;
        max-height: 52vh;
        padding: 9px;
    }

    .chat-message {
        width: 92%;
        max-width: 92%;
        padding: 10px 11px;
        overflow-wrap: anywhere;
    }

    .chat-message-meta {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }

    .chat-compose textarea,
    .chat-compose button {
        width: 100%;
    }
}

@media screen and (max-width: 420px) {
    .client-topbar {
        padding-inline: 10px;
    }

    .client-topbar .brand .mark {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }

    .client-topbar .brand span {
        font-size: 14px;
    }

    .client-menu-toggle {
        min-height: 38px;
        padding: 7px 9px;
    }

    .client-case-strip {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .client-case-strip > span:first-child {
        display: none;
    }

    body:has(.client-topbar) .page {
        padding-inline: 9px;
    }

    body:has(.client-topbar) .card {
        padding: 13px;
    }

    .timeline-node {
        grid-template-columns: 26px minmax(0, 1fr);
        gap: 5px;
    }

    .timeline-node-dot {
        width: 26px;
        height: 26px;
    }

    .timeline-node::before {
        left: 12px;
    }

    .timeline-node-card {
        padding: 11px;
    }
}
