:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --secondary: #334155;
    --danger: #b91c1c;
    --warning: #b45309;
    --success: #15803d;
    --info: #2563eb;
    --shadow: 0 16px 40px rgba(17, 24, 39, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

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

a:hover {
    color: var(--primary-dark);
}

button,
input,
select,
textarea {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    padding: 11px 12px;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

label span {
    display: block;
    margin-bottom: 6px;
    color: #374151;
    font-size: 13px;
    font-weight: 700;
}

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

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

th {
    color: #475569;
    font-size: 12px;
    text-transform: uppercase;
}

tbody tr:hover {
    background: #f8fafc;
}

.auth-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.14), rgba(37, 99, 235, 0.10)),
        #f8fafc;
}

.auth-shell {
    width: min(100%, 460px);
}

.auth-panel,
.panel,
.stat-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.auth-panel {
    padding: 32px;
}

.auth-copy {
    margin: 28px 0 24px;
}

.auth-copy h1,
.topbar h1,
.panel-heading h2,
.record-heading h2,
.empty-screen h2 {
    margin: 0;
    line-height: 1.14;
}

.auth-copy h1 {
    font-size: 30px;
}

.auth-copy p,
.hint {
    color: var(--muted);
}

.hint {
    margin: 18px 0 0;
    font-size: 13px;
}

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

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    height: 100vh;
    flex-direction: column;
    gap: 28px;
    border-right: 1px solid var(--line);
    background: #ffffff;
    padding: 24px;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    place-items: center;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    font-weight: 800;
}

.brand-block strong,
.brand-block span,
.user-chip strong,
.user-chip span,
.muted-line {
    display: block;
}

.brand-block span,
.user-chip span,
.muted-line {
    color: var(--muted);
    font-size: 12px;
}

.side-nav {
    display: grid;
    gap: 6px;
}

.side-nav a {
    border-radius: 8px;
    color: #334155;
    font-weight: 700;
    padding: 11px 12px;
}

.side-nav a:hover,
.side-nav a.is-active {
    background: #e6f4f1;
    color: var(--primary-dark);
}

.sidebar-footer {
    display: grid;
    gap: 14px;
    margin-top: auto;
}

.user-chip {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.main-panel {
    min-width: 0;
    padding: 28px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.topbar h1 {
    font-size: 28px;
}

.eyebrow {
    display: block;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.btn {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
    padding: 10px 14px;
    text-align: center;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: #ffffff;
}

.btn-secondary {
    background: #e2e8f0;
    color: #0f172a;
}

.btn-ghost {
    border-color: var(--line);
    background: #ffffff;
    color: #334155;
}

.btn-full {
    width: 100%;
}

.alert {
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 12px 14px;
    font-weight: 700;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.stat-card {
    padding: 20px;
}

.stat-card span,
.stat-card small {
    color: var(--muted);
}

.stat-card strong {
    display: block;
    font-size: 34px;
    line-height: 1;
    margin: 12px 0 8px;
}

.two-column,
.detail-grid,
.split-layout {
    display: grid;
    gap: 18px;
}

.two-column {
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
}

.detail-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
}

.split-layout {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
}

.panel {
    min-width: 0;
    padding: 20px;
}

.panel-heading,
.record-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.panel-heading h2,
.record-heading h2 {
    font-size: 20px;
}

body.modal-open {
    overflow: hidden;
}

.modal {
    display: none;
    inset: 0;
    position: fixed;
    z-index: 1000;
}

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

.modal.is-open {
    display: grid;
    place-items: center;
}

.modal-backdrop {
    background: rgba(15, 23, 42, 0.55);
    inset: 0;
    position: absolute;
}

.modal-panel {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
    max-height: min(760px, calc(100vh - 40px));
    overflow-y: auto;
    padding: 22px;
    position: relative;
    width: min(620px, calc(100vw - 32px));
}

.modal-heading {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 18px;
}

.modal-heading h2 {
    margin: 0;
}

.icon-button {
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #334155;
    cursor: pointer;
    display: inline-flex;
    font-weight: 900;
    height: 36px;
    justify-content: center;
    line-height: 1;
    width: 36px;
}

.icon-button:hover {
    border-color: var(--primary);
    color: var(--primary-dark);
}

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

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

.empty-screen {
    display: grid;
    gap: 12px;
    justify-items: start;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    padding: 7px 10px;
    text-transform: capitalize;
    white-space: nowrap;
}

.status-recibido,
.status-activo {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-en_revision {
    background: #fef3c7;
    color: #92400e;
}

.status-observado {
    background: #ffedd5;
    color: #9a3412;
}

.status-aprobado {
    background: #dcfce7;
    color: #166534;
}

.status-archivado,
.status-cerrado {
    background: #e5e7eb;
    color: #374151;
}

.status-enviado {
    background: #ccfbf1;
    color: #0f766e;
}

.status-pendiente {
    background: #fef3c7;
    color: #92400e;
}

.status-registrada {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-convertida {
    background: #dcfce7;
    color: #166534;
}

.status-en_proceso {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-completada {
    background: #dcfce7;
    color: #166534;
}

.status-cancelada {
    background: #fee2e2;
    color: #991b1b;
}

.priority-baja {
    background: #e0f2fe;
    color: #0369a1;
}

.priority-media {
    background: #e5e7eb;
    color: #374151;
}

.priority-alta {
    background: #fef3c7;
    color: #92400e;
}

.priority-urgente {
    background: #fee2e2;
    color: #991b1b;
}

.filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
}

.filter-bar.single {
    grid-template-columns: minmax(220px, 1fr) auto;
}

.form-stack,
.compact-form {
    display: grid;
    gap: 14px;
}

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

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

.inline-fields {
    display: grid;
    grid-template-columns: minmax(100px, 0.6fr) minmax(0, 1fr);
    gap: 12px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}

.record-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 0 0 18px;
}

.record-list div {
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
}

.record-list dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.record-list dd {
    margin: 4px 0 0;
}

.note-box {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    margin-top: 18px;
    padding: 14px;
}

.context-note {
    display: grid;
    gap: 4px;
    margin: 0 0 18px;
}

.context-note span {
    color: var(--muted);
}

.timeline {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.timeline.compact {
    margin-top: 0;
}

.timeline-item {
    display: block;
    border-left: 3px solid var(--primary);
    background: #f8fafc;
    border-radius: 0 8px 8px 0;
    color: var(--ink);
    padding: 12px 14px;
}

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

.timeline-item strong {
    display: block;
    margin: 3px 0;
}

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

.panel-subheading {
    margin: 22px 0 12px;
}

.panel-subheading h3 {
    font-size: 18px;
    margin: 2px 0 0;
}

@media (max-width: 1120px) {
    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .two-column,
    .detail-grid,
    .split-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        gap: 16px;
    }

    .side-nav {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    }

    .side-nav a {
        text-align: center;
    }

    .main-panel {
        padding: 20px;
    }

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

    .topbar .btn {
        width: 100%;
    }

    .panel-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .panel-heading .btn,
    .panel-heading button,
    .action-group,
    .action-group .btn {
        width: 100%;
    }

    .filter-bar,
    .filter-bar.single,
    .form-grid,
    .record-list {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .auth-panel {
        padding: 22px;
    }

    .main-panel {
        padding: 16px;
    }

    .panel,
    .stat-card {
        padding: 16px;
    }

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

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

    th,
    td {
        padding: 12px;
    }
}

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

.case-hero h2 {
    margin: 0 0 8px;
    font-size: 26px;
}

.case-hero p {
    margin: 0;
    color: var(--muted);
}

.case-meta {
    display: grid;
    justify-items: end;
    gap: 6px;
    min-width: 190px;
}

.case-meta strong,
.stat-name {
    font-size: 18px;
    line-height: 1.2;
}

.case-stats .stat-card strong {
    font-size: 28px;
}

.soft-line {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 20px 0;
}

.small-heading {
    margin-bottom: 12px;
}

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

.template-row,
.party-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: block;
    padding: 12px;
}

.template-row:hover {
    border-color: rgba(15, 118, 110, 0.35);
    background: #f0fdfa;
}

.template-row strong,
.template-row span,
.party-card strong,
.party-card span,
.party-card small {
    display: block;
}

.template-row span,
.party-card span,
.party-card small {
    color: var(--muted);
    font-size: 12px;
}

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

.legal-timeline .timeline-item {
    border-left-width: 4px;
}

.action-cell {
    white-space: nowrap;
}

.row-actions {
    align-items: center;
    display: flex;
    gap: 6px;
}

.row-actions form {
    margin: 0;
}

.icon-action {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 999px;
    color: #40534f;
    cursor: pointer;
    display: inline-flex;
    height: 38px;
    justify-content: center;
    padding: 0;
    width: 38px;
}

.icon-action:hover {
    background: var(--surface-container);
    color: var(--primary-dark);
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check-row input {
    width: 18px;
    height: 18px;
}

.check-row span {
    margin: 0;
}

.editor-help {
    align-items: center;
    border: 1px dashed #b7c4d5;
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    padding: 12px;
}

.editor-help strong {
    margin-right: 4px;
}

.editor-help span {
    background: #eef2ff;
    border-radius: 999px;
    color: #3730a3;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    padding: 6px 9px;
}

.miniword {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.editor-toolbar {
    align-items: center;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
}

.editor-toolbar button {
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #1f2937;
    cursor: pointer;
    display: inline-flex;
    font-weight: 800;
    height: 34px;
    justify-content: center;
    min-width: 38px;
    padding: 0 10px;
}

.editor-toolbar button:hover {
    border-color: var(--primary);
    color: var(--primary-dark);
}

.editor-surface {
    background: #ffffff;
    min-height: 420px;
    outline: none;
    padding: 22px;
}

.document-sheet {
    margin: 0 auto;
    max-width: 850px;
}

.editor-surface h1,
.document-preview h1 {
    font-size: 26px;
    line-height: 1.2;
}

.editor-surface h2,
.document-preview h2 {
    font-size: 20px;
}

.editor-hidden {
    display: none;
}

.document-preview {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    margin-top: 18px;
    padding: 22px;
}

.single-list {
    grid-template-columns: 1fr;
}

@media (max-width: 820px) {
    .case-hero {
        flex-direction: column;
    }

    .case-meta {
        justify-items: start;
        min-width: 0;
    }

    .editor-surface {
        min-height: 340px;
        padding: 16px;
    }
}

/* Material 3 visual layer */
:root {
    --bg: #f7faf8;
    --panel: #fffbff;
    --ink: #171d1b;
    --muted: #65736f;
    --line: #dbe5e1;
    --primary: #006a60;
    --primary-dark: #005049;
    --primary-container: #9cf2e5;
    --on-primary-container: #00201d;
    --secondary-container: #d1e8e2;
    --surface-container-lowest: #ffffff;
    --surface-container-low: #f2f7f4;
    --surface-container: #edf2ef;
    --surface-container-high: #e7eeea;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-strong: 0 8px 24px rgba(0, 0, 0, 0.16), 0 24px 64px rgba(0, 0, 0, 0.16);
}

.material-symbols-rounded {
    direction: ltr;
    display: inline-flex;
    font-family: "Material Symbols Rounded";
    font-feature-settings: "liga";
    font-size: 20px;
    font-style: normal;
    font-weight: 500;
    letter-spacing: 0;
    line-height: 1;
    text-transform: none;
    white-space: nowrap;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: Roboto, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

a:hover {
    color: var(--primary-dark);
}

.app-shell {
    grid-template-columns: 292px minmax(0, 1fr);
}

.sidebar {
    background: var(--surface-container-lowest);
    border-right: 1px solid var(--line);
    gap: 30px;
    padding: 28px 20px;
}

.brand-block {
    gap: 14px;
}

.brand-mark {
    background: var(--primary-container);
    border-radius: 18px;
    color: var(--on-primary-container);
    height: 52px;
    width: 52px;
}

.brand-block strong {
    color: #111816;
    font-size: 17px;
    font-weight: 800;
}

.brand-block span,
.user-chip span,
.muted-line {
    color: var(--muted);
}

.side-nav {
    gap: 6px;
}

.side-nav a {
    align-items: center;
    border-radius: 999px;
    color: #304541;
    display: flex;
    font-weight: 500;
    gap: 12px;
    min-height: 48px;
    padding: 0 18px;
}

.side-nav a:hover {
    background: var(--surface-container);
    color: #123d37;
}

.side-nav a.is-active {
    background: var(--secondary-container);
    color: #0f312d;
    font-weight: 700;
}

.side-nav a.is-active .material-symbols-rounded {
    font-variation-settings: "FILL" 1;
}

.user-chip {
    background: var(--surface-container-low);
    border: 0;
    border-radius: 18px;
    padding: 14px 16px;
}

.main-panel {
    padding: 36px;
}

.topbar {
    margin-bottom: 26px;
}

.topbar h1 {
    font-size: 34px;
    font-weight: 800;
}

.eyebrow {
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
}

.panel,
.auth-panel,
.stat-card {
    background: var(--surface-container-lowest);
    border: 0;
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 26px;
}

.panel-heading {
    align-items: center;
    margin-bottom: 24px;
}

.panel-heading h2,
.record-heading h2 {
    font-size: 24px;
    font-weight: 800;
}

.btn {
    align-items: center;
    border: 0;
    border-radius: 999px;
    box-shadow: none;
    gap: 8px;
    min-height: 42px;
    padding: 0 20px;
    font-size: 14px;
    font-weight: 700;
}

.btn:hover {
    transform: none;
}

.btn-primary {
    background: var(--primary);
    box-shadow: 0 2px 6px rgba(0, 106, 96, 0.28);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: #ffffff;
}

.btn-secondary {
    background: var(--secondary-container);
    color: #123d37;
}

.btn-secondary:hover {
    background: #bddad4;
    color: #0c302b;
}

.btn-ghost {
    background: transparent;
    border: 1px solid #71817c;
    color: var(--primary-dark);
}

.btn-ghost:hover {
    background: rgba(0, 106, 96, 0.08);
}

input,
select,
textarea {
    background: var(--surface-container-lowest);
    border: 1px solid #bfc9c5;
    border-radius: 12px;
    color: var(--ink);
    min-height: 52px;
    padding: 14px 16px;
}

textarea {
    min-height: 104px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 106, 96, 0.12);
}

label span {
    color: #263c38;
    font-size: 13px;
    font-weight: 700;
}

.filter-bar {
    gap: 14px;
    margin-bottom: 22px;
}

.table-wrap {
    border-radius: 18px;
    overflow: hidden;
}

table {
    background: var(--surface-container-lowest);
}

th {
    background: var(--surface-container-low);
    color: #39504b;
    font-size: 12px;
    font-weight: 800;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 16px 18px;
}

tbody tr:hover {
    background: #f4faf7;
}

.badge {
    border-radius: 999px;
    font-weight: 700;
    padding: 8px 12px;
}

.stat-card {
    padding: 22px;
}

.stat-card strong {
    font-size: 36px;
    font-weight: 800;
}

.stat-link {
    color: var(--ink);
    display: block;
    position: relative;
    transition: box-shadow 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.stat-link:hover {
    background: #f8fffc;
    box-shadow: 0 4px 14px rgba(0, 106, 96, 0.14);
    color: var(--ink);
    transform: translateY(-2px);
}

.stat-link.stat-warning {
    box-shadow: 0 1px 2px rgba(180, 83, 9, 0.10), 0 2px 10px rgba(180, 83, 9, 0.08);
}

.stat-link.stat-danger {
    box-shadow: 0 1px 2px rgba(179, 38, 30, 0.10), 0 2px 10px rgba(179, 38, 30, 0.08);
}

.stat-action {
    align-items: center;
    background: var(--secondary-container);
    border-radius: 999px;
    color: var(--primary-dark);
    display: inline-flex;
    height: 34px;
    justify-content: center;
    position: absolute;
    right: 18px;
    top: 18px;
    width: 34px;
}

.due-chip {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    padding: 8px 11px;
    white-space: nowrap;
}

.due-chip + .muted-line {
    margin-top: 6px;
}

.plazo-vencido .due-chip,
.due-chip.plazo-vencido {
    background: #ffdad6;
    color: #8c1d18;
}

.plazo-vence-hoy .due-chip,
.due-chip.plazo-vence-hoy {
    background: #ffefc2;
    color: #6f4b00;
}

.plazo-por-vencer .due-chip,
.due-chip.plazo-por-vencer {
    background: #fff8db;
    color: #6b5200;
}

.plazo-vigente .due-chip,
.due-chip.plazo-vigente {
    background: #dff7f2;
    color: #005049;
}

.plazo-sin-plazo .due-chip,
.due-chip.plazo-sin-plazo,
.plazo-atendido .due-chip,
.due-chip.plazo-atendido {
    background: var(--surface-container);
    color: #40534f;
}

tr.plazo-vencido td:first-child {
    box-shadow: inset 4px 0 0 #b3261e;
}

tr.plazo-vence-hoy td:first-child {
    box-shadow: inset 4px 0 0 #b45309;
}

.modal.is-open {
    align-items: flex-start;
    display: grid;
    justify-items: center;
    overflow-y: auto;
    padding: 54px 18px;
}

.modal-backdrop {
    background: rgba(21, 28, 26, 0.58);
    backdrop-filter: blur(3px);
}

.modal-panel {
    background: var(--surface-container-lowest);
    border: 0;
    border-radius: 28px;
    box-shadow: var(--shadow-strong);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 108px);
    overflow: hidden;
    padding: 0;
    width: min(560px, calc(100vw - 36px));
}

.modal-heading {
    align-items: center;
    background: var(--surface-container-lowest);
    flex: 0 0 auto;
    margin: 0;
    padding: 24px 24px 12px;
}

.modal-heading h2 {
    color: var(--ink);
    font-size: 24px;
    font-weight: 800;
}

.icon-button {
    background: transparent;
    border: 0;
    border-radius: 999px;
    color: #455653;
    height: 40px;
    width: 40px;
}

.icon-button:hover {
    background: var(--surface-container);
    color: var(--primary-dark);
}

.modal-panel .form-stack {
    display: grid;
    flex: 1 1 auto;
    gap: 14px 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-y: auto;
    padding: 8px 24px 24px;
}

.modal-panel .wide,
.modal-panel .inline-fields,
.modal-panel label:has(textarea),
.modal-panel .form-actions {
    grid-column: 1 / -1;
}

.modal-panel .inline-fields {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.modal-panel .form-actions {
    background: var(--surface-container-lowest);
    border-top: 1px solid var(--line);
    bottom: 0;
    margin: 6px -24px -24px;
    padding: 16px 24px 20px;
    position: sticky;
}

.action-group {
    gap: 10px;
}

.timeline-item,
.template-row,
.party-card,
.note-box,
.document-preview,
.miniword {
    border-color: var(--line);
    border-radius: 18px;
}

.timeline-item {
    background: var(--surface-container-low);
    border-left-color: var(--primary);
}

.template-row:hover {
    background: var(--surface-container-low);
}

.auth-body {
    background: radial-gradient(circle at top left, rgba(156, 242, 229, 0.5), transparent 34%), var(--bg);
}

.topbar-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.global-search {
    align-items: center;
    background: var(--surface-container-lowest);
    border: 1px solid #d3ddda;
    border-radius: 999px;
    display: flex;
    gap: 8px;
    min-height: 46px;
    min-width: 0;
    padding: 0 8px 0 16px;
}

.global-search .material-symbols-rounded {
    color: #5f726e;
}

.global-search input {
    background: transparent;
    border: 0;
    box-shadow: none;
    min-height: 42px;
    padding: 0;
}

.global-search input:focus {
    border: 0;
    box-shadow: none;
}

.topbar-search {
    flex: 1 1 320px;
    max-width: 520px;
}

.large-search {
    border-radius: 18px;
    margin-bottom: 18px;
    padding: 8px 8px 8px 18px;
}

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

.search-results-grid {
    display: grid;
    gap: 18px;
}

.search-section .panel-heading {
    margin-bottom: 16px;
}

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

.result-row {
    align-items: center;
    background: var(--surface-container-low);
    border: 1px solid var(--line);
    border-radius: 18px;
    color: var(--ink);
    display: grid;
    gap: 14px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 14px 16px;
}

.result-row:hover {
    background: var(--secondary-container);
    color: #0f312d;
}

.result-row > .material-symbols-rounded {
    align-items: center;
    background: var(--surface-container);
    border-radius: 999px;
    color: var(--primary);
    display: flex;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.result-row small {
    color: var(--muted);
    display: block;
    margin-top: 3px;
}

.result-row em {
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
    font-weight: 800;
    text-transform: uppercase;
}

.notification-button {
    align-items: center;
    background: var(--surface-container-lowest);
    border: 1px solid #d3ddda;
    border-radius: 999px;
    color: var(--primary-dark);
    display: inline-flex;
    height: 46px;
    justify-content: center;
    position: relative;
    width: 46px;
}

.notification-button:hover,
.notification-button.has-notifications {
    background: var(--secondary-container);
    color: #0f312d;
}

.notification-badge {
    align-items: center;
    background: #b3261e;
    border: 2px solid var(--surface-container-lowest);
    border-radius: 999px;
    color: #ffffff;
    display: flex;
    font-size: 11px;
    font-weight: 800;
    height: 22px;
    justify-content: center;
    min-width: 22px;
    padding: 0 5px;
    position: absolute;
    right: -4px;
    top: -6px;
}

.notification-list {
    gap: 12px;
}

.notification-item {
    align-items: center;
    display: grid;
    gap: 14px;
    grid-template-columns: auto minmax(0, 1fr) auto;
}

.notification-item.is-seen {
    opacity: 0.68;
}

.notification-icon {
    align-items: center;
    background: var(--surface-container);
    border-radius: 999px;
    color: var(--primary);
    display: flex;
    height: 44px;
    justify-content: center;
    width: 44px;
}

.notification-urgente {
    border-left-color: #b3261e;
}

.notification-urgente .notification-icon {
    background: #ffdad6;
    color: #8c1d18;
}

.notification-advertencia {
    border-left-color: #9a6700;
}

.notification-advertencia .notification-icon {
    background: #ffefc2;
    color: #684500;
}

.notification-info {
    border-left-color: var(--primary);
}

.notification-body {
    min-width: 0;
}

.agenda-layout {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.75fr);
}

.calendar-panel {
    overflow: hidden;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
    background: var(--surface-container-low);
    border-radius: 18px 18px 0 0;
    color: #39504b;
    font-size: 12px;
    font-weight: 800;
    overflow: hidden;
    text-align: center;
    text-transform: uppercase;
}

.calendar-weekdays span {
    padding: 12px 8px;
}

.calendar-days {
    border: 1px solid var(--line);
    border-radius: 0 0 18px 18px;
    border-right: 0;
    border-bottom: 0;
    overflow: hidden;
}

.calendar-day {
    background: var(--surface-container-lowest);
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    min-height: 132px;
    padding: 10px;
}

.calendar-day.is-outside {
    background: var(--surface-container-low);
    color: var(--muted);
}

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

.calendar-day-number {
    color: var(--primary-dark);
    font-weight: 800;
    margin-bottom: 8px;
}

.calendar-events {
    display: grid;
    gap: 6px;
}

.calendar-event {
    border-radius: 10px;
    color: #1e2f2c;
    display: block;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.25;
    overflow: hidden;
    padding: 6px 8px;
    text-overflow: ellipsis;
}

.calendar-event span {
    display: block;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.event-documentos {
    background: #dff7f2;
}

.event-tareas {
    background: #e7edff;
}

.event-actuaciones {
    background: #f0e5ff;
}

.level-urgente {
    border-left-color: #b3261e;
}

.calendar-event.level-urgente {
    background: #ffdad6;
}

.calendar-event.level-advertencia {
    background: #ffefc2;
}

.agenda-event-card strong {
    align-items: center;
    display: flex;
    gap: 8px;
}

.case-workspace {
    display: grid;
    gap: 18px;
}

.case-tabs-toolbar {
    display: grid;
    gap: 18px;
}

.case-tabs-heading {
    margin-bottom: 0;
}

.tab-list {
    align-items: center;
    background: var(--surface-container-low);
    border: 1px solid var(--line);
    border-radius: 999px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 6px;
    scrollbar-width: thin;
}

.tab-button {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 999px;
    color: #40534f;
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 auto;
    font-weight: 800;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.tab-button:hover {
    background: var(--surface-container-high);
    color: var(--primary-dark);
}

.tab-button.is-active {
    background: var(--primary);
    box-shadow: 0 6px 16px rgba(0, 106, 96, 0.22);
    color: #ffffff;
}

.tab-button.is-active .tab-count {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

.tab-count {
    align-items: center;
    background: var(--surface-container);
    border-radius: 999px;
    color: var(--primary-dark);
    display: inline-flex;
    font-size: 12px;
    height: 24px;
    justify-content: center;
    min-width: 24px;
    padding: 0 7px;
}

.tab-panel {
    display: block;
}

.tab-panel[hidden] {
    display: none !important;
}

.case-summary-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

.case-intelligence {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
}

.next-action-card {
    align-items: center;
    background: var(--surface-container-low);
    border: 1px solid var(--line);
    border-radius: 22px;
    display: grid;
    gap: 16px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 18px;
}

.next-action-card h3 {
    font-size: 22px;
    margin: 2px 0 6px;
}

.next-action-card p {
    color: var(--muted);
    margin: 0;
}

.next-action-icon {
    align-items: center;
    background: var(--secondary-container);
    border-radius: 18px;
    color: var(--primary-dark);
    display: inline-flex;
    height: 54px;
    justify-content: center;
    width: 54px;
}

.next-action-icon .material-symbols-rounded {
    font-size: 28px;
}

.next-action-critico {
    background: #fff6f5;
    border-color: #ffb4ab;
}

.next-action-critico .next-action-icon {
    background: #ffdad6;
    color: #8c1d18;
}

.next-action-alerta {
    background: #fffaf0;
    border-color: #f2d58a;
}

.next-action-alerta .next-action-icon {
    background: #ffefc2;
    color: #6f4b00;
}

.case-intelligence-metrics {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.case-metric {
    background: var(--surface-container-lowest);
    border: 1px solid var(--line);
    border-radius: 18px;
    color: var(--ink);
    display: block;
    min-height: 126px;
    padding: 16px;
}

.case-metric:hover {
    background: #f8fffc;
    color: var(--ink);
}

.case-metric .material-symbols-rounded {
    color: var(--primary);
}

.case-metric strong {
    display: block;
    font-size: 30px;
    line-height: 1;
    margin: 12px 0 6px;
}

.case-metric small {
    color: var(--muted);
    display: block;
}

.case-metric.metric-danger .material-symbols-rounded {
    color: #b3261e;
}

.case-context-strip {
    border: 1px solid var(--line);
    border-radius: 18px;
    display: grid;
    gap: 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
    overflow: hidden;
}

.case-context-strip > div {
    background: var(--surface-container-lowest);
    border-right: 1px solid var(--line);
    min-width: 0;
    padding: 14px 16px;
}

.case-context-strip > div:last-child {
    border-right: 0;
}

.case-context-strip span,
.case-context-strip small {
    color: var(--muted);
    display: block;
}

.case-context-strip span {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.case-context-strip strong {
    display: block;
    margin: 5px 0 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.case-context-strip small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.case-summary-block {
    min-width: 0;
}

.case-summary-block .record-list {
    margin-bottom: 0;
}

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

.case-health-item {
    background: var(--surface-container-lowest);
    border: 1px solid var(--line);
    border-radius: 18px;
    min-height: 128px;
    padding: 16px;
}

.case-health-item .material-symbols-rounded {
    color: var(--primary);
}

.case-health-item strong {
    display: block;
    font-size: 30px;
    line-height: 1;
    margin: 12px 0 6px;
}

.case-health-item small {
    color: var(--muted);
    display: block;
}

.party-list-grid,
.template-list-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.modal-wide .modal-panel,
.consolidated-modal-panel {
    width: min(1180px, calc(100vw - 36px));
}

.consolidated-layout {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(340px, 0.95fr) minmax(420px, 1.05fr);
    min-height: 560px;
}

.consolidated-list {
    display: grid;
    align-content: start;
    gap: 12px;
    max-height: 68vh;
    overflow-y: auto;
    padding-right: 4px;
}

.consolidated-item {
    background: var(--surface-container-low);
    border: 1px solid var(--line);
    border-radius: 18px;
    display: grid;
    gap: 12px;
    padding: 14px;
}

.consolidated-item h3 {
    font-size: 16px;
    margin: 4px 0;
}

.consolidated-item p {
    color: var(--muted);
    margin: 0 0 6px;
}

.consolidated-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.consolidated-files .btn {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.consolidated-preview {
    background: var(--surface-container-lowest);
    border: 1px solid var(--line);
    border-radius: 18px;
    display: grid;
    grid-template-rows: auto minmax(360px, 1fr);
    min-width: 0;
    overflow: hidden;
}

.consolidated-preview .panel-heading {
    margin: 0;
    padding: 16px 16px 8px;
}

.document-frame,
.external-frame {
    background: #ffffff;
    border: 0;
    min-height: 520px;
    width: 100%;
}

.document-frame {
    height: 100%;
}

.external-frame {
    border: 1px solid var(--line);
    border-radius: 18px;
}

.sinoe-frame-panel {
    display: grid;
    gap: 12px;
}

.compact-empty {
    border: 1px dashed var(--line);
    border-radius: 999px;
    padding: 8px 12px;
}

@media (max-width: 1120px) {
    .case-summary-grid {
        grid-template-columns: 1fr;
    }

    .case-intelligence-metrics,
    .case-context-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .case-context-strip > div:nth-child(2) {
        border-right: 0;
    }

    .case-context-strip > div:nth-child(-n + 2) {
        border-bottom: 1px solid var(--line);
    }
}

@media (max-width: 820px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .main-panel {
        padding: 20px;
    }

    .side-nav a {
        justify-content: center;
        padding: 0 12px;
    }

    .panel-heading {
        align-items: stretch;
    }

    .topbar-search {
        flex-basis: 100%;
        max-width: none;
        order: 3;
    }

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

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

    .case-tabs-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .tab-list {
        border-radius: 24px;
    }

    .tab-button {
        padding: 0 14px;
    }

    .case-health-grid {
        grid-template-columns: 1fr;
    }

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

    .consolidated-list {
        max-height: none;
    }

    .next-action-card {
        align-items: stretch;
        grid-template-columns: 1fr;
    }

    .case-intelligence-metrics,
    .case-context-strip {
        grid-template-columns: 1fr;
    }

    .case-context-strip > div,
    .case-context-strip > div:nth-child(2) {
        border-bottom: 1px solid var(--line);
        border-right: 0;
    }

    .case-context-strip > div:last-child {
        border-bottom: 0;
    }

    .calendar-day {
        min-height: 108px;
        padding: 8px;
    }

    .modal.is-open {
        padding: 20px 12px;
    }

    .modal-panel {
        border-radius: 24px;
        max-height: calc(100vh - 40px);
    }

    .modal-panel .form-stack,
    .modal-panel .inline-fields {
        grid-template-columns: 1fr;
    }
}
