:root {
    color-scheme: light;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-muted: #eef2f7;
    --border: #dfe5ee;
    --border-soft: #e8edf4;
    --text: #172033;
    --muted: #5f6b7a;
    --accent: #1d5fa7;
    --accent-dark: #15527f;
    --accent-soft: #e7f0fb;
    --control-border: #c2cdda;
    --label: #334155;
    --success: #157347;
    --success-bg: #eaf7ef;
    --danger: #b42318;
    --danger-bg: #fff4f2;
    --shadow-sm: 0 1px 2px rgba(23, 32, 51, 0.06);
    --shadow-md: 0 6px 20px rgba(23, 32, 51, 0.07);
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --ease: 0.16s ease;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent);
}

.page {
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(320px, 470px) 1fr;
}

.auth-panel,
.workspace-panel {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    justify-content: center;
    padding: 48px;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.brand {
    margin-bottom: 40px;
}

.brand-mark {
    display: inline-grid;
    width: 44px;
    height: 44px;
    margin-bottom: 20px;
    place-items: center;
    border-radius: 8px;
    background: var(--accent);
    color: #ffffff;
    font-size: 20px;
    font-weight: 700;
}

h1,
h2 {
    letter-spacing: 0;
}

h1 {
    margin: 0 0 8px;
    font-size: 24px;
    line-height: 1.18;
}

h2 {
    margin: 0 0 14px;
    font-size: 17px;
    line-height: 1.3;
}

.subtitle {
    max-width: 520px;
    margin: 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.55;
}

.form {
    display: grid;
    gap: 18px;
    width: 100%;
    max-width: 360px;
}

.field {
    display: grid;
    position: relative;
    gap: 8px;
    /* Не даём grid-строке растягивать инпут по высоте соседей. */
    align-content: start;
}

.field--wide {
    grid-column: 1 / -1;
}

label {
    color: var(--label);
    font-size: 14px;
    font-weight: 700;
}

.field-label-with-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
}

.field-label-with-hint label {
    margin: 0;
}

.field-hint {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    color: var(--muted);
    cursor: help;
    outline: none;
}

.field-hint-icon {
    display: inline-grid;
    width: 16px;
    height: 16px;
    place-items: center;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.field-hint-tooltip {
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    left: 0;
    width: max-content;
    max-width: min(300px, calc(100vw - 32px));
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 8px 18px rgba(16, 35, 62, 0.14);
    color: var(--text);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-2px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    visibility: hidden;
}

.field-hint:hover .field-hint-tooltip,
.field-hint:focus .field-hint-tooltip,
.field-hint:focus-visible .field-hint-tooltip {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

.form-control {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--control-border);
    border-radius: 6px;
    padding: 7px 10px;
    color: var(--text);
    background: #ffffff;
    font-size: 14px;
    outline: none;
}

textarea.form-control {
    resize: vertical;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(29, 95, 167, 0.18);
}

.address-suggestions {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    display: grid;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 14px 30px rgba(23, 32, 51, 0.14);
}

.address-suggestions[hidden] {
    display: none;
}

.address-suggestion {
    display: grid;
    gap: 3px;
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.address-suggestion:last-child {
    border-bottom: 0;
}

.address-suggestion:hover,
.address-suggestion.is-active {
    background: var(--accent-soft);
}

.address-suggestion-main {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
}

.address-suggestion-meta {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.checkbox-field {
    display: flex;
    gap: 10px;
    align-items: center;
}

.checkbox-input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.error-list,
.messages {
    margin: 0;
    padding: 0;
    list-style: none;
}

.error-list {
    display: grid;
    gap: 6px;
    padding: 12px 14px;
    border: 1px solid #f2b8b5;
    border-radius: 6px;
    background: var(--danger-bg);
    color: var(--danger);
    font-size: 14px;
    line-height: 1.45;
}

.field-error {
    margin: 0;
    color: var(--danger);
    font-size: 13px;
    line-height: 1.4;
}

.field-input-action {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.field-input-action .form-control {
    min-width: 0;
    flex: 1 1 auto;
}

.field-input-action .button {
    flex: 0 0 auto;
    white-space: nowrap;
}

.inn-field-action {
    gap: 4px;
}

.inn-field-action .field-icon-action {
    width: 34px;
    min-height: 34px;
    padding: 0;
    font-size: 17px;
    line-height: 1;
}

.inn-validation {
    margin: -2px 0 0;
    font-size: 13px;
    line-height: 1.4;
}

.inn-validation.is-pending {
    color: var(--muted);
}

.inn-validation.is-valid {
    color: var(--success);
}

.inn-validation.is-invalid {
    color: var(--danger);
}

.quick-choice-field {
    min-width: 0;
    margin: 0;
    border: 0;
    padding: 0;
}

.quick-choice-field legend {
    margin-bottom: 8px;
    padding: 0;
    color: var(--label);
    font-size: 14px;
    font-weight: 700;
}

.quick-choice {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.quick-choice-option {
    position: relative;
    cursor: pointer;
}

.quick-choice-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.quick-choice-option span {
    display: flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--control-border);
    border-radius: 6px;
    background: #ffffff;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.quick-choice-option input:checked + span {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.quick-choice-option input:focus-visible + span {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(29, 95, 167, 0.18);
}

.snils-validation {
    margin: -2px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.snils-validation.is-valid {
    color: var(--success);
}

.snils-validation.is-invalid {
    color: var(--danger);
}

.button-row,
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.section-actions {
    margin-top: 18px;
}

.button {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 7px 14px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
}

.button-primary {
    background: var(--accent);
    color: #ffffff;
}

.button-primary:hover {
    background: var(--accent-dark);
}

.button-secondary {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
}

.button-secondary:hover {
    background: var(--surface-muted);
}

.button-small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-page .auth-panel {
    width: min(100%, 420px);
    min-height: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.content-panel {
    display: flex;
    min-height: 100vh;
    align-items: center;
    padding: 48px;
}

.status-board {
    width: min(780px, 100%);
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 28px;
}

.status-item {
    min-height: 118px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.status-label {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 13px;
}

.status-value {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.3;
}

.app-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    padding: 28px 18px;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.sidebar .brand {
    margin-bottom: 28px;
}

.sidebar-head {
    display: block;
}

.sidebar .brand-mark {
    width: 38px;
    height: 38px;
    margin-bottom: 14px;
    font-size: 17px;
}

.sidebar-title {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 700;
}

.sidebar-user {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.sidebar-toggle {
    display: none;
    min-height: 40px;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.sidebar-toggle-icon,
.sidebar-toggle-icon::before,
.sidebar-toggle-icon::after {
    display: block;
    width: 16px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
}

.sidebar-toggle-icon {
    position: relative;
}

.sidebar-toggle-icon::before,
.sidebar-toggle-icon::after {
    content: "";
    position: absolute;
    left: 0;
}

.sidebar-toggle-icon::before {
    top: -5px;
}

.sidebar-toggle-icon::after {
    top: 5px;
}

.nav-menu {
    display: grid;
    gap: 6px;
}

.nav-link {
    display: flex;
    min-height: 40px;
    align-items: center;
    border-radius: 6px;
    padding: 8px 10px;
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
}

.nav-link:hover,
.nav-link.is-active {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.nav-group-label {
    margin: 12px 10px 2px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.nav-badge {
    display: inline-flex;
    min-width: 22px;
    height: 20px;
    margin-left: auto;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0 6px;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.nav-badge.is-attention {
    background: #fff3cd;
    color: #6b4400;
}

.nav-link.is-active .nav-badge {
    background: rgba(29, 95, 167, 0.14);
    color: var(--accent-dark);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 22px;
}

.main-panel {
    min-width: 0;
    padding: 24px 28px 40px;
}

.page-header {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 18px;
}

.messages {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.message {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
}

.message.success {
    border-color: #b8e1c8;
    background: var(--success-bg);
    color: var(--success);
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: -6px 0 18px;
}

.filter-chip {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
    text-decoration: none;
}

.filter-chip-reset {
    color: var(--accent);
}

.filter-chip-reset:hover {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.filter-chip-removable {
    gap: 7px;
    padding-right: 7px;
}

.filter-chip-removable:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.filter-chip-remove {
    display: inline-grid;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    place-items: center;
    border-radius: 50%;
    background: var(--surface-muted);
    font-size: 16px;
    font-weight: 500;
    line-height: 1;
}

.filter-chip-removable:hover .filter-chip-remove {
    background: rgba(29, 95, 167, 0.14);
}

.list-filter,
.board-filter {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    align-items: end;
    margin-bottom: 18px;
}

.filter-field {
    display: grid;
    min-width: 0;
    gap: 6px;
}

.filter-label {
    color: var(--label);
    font-size: 13px;
    font-weight: 700;
}

.board-toolbar {
    display: flex;
    justify-content: flex-end;
    margin: -6px 0 18px;
}

.switch-field {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    color: var(--label);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

.switch-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.switch-control {
    position: relative;
    width: 44px;
    height: 24px;
    flex: 0 0 44px;
    border: 1px solid var(--control-border);
    border-radius: 999px;
    background: #e8eef6;
    transition: background 0.16s ease, border-color 0.16s ease;
}

.switch-control::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(23, 32, 51, 0.22);
    transition: transform 0.16s ease;
}

.switch-input:checked + .switch-control {
    border-color: var(--accent);
    background: var(--accent);
}

.switch-input:checked + .switch-control::after {
    transform: translateX(20px);
}

.switch-input:focus + .switch-control {
    box-shadow: 0 0 0 3px rgba(29, 95, 167, 0.18);
}

.switch-input:disabled + .switch-control {
    opacity: 0.65;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 820px;
    font-size: 14px;
}

th,
td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

th {
    position: sticky;
    top: 0;
    z-index: 3;
    color: var(--muted);
    background: #f8fafc;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.sort-button {
    display: inline-flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    text-transform: inherit;
    cursor: pointer;
}

.sort-button::after {
    content: "";
    width: 0;
    height: 0;
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
    opacity: 0.45;
}

.sort-button.is-asc::after {
    border-bottom: 6px solid currentColor;
}

.sort-button.is-desc::after {
    border-top: 6px solid currentColor;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.company-link {
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.table-sub {
    margin-top: 2px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 400;
}

.list-total {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 13px;
}

.company-link:hover {
    color: var(--accent);
}

.table-action {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    color: var(--accent);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.table-action::before {
    content: "";
    width: 6px;
    height: 6px;
    flex: 0 0 6px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: rotate(45deg);
}

.table-action:hover {
    color: var(--accent-dark);
    text-decoration: underline;
}

.muted-inline {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.status-pill {
    display: inline-flex;
    min-height: 26px;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 700;
}

.status-pill::before {
    content: "";
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.75;
}

.status-pill.is-active {
    background: var(--success-bg);
    color: var(--success);
}

.status-pill.is-inactive {
    background: #eef1f5;
    color: var(--muted);
}

.status-pill.status-moderation {
    background: #fff3cd;
    color: #6b4400;
}

.status-pill.status-published {
    background: var(--success-bg);
    color: var(--success);
}

.status-pill.status-rejected {
    background: var(--danger-bg);
    color: var(--danger);
}

.status-pill.status-draft,
.status-pill.status-pending {
    background: #eef1f5;
    color: var(--muted);
}

.status-pill.status-submitted,
.status-pill.status-in_review {
    background: #fff3cd;
    color: #6b4400;
}

.status-pill.status-approved,
.status-pill.status-completed {
    background: var(--success-bg);
    color: var(--success);
}

.status-pill.status-new,
.status-pill.status-screening,
.status-pill.status-in_process,
.status-pill.status-planned,
.status-pill.status-review {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.status-pill.status-employed,
.status-pill.status-accepted,
.status-pill.status-done,
.status-pill.status-confirmed {
    background: var(--success-bg);
    color: var(--success);
}

.status-pill.status-problem,
.status-pill.status-needs_fix,
.status-pill.status-expired,
.status-pill.status-no_show,
.status-pill.status-late,
.status-pill.status-violation,
.status-pill.status-document_issue {
    background: var(--danger-bg);
    color: var(--danger);
}

.status-pill.status-expiring,
.status-pill.status-postponed,
.status-pill.status-in_progress {
    background: #fff3cd;
    color: #6b4400;
}

.empty-state {
    padding: 34px 18px;
    color: var(--muted);
    text-align: center;
}

.compact-header {
    margin-bottom: 14px;
}

.attachment-list {
    display: grid;
    gap: 8px;
    margin: 12px 0 16px;
    padding: 0;
    list-style: none;
}

.attachment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
}

.client-summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.case-block-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
    margin-top: 18px;
}

.case-block-grid {
    grid-template-columns: repeat(2, minmax(320px, 1fr));
}

.case-block-wide {
    grid-column: 1 / -1;
}

.attention-list,
.compact-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.attention-list li,
.compact-list li {
    display: grid;
    gap: 6px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.attention-list li {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
}

.attention-list li:last-child,
.compact-list li:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.attention-list a,
.compact-list a {
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.attention-list a:hover,
.compact-list a:hover {
    color: var(--accent);
}

.attention-list span,
.compact-list span {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.case-headline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
}

.case-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.case-block-list {
    display: grid;
    gap: 10px;
    margin: 0 0 18px;
    padding: 0;
    list-style: none;
}

.case-block-item {
    display: grid;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: #f8fafc;
}

.case-block-title {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
}

.case-block-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.case-block-text {
    margin: 0;
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-line;
}

.document-compact-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.document-compact-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: #f8fafc;
}

.document-compact-main {
    display: grid;
    min-width: 0;
    gap: 6px;
}

.document-compact-title {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
}

.document-compact-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 12px;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.modal {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    border: 0;
    border-radius: 8px;
    padding: 0;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 22px 60px rgba(23, 32, 51, 0.28);
}

.modal::backdrop {
    background: rgba(23, 32, 51, 0.48);
}

.modal-content {
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 22px;
}

.modal-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 4px;
}

.modal-header h2 {
    margin-bottom: 0;
}

.modal-close {
    display: inline-grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    background: var(--surface-muted);
}

/* --- Confirm dialog for destructive actions --- */
.confirm-modal {
    width: min(440px, calc(100vw - 32px));
}

.confirm-modal .modal-card {
    padding: 22px;
}

.confirm-modal-title {
    margin: 0 0 8px;
    font-size: 18px;
}

.confirm-modal-text {
    margin: 0 0 18px;
    color: var(--muted);
}

.confirm-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.button-danger {
    border: 1px solid var(--danger, #b3261e);
    background: var(--danger, #b3261e);
    color: #fff;
}

.button-danger:hover {
    filter: brightness(0.92);
}

body.modal-open {
    overflow: hidden;
}

.mvd-registry-modal {
    width: min(1180px, calc(100vw - 32px));
}

.mvd-registry-modal-content {
    padding: 0;
    overflow: hidden;
}

.mvd-registry-modal .modal-header {
    margin: 0;
    border-bottom: 1px solid var(--border);
    padding: 20px 22px;
}

.mvd-registry-layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    min-height: min(680px, calc(100vh - 150px));
}

.inn-registry-layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    min-height: min(480px, calc(100vh - 150px));
}

.mvd-registry-sidebar {
    display: grid;
    align-content: start;
    gap: 14px;
    border-right: 1px solid var(--border);
    padding: 18px;
    background: var(--surface-muted);
}

.mvd-registry-note {
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.mvd-registry-data {
    display: grid;
    gap: 8px;
}

.mvd-registry-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
}

.mvd-registry-row > div {
    display: grid;
    min-width: 0;
    gap: 3px;
}

.mvd-registry-row span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.mvd-registry-row strong {
    overflow-wrap: anywhere;
    font-size: 14px;
}

.mvd-registry-copy {
    min-height: 32px;
    padding: 5px 9px;
    font-size: 12px;
}

.mvd-registry-service {
    display: grid;
    grid-template-rows: auto minmax(420px, 1fr) auto;
    min-width: 0;
    gap: 12px;
    padding: 18px;
}

.inn-registry-service {
    display: grid;
    align-content: center;
    justify-items: start;
    gap: 16px;
    padding: 28px;
}

.inn-registry-service h3,
.inn-registry-service p {
    margin: 0;
}

.inn-registry-service p {
    max-width: 520px;
    margin-top: 6px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.mvd-registry-toolbar {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    justify-content: space-between;
}

.mvd-registry-toolbar h3,
.mvd-registry-toolbar p {
    margin: 0;
}

.mvd-registry-toolbar p {
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
}

.mvd-registry-frame-shell {
    min-height: 420px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.mvd-registry-frame {
    width: 100%;
    height: 100%;
    min-height: 520px;
    border: 0;
    background: #fff;
}

.inn-registry-save {
    display: grid;
    gap: 9px;
    border-top: 1px solid var(--border);
    padding-top: 14px;
}

.inn-registry-save label {
    font-size: 13px;
}

@media (max-width: 900px) {
    .mvd-registry-layout,
    .inn-registry-layout {
        grid-template-columns: 1fr;
    }

    .mvd-registry-sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .mvd-registry-toolbar {
        display: grid;
    }
}

.inline-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}

.inline-form-grid .field--wide,
.inline-form-grid .form-actions {
    grid-column: 1 / -1;
}

.checkbox-form-field {
    min-height: 46px;
    display: flex;
    gap: 10px;
    align-items: center;
    padding-top: 26px;
}

.client-summary-number {
    color: var(--text);
    font-weight: 700;
    text-align: right;
}

.form-shell {
    max-width: 920px;
}

/* В карточке физлица паспорт расположен между личными данными и контактами.
   Основная форма остаётся одной: display: contents исключает вложенные form. */
.person-form-shell {
    display: grid;
    gap: 14px;
}

.person-form-shell > .page-header {
    order: 0;
}

.person-form-shell > .person-details-form {
    display: contents;
}

.person-name-section {
    order: 1;
}

.person-details-section {
    order: 2;
}

.person-passport-section {
    order: 3;
}

.person-documents-section {
    order: 4;
}

.person-contacts-section {
    order: 5;
}

.person-main-form-actions {
    order: 6;
}

.person-support-section {
    order: 7;
}

.person-form-shell > .drawer {
    order: 8;
}

.form-shell-with-sidebar {
    max-width: 1280px;
}

.details-form {
    display: grid;
    gap: 18px;
}

.details-form[data-unsaved-guard] > .form-actions {
    position: sticky;
    z-index: 12;
    bottom: 0;
    margin: 0 -2px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 -10px 24px rgba(23, 32, 51, 0.08);
    backdrop-filter: blur(8px);
}

.form-section {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 18px;
    background: var(--surface);
}

.section-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    margin: -4px 0 16px;
}

.section-heading-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-heading-row h2 {
    margin-bottom: 0;
}

.contact-form-table-wrap {
    border-radius: 6px;
}

.contact-form-table {
    min-width: 980px;
}

.contact-form-table th,
.contact-form-table td {
    padding: 10px;
}

.contact-form-table .form-control {
    font-size: 14px;
}

.contact-form-table textarea.form-control {
    min-height: 56px;
}

.contact-delete-field {
    min-height: 38px;
    align-items: center;
    white-space: nowrap;
}

.form-grid[hidden] {
    display: none;
}

.form-grid {
    display: grid;
    /* auto-fill: колонки одинаковой ширины, число подстраивается под доступное
       место (3 на десктопе, 2 на планшете/при открытой шторке, 1 на телефоне). */
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px 14px;
    align-items: start;
}

.profile-section {
    margin-top: 18px;
}

.activity-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    gap: 18px;
    align-items: start;
}

.activity-main {
    min-width: 0;
}

.activity-sidebar {
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}

.activity-sidebar .profile-section {
    margin-top: 0;
}

.activity-sidebar .activity-comment-form {
    gap: 12px;
}

.activity-sidebar .form-actions .button {
    width: 100%;
}

.company-activity-layout {
    display: block;
}

.company-activity-layout > .activity-sidebar {
    position: static;
    margin-top: 18px;
    max-height: none;
    overflow: visible;
}

.company-activity-layout .table-wrap {
    max-width: 100%;
    min-width: 0;
}

.profile-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin: 0;
}

.profile-list div {
    display: grid;
    gap: 5px;
    padding: 14px 0;
    border-top: 1px solid var(--border);
}

.profile-list dt {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.profile-list dd {
    margin: 0;
    color: var(--text);
    font-size: 15px;
    line-height: 1.4;
}

.case-attention {
    display: grid;
    gap: 12px;
    margin: 18px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    background: var(--surface);
}

.case-attention-header {
    display: flex;
    gap: 10px;
    align-items: baseline;
    justify-content: space-between;
}

.case-attention-title {
    margin: 0;
    font-size: 17px;
    line-height: 1.3;
}

.case-attention-count {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.case-attention-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.case-attention-item {
    display: grid;
    gap: 4px;
    border-left: 4px solid var(--accent);
    border-radius: 6px;
    padding: 10px 12px;
    background: #f8fafc;
}

.case-attention-item.is-warning {
    border-left-color: #d99100;
    background: #fff9e8;
}

.case-attention-item.is-danger {
    border-left-color: var(--danger);
    background: var(--danger-bg);
}

.case-attention-item-title {
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
}

.case-attention-item-text {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

/* Свернутый вид блока «Требует внимания», когда предупреждений нет. */
.case-attention.is-empty {
    gap: 2px;
    margin: 12px 0;
    padding: 10px 16px;
}

.case-attention.is-empty .case-attention-title {
    font-size: 14px;
}

.case-attention-ok {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.case-layout > .case-tabs {
    min-width: 0;
}

.case-layout .section-tabs {
    margin-top: 0;
}

.case-requisites {
    margin-top: 22px;
}

.case-requisites .profile-list {
    column-gap: 28px;
}

.case-requisites .profile-list div:nth-child(-n + 2) {
    padding-top: 0;
    border-top: 0;
}

/* Раскрывашка с формой: summary выглядит кнопкой, маркер прячем. */
.section-disclosure {
    margin-top: 14px;
}

.section-disclosure > summary {
    width: fit-content;
    list-style: none;
}

.section-disclosure > summary::-webkit-details-marker {
    display: none;
}

.section-disclosure[open] > summary {
    margin-bottom: 14px;
}

.section-tabs {
    display: flex;
    gap: 8px;
    margin: 18px 0;
    overflow-x: auto;
    padding-bottom: 2px;
}

.section-tab {
    display: inline-flex;
    min-height: 38px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 14px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.section-tab:hover,
.section-tab.is-active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.case-tabs.tabs-ready .case-tab-panel:not(.is-active) {
    display: none;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.file-list {
    display: grid;
    gap: 10px;
    margin: 0 0 18px;
    padding: 0;
    list-style: none;
}

.file-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: #f8fafc;
}

.file-name {
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.file-name:hover {
    color: var(--accent);
}

.file-meta {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.8fr);
    gap: 18px;
    align-items: start;
}

.detail-list {
    display: grid;
    /* Компактная сетка вместо вертикальной простыни «поле — строка». */
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px 18px;
    margin: 0;
}

.detail-list div {
    display: grid;
    gap: 3px;
    align-content: start;
}

.detail-list dt {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.detail-list dd {
    margin: 0;
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-line;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    align-items: center;
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 14px;
}

.detail-meta strong {
    color: var(--text);
    font-weight: 700;
}

.activity-comment-form {
    margin-bottom: 18px;
}

.activity-list {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.activity-item {
    display: grid;
    gap: 8px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 12px;
    background: #f8fafc;
}

.activity-comment {
    border-left-color: var(--success);
}

.activity-file_uploaded,
.activity-file_deleted {
    border-left-color: #64748b;
}

.activity-status_changed {
    border-left-color: #d99100;
}

.activity-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.activity-title {
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
}

.activity-message {
    margin: 0;
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
}

.activity-changes {
    display: grid;
    gap: 8px;
    margin: 0;
}

.activity-changes div {
    display: grid;
    gap: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.activity-changes dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.activity-changes dd {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    color: var(--text);
    font-size: 13px;
    line-height: 1.4;
}

.activity-arrow {
    color: var(--muted);
}

.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(210px, 1fr));
    gap: 14px;
    align-items: start;
    overflow-x: auto;
    padding-bottom: 4px;
}

.board-column-tabs {
    display: none;
}

.kanban-column {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.kanban-column-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px;
    border-bottom: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
    background: #f8fafc;
}

.kanban-column-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

.kanban-count {
    display: inline-flex;
    min-width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 13px;
    font-weight: 700;
}

.kanban-column-body {
    display: grid;
    min-height: 360px;
    align-content: start;
    gap: 10px;
    padding: 12px;
}

.kanban-column-body.is-over {
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 2px var(--accent);
    border-radius: 8px;
}

.task-card {
    display: grid;
    gap: 10px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(23, 32, 51, 0.06);
    cursor: grab;
}

.task-card:active {
    cursor: grabbing;
}

.task-card.is-dragging {
    opacity: 0.65;
    border-style: dashed;
    border-color: var(--accent);
    border-left-style: solid;
    background: var(--accent-soft);
    box-shadow: none;
}

.task-card.is-saving {
    pointer-events: none;
}

.task-card-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
}

.task-card-full {
    display: grid;
    gap: 10px;
}

.task-card-toggle {
    display: none;
    min-height: 28px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    background: var(--surface);
    color: var(--accent-dark);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
}

.task-card-toggle:hover,
.task-card-toggle:focus {
    background: var(--accent-soft);
}

.kanban-board.is-compact .task-card {
    gap: 8px;
    padding: 10px;
}

.kanban-board.is-compact .task-card-toggle {
    display: inline-flex;
}

.kanban-board.is-compact .task-card:not(.is-expanded) .task-card-full {
    display: none;
}

.task-title {
    min-width: 0;
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.task-title:hover {
    color: var(--accent);
}

.task-description {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.task-meta {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.task-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.task-badge {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 3px 9px;
    background: #eef1f5;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.task-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    flex: 0 0 6px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.72;
}

.task-badge.priority-low {
    background: #eef1f5;
    color: #475569;
}

.task-badge.priority-normal {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.task-badge.priority-high {
    background: #fff3cd;
    color: #8a5a00;
}

.task-badge.priority-urgent {
    background: var(--danger-bg);
    color: var(--danger);
}

.task-card.priority-low {
    border-left-color: #94a3b8;
}

.task-card.priority-normal {
    border-left-color: var(--accent);
}

.task-card.priority-high {
    border-left-color: #d99100;
}

.task-card.priority-urgent {
    border-left-color: var(--danger);
}

.task-card.is-overdue {
    background: #fffaf9;
    box-shadow: 0 0 0 1px rgba(180, 35, 24, 0.14);
}

.task-card.is-soon {
    background: #fffdf7;
    box-shadow: 0 0 0 1px rgba(217, 145, 0, 0.12);
}

.due-badge.is-overdue {
    background: var(--danger-bg);
    color: var(--danger);
}

.due-badge.is-today {
    background: #fff3cd;
    color: #6b4400;
}

.due-badge.is-soon {
    background: #fff9e8;
    color: #6b4400;
}

.task-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 2px;
}

.task-card-action {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    background: #f8fafc;
    color: var(--accent-dark);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
}

.task-card-action::before {
    content: "";
    width: 6px;
    height: 6px;
    flex: 0 0 6px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.72;
}

.task-card-action:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 30;
        min-height: auto;
        padding: 10px 18px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-head {
        display: flex;
        gap: 14px;
        align-items: center;
        justify-content: space-between;
    }

    .sidebar .brand {
        min-width: 0;
        margin-bottom: 0;
    }

    .sidebar .brand-mark {
        display: none;
    }

    .sidebar-title {
        margin: 0;
        font-size: 17px;
        line-height: 1.2;
    }

    .sidebar-user {
        display: none;
    }

    .sidebar-toggle {
        display: inline-flex;
        min-height: 38px;
        flex: 0 0 auto;
    }

    .sidebar:not(.is-open) .nav-menu,
    .sidebar:not(.is-open) .sidebar-footer {
        display: none;
    }

    .nav-menu {
        margin-top: 10px;
    }

    .sidebar-footer {
        margin-top: 12px;
    }

    .main-panel {
        padding: 28px 22px 38px;
    }

    .page-header {
        flex-direction: column;
    }

    .profile-list,
    .detail-grid,
    .activity-layout,
    .list-filter,
    .board-filter,
    .document-compact-item,
    .case-block-grid,
    .inline-form-grid {
        grid-template-columns: 1fr;
    }

    .case-headline {
        grid-template-columns: 1fr;
    }

    .case-requisites .profile-list div:nth-child(2) {
        padding-top: 14px;
        border-top: 1px solid var(--border);
    }

    .case-badges {
        justify-content: flex-start;
    }

    .file-item {
        grid-template-columns: 1fr;
    }

    .activity-sidebar {
        position: static;
        max-height: none;
        overflow: visible;
    }

}

@media (max-width: 860px) {
    .page {
        grid-template-columns: 1fr;
    }

    .auth-panel,
    .workspace-panel {
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 32px 22px;
    }

    .login-page .auth-panel {
        border: 1px solid var(--border);
    }

    .content-panel {
        min-height: auto;
        padding: 32px 22px;
    }

    .status-grid {
        grid-template-columns: 1fr;
    }
}


/* Tablets: wide tables scroll inside the wrapper so the sticky header
   stays visible while scrolling rows. */
@media (min-width: 721px) and (max-width: 980px) {
    .table-wrap {
        max-height: min(72vh, 640px);
        overflow: auto;
    }
}

@media (max-width: 720px) {
    .table-wrap {
        overflow: visible;
        border: 0;
        background: transparent;
    }

    .contact-form-table-wrap {
        overflow-x: auto;
        border: 1px solid var(--border);
        background: var(--surface);
    }

    table[data-sortable-table] {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0 10px;
    }

    table[data-sortable-table] thead {
        display: none;
    }

    table[data-sortable-table] tbody,
    table[data-sortable-table] tr,
    table[data-sortable-table] td {
        display: block;
        width: 100%;
    }

    table[data-sortable-table] tbody tr {
        border: 1px solid var(--border);
        border-radius: 8px;
        background: var(--surface);
        overflow: hidden;
    }

    table[data-sortable-table] td {
        border-bottom: 1px solid var(--border);
        padding: 11px 14px;
    }

    table[data-sortable-table] td:last-child {
        border-bottom: 0;
    }

    table[data-sortable-table] td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 5px;
        color: var(--muted);
        font-size: 12px;
        font-weight: 700;
        text-transform: uppercase;
    }

    table[data-sortable-table] td[colspan] {
        display: table-cell;
    }

    .board-toolbar {
        justify-content: flex-start;
    }

    .board-column-tabs {
        display: flex;
        gap: 8px;
        margin: 0 0 12px;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .board-column-tab {
        display: inline-flex;
        min-height: 38px;
        flex: 0 0 auto;
        align-items: center;
        gap: 8px;
        border: 1px solid var(--border);
        border-radius: 999px;
        padding: 6px 8px 6px 12px;
        background: var(--surface);
        color: var(--text);
        font: inherit;
        font-size: 14px;
        font-weight: 700;
        cursor: pointer;
    }

    .board-column-tab.is-active {
        border-color: var(--accent);
        background: var(--accent-soft);
        color: var(--accent-dark);
    }

    /* Горизонтальный свайп по колонкам со снапом; табы — быстрый переход. */
    .kanban-board {
        display: flex;
        overflow-x: auto;
        gap: 12px;
        margin: 0 -16px;
        padding: 0 16px 8px;
        scroll-snap-type: x mandatory;
        scroll-padding: 0 16px;
        -webkit-overflow-scrolling: touch;
    }

    .kanban-column {
        flex: 0 0 86%;
        scroll-snap-align: center;
    }

    .kanban-column-body {
        min-height: 260px;
    }

    .case-attention-header {
        display: grid;
    }

    .case-attention-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   UX/UI enhancements: toasts, loading bar, breadcrumbs,
   pagination, sortable headers, global search, combobox,
   rich empty states, search results, kanban polish.
   ============================================================ */

/* --- Loading bar (top progress indicator) --- */
.loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 80;
    width: 0;
    height: 3px;
    background: var(--accent);
    opacity: 0;
    pointer-events: none;
}

.loading-bar.is-active {
    width: 82%;
    opacity: 1;
    transition: width 8s cubic-bezier(0.1, 0.7, 0.1, 1), opacity 0.2s ease;
}

.loading-bar.is-done {
    width: 100%;
    opacity: 0;
    transition: width 0.2s ease, opacity 0.3s ease 0.1s;
}

/* --- Toast notifications --- */
.toast-stack {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 60;
    display: grid;
    gap: 10px;
    width: min(360px, calc(100vw - 32px));
    margin: 0;
}

.toast {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    justify-content: space-between;
    opacity: 0;
    transform: translateX(18px);
    box-shadow: 0 12px 32px rgba(23, 32, 51, 0.16);
    transition: transform 0.26s ease, opacity 0.26s ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.toast.is-leaving {
    opacity: 0;
    transform: translateX(18px);
}

.toast-text {
    font-size: 14px;
    line-height: 1.4;
}

.toast-close {
    flex: 0 0 auto;
    border: 0;
    padding: 0 2px;
    background: transparent;
    color: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
}

.toast-close:hover {
    opacity: 1;
}

.message.error,
.message.danger {
    border-color: #f2b8b5;
    background: var(--danger-bg);
    color: var(--danger);
}

/* --- Breadcrumbs --- */
.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin: 0 0 18px;
    font-size: 13px;
    color: var(--muted);
}

.breadcrumbs > * {
    display: inline-flex;
    align-items: center;
}

.breadcrumbs > * + *::before {
    content: "›";
    margin: 0 8px;
    color: var(--control-border);
}

.breadcrumbs a {
    color: var(--muted);
    font-weight: 700;
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--accent);
}

.breadcrumbs [aria-current="page"] {
    color: var(--text);
    font-weight: 700;
}

/* --- Employee dashboard --- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 18px;
    background: var(--surface);
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
    border-color: var(--accent);
    box-shadow: 0 6px 18px rgba(23, 32, 51, 0.08);
}

.stat-card.is-danger {
    border-color: var(--danger);
    background: var(--danger-bg);
}

.stat-card.is-warning {
    border-color: #b76e00;
    background: #fff8eb;
}

.stat-value {
    color: var(--text);
    font-size: 28px;
    font-weight: 800;
    line-height: 1.1;
}

.stat-label {
    color: var(--muted);
    font-size: 13px;
}

.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    align-items: start;
}

.dash-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 18px;
    background: var(--surface);
}

.dash-card-head {
    display: flex;
    gap: 12px;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 10px;
}

.dash-card-head h2 {
    margin: 0;
    font-size: 16px;
}

.dash-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    border-bottom: 1px solid var(--border);
    padding: 9px 2px;
    text-decoration: none;
}

.dash-item:last-child {
    border-bottom: 0;
}

.dash-item:hover .dash-item-title {
    color: var(--accent);
}

.dash-item-title {
    color: var(--text);
    font-weight: 700;
}

.dash-item-meta {
    color: var(--muted);
    font-size: 13px;
}

/* --- Bulk action bar --- */
.bulk-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 10px 14px;
    background: var(--accent-soft, #eef4fb);
}

.bulk-bar[hidden] {
    display: none;
}

.bulk-bar-count {
    color: var(--text);
    font-size: 14px;
}

.bulk-bar .form-control {
    width: auto;
    min-width: 200px;
}

.check-cell {
    width: 40px;
}

.check-cell input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-top: 18px;
}

.pagination-info {
    color: var(--muted);
    font-size: 13px;
}

.pagination-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pagination-link {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 14px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.pagination-link:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.pagination-link.is-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.pagination-controls .pagination-link {
    min-width: 36px;
    justify-content: center;
    padding: 7px 10px;
}

.pagination-link.is-current {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    cursor: default;
}

.pagination-ellipsis {
    align-self: center;
    padding: 0 2px;
    color: var(--muted);
    font-weight: 700;
}

.pagination-size {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
}

.pagination-size .pagination-link {
    min-height: 30px;
    padding: 4px 9px;
    font-size: 13px;
}

/* --- Sortable column headers (server-side) --- */
.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: inherit;
    font: inherit;
    text-transform: inherit;
    text-decoration: none;
}

.sort-link:hover {
    color: var(--accent-dark);
}

.sort-link::after {
    content: "";
    width: 0;
    height: 0;
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
    border-top: 5px solid currentColor;
    opacity: 0.25;
}

.sort-link.is-active.is-asc::after {
    border-top: 0;
    border-bottom: 5px solid currentColor;
    opacity: 0.85;
}

.sort-link.is-active.is-desc::after {
    opacity: 0.85;
}

/* --- Global search (sidebar) --- */
.global-search {
    margin: 0 0 18px;
}

.global-search-input {
    min-height: 40px;
    font-size: 14px;
}

.search-groups {
    display: grid;
    gap: 16px;
}

.search-group h2 {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-group-count {
    display: inline-flex;
    min-width: 26px;
    height: 24px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 12px;
    font-weight: 700;
}

.search-result-list {
    display: grid;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.search-result {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    align-items: baseline;
    border-radius: 6px;
    padding: 8px 10px;
    text-decoration: none;
}

.search-result:hover {
    background: var(--accent-soft);
}

.search-result-title {
    color: var(--text);
    font-weight: 700;
}

.search-result-meta {
    color: var(--muted);
    font-size: 13px;
}

/* --- Searchable select (combobox) --- */
.combo {
    position: relative;
    display: block;
}

.combo-native {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.combo-input::after {
    content: "";
}

.combo-list {
    position: absolute;
    z-index: 25;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    display: grid;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 14px 30px rgba(23, 32, 51, 0.14);
}

.combo-list[hidden] {
    display: none;
}

.combo-option {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 14px;
    line-height: 1.35;
    cursor: pointer;
}

.combo-option:last-child {
    border-bottom: 0;
}

.combo-option.is-selected {
    font-weight: 700;
}

.combo-option:hover,
.combo-option.is-active {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.combo-empty {
    padding: 10px 12px;
    color: var(--muted);
    font-size: 13px;
}

/* --- Rich empty states --- */
.empty-state-rich {
    display: grid;
    gap: 10px;
    justify-items: center;
    padding: 48px 18px;
}

.empty-state-icon {
    font-size: 40px;
    line-height: 1;
}

.empty-state-title {
    margin: 0;
    color: var(--text);
    font-size: 17px;
    font-weight: 700;
}

.empty-state-text {
    max-width: 440px;
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.empty-state-rich .button {
    margin-top: 6px;
}

/* --- Kanban: saving spinner --- */
.task-card.is-saving {
    position: relative;
    opacity: 0.7;
}

.task-card.is-saving::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 16px;
    height: 16px;
    border: 2px solid var(--accent-soft);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: crm-spin 0.7s linear infinite;
}

@keyframes crm-spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Mobile: hide the global search when the sidebar is collapsed --- */
@media (max-width: 980px) {
    .sidebar:not(.is-open) .global-search {
        display: none;
    }
}

/* --- Mobile kanban: horizontal scroll with snap instead of one-column tabs --- */
@media (max-width: 720px) {
    .board-column-tabs {
        display: none;
    }

    .kanban-board {
        grid-template-columns: repeat(4, minmax(82vw, 1fr));
        overflow-x: auto;
        scroll-snap-type: x mandatory;
    }

    .kanban-column,
    .kanban-column.is-active {
        display: block;
        scroll-snap-align: start;
    }
}

/* ============================================================
   Visual refresh: softer surfaces, smoother interactions,
   accessible focus, tabular numerals, reduced-motion support.
   ============================================================ */

/* Softer cards: light shadow, gentler borders, larger radii */
.form-section,
.status-item,
.kanban-column {
    border-color: var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.table-wrap {
    border-color: var(--border-soft);
    border-radius: var(--radius-lg);
}

.modal {
    border-radius: var(--radius-lg);
}

.message,
.toast,
.case-attention,
.activity-item,
.file-item,
.task-card,
.document-compact-item,
.case-block-item {
    border-radius: var(--radius-md);
}

/* Lighter table grid lines */
th,
td {
    border-bottom-color: var(--border-soft);
}

/* Tabular numerals so INN / amounts / counts align in columns */
td,
.status-value,
.kanban-count,
.client-summary-number {
    font-variant-numeric: tabular-nums;
}

/* Inputs and buttons: slightly rounder, smooth transitions */
.form-control {
    border-radius: var(--radius-sm);
    transition: border-color var(--ease), box-shadow var(--ease);
}

.button {
    border-radius: var(--radius-sm);
}

.button,
.nav-link,
.table-action,
.filter-chip,
.pagination-link,
.sort-link,
.combo-option,
.task-card,
.status-pill,
a {
    transition: background-color var(--ease), border-color var(--ease),
        color var(--ease), box-shadow var(--ease), transform var(--ease);
}

.button:active {
    transform: translateY(1px);
}

.task-card:hover {
    box-shadow: var(--shadow-md);
}

/* Visible keyboard focus on interactive elements (inputs keep their ring) */
a:focus-visible,
button:focus-visible,
.nav-link:focus-visible,
.sort-link:focus-visible,
.filter-chip:focus-visible,
.pagination-link:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Respect users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================
   Universal file/scan preview lightbox + attachment list layout.
   ============================================================ */

.file-main {
    min-width: 0;
}

.file-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.file-name {
    cursor: pointer;
    overflow-wrap: anywhere;
}

.file-preview {
    width: min(960px, calc(100vw - 32px));
    max-width: 960px;
    max-height: calc(100vh - 40px);
    border: 0;
    border-radius: var(--radius-lg);
    padding: 0;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 22px 60px rgba(23, 32, 51, 0.32);
}

.file-preview::backdrop {
    background: rgba(23, 32, 51, 0.62);
}

.file-preview-head {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.file-preview-name {
    min-width: 0;
    font-size: 15px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.file-preview-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
    align-items: center;
}

.file-preview-body {
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: calc(100vh - 140px);
    padding: 14px;
    overflow: auto;
    background: #f8fafc;
}

.file-preview-body .file-render-image {
    max-width: 100%;
    max-height: calc(100vh - 180px);
    border-radius: var(--radius-sm);
}

.file-preview-body .file-render-frame {
    width: 100%;
    height: calc(100vh - 180px);
    border: 0;
    border-radius: var(--radius-sm);
    background: #ffffff;
}

.file-render-note {
    margin: 0;
    padding: 40px 16px;
    color: var(--muted);
    text-align: center;
}

/* --- Inline master–detail file panel --- */
.file-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 1fr);
    gap: 16px;
    align-items: start;
}

.file-panel .file-list {
    margin: 0;
}

.file-pick {
    display: grid;
    gap: 4px;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.file-pick .file-name {
    color: var(--text);
    font-weight: 700;
}

.file-pick:hover .file-name,
.file-pick.is-active .file-name {
    color: var(--accent-dark);
}

.file-item:has(.file-pick.is-active) {
    border-color: var(--accent);
    box-shadow: inset 3px 0 0 var(--accent);
}

.file-pane {
    position: sticky;
    top: 16px;
    overflow: hidden;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.file-pane-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.file-pane-name {
    min-width: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.file-pane-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    max-height: 440px;
    padding: 12px;
    overflow: auto;
    background: #f8fafc;
}

.file-pane-body .file-render-image {
    max-width: 100%;
    max-height: 416px;
    border-radius: var(--radius-sm);
}

.file-pane-body .file-render-frame {
    width: 100%;
    height: 416px;
    border: 0;
    border-radius: var(--radius-sm);
    background: #ffffff;
}

@media (max-width: 860px) {
    .file-panel {
        grid-template-columns: 1fr;
    }

    .file-pane {
        position: static;
    }
}

/* ============================================================
   Right slide-out drawer (used for the Files block).
   ============================================================ */

.drawer-toggle-fixed {
    position: fixed;
    top: 14px;
    right: 16px;
    z-index: 55;
    box-shadow: var(--shadow-md);
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 58;
    background: rgba(23, 32, 51, 0.48);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.26s ease, visibility 0.26s ease;
}

.drawer-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

body {
    --drawer-w: min(520px, calc(100vw - 24px));
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 59;
    display: flex;
    flex-direction: column;
    width: var(--drawer-w);
    height: 100vh;
    background: var(--surface);
    box-shadow: none;
    transform: translateX(100%);
    transition: transform 0.28s ease, box-shadow 0.28s ease;
}

.drawer.is-open {
    transform: translateX(0);
    box-shadow: -16px 0 44px rgba(23, 32, 51, 0.26);
}

.drawer-head {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.drawer-head h2 {
    margin: 0;
    font-size: 18px;
}

.drawer-body {
    flex: 1;
    padding: 18px;
    overflow: auto;
}

/* In the narrow drawer the file panel stacks (list above preview). */
.drawer .file-panel {
    grid-template-columns: 1fr;
}

.drawer .file-pane {
    position: static;
}

/* Open drawer is non-modal: the main form stays editable. The sidebar
   collapses and the whole shell is physically narrowed to the space left of the
   drawer, so the content reflows into it and nothing hides under the drawer. */
.app-shell {
    transition: width 0.28s ease;
}

body.drawer-open .app-shell {
    width: calc(100vw - var(--drawer-w));
    grid-template-columns: 1fr;
    overflow-x: hidden;
}

body.drawer-open .sidebar {
    display: none;
}

body.drawer-open .drawer-toggle-fixed {
    display: none;
}

@media (max-width: 600px) {
    .drawer {
        width: 100vw;
    }

    /* No room beside a full-width drawer on phones — let it cover the screen. */
    body.drawer-open .app-shell {
        width: auto;
    }
}

/* ============================================================
   Compact desktop density — tighter controls, spacing and type.
   (Overrides the touch-sized defaults above.)
   ============================================================ */

/* Все однострочные контролы — строго одной высоты (текст, date, select),
   иначе поля в одном ряду «пляшут». Многострочные — исключения ниже. */
.form-control {
    height: 38px;
    min-height: 38px;
    padding: 0 11px;
    font-size: 14px;
}

textarea.form-control,
select.form-control[multiple] {
    height: auto;
    min-height: 84px;
    padding: 8px 11px;
}

.form-control[type="checkbox"],
.form-control[type="radio"] {
    width: 16px;
    height: 16px;
    min-height: 0;
    padding: 0;
    accent-color: var(--accent);
}

.combo-input,
.global-search-input {
    min-height: 38px;
}

.button {
    min-height: 34px;
    padding: 7px 14px;
    font-size: 14px;
}

.button-small {
    min-height: 28px;
    padding: 4px 9px;
    font-size: 13px;
}

label,
.quick-choice-field legend {
    font-size: 13px;
    font-weight: 600;
}

/* Легенда не участвует в grid-gap поля — отступ задаём вручную, в размер gap. */
.quick-choice-field legend {
    margin-bottom: 6px;
}

.quick-choice-option span {
    min-height: 38px;
    font-size: 14px;
    font-weight: 600;
}

.checkbox-input {
    width: 16px;
    height: 16px;
}

h1 {
    font-size: 24px;
}

h2 {
    margin-bottom: 14px;
    font-size: 17px;
}

.subtitle {
    font-size: 14px;
}

.main-panel {
    padding: 22px 26px 28px;
}

.page-header {
    margin-bottom: 18px;
}

.nav-link {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 14px;
}

.sidebar {
    padding: 20px 14px;
}

.form,
.details-form {
    gap: 14px;
}

.form-grid {
    gap: 12px 16px;
}

.field {
    gap: 6px;
}

.form-section {
    padding: 18px 20px 20px;
}

/* Заголовок секции формы отделяем линией — длинная форма читается по блокам. */
.form-section > h2,
.form-section > .section-heading-row {
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-soft);
}

.details-form h3 {
    margin: 6px 0 0;
    font-size: 15px;
}

th,
td {
    padding: 9px 12px;
}

.status-item {
    min-height: auto;
    padding: 14px;
}

.status-value {
    font-size: 17px;
}

.status-grid {
    gap: 10px;
}

.section-tab {
    min-height: 32px;
    padding: 6px 12px;
}

.task-card {
    gap: 8px;
    padding: 10px;
}

.kanban-column-body {
    min-height: 280px;
    padding: 10px;
}

.kanban-column-header {
    padding: 10px 12px;
}

/* Second drawer toggle (activity) sits below the files toggle. */
.drawer-toggle--stacked {
    top: 56px;
}

/* Activity log now lives in a drawer — drop its in-flow sidebar layout and the
   inner card chrome / duplicate heading. */
.activity-layout {
    display: block;
}

.drawer .activity-log-section {
    border: 0;
    padding: 0;
    box-shadow: none;
}

.drawer .activity-log-section h2 {
    display: none;
}

/* Compact attachment rows in the Files drawer — free up height for the preview. */
.file-list {
    gap: 6px;
}

.file-item {
    align-items: center;
    gap: 8px;
    padding: 6px 9px;
}

.file-pick {
    min-width: 0;
    gap: 1px;
}

.file-pick .file-name {
    overflow: hidden;
    font-size: 13px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-pick .file-meta {
    overflow: hidden;
    margin-top: 0;
    font-size: 11px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-actions .button {
    min-height: 26px;
    padding: 3px 8px;
    font-size: 12px;
}

/* Inline action next to a field label (e.g. "Совпадает с юридическим"). */
.field-label-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: center;
    justify-content: space-between;
}

.field-label-row label {
    margin: 0;
}

/* --- Print menu (документы с карточек) --- */
.print-menu {
    position: relative;
    display: inline-block;
}

.print-menu > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.print-menu > summary::-webkit-details-marker {
    display: none;
}

.print-menu-list {
    position: absolute;
    left: 0;
    top: calc(100% + 6px);
    z-index: 30;
    min-width: 240px;
    max-width: calc(100vw - 32px);
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.print-menu-item {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.92rem;
}

.print-menu-item:hover {
    background: var(--surface-muted);
}

.print-menu-versions {
    margin: 0 4px 4px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.84rem;
}

.print-menu-versions summary {
    padding: 8px 6px 5px;
    cursor: pointer;
    user-select: none;
}

.print-menu-version-list {
    display: grid;
    gap: 2px;
    padding-bottom: 4px;
}

.print-menu-version-list .print-menu-item {
    padding-left: 16px;
    font-size: 0.88rem;
}

/* --- Дедлайны в таблицах --- */
.due-pill {
    display: inline-block;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.due-pill.is-overdue {
    background: var(--danger-bg);
    color: var(--danger);
}

.due-pill.is-today {
    background: #fff3cd;
    color: #6b4400;
}

.due-pill.is-soon {
    background: #fff9e8;
    color: #6b4400;
}

/* --- Ошибки строк formset --- */
.formset-error-row td {
    padding-top: 6px;
    padding-bottom: 0;
    border-bottom: 0;
}

.formset-error-row .error-list {
    margin: 0 0 6px;
    border-left: 3px solid var(--danger);
}

@media (max-width: 720px) {
    table[data-sortable-table] .formset-error-row,
    .contact-form-table .formset-error-row td[colspan] {
        display: block;
        width: 100%;
        border: 0;
        padding: 8px 10px 0;
    }
}

/* --- Ограничение ширины полей на широких карточках --- */
.form-shell-with-sidebar .form-grid {
    max-width: 960px;
}

/* --- Оглавление длинной формы --- */
.form-toc {
    position: sticky;
    top: 0;
    z-index: 14;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 -2px 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(8px);
}

.form-toc:empty {
    display: none;
}

.form-toc-link {
    display: inline-block;
    border-radius: 999px;
    padding: 5px 12px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.form-toc-link:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.form-toc-link.is-active {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

/* --- Кнопка в состоянии отправки --- */
.button.is-loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}

.button.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: button-spin 0.7s linear infinite;
}

.button-secondary.is-loading::after {
    border-color: rgba(29, 95, 167, 0.3);
    border-top-color: var(--accent);
}

@keyframes button-spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Скелетоны при навигации по спискам --- */
.skeleton-line {
    display: block;
    height: 14px;
    border-radius: 6px;
    background: linear-gradient(
        90deg,
        var(--surface-muted) 25%,
        var(--border-soft) 40%,
        var(--surface-muted) 55%
    );
    background-size: 300% 100%;
    animation: skeleton-shimmer 1.1s ease-in-out infinite;
}

.skeleton-line + .skeleton-line {
    margin-top: 8px;
}

@keyframes skeleton-shimmer {
    from {
        background-position: 100% 0;
    }
    to {
        background-position: 0 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .skeleton-line,
    .button.is-loading::after {
        animation-duration: 2.5s;
    }
}

/* --- Sticky «Сохранить» на мобильных --- */
@media (max-width: 980px) {
    .details-form[data-unsaved-guard] > .form-actions {
        position: sticky;
        bottom: 0;
        margin: 0 -8px;
        padding: 10px max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-bottom));
    }
}
