:root {
    --bg: #f5f8fc;
    --surface: #ffffff;
    --surface-muted: #f9fbff;
    --sidebar: #ffffff;
    --text: #12305c;
    --muted: #6a7891;
    --border: #dbe4f0;
    --brand: #13386a;
    --brand-dark: #0f2b50;
    --accent: #f5b61c;
    --accent-dark: #df9f08;
    --danger: #eb5757;
    --shadow: 0 12px 30px rgba(19, 48, 92, 0.08);
}

html {
    font-size: 12px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    line-height: 1.4;
    background:
        radial-gradient(circle at top left, rgba(245, 182, 28, 0.16), transparent 22%),
        linear-gradient(180deg, #f8fbff 0%, #edf3fb 100%);
    color: var(--text);
}

.legal-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(245, 182, 28, 0.18), transparent 20%),
        linear-gradient(180deg, #f7fbff 0%, #edf3fb 100%);
}

a {
    color: var(--brand);
    text-decoration: none;
}

.page-head,
.actions,
.filter-actions,
.sidebar-top,
.sidebar-brand,
.sidebar-link,
.topbar,
.user-chip,
.row-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-head {
    justify-content: space-between;
}

.auth-card,
.form-card,
.detail-card,
.panel,
.empty-state {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.auth-card,
.form-card {
    width: min(560px, 100%);
    margin: 2rem auto 0;
    padding: 2rem;
}

.detail-card {
    padding: 2rem;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 278px minmax(0, 1fr);
    transition: grid-template-columns 0.22s ease;
    position: relative;
}

.sidebar {
    background: rgba(255, 255, 255, 0.92);
    border-right: 1px solid var(--border);
    padding: 20px 10px 20px 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    transition: padding 0.22s ease;
}

.sidebar-backdrop {
    display: none;
}

.sidebar-top {
    justify-content: space-between;
    padding: 0 22px 24px 12px;
}

.sidebar-brand {
    font-size: 1.05rem;
    color: var(--brand);
    font-weight: 600;
}

.sidebar-brand-label,
.sidebar-link-label {
    white-space: nowrap;
    transition: opacity 0.18s ease;
}

.brand-mark,
.user-chip-mark {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand);
    color: white;
    font-weight: 700;
}

.sidebar-toggle {
    appearance: none;
    border: 0;
    padding: 0;
    background: transparent;
    width: 28px;
    height: 28px;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.18s ease, transform 0.18s ease;
}

.sidebar-toggle:hover {
    color: var(--brand);
}

.sidebar-toggle svg,
.sidebar-link svg {
    width: 100%;
    height: 100%;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
    align-content: start;
}

.sidebar-link {
    margin-right: 12px;
    padding: 14px 16px;
    border-radius: 0 14px 14px 0;
    color: var(--muted);
    font-weight: 500;
    border-left: 3px solid transparent;
}

.sidebar-link svg {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    overflow: visible;
}

.sidebar-link.active {
    background: #ffffff;
    border-left-color: var(--accent);
    color: var(--brand);
    box-shadow: 0 6px 20px rgba(19, 48, 92, 0.08);
}

.sidebar-logout-form {
    margin-top: auto;
    padding-top: 16px;
}

.sidebar-logout {
    width: calc(100% - 12px);
    appearance: none;
    border: 0;
    border-left: 3px solid transparent;
    background: transparent;
    font: inherit;
    text-align: left;
    justify-content: flex-start;
    cursor: pointer;
}

.sidebar-logout:hover,
.sidebar-logout:focus-visible {
    background: #ffffff;
    color: var(--brand);
}

.sidebar-collapsed {
    grid-template-columns: 92px minmax(0, 1fr);
}

.sidebar-collapsed .sidebar {
    padding-right: 8px;
}

.sidebar-collapsed .sidebar-top {
    position: relative;
    padding-right: 0;
}

.sidebar-collapsed .sidebar-brand {
    gap: 0;
}

.sidebar-collapsed .sidebar-brand-label,
.sidebar-collapsed .sidebar-link-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    pointer-events: none;
}

.sidebar-collapsed .sidebar-toggle {
    position: absolute;
    right: 0;
    transform: rotate(180deg);
}

.sidebar-collapsed .sidebar-link {
    justify-content: center;
    margin-right: 10px;
    padding-left: 12px;
    padding-right: 12px;
}

.app-main {
    padding: 20px 20px 32px;
}

.topbar {
    justify-content: space-between;
    min-height: 54px;
    padding: 0 12px 12px;
    border-bottom: 1px solid var(--border);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.topbar-spacer {
    flex: 1;
}

.mobile-menu-toggle {
    display: none;
    appearance: none;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.94);
    color: var(--brand);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.mobile-menu-toggle svg {
    width: 20px;
    height: 20px;
}

.user-chip {
    padding: 6px 12px 6px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
}

.user-chip-mark {
    width: 34px;
    height: 34px;
    background: #f3f7fd;
    color: var(--brand);
    border: 1px solid var(--border);
}

.app-content {
    padding-top: 20px;
}

.dashboard-head {
    margin-bottom: 16px;
}

.page-head h1,
.panel-header h2,
.placeholder-body h2 {
    margin: 0;
    font-size: 1.15rem;
}

.page-head-tight {
    justify-content: flex-start;
}

.panel {
    padding: 18px 20px;
    margin-bottom: 16px;
}

.summary-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 20px;
}

.summary-metric {
    display: flex;
    align-items: center;
    font-size: 1rem;
}

.summary-copy strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.summary-copy p {
    margin: 0;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
    gap: 10px;
    align-items: end;
}

.filters-grid label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

.filter-actions {
    gap: 10px;
}

.users-summary-panel {
    grid-template-columns: minmax(220px, 1fr) minmax(0, 3fr);
}

.users-filters-grid {
    grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
}

.logs-summary-panel {
    grid-template-columns: minmax(220px, 1fr) minmax(0, 3fr);
}

.logs-filters-grid {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.roles-summary-panel {
    padding: 0;
    border: none;
    box-shadow: none;
    background: transparent;
}

.roles-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.role-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 20px;
}

.role-card h2 {
    margin: 0 0 12px;
    color: var(--brand);
    font-size: 1.05rem;
}

.role-card p {
    margin: 0;
    line-height: 1.6;
}

.role-card p + p {
    margin-top: 12px;
}

.table-panel {
    padding: 0;
    overflow: hidden;
}

.case-list-empty-state {
    padding: 24px 20px 28px;
    border-radius: 0;
}

.case-list-empty-state h2 {
    margin: 0 0 16px;
}

.case-list-empty-state p {
    margin: 0;
}

.panel-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.cases-table-wrapper {
    overflow-x: auto;
}

.cases-table {
    width: 100%;
    border-collapse: collapse;
}

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

.cases-table th {
    text-transform: uppercase;
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 700;
}

.cases-table tbody tr:last-child td {
    border-bottom: none;
}

.case-link {
    color: var(--brand);
    font-weight: 700;
    text-transform: uppercase;
}

.description-cell {
    min-width: 240px;
    color: var(--muted);
}

.logs-table td:nth-child(1) {
    min-width: 190px;
}

.logs-table td:nth-child(2) {
    min-width: 190px;
}

.logs-table td:nth-child(4) {
    min-width: 360px;
}

.assignee-list {
    display: grid;
    gap: 8px;
    min-width: 240px;
}

.cases-summary-panel {
    grid-template-columns: minmax(140px, 1fr) minmax(0, 3fr);
}

.cases-filters-grid {
    grid-template-columns: repeat(3, minmax(170px, 1fr)) auto;
}

.filter-button,
.case-action-button,
.delete-case-button,
.case-modal-submit,
.create-user-from-modal {
    gap: 8px;
    white-space: nowrap;
}

.filter-button svg,
.case-action-button svg,
.delete-case-button svg,
.case-modal-submit svg,
.create-user-from-modal svg {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.case-list-table {
    min-width: 1120px;
}

.case-list-table th,
.case-list-table td {
    vertical-align: middle;
}

.case-list-table th:nth-child(1) { width: 18%; }
.case-list-table th:nth-child(2) { width: 12%; }
.case-list-table th:nth-child(3) { width: 14%; text-align: center; }
.case-list-table th:nth-child(4) { width: 28%; }
.case-list-table th:nth-child(5) { width: 20%; }
.case-list-table th:nth-child(6) { width: 8%; }

.case-link {
    text-transform: none;
}

.case-checklist-summary {
    display: grid;
    justify-items: center;
    gap: 4px;
    color: var(--muted);
    white-space: nowrap;
}

.case-checklist-summary progress {
    appearance: none;
    width: 78px;
    height: 7px;
    overflow: hidden;
    border: 0;
    border-radius: 999px;
    background: #dfe8f4;
}

.case-checklist-summary progress::-webkit-progress-bar {
    background: #dfe8f4;
    border-radius: 999px;
}

.case-checklist-summary progress::-webkit-progress-value {
    background: var(--accent);
    border-radius: 999px;
}

.case-checklist-summary progress::-moz-progress-bar {
    background: var(--accent);
    border-radius: 999px;
}

.case-checklist-summary strong {
    color: var(--text);
    font-size: 1rem;
}

.case-checklist-summary span {
    font-size: 0.82rem;
}

.delete-case-button {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
}

.case-modal {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    color: var(--text);
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 24px 70px rgba(19, 48, 92, 0.24);
}

.case-modal::backdrop {
    background: rgba(19, 33, 54, 0.36);
    backdrop-filter: blur(2px);
}

.case-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}

.case-modal-header h2,
.case-modal-header p {
    margin: 0;
}

.case-modal-header p {
    margin-top: 4px;
}

.case-modal-close {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    font-size: 30px;
    font-weight: 300;
    line-height: 1;
}

.case-modal-close:hover {
    background: #f3f7fd;
    color: var(--brand);
    transform: none;
}

.case-modal-body {
    display: grid;
    gap: 12px;
    padding: 20px 22px 22px;
}

.case-modal-body label {
    color: var(--muted);
    font-weight: 600;
}

.case-modal-body select {
    width: 100%;
}

.user-create-modal {
    width: min(760px, calc(100vw - 32px));
    overflow: hidden;
}

.user-create-modal-form {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 50px);
}

.user-create-modal .case-modal-body {
    overflow-y: auto;
}

.user-create-modal-actions {
    margin-top: 4px;
}

.checklist-access-modal {
    width: min(620px, calc(100vw - 32px));
}

.checklist-access-modal .case-modal-header p {
    color: var(--muted);
    font-size: 0.92rem;
}

.checklist-access-form fieldset {
    display: grid;
    gap: 9px;
    margin: 0;
    padding: 0;
    border: 0;
}

.checklist-access-form legend {
    margin-bottom: 3px;
    color: var(--text);
    font-weight: 700;
}

.checklist-access-form fieldset label {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    font-weight: 500;
}

.checklist-access-form input[type="checkbox"],
.checklist-access-form input[type="radio"] {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--accent);
}

.checklist-access-form input:disabled + span {
    color: var(--muted);
}

.checklist-access-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 5px;
}

.assignee-picker {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.assignee-picker-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.assignee-picker-chips:empty {
    display: none;
}

.assignee-picker-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 6px 8px 6px 12px;
    color: var(--brand-dark);
    background: #eaf2ff;
    border: 1px solid #c8dcf8;
    border-radius: 999px;
    font-size: 0.9rem;
}

.assignee-picker-chip > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.assignee-picker-chip-remove {
    width: 26px;
    height: 26px;
    padding: 0;
    flex: 0 0 auto;
    color: var(--brand);
    background: transparent;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
}

.assignee-picker-chip-remove:hover,
.assignee-picker-chip-remove:focus-visible {
    color: white;
    background: var(--brand);
    transform: none;
}

.assignee-picker-results {
    max-height: 240px;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 14px 32px rgba(19, 48, 92, 0.12);
}

.assignee-picker-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 11px 12px;
    color: var(--text);
    background: white;
    border: 0;
    border-bottom: 1px solid #edf2f8;
    border-radius: 0;
    text-align: left;
}

.assignee-picker-option:last-child {
    border-bottom: 0;
}

.assignee-picker-option:hover,
.assignee-picker-option.is-active {
    color: var(--text);
    background: #f1f6fd;
    transform: none;
}

.assignee-picker-option.is-selected,
.assignee-picker-option.is-assigned {
    color: var(--muted);
    background: #f7f9fc;
    cursor: default;
    opacity: 1;
}

.assignee-picker-option-identity {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.assignee-picker-option-identity strong,
.assignee-picker-option-identity span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.assignee-picker-option-identity span,
.assignee-picker-option-state,
.assignee-picker-status,
.assignee-picker-empty {
    color: var(--muted);
    font-size: 0.86rem;
}

.assignee-picker-option-state {
    flex: 0 0 auto;
}

.assignee-picker-status,
.assignee-picker-empty {
    margin: 0;
}

.assignee-picker-empty {
    padding: 18px 14px;
    text-align: center;
}

.case-modal-submit:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.case-modal-submit,
.create-user-from-modal {
    width: 100%;
}

.create-user-from-modal {
    margin-top: 6px;
}

.delete-case-modal {
    width: min(500px, calc(100vw - 32px));
}

.delete-case-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}

.small-button {
    padding: 0.7rem 1rem;
    font-size: 0.92rem;
}

.placeholder-panel {
    min-height: 320px;
    display: grid;
    place-items: center;
}

.placeholder-body {
    text-align: center;
    max-width: 520px;
}

.form-panel {
    max-width: 920px;
}

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

.form-grid label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

.full-width-field {
    grid-column: 1 / -1;
}

.field-help,
.field-error {
    margin: 8px 0 0;
    font-size: 0.88rem;
}

.field-help {
    color: var(--muted);
}

.field-error {
    color: var(--danger);
}

.stack > * + * {
    margin-top: 1rem;
}

input,
textarea,
select,
button {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 0.85rem 1rem;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    background: white;
}

button,
.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: auto;
    background: var(--brand);
    color: white;
    border: none;
    cursor: pointer;
    padding: 0.85rem 1.2rem;
    border-radius: 14px;
    transition: transform 0.15s ease, background 0.15s ease;
}

button:hover,
.button:hover {
    background: var(--brand-dark);
    transform: translateY(-1px);
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
    background: transparent;
}

.sidebar-toggle:hover {
    transform: none;
}

.sidebar-collapsed .sidebar-toggle:hover {
    transform: rotate(180deg);
}

.secondary {
    background: transparent;
    color: var(--brand);
    border: 1px solid var(--brand);
}

.accent-button {
    background: var(--accent);
    color: #172b4d;
    font-weight: 700;
}

.accent-button:hover {
    background: var(--accent-dark);
}

.button.outline-danger-button {
    background: white;
    color: var(--brand);
    border: 2px solid rgba(18, 48, 92, 0.35);
    box-shadow: none;
}

.button.outline-danger-button:hover {
    background: #f8fbff;
}

.button.ghost-button {
    background: #fff3f2;
    color: var(--danger);
}

.button.ghost-button:hover {
    background: #ffe7e5;
}

.button-icon {
    font-size: 19px;
    line-height: 1;
}

.link-button {
    background: none;
    color: var(--brand);
    padding: 0;
    border: none;
}

.muted {
    color: var(--muted);
}

.badge {
    display: inline-flex;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-new {
    background: #e8f0fe;
    color: #21446d;
}

.badge-in_progress {
    background: #e8f0fe;
    color: #21446d;
}

.badge-closed {
    background: #e8f6ee;
    color: #2f7d45;
}

.badge-client {
    background: #e8f0fe;
    color: #21446d;
}

.badge-expert {
    background: #e9f6ef;
    color: #2c6b48;
}

.badge-document_specialist {
    background: #eef4ff;
    color: #1d4c82;
}

.badge-administrator {
    background: #fff1cf;
    color: #916300;
}

.badge-call_center {
    background: #fce9f2;
    color: #9a3462;
}

.badge-active {
    background: #e8f6ee;
    color: #2f7d45;
}

.badge-inactive {
    background: #f1f3f5;
    color: #5b6573;
}

.demo-box {
    background: #fff7e1;
    border: 1px solid #f5d272;
    border-radius: 16px;
    padding: 1rem;
}

.toast-container {
    position: fixed;
    right: 24px;
    bottom: calc(24px + env(safe-area-inset-bottom));
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(420px, calc(100vw - 48px));
    max-height: min(70vh, 560px);
    overflow-y: auto;
    padding: 4px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    padding: 14px 14px 14px 16px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 14px;
    box-shadow: 0 14px 36px rgba(19, 48, 92, 0.18);
    pointer-events: auto;
    overflow-wrap: anywhere;
    animation: toast-in 180ms ease-out both;
}

.toast-success { border-left-color: #3b9b68; }
.toast-info { border-left-color: var(--accent); }
.toast-warning { border-left-color: #d59626; }
.toast-error { border-left-color: #c95757; }

.toast-text {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.45;
}

.toast-close {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border-radius: 50%;
    font-size: 23px;
    font-weight: 300;
    line-height: 1;
}

.toast-close:hover,
.toast-close:focus-visible {
    color: var(--brand);
    background: #f3f7fd;
    transform: none;
}

.toast.is-closing {
    animation: toast-out 180ms ease-in forwards;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(8px); }
}

@media (max-width: 720px) {
    .toast-container {
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom));
        width: calc(100vw - 24px);
        max-height: 60vh;
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast,
    .toast.is-closing {
        animation: none;
    }
}

.auth-layout {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-messages {
    width: min(560px, 100%);
    margin: 0 auto 1rem;
}

.clear-link {
    color: var(--brand);
}

.inline-action-link {
    color: var(--brand);
    font-weight: 500;
}

.user-primary-name {
    color: #1f2f47;
    font-weight: 500;
}

.empty-inline-state {
    padding: 24px 0;
    text-align: center;
    color: var(--muted);
}

.log-badge {
    background: #e8f0fe;
    color: #5d6f8d;
    font-weight: 600;
}

.log-description {
    display: grid;
    gap: 8px;
}

.log-description small {
    color: var(--muted);
}

.roles-table td:not(:first-child),
.roles-table th:not(:first-child) {
    text-align: center;
}

.permission-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 700;
}

.permission-chip.allowed {
    background: #e9f6ef;
    color: #2c6b48;
}

.permission-chip.denied {
    background: #fff1f1;
    color: #b74848;
}

.settings-panel {
    padding: 0;
    overflow: hidden;
}

.settings-form {
    padding: 18px 20px;
}

.settings-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.settings-grid-top .full-width-field {
    grid-column: 1 / -1;
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 18px;
}

.settings-text {
    padding: 18px 20px 0;
    color: var(--muted);
}

.password-requirements {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    margin-top: 18px;
    padding: 12px 14px;
    color: var(--muted);
    background: #f3f7fd;
    border: 1px solid #dbe7f5;
    border-radius: 8px;
}

.password-requirements-icon {
    width: 22px;
    height: 22px;
    margin-top: 1px;
    color: #5d6f8d;
}

.password-requirements h3 {
    margin: 0;
    color: var(--text);
    font-size: 0.94rem;
}

.password-requirements-list ul {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px 24px;
    margin: 7px 0 0;
    padding: 0;
    list-style: none;
}

.password-requirements-list li {
    position: relative;
    padding-left: 14px;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.password-requirements-list li::before {
    content: "•";
    position: absolute;
    top: 0;
    left: 0;
    color: #7d8da5;
}

.settings-text p,
.settings-note {
    margin: 0;
}

.settings-note {
    padding-top: 16px;
    color: var(--muted);
}

.settings-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 28px;
    align-items: center;
}

.settings-links a {
    color: var(--brand);
    font-weight: 600;
}

.security-links-content {
    padding: 18px 20px 20px;
}

.security-links a {
    display: inline;
    max-width: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.security-links a:hover {
    color: var(--brand-dark);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.security-links a:focus-visible {
    outline: 3px solid rgba(49, 95, 158, 0.32);
    outline-offset: 4px;
}

.legal-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 16px;
}

.legal-card {
    width: min(980px, 100%);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: 0 18px 45px rgba(19, 48, 92, 0.12);
    padding: 24px;
}

.legal-topbar,
.legal-switcher {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.legal-topbar {
    margin-bottom: 24px;
}

.legal-backlink {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.legal-updated,
.legal-header p,
.legal-section p {
    color: var(--muted);
}

.legal-header {
    margin-bottom: 24px;
}

.legal-header h1 {
    margin: 8px 0 12px;
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    color: var(--brand);
}

.legal-kicker {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--brand);
}

.legal-switcher {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.legal-switcher-link {
    padding: 0.85rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #f8fbff;
    font-weight: 600;
}

.legal-switcher-link.is-active {
    background: var(--brand);
    color: white;
    border-color: var(--brand);
}

.legal-content {
    display: grid;
    gap: 20px;
}

.legal-section {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #ffffff;
}

.legal-section h2 {
    margin: 0 0 12px;
    color: var(--brand);
    font-size: 1.08rem;
}

.legal-section p {
    margin: 0;
    line-height: 1.65;
}

.legal-section p + p {
    margin-top: 12px;
}

.case-detail-shell {
    padding: 18px;
}

.case-hero,
.case-hero-left,
.case-tabs,
.case-hero-actions,
.checklist-item-header,
.checklist-item-controls,
.checklist-item-title-row,
.document-actions,
.checklist-add-action {
    display: flex;
    align-items: center;
    gap: 12px;
}

.case-hero,
.checklist-item-header {
    justify-content: space-between;
}

.case-hero {
    padding-bottom: 14px;
}

.case-hero h1 {
    margin: 0;
    font-size: 1.9rem;
    color: var(--brand);
}

.case-tabs {
    flex-wrap: wrap;
    gap: 10px;
}

.case-tab {
    flex: 1 1 150px;
    min-width: 150px;
    padding: 0.9rem 1.2rem;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: white;
    text-align: center;
    font-weight: 700;
    color: var(--muted);
}

.case-tab.active {
    background: linear-gradient(180deg, #315f9e 0%, #224b83 100%);
    color: white;
    border-color: #224b83;
}

.case-documents-panel {
    padding: 0;
}

.case-documents-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.case-users-panel {
    padding: 0;
}

.case-activity-panel {
    padding: 0;
}

.case-activity-header h2,
.case-activity-header p {
    margin: 0;
}

.case-activity-header p {
    margin-top: 6px;
}

.case-activity-list {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 8px 20px 20px;
    list-style: none;
}

.case-activity-entry {
    position: relative;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 14px;
    min-width: 0;
    padding: 10px 0;
}

.case-activity-entry:not(:last-child)::before {
    content: "";
    position: absolute;
    top: 42px;
    bottom: -10px;
    left: 16px;
    width: 2px;
    background: #d7e1ef;
}

.case-activity-marker {
    position: relative;
    z-index: 1;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 50%;
    background: #e8f0fe;
    color: var(--brand);
}

.case-activity-marker svg {
    width: 18px;
    height: 18px;
}

.case-activity-card {
    min-width: 0;
    padding: 14px 16px;
    border: 1px solid #d7e1ef;
    border-radius: 16px;
    background: #f8fbff;
}

.case-activity-card-header,
.case-activity-meta,
.case-activity-pagination-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 14px;
}

.case-activity-card-header {
    justify-content: space-between;
}

.case-activity-card time {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.case-activity-description {
    margin: 10px 0;
    overflow-wrap: anywhere;
    line-height: 1.5;
}

.case-activity-meta {
    color: var(--muted);
    font-size: 0.88rem;
}

.case-activity-meta span {
    overflow-wrap: anywhere;
}

.case-activity-pagination {
    padding: 0 20px 20px 68px;
}

.case-activity-pagination-links {
    justify-content: center;
}

.case-users-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.case-users-header h2,
.case-users-header p {
    margin: 0;
}

.case-users-header p {
    margin-top: 6px;
}

.case-users-list {
    display: grid;
    gap: 10px;
    padding: 14px;
}

.case-user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-width: 0;
    padding: 14px;
    border: 1px solid #d7e1ef;
    border-radius: 16px;
    background: #f8fbff;
}

.case-user-identity {
    display: grid;
    gap: 3px;
    min-width: 0;
}

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

.user-detail-grid > div {
    padding: 14px 16px;
    border: 1px solid #d7e1ef;
    border-radius: 16px;
    background: #f8fbff;
}

.user-detail-grid dt {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
}

.user-detail-grid dd {
    margin: 6px 0 0;
    overflow-wrap: anywhere;
}

.user-readonly-note {
    margin: 16px 0 0;
}

.user-cases-pagination {
    padding: 16px 20px 20px;
}

.case-user-identity strong,
.case-user-identity span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.case-user-identity span {
    color: var(--muted);
    font-size: 0.9rem;
}

.disabled-button {
    opacity: 0.75;
    pointer-events: none;
}

.checklist-wrapper {
    padding: 12px;
    display: grid;
    gap: 12px;
}

.checklist-item-card {
    position: relative;
    min-width: 0;
    border-radius: 14px;
    border: 1px solid #c9d8ee;
    padding: 12px;
}

.checklist-item-section {
    background: #f3f7fd;
    border: 2px solid #94b5df;
}

.checklist-item-document.checklist-status-approved {
    background: #f5fff6;
    border-color: #b6e5bd;
}

.checklist-item-document.checklist-status-needs_fix {
    background: #fff6f5;
    border-color: #f3c3be;
}

.checklist-item-document.checklist-status-pending {
    background: #fffaf0;
    border-color: #f0d08c;
}

.checklist-item-document.checklist-status-in_review {
    background: #f3f7ff;
    border-color: #bfd3f6;
}

.checklist-item-header {
    align-items: flex-start;
    gap: 12px;
}

.checklist-item-main {
    display: flex;
    align-items: center;
    flex: 1 1 620px;
    flex-wrap: wrap;
    gap: 10px 14px;
    min-width: 0;
}

.checklist-item-heading {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.checklist-item-heading h3 {
    margin: 0;
    max-width: min(38vw, 420px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1.08rem;
    line-height: 1.3;
    color: #1d2d45;
}

.edit-link {
    flex: 0 0 auto;
}

.checklist-item-description,
.client-access-line {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.45;
}

.client-access-line strong,
.document-meta strong {
    color: #425778;
}

.checklist-section-progress {
    flex: 0 0 auto;
    margin: 0 2px;
}

.checklist-section-progress progress {
    width: 136px;
}

.status-select {
    min-width: 190px;
    max-width: 250px;
    padding: 0.65rem 2.4rem 0.65rem 0.9rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
}

.checklist-status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0.55rem 0.9rem;
    border: 1px solid;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
}

.status-select-approved {
    border-color: #8fcf9c;
    background: #eaf8ec;
    color: #21753e;
}

.status-select-needs_fix {
    border-color: #f1aaa2;
    background: #fff0ef;
    color: #b14235;
}

.status-select-pending {
    border-color: #efc562;
    background: #fff6dd;
    color: #a86a05;
}

.status-select-in_review {
    border-color: #9eb8ea;
    background: #edf4ff;
    color: #315f9e;
}

.checklist-item-controls {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.checklist-item-controls form,
.document-actions form {
    margin: 0;
}

.checklist-icon-button {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 8px;
    border-radius: 10px;
}

.edit-link.checklist-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.72);
    color: var(--muted);
}

.edit-link.checklist-icon-button:hover {
    background: white;
    color: var(--brand);
}

.checklist-action-button {
    gap: 7px;
    min-height: 40px;
    padding: 0.62rem 0.9rem;
    border-radius: 11px;
    white-space: nowrap;
}

.checklist-action-button svg,
.checklist-icon-button svg {
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
}

.checklist-delete-item {
    border: 1px solid rgba(235, 87, 87, 0.18);
}

.checklist-item-card :is(a, button, summary, select, input):focus-visible {
    outline: 3px solid rgba(49, 95, 158, 0.32);
    outline-offset: 2px;
}

.checklist-item-card :is(button, input, select):disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.checklist-upload-control {
    position: relative;
}

.checklist-upload-control summary {
    list-style: none;
}

.checklist-upload-control summary::-webkit-details-marker {
    display: none;
}

.checklist-upload-control[open] summary {
    background: var(--accent-dark);
}

.document-upload-form {
    position: absolute;
    z-index: 8;
    top: calc(100% + 8px);
    right: 0;
    width: min(540px, calc(100vw - 48px));
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(180px, 0.9fr) auto;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: white;
    box-shadow: var(--shadow);
}

.document-upload-form label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.document-upload-form input {
    min-width: 0;
    padding: 0.65rem 0.75rem;
    font-size: 0.9rem;
}

.document-upload-form .button {
    align-self: end;
    min-height: 42px;
}

.checklist-documents-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.document-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f6f8fc;
    padding: 10px 12px;
}

.document-meta {
    display: grid;
    flex: 1 1 520px;
    gap: 6px;
    min-width: 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.document-file-name {
    display: flex;
    gap: 5px;
    min-width: 0;
}

.document-file-name span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-meta-details {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 16px;
}

.document-meta p,
.document-meta-details p {
    margin: 0;
}

.document-actions {
    justify-content: flex-end;
    flex: 0 1 auto;
    flex-wrap: wrap;
    gap: 7px;
}

.checklist-children {
    margin-top: 10px;
    margin-left: 24px;
    padding-left: 16px;
    border-left: 2px solid #d5e1f2;
    display: grid;
    gap: 10px;
}

.checklist-children > .checklist-item-card::before {
    content: "";
    position: absolute;
    top: 27px;
    left: -18px;
    width: 16px;
    border-top: 2px solid #d5e1f2;
}

.checklist-create-panel {
    padding: 18px;
}

.checklist-add-form {
    display: grid;
    gap: 12px;
}

.checklist-add-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(180px, 0.8fr) minmax(220px, 1fr) minmax(280px, 1.4fr) auto;
    gap: 12px;
    align-items: end;
}

.checklist-add-grid > div:not(.checklist-add-action) {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.checklist-add-grid input,
.checklist-add-grid select,
.checklist-add-grid textarea {
    height: 50px;
    min-height: 50px;
}

.checklist-add-grid textarea {
    resize: vertical;
}

.checklist-add-grid .checklist-add-action {
    align-self: end;
}

.inline-edit-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) auto;
    gap: 10px;
    width: 100%;
}

.detail-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.detail-list dt {
    font-weight: 700;
    margin-bottom: 0.35rem;
}

@media (max-width: 720px) {
    input,
    textarea,
    select,
    button {
        font-size: 16px;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 40;
        width: min(290px, calc(100vw - 44px));
        height: 100vh;
        padding-right: 10px;
        transform: translateX(-105%);
        transition: transform 0.24s ease;
        box-shadow: 0 18px 40px rgba(19, 48, 92, 0.16);
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 30;
        background: rgba(15, 43, 80, 0.34);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.22s ease;
    }

    .sidebar-mobile-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-mobile-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-brand-label,
    .sidebar-link-label {
        opacity: 1;
        width: auto;
        overflow: visible;
        pointer-events: auto;
    }

    .sidebar-toggle {
        transform: none;
    }

    .mobile-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .topbar {
        padding-left: 0;
        padding-right: 0;
    }

    .topbar-left {
        width: 100%;
        justify-content: space-between;
    }

    .page-head,
    .actions,
    .summary-panel,
    .filter-actions,
    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .summary-panel {
        display: flex;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .users-filters-grid,
    .cases-filters-grid,
    .form-grid,
    .user-detail-grid,
    .settings-grid,
    .logs-filters-grid {
        grid-template-columns: 1fr;
    }

    .case-hero,
    .case-hero-left,
    .case-tabs,
    .case-users-header,
    .case-user-card,
    .checklist-item-header,
    .checklist-item-controls,
    .document-row {
        flex-direction: column;
        align-items: stretch;
    }

    .case-users-header .button {
        width: 100%;
    }

    .case-activity-list {
        padding: 8px 12px 16px;
    }

    .case-activity-entry {
        grid-template-columns: 28px minmax(0, 1fr);
        gap: 10px;
    }

    .case-activity-entry:not(:last-child)::before {
        left: 13px;
    }

    .case-activity-marker {
        width: 28px;
        height: 28px;
    }

    .case-activity-card {
        padding: 12px;
    }

    .case-activity-card-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .case-activity-pagination {
        padding: 0 12px 16px;
    }

    .checklist-wrapper {
        padding: 10px;
    }

    .checklist-item-card {
        padding: 11px;
    }

    .checklist-item-main,
    .checklist-item-controls {
        align-items: stretch;
    }

    .checklist-item-main {
        display: grid;
        flex: 0 1 auto;
        grid-template-columns: minmax(0, 1fr);
    }

    .checklist-item-heading h3 {
        max-width: calc(100vw - 150px);
    }

    .checklist-item-controls {
        flex-direction: row;
        justify-content: flex-start;
    }

    .status-form,
    .status-select,
    .checklist-status-badge {
        width: 100%;
        max-width: none;
    }

    .checklist-section-progress {
        justify-self: start;
    }

    .checklist-children {
        margin-left: 10px;
        padding-left: 13px;
    }

    .checklist-children > .checklist-item-card::before {
        left: -15px;
        width: 13px;
    }

    .document-upload-form {
        position: static;
        width: min(100%, 540px);
        margin-top: 8px;
    }

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

    .document-upload-form,
    .checklist-add-grid,
    .inline-edit-form {
        grid-template-columns: 1fr;
    }

    .password-requirements-list ul {
        grid-template-columns: 1fr;
    }

    .legal-topbar,
    .legal-switcher {
        flex-direction: column;
        align-items: flex-start;
    }

    .row-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .delete-case-actions {
        flex-direction: column-reverse;
    }

    .delete-case-actions .button {
        width: 100%;
    }

    .case-modal {
        width: min(100% - 20px, 560px);
        max-height: calc(100dvh - 20px);
    }

    .user-create-modal {
        width: min(100% - 20px, 760px);
    }

    .user-create-modal-form {
        max-height: calc(100dvh - 22px);
    }

    .case-modal-header,
    .case-modal-body {
        padding-left: 16px;
        padding-right: 16px;
    }

    .assignee-picker-results {
        max-height: 34dvh;
    }
}
