:root {
    --bg-app: #edf4fb;
    --bg-panel: rgba(255, 255, 255, 0.96);
    --bg-brand: #10273f;
    --bg-brand-soft: #173c61;
    --line-soft: #d3e0ed;
    --line-strong: #b9cbdb;
    --ink-900: #10243a;
    --ink-700: #34526d;
    --ink-500: #647d96;
    --brand-900: #123557;
    --brand-700: #1e5b8f;
    --brand-500: #3582c5;
    --accent-500: #d57b1a;
    --accent-600: #b7650d;
    --ok-500: #21764b;
    --danger-500: #b13e30;
    --shadow-lg: 0 24px 64px rgba(16, 36, 58, 0.16);
    --shadow-md: 0 16px 36px rgba(16, 36, 58, 0.11);
    --shadow-sm: 0 10px 24px rgba(16, 36, 58, 0.08);
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --sidebar-width: 268px;
    --font-main: "Segoe UI", "Trebuchet MS", Verdana, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(238, 246, 252, 0.9), rgba(246, 250, 255, 0.84)),
        url('/static/imagenes/FONDO_HTML_BIENVENIDO.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--ink-900);
    font-family: var(--font-main);
}

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

button,
a {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    transition: grid-template-columns 0.22s ease;
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 26px 20px 20px;
    background:
        linear-gradient(180deg, rgba(9, 27, 46, 0.98) 0%, rgba(18, 51, 83, 0.97) 56%, rgba(12, 34, 57, 0.98) 100%);
    color: #eef4fb;
    border-right: 1px solid rgba(199, 215, 230, 0.12);
    box-shadow: 16px 0 44px rgba(16, 36, 58, 0.12);
    overflow: hidden;
    transition: opacity 0.18s ease, transform 0.22s ease, padding 0.22s ease;
}

.sidebar-collapsed .sidebar {
    opacity: 0;
    padding-left: 0;
    padding-right: 0;
    pointer-events: none;
    transform: translateX(-14px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(199, 215, 230, 0.14);
}

.brand img {
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.brand span {
    display: grid;
    gap: 3px;
}

.brand strong {
    color: white;
    font-size: 18px;
}

.brand small {
    color: rgba(238, 244, 251, 0.86);
}

.nav {
    display: grid;
    gap: 9px;
}

.nav a {
    min-height: 44px;
    display: flex;
    align-items: center;
    border: 1px solid transparent;
    border-radius: 15px;
    padding: 12px 14px;
    background: transparent;
    color: rgba(238, 244, 251, 0.92);
    font-weight: 800;
    transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.nav a.is-active,
.nav a:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.08));
    border-color: rgba(255, 255, 255, 0.08);
    transform: translateX(2px);
}

.main {
    min-width: 0;
    width: 100%;
    margin: 0 0 28px;
    padding: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 15;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    width: 100%;
    margin: 0 0 20px;
    padding: 18px 24px;
    border: 0;
    border-bottom: 1px solid rgba(185, 203, 219, 0.76);
    border-radius: 0;
    background: linear-gradient(180deg, rgba(250, 253, 255, 0.98), rgba(244, 249, 255, 0.92));
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 26px rgba(16, 36, 58, 0.08);
}

.topbar > * {
    grid-row: 1;
}

.topbar-left,
.topbar-actions {
    display: flex;
    align-items: center;
    min-width: 0;
}

.topbar-company-block {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 0;
}

#content {
    width: min(1840px, calc(100% - 18px));
    margin: 0 auto 28px;
    padding: 22px;
    border: 1px solid rgba(222, 234, 246, 0.22);
    border-radius: 28px;
    background: linear-gradient(135deg, rgba(8, 26, 46, 0.92), rgba(22, 58, 91, 0.82) 56%, rgba(12, 35, 60, 0.88));
    box-shadow: 0 28px 72px rgba(8, 24, 42, 0.34);
}

#message {
    width: min(1840px, calc(100% - 18px));
    margin: 0 auto 14px;
}

.eyebrow {
    color: var(--brand-700);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.menu-toggle,
.topbar #logoutBtn {
    min-height: 42px;
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    color: #fff;
    font-weight: 900;
    box-shadow: 0 10px 20px rgba(16, 36, 58, 0.16);
}

.menu-toggle {
    background: linear-gradient(135deg, #2b6fb1, #3b82c4);
    white-space: nowrap;
}

.menu-toggle:hover {
    background: linear-gradient(135deg, #245f99, #3375b3);
    transform: translateY(-1px);
}

.company-pill,
.user-pill {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid rgba(185, 203, 219, 0.9);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--ink-900);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 6px 18px rgba(16, 36, 58, 0.06);
    min-width: 0;
}

.company-pill {
    max-width: 100%;
    padding: 9px 18px;
    color: var(--brand-900);
    font-size: 17px;
    font-weight: 900;
    letter-spacing: 0;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.company-pill span,
.user-pill span {
    min-width: 0;
}

.company-pill strong,
.user-pill strong {
    color: var(--ink-900);
}

.topbar-actions {
    justify-content: flex-end;
    gap: 12px;
    min-width: max-content;
}

.user-pill {
    width: max-content;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 900;
    white-space: nowrap;
}

.topbar #logoutBtn {
    white-space: nowrap;
    background: #0b7a7a;
    box-shadow: 0 12px 24px rgba(11, 122, 122, 0.18);
}

.topbar #logoutBtn:hover {
    background: #096767;
    transform: translateY(-1px);
}

.grid-3,
.grid-4,
.grid-6,
.workspace-grid,
.task-board {
    display: grid;
    gap: 16px;
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 18px;
}

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

.grid-6 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    margin-bottom: 22px;
}

.workspace-grid {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    margin-bottom: 18px;
}

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

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

.workspace-grid.client-docs {
    grid-template-columns: minmax(280px, 0.75fr) minmax(0, 1.25fr);
}

.section-gap {
    margin-top: 28px;
}

.card,
.metric-card,
.record-card,
.task-card,
.catalog-card {
    border: 1px solid rgba(185, 203, 219, 0.88);
    border-radius: var(--radius-lg);
    background: var(--bg-panel);
    box-shadow: var(--shadow-sm);
}

.card,
.catalog-card {
    padding: 18px;
}

.admin-company-card {
    margin-bottom: 18px;
}

.metric-card {
    min-height: 116px;
    display: grid;
    gap: 5px;
    padding: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 252, 255, 0.94));
}

.metric-card span {
    color: var(--ink-500);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.metric-card strong {
    color: var(--brand-900);
    font-size: 30px;
    line-height: 1;
}

.metric-card small,
.record-card small,
.task-card small {
    color: var(--ink-700);
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.card-head h2 {
    margin: 4px 0 0;
    font-size: 21px;
}

.card-head p {
    margin: 6px 0 0;
    color: var(--ink-700);
}

.record-list {
    display: grid;
    gap: 12px;
}

.record-card,
.task-card {
    display: grid;
    gap: 12px;
    padding: 16px;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.record-card:hover,
.task-card:hover {
    transform: translateY(-1px);
    border-color: rgba(53, 130, 197, 0.35);
    box-shadow: var(--shadow-md);
}

.record-card h3,
.task-card h3 {
    margin: 0 0 7px;
    font-size: 16px;
}

.record-card p,
.task-card p {
    margin: 0;
    color: var(--ink-700);
}

.norm-card small {
    display: block;
    margin-top: 6px;
}

.badge-row {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 10px;
}

.badge-title {
    color: var(--ink-500);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.badge {
    display: inline-flex;
    min-height: 26px;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    background: #e8f1fb;
    color: var(--brand-700);
    font-size: 12px;
    font-weight: 900;
}

.badge.high,
.badge.critical {
    background: #fff0e4;
    color: #8a3f00;
}

.badge.active,
.badge.done,
.badge.resolved,
.badge.validated,
.badge.published {
    background: #e7f5ee;
    color: #17633b;
}

form {
    display: grid;
    gap: 12px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--ink-900);
    font-size: 13px;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--ink-900);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(53, 130, 197, 0.72);
    background: #fff;
    outline: 0;
    box-shadow: 0 0 0 4px rgba(53, 130, 197, 0.12);
}

textarea {
    resize: vertical;
}

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

.primary,
.secondary,
.primary-link,
.danger {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    padding: 12px 16px;
    font-weight: 800;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.primary,
.primary-link {
    background: linear-gradient(160deg, var(--accent-500), var(--accent-600));
    color: #fff;
    box-shadow: 0 12px 24px rgba(181, 101, 13, 0.22);
}

.secondary {
    background: linear-gradient(160deg, var(--brand-700), var(--brand-500));
    color: #fff;
    box-shadow: 0 12px 24px rgba(30, 91, 143, 0.2);
}

.secondary.dark {
    background: linear-gradient(160deg, var(--brand-900), var(--bg-brand-soft));
}

.danger {
    background: linear-gradient(160deg, #c94d3d, var(--danger-500));
    color: #fff;
    box-shadow: 0 12px 24px rgba(177, 62, 48, 0.22);
}

.primary:hover,
.primary-link:hover,
.secondary:hover,
.danger:hover {
    transform: translateY(-1px);
}

.action-row,
.record-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.record-actions {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line-soft);
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.row-actions button,
.row-actions .secondary,
.row-actions .danger,
.record-actions button,
.record-actions .secondary {
    min-height: 32px;
    padding: 7px 9px;
    font-size: 12px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    background: #fff;
}

.table-wrap.no-scroll {
    overflow-x: visible;
}

.audit-table {
    min-width: 1120px;
}

table,
.data-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    background: #fff;
}

.no-scroll table,
.catalog-table table {
    min-width: 0;
}

.compact-users {
    min-width: 1120px;
}

th,
td {
    padding: 11px 10px;
    border-bottom: 1px solid #e4ecf4;
    text-align: left;
    vertical-align: top;
    font-size: 13px;
}

th {
    background: linear-gradient(180deg, #f7fbff, #edf5fd);
    color: var(--ink-700);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

tbody tr:hover {
    background: #fbfdff;
}

td small {
    display: block;
    margin-top: 4px;
    color: var(--ink-700);
}

.message {
    margin-bottom: 16px;
    border: 1px solid rgba(213, 123, 26, 0.26);
    border-radius: var(--radius-sm);
    background: #fff8ec;
    color: #774100;
    padding: 11px 12px;
    font-weight: 800;
}

.empty {
    min-height: 92px;
    display: grid;
    place-items: center;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-md);
    color: var(--ink-500);
    background: #f8fbff;
    font-weight: 800;
}

.helper-copy {
    margin: 0 0 14px;
    color: var(--ink-700);
    font-size: 13px;
    line-height: 1.45;
}

.muted {
    color: var(--ink-500);
    font-size: 12px;
    font-weight: 800;
}

.search-box {
    margin-bottom: 14px;
}

.filter-toolbar {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 14px;
    padding: 12px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-md);
    background: #f8fbff;
}

.filter-toolbar label {
    min-width: 150px;
    margin: 0;
}

.filter-toolbar button {
    min-height: 42px;
}

.modal-root {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(10, 27, 45, 0.38);
    backdrop-filter: blur(6px);
}

.modal-root[hidden] {
    display: none;
}

.modal-panel {
    width: min(1360px, 97vw);
    max-height: min(90vh, 960px);
    overflow: auto;
    border: 1px solid rgba(185, 203, 219, 0.88);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 24px 56px rgba(16, 36, 58, 0.22);
    padding: 22px;
}

.modal-panel-compact {
    width: min(430px, 92vw);
    padding: 18px;
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(24, 56, 110, 0.12);
}

.modal-head h2 {
    margin: 0;
}

.confirm-box {
    display: grid;
    gap: 14px;
}

.confirm-copy {
    margin: 0;
    color: var(--ink-900);
    font-size: 18px;
    font-weight: 900;
    line-height: 1.35;
}

.confirm-actions {
    justify-content: flex-end;
}

.modal-error {
    margin: 0;
    border: 1px solid rgba(177, 62, 48, 0.24);
    border-radius: var(--radius-sm);
    background: #fff4f1;
    color: var(--danger-500);
    padding: 10px 12px;
    font-weight: 800;
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    width: 100%;
}

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

.catalog-card .data-table th,
.catalog-card .data-table td {
    padding: 9px 8px;
    font-size: 12px;
}

.pager {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    margin-top: 12px;
    color: var(--ink-500);
    font-size: 13px;
}

.pager strong {
    color: var(--ink-700);
}

.pager .secondary {
    min-height: 34px;
    padding: 8px 11px;
    font-size: 12px;
}

.org-selected {
    outline: 3px solid rgba(213, 123, 26, 0.25);
}

.tools-card {
    margin: 24px 0 20px;
}

.phase3-card {
    margin: 22px 0 18px;
    border-color: rgba(53, 130, 197, 0.28);
}

.phase3-grid .card {
    min-width: 0;
}

.diff-box {
    max-height: 360px;
    overflow: auto;
    margin: 0;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    padding: 14px;
    background: #0e2238;
    color: #eaf4ff;
    font-size: 12px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.workflow-grid {
    margin-top: 20px;
}

.executive-metrics {
    margin-bottom: 18px;
}

.executive-grid {
    margin-bottom: 20px;
}

.mini-metrics {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.mini-metrics .metric-card {
    min-height: 92px;
    padding: 14px;
}

.mini-metrics .metric-card strong {
    font-size: 24px;
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}

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

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

.compact-list {
    gap: 8px;
}

.slim-card {
    padding: 12px;
    gap: 8px;
}

.slim-card h3 {
    font-size: 14px;
}

.subtable-title {
    margin: 14px 0 8px;
    color: var(--brand-900);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.timeline-layout {
    display: grid;
    gap: 16px;
}

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

.nested-free {
    box-shadow: none;
}

.check-row {
    display: flex;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
}

.check-row input {
    width: auto;
}

.landing-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background-image: linear-gradient(90deg, rgba(10, 31, 49, 0.62), rgba(10, 31, 49, 0.22)), url('/static/imagenes/FONDO_HTML_BIENVENIDO.jpg');
    background-size: cover;
    background-position: center;
}

.landing {
    width: min(760px, 100%);
    display: grid;
    gap: 12px;
    justify-items: start;
    padding: 28px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow-lg);
}

.landing img {
    width: 78px;
}

.landing h1 {
    margin: 0;
    font-size: clamp(40px, 7vw, 72px);
}

.landing p {
    margin: 0 0 10px;
    color: var(--ink-700);
    font-size: 18px;
}

@media (max-width: 1280px) {
    .grid-6,
    .mini-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

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

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

    .sidebar {
        position: static;
        height: auto;
    }

    .main {
        width: 100%;
        margin: 0 0 28px;
        padding: 0;
    }

    .topbar {
        grid-template-columns: auto 1fr;
        margin: 0 0 14px;
        padding: 18px 24px;
        border-radius: 0;
    }

    .topbar-left {
        grid-column: 1;
    }

    .topbar-company-block {
        grid-column: 2;
        justify-content: flex-start;
    }

    .topbar-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
        flex-wrap: wrap;
        min-width: 0;
    }

    .company-pill,
    .user-pill {
        white-space: normal;
        text-align: left;
    }

    #content {
        padding: 16px;
        border-radius: 20px;
    }

    .grid-3,
    .grid-4,
    .grid-6,
    .mini-metrics,
    .report-grid,
    .score-grid,
    .workspace-grid,
    .workspace-grid.equal,
    .workspace-grid.client-docs,
    .timeline-grid {
        grid-template-columns: 1fr;
    }

    .sidebar-collapsed .sidebar {
        display: none;
    }
}

@media (max-width: 640px) {
    .form-grid,
    .task-board {
        grid-template-columns: 1fr;
    }

    .card-head,
    .modal-head {
        display: grid;
    }

    .pager {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}
