:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #eef4ff;
    --text: #111827;
    --muted: #64748b;
    --line: #dbe3ef;
    --blue: #0755a3;
    --blue-2: #0f6cbd;
    --green: #159447;
    --amber: #f4b731;
    --orange: #f97316;
    --slate: #0f172a;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr);
    background: var(--surface);
}
.auth-visual {
    position: relative;
    overflow: hidden;
    background: #0f172a;
    color: #fff;
    padding: 64px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
/* Velo neutro sutil (sin tinte azul) solo para legibilidad del título, anclado a la izquierda. */
.auth-visual::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(90deg, rgba(12, 17, 28, .58) 0%, rgba(12, 17, 28, .28) 42%, rgba(12, 17, 28, 0) 72%);
}
.auth-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.auth-brand img { width: 230px; max-width: 100%; filter: brightness(0) invert(1); }
.auth-copy {
    position: relative;
    z-index: 2;
    max-width: 640px;
}
/* Título de marca: "Gestión de" (light) + "CONTRATOS" (bold) + "SANTOLAYA" (tracking amplio). */
.hero-title {
    margin: 0;
    display: flex;
    flex-direction: column;
    font-family: "Montserrat", Inter, ui-sans-serif, system-ui, sans-serif;
    color: #fff;
    line-height: 1;
    text-shadow: 0 14px 40px rgba(15, 23, 42, .4);
}
.hero-title-light {
    font-weight: 300;
    font-size: clamp(30px, 4vw, 56px);
    letter-spacing: .005em;
}
.hero-title-bold {
    font-weight: 700;
    font-size: clamp(52px, 7.4vw, 108px);
    letter-spacing: -.015em;
    text-transform: uppercase;
    margin-top: 4px;
}
.hero-brand {
    display: block;
    margin-top: 26px;
    font-family: "Montserrat", Inter, ui-sans-serif, system-ui, sans-serif;
    font-weight: 500;
    font-size: clamp(13px, 1.5vw, 19px);
    letter-spacing: .5em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .92);
    text-shadow: 0 6px 22px rgba(15, 23, 42, .4);
}
.auth-copy p { font-size: 18px; line-height: 1.6; color: rgba(255, 255, 255, .78); margin: 0; }
.auth-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; position: relative; }
.auth-metric { border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08); padding: 18px; border-radius: 8px; }
.auth-metric strong { display: block; font-size: 26px; }
.auth-metric span { display: block; color: rgba(255,255,255,.72); font-size: 13px; margin-top: 5px; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-card { width: 100%; max-width: 430px; }
.login-card img { width: 260px; max-width: 100%; margin-bottom: 34px; }
.login-card h2 { font-size: 30px; margin: 0 0 8px; }
.login-card p { margin: 0 0 28px; color: var(--muted); }

.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field.no-margin { margin-bottom: 0; }
.field label { font-size: 13px; font-weight: 700; color: #344054; }
.field-help { color: var(--muted); font-size: 12px; line-height: 1.35; }
.input, .select, .textarea {
    width: 100%;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #fff;
    padding: 10px 13px;
    min-height: 46px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.input:hover, .select:hover, .textarea:hover { border-color: #98a2b3; }
.textarea { min-height: 110px; resize: vertical; }
.no-spin::-webkit-outer-spin-button,
.no-spin::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
}
.no-spin[type=number] {
    -moz-appearance: textfield;
}
.input:focus, .select:focus, .textarea:focus {
    outline: 0;
    border-color: #86b7fe;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, .14), 0 1px 2px rgba(16, 24, 40, .05);
}
.input-unit {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}
.input-unit .input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
.input-unit span {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    padding: 0 14px;
    border: 1px solid #d0d5dd;
    border-left: 0;
    border-radius: 0 8px 8px 0;
    background: #f8fafc;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}
.select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 42px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364758b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 14px 10px;
}
.select:disabled, .input:disabled, .textarea:disabled {
    background-color: #f2f4f7;
    color: #667085;
    cursor: not-allowed;
}
.check-row { display: flex; align-items: center; gap: 10px; margin: 8px 0 18px; color: #334155; }
.type-feature-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.feature-check {
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #f8fafc;
    color: #334155;
    font-size: 13px;
    font-weight: 850;
}
.table-check {
    display: inline-grid;
    place-items: center;
}
.table-check input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.table-check span {
    width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
}
.table-check span::after {
    content: "";
    width: 10px;
    height: 6px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translateY(-1px);
    opacity: 0;
}
.table-check input:checked + span {
    border-color: var(--blue-2);
    background: var(--blue-2);
}
.table-check input:checked + span::after {
    opacity: 1;
}
.btn {
    border: 0;
    border-radius: 8px;
    padding: 11px 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 800;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(15, 23, 42, .12); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(47, 111, 237, .30); }
/* Avance de aprobaciones en el listado: chips cortos + icono de detalle. */
.appr-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.appr-chip {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 1px 6px; border-radius: 999px;
    font-size: 10.5px; font-weight: 800; line-height: 1.5;
    border: 1px solid transparent; white-space: nowrap;
}
.appr-chip-dot { font-size: 9px; line-height: 1; }
.appr-chip-step { font-weight: 600; opacity: .75; }
.appr-chip.is-ok   { background: #e7f6ec; color: #166534; border-color: #bbe6cb; }
.appr-chip.is-wait { background: #fff6e5; color: #92400e; border-color: #fadfae; }
.appr-chip.is-no   { background: #fdebeb; color: #991b1b; border-color: #f6c6c6; }
.appr-chip.is-off  { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.appr-info {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; margin-left: 6px; padding: 0;
    border: 1px solid var(--border, #cbd5e1); border-radius: 50%;
    background: #fff; color: var(--muted, #64748b);
    font-size: 10px; font-weight: 800; font-style: italic; line-height: 1;
    cursor: pointer; vertical-align: middle;
}
.appr-info:hover { background: var(--blue, #0f6cbd); border-color: var(--blue, #0f6cbd); color: #fff; }

/* Vista previa del logo en el mantenedor de empresas. */
.logo-preview { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.logo-preview img {
    max-height: 56px; max-width: 220px; object-fit: contain;
    background: #fff; border: 1px solid var(--line, #e2e8f0); border-radius: 8px; padding: 6px;
}

/* Integraciones por empresa (mantenedor de empresas). */
.integrations-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fbfcfe; }
.integrations-title { font-size: 11px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 4px 0 8px; }
.integration-row { display: grid; grid-template-columns: minmax(0, 1.4fr) 160px; gap: 6px 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid #e9eef5; }
.integration-row:last-child { border-bottom: 0; }
.integration-row.is-switch { grid-template-columns: 1fr; }
.integration-row > div > span.muted { display: block; font-size: 11px; }
.integration-row .integration-help { grid-column: 1 / -1; margin: 0; line-height: 1.45; }
@media (max-width: 720px) { .integration-row { grid-template-columns: 1fr; } }

/* Un botón deshabilitado debe verse deshabilitado: sin esto queda idéntico a uno activo. */
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; filter: grayscale(35%); }
.btn:disabled:hover, .btn[disabled]:hover { transform: none; box-shadow: none; }
.btn svg { flex: 0 0 auto; width: 16px; height: 16px; opacity: .95; }
.btn-primary { background: var(--blue-2); color: #fff; }
.btn-primary:hover { box-shadow: 0 10px 24px rgba(37, 99, 235, .34); }
.btn-dark { background: var(--slate); color: #fff; }
.btn-dark:hover { box-shadow: 0 10px 24px rgba(51, 65, 85, .34); }
.btn-soft { background: #e8f1ff; color: var(--blue); }
.btn-soft:hover { background: #dbeafe; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { box-shadow: 0 10px 24px rgba(22, 163, 74, .32); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { box-shadow: 0 10px 24px rgba(220, 38, 38, .32); }
.btn-warn { background: var(--amber); color: #111827; }
.btn-outline { background: #fff; border: 1px solid var(--line); color: #334155; }
.btn-outline:hover { border-color: #b7d4f6; color: var(--blue); background: #f7fafe; }
.btn-outline svg { opacity: .85; }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 10px; font-size: 13px; }

.app-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    background: #fff;
    border-right: 1px solid var(--line);
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-logo { display: block; padding: 4px 10px 26px; }
.sidebar-logo img { width: 210px; max-width: 100%; }
.nav-title { color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; margin: 20px 12px 8px; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    border-radius: 8px;
    color: #334155;
    font-weight: 750;
    margin-bottom: 4px;
}
.nav-link:hover, .nav-link.active { background: #eaf3ff; color: var(--blue); }
.nav-icon {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.nav-icon path {
    stroke: currentColor;
    vector-effect: non-scaling-stroke;
}
.main { min-width: 0; }
.topbar {
    min-height: 110px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 30px;
    background: rgba(255,255,255,.86);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 5;
}
.topbar h1 {
    margin: 0;
    font-size: 26px;
    line-height: 1.05;
    font-weight: 300;
    letter-spacing: 0;
    color: #0f172a;
}
.topbar-meta { color: var(--muted); font-size: 13px; }
.content { padding: 30px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.card-body { padding: 20px; }
.card-title { margin: 0 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.maintenance-link {
    min-height: 148px;
    transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.maintenance-link:hover {
    transform: translateY(-2px);
    border-color: #9bc4ef;
    box-shadow: 0 18px 34px rgba(15, 108, 189, .12);
}
.stat { padding: 20px; border-left: 5px solid var(--blue-2); position: relative; }
.stat span { color: var(--muted); font-weight: 750; font-size: 13px; }
.stat strong { display: block; font-size: 34px; margin-top: 8px; }
.stat-link {
    position: absolute;
    top: 14px;
    right: 14px;
    font-size: 12px;
    font-weight: 800;
    color: var(--blue, #2f6fed);
    text-decoration: none;
    opacity: .75;
    transition: opacity .15s ease;
}
.stat-link:hover { opacity: 1; text-decoration: underline; }
.stat-link span { color: inherit; font-weight: 800; font-size: 13px; }
.dashboard-filter { margin-bottom: 18px; }
.dashboard-filter-form {
    display: grid;
    grid-template-columns: minmax(260px, 460px) auto;
    align-items: end;
    gap: 12px;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #475569; background: #f8fafc; }
td { font-size: 14px; }
.badge { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 850; background: #eef2ff; }
.badge-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.badge-success {
    border: 1px solid #86efac;
    background: #dcfce7;
    color: #166534;
}
.badge-danger {
    border: 1px solid #fecaca;
    background: #fee2e2;
    color: #991b1b;
}
.muted { color: var(--muted); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2 {
    margin: 0;
    font-size: 31px;
    line-height: 1.06;
    font-weight: 300;
    letter-spacing: 0;
    color: #0f172a;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.alert {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    border-radius: 10px;
    padding: 13px 15px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-left: 4px solid #cbd5e1;
    background: #fff;
    color: #334155;
    font-size: 13.5px;
    line-height: 1.45;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .05);
    --alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'/%3E%3C/svg%3E");
}
.alert::before {
    content: "";
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    background-color: currentColor;
    -webkit-mask: var(--alert-icon) center / contain no-repeat;
    mask: var(--alert-icon) center / contain no-repeat;
}
.alert-ok {
    border-color: #bbf7d0;
    border-left-color: #22c55e;
    background: #f0fdf4;
    color: #166534;
    --alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm-1.2 14.6-4-4 1.4-1.4 2.6 2.6 5.6-5.6 1.4 1.4-7 7z'/%3E%3C/svg%3E");
}
.alert-error {
    border-color: #fecaca;
    border-left-color: #ef4444;
    background: #fef2f2;
    color: #991b1b;
    --alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2 1 21h22L12 2zm1 15h-2v-2h2v2zm0-4h-2V9h2v4z'/%3E%3C/svg%3E");
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: span 2; }
.financial-row {
    display: grid;
    grid-template-columns: minmax(130px, 170px) minmax(260px, 1fr) minmax(150px, 190px);
    gap: 16px;
    align-items: start;
}
.percent-card {
    padding: 16px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.percent-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.percent-label-row label {
    font-size: 15px;
    color: #0f172a;
}
.percent-label-row span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
}
.percent-input {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 54px;
    align-items: stretch;
    margin-top: 10px;
}
.percent-input .input {
    min-height: 52px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    font-size: 18px;
    font-weight: 800;
}
.percent-input > span {
    display: grid;
    place-items: center;
    min-height: 52px;
    border: 1px solid #d0d5dd;
    border-left: 0;
    border-radius: 0 8px 8px 0;
    background: #eef6ff;
    color: var(--blue);
    font-size: 16px;
    font-weight: 900;
}
.percent-check {
    margin: 12px 0 0;
    font-weight: 850;
}
.approval-indicator {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr);
    gap: 10px;
    align-items: flex-start;
    margin-top: 12px;
    padding: 11px 12px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #f8fafc;
    color: #475569;
}
.approval-indicator strong {
    display: block;
    font-size: 12px;
    line-height: 1.25;
    color: #334155;
}
.approval-indicator p {
    margin: 3px 0 0;
    color: inherit;
    font-size: 12px;
    line-height: 1.35;
}
.approval-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    margin-top: 3px;
    background: #94a3b8;
    box-shadow: 0 0 0 4px rgba(148, 163, 184, .14);
}
.approval-indicator.is-ok {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}
.approval-indicator.is-ok strong { color: #14532d; }
.approval-indicator.is-ok .approval-dot {
    background: #16a34a;
    box-shadow: 0 0 0 4px rgba(22, 163, 74, .14);
}
.approval-indicator.is-required {
    border-color: #fed7aa;
    background: #fff7ed;
    color: #9a3412;
}
.approval-indicator.is-required strong { color: #7c2d12; }
.approval-indicator.is-required .approval-dot {
    background: #f97316;
    box-shadow: 0 0 0 4px rgba(249, 115, 22, .16);
}
.approval-indicator.is-muted {
    border-color: #e2e8f0;
    background: #f8fafc;
    color: #64748b;
}
.approval-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}
.approval-list h4 {
    margin: 0;
    font-size: 13px;
    color: #334155;
}
.approval-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}
.approval-row strong {
    display: block;
    font-size: 13px;
}
.approval-row span:not(.badge) {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}
.approval-flow-grid {
    display: grid;
    gap: 18px;
}
.approval-inbox {
    display: grid;
    gap: 18px;
}
.approval-task {
    border-left: 5px solid var(--amber);
}
.approval-task-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}
.approval-task-head span:not(.badge) {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.approval-task-head h3 {
    margin: 4px 0 5px;
    font-size: 20px;
    font-weight: 500;
}
.approval-task-head p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}
.approval-meta-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0;
}
.approval-meta-grid div {
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}
.approval-meta-grid span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.approval-meta-grid strong {
    display: block;
    margin-top: 4px;
    font-size: 13px;
}
.approval-request-box {
    margin: 6px 0 4px;
    padding: 12px 14px 4px;
    border: 1px solid #dbe7f4;
    border-radius: 10px;
    background: #f4f8fd;
}
.approval-request-box .approval-meta-grid {
    margin: 8px 0 4px;
}
.approval-request-box .approval-meta-grid div {
    background: #ffffff;
}
.approval-request-title {
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #0f6cbd;
}
.approval-resolution-form {
    display: grid;
    gap: 10px;
}
.approval-flow-card {
    border-left: 5px solid var(--blue-2);
}
.approval-flow-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.approval-flow-head span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
}
.approval-flow-head h3 {
    margin: 4px 0 0;
    font-size: 20px;
    font-weight: 500;
}
.switch-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f8fafc;
    color: #334155;
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap;
}
.switch-row input {
    accent-color: var(--blue-2);
}
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #f8fafc;
    max-height: 220px;
    overflow: auto;
}
.check-row.compact {
    align-items: flex-start;
    margin: 0;
    padding: 7px 8px;
    border-radius: 7px;
    background: #fff;
    border: 1px solid #eef2f7;
    font-size: 12px;
    line-height: 1.3;
}
.check-row.compact input {
    margin-top: 2px;
}
.user-maintenance-list {
    display: grid;
    gap: 14px;
}
.user-maintenance-card {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.user-maintenance-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}
.user-maintenance-head strong {
    display: block;
    font-size: 16px;
}
.user-maintenance-head span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}
.itemized-panel {
    padding: 16px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #f8fbff;
}
/* El atributo hidden debe ocultar los campos condicionales del formulario
   (por defecto `.field { display:grid }` lo anula). */
.field[hidden],
[data-itemized-panel][hidden],
[data-retention-field][hidden],
[data-advance-field][hidden],
[data-guarantee-field][hidden] {
    display: none !important;
}
.itemized-list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}
.itemized-head,
.itemized-row {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) minmax(135px, .55fr) minmax(135px, .55fr) minmax(105px, .4fr) minmax(125px, .45fr) auto;
    gap: 10px;
    align-items: center;
}
.itemized-head {
    color: #475569;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.itemized-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding-top: 4px;
}
.itemized-balance {
    padding: 11px 13px;
    border-radius: 8px;
    border: 1px solid #dbe3ef;
    background: #fff;
    font-size: 13px;
    font-weight: 800;
}
.itemized-balance.is-muted {
    color: #64748b;
}
.itemized-balance.is-ok {
    border-color: #86efac;
    background: #f0fdf4;
    color: #166534;
}
.itemized-balance.is-warning {
    border-color: #fed7aa;
    background: #fff7ed;
    color: #c2410c;
}
.contract-type-panel {
    padding: 20px;
    border: 1px solid #b7d4f6;
    border-left: 5px solid var(--blue-2);
    border-radius: 8px;
    background: linear-gradient(180deg, #f7fbff 0%, #eef6ff 100%);
    box-shadow: 0 12px 28px rgba(15, 108, 189, .10);
}
.contract-type-panel label {
    font-size: 20px;
    font-weight: 300;
    color: #0f172a;
}
.contract-type-panel .select {
    min-height: 58px;
    font-size: 18px;
    font-weight: 700;
    border-color: #9bc4ef;
    color: var(--blue);
}
.contract-type-panel .field-help {
    font-size: 13px;
    color: #305878;
}
.timeline { display: grid; gap: 10px; }
.timeline-item { display: grid; grid-template-columns: 20px 1fr; gap: 11px; align-items: start; color: var(--muted); font-weight: 700; }
.timeline-dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 3px; background: var(--line); }
.timeline-item.done { color: #0f172a; }
.pie-chart-wrap {
    display: grid;
    place-items: center;
    padding: 4px 0 18px;
}
.pie-chart {
    width: 176px;
    aspect-ratio: 1;
    border-radius: 50%;
    display: grid;
    place-items: center;
    align-content: center;
    background: conic-gradient(var(--pie));
    box-shadow: inset 0 0 0 16px #fff, 0 16px 32px rgba(15, 23, 42, .10);
}
.pie-chart span {
    display: block;
    color: #0f172a;
    font-size: 34px;
    font-weight: 850;
    line-height: 1;
}
.pie-chart small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}
.chart-legend {
    display: grid;
    gap: 8px;
}
.chart-legend-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    color: #334155;
    font-size: 13px;
}
.chart-legend-item strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chart-legend-item em {
    color: #0f172a;
    font-style: normal;
    font-weight: 850;
}
.chart-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.contract-status-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    border-left: 6px solid var(--blue-2);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.contract-status-hero .status-kicker,
.status-version span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.contract-status-hero strong {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
    font-size: 32px;
    line-height: 1.1;
}
.contract-status-hero p {
    max-width: 760px;
    margin: 10px 0 0;
    color: var(--muted);
}
.status-version {
    min-width: 150px;
    padding: 14px 16px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #fff;
    text-align: center;
}
.status-version strong { justify-content: center; font-size: 28px; color: var(--blue); }
.status-version.is-versions strong { font-size: 19px; letter-spacing: .3px; white-space: nowrap; }
.status-version small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    line-height: 1.35;
}
.guarantee-status.is-pending {
    border-color: #fed7aa;
    background: #fff7ed;
}
.guarantee-status.is-pending strong { color: #c2410c; }
.guarantee-status.is-processed {
    border-color: #86efac;
    background: #f0fdf4;
}
.guarantee-status.is-processed strong { color: #166534; }
.contract-progress {
    margin-top: 18px;
    overflow-x: auto;
    overflow-y: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .96) 0%, rgba(248, 251, 255, .98) 100%),
        radial-gradient(circle at top left, rgba(15, 108, 189, .10), transparent 34%);
}
.progress-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}
.progress-head span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 950;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.progress-head h3 {
    margin: 4px 0 0;
    color: #0f172a;
    font-size: 22px;
    line-height: 1.15;
    font-weight: 450;
}
.progress-head strong {
    min-width: 92px;
    padding: 9px 13px;
    border: 1px solid #b7d4f6;
    border-radius: 8px;
    background: #eef6ff;
    color: var(--blue);
    text-align: center;
    font-size: 13px;
    font-weight: 900;
}
.process-stepper {
    --rail-top: 20px;
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--step-count, 12), minmax(92px, 1fr));
    gap: 0;
    min-width: 1040px;
    padding: 0 4px 4px;
}
.process-stepper::before,
.process-stepper::after {
    content: "";
    position: absolute;
    left: 48px;
    right: 48px;
    top: var(--rail-top);
    height: 4px;
    border-radius: 999px;
}
.process-stepper::before {
    background: #dbe3ef;
}
.process-stepper::after {
    right: auto;
    width: calc((100% - 96px) * var(--progress) / 100);
    background: linear-gradient(90deg, var(--green), var(--blue-2));
    box-shadow: 0 0 0 4px rgba(15, 108, 189, .08);
}
.process-step {
    position: relative;
    z-index: 1;
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 9px;
    min-width: 0;
}
.process-node {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 3px solid #cbd5e1;
    border-radius: 50%;
    background: #fff;
    color: #64748b;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .08);
    font-size: 11px;
    font-weight: 950;
    font-variant-numeric: tabular-nums;
}
.process-step.is-done .process-node {
    border-color: var(--status-color, var(--green));
    background: var(--status-color, var(--green));
    color: #fff;
}
.process-step.is-current .process-node {
    width: 52px;
    height: 52px;
    margin-top: -4px;
    border-color: var(--status-color, var(--blue-2));
    background: #fff;
    color: var(--status-color, var(--blue-2));
    box-shadow: 0 0 0 8px rgba(15, 108, 189, .12), 0 16px 28px rgba(15, 108, 189, .18);
}
.process-label {
    display: grid;
    gap: 3px;
    max-width: 106px;
    text-align: center;
}
.process-label strong {
    color: #334155;
    font-size: 11px;
    line-height: 1.2;
    font-weight: 850;
}
.process-label small {
    color: var(--muted);
    font-size: 10px;
    line-height: 1.2;
    font-weight: 800;
}
.process-step.is-done .process-label strong {
    color: #334155;
}
.process-step.is-current .process-label strong {
    color: #0f172a;
    font-size: 12px;
}
.process-step.is-current .process-label small {
    color: var(--blue);
}
.quick-panel { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 18px; }
.trace-print-list {
    display: grid;
    gap: 9px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.trace-print-list h4 {
    margin: 0 0 2px;
    color: #334155;
    font-size: 13px;
}
.trace-print-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}
.trace-print-row span {
    color: var(--blue);
    font-size: 12px;
    font-weight: 900;
}
.trace-print-row strong {
    color: #0f172a;
    font-size: 13px;
}
.trace-print-row small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
}
.empty-note {
    padding: 13px 14px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}
.contract-stage-list {
    display: grid;
    gap: 20px;
    margin-top: 18px;
}
.contract-stage {
    --stage-accent: #cbd5e1;
    position: relative;
    width: 100%;
    border-left: 4px solid var(--stage-accent);
    box-shadow: 0 12px 30px rgba(15, 23, 42, .06);
    transition: box-shadow .2s ease, border-color .2s ease;
}
/* Espina continua que conecta las etapas consecutivas del proceso. */
.contract-stage-list .contract-stage:not(:last-child)::after {
    content: '';
    position: absolute;
    left: -4px;
    top: 100%;
    width: 4px;
    height: 20px;
    background: #e2e8f0;
}
/* Estado: etapa completada */
.contract-stage.is-done { --stage-accent: #16a34a; }
.contract-stage.is-done .stage-number {
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
}
/* Estado: etapa actual accionable */
.contract-stage.is-active {
    --stage-accent: var(--blue, #2f6fed);
    background: linear-gradient(180deg, #f5f9ff 0%, #ffffff 62%);
    box-shadow: 0 16px 36px rgba(47, 111, 237, .16);
}
.contract-stage.is-active .stage-number {
    background: var(--blue, #2f6fed);
    border-color: var(--blue, #2f6fed);
    color: #fff;
}
/* Estado: etapa pendiente / bloqueada */
.contract-stage.is-locked {
    --stage-accent: #cbd5e1;
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
}
.contract-stage.is-locked .stage-number {
    background: #f1f5f9;
    border-color: #dde5ef;
    color: #94a3b8;
}
.stage-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 14px;
    align-items: start;
    margin-bottom: 16px;
}
.stage-head .card-title {
    margin-bottom: 4px;
}
.stage-head p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}
.stage-number {
    min-width: 50px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    border: 1px solid #b7d4f6;
    border-radius: 8px;
    background: #eef6ff;
    color: var(--blue);
    font-size: 13px;
    font-weight: 950;
}
.stage-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.stage-summary div {
    padding: 11px 12px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #f8fafc;
}
.stage-summary span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.stage-summary strong {
    display: block;
    margin-top: 4px;
    color: #0f172a;
    font-size: 13px;
}
.stage-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}
.contract-stage button:disabled {
    opacity: .62;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.settlement-form {
    margin-top: 6px;
}
.settlement-subhead {
    padding: 11px 13px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #f0f7ff;
    color: var(--blue);
    font-size: 12px;
    font-weight: 950;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.settlement-approvals {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}
.settlement-approvals div {
    padding: 11px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}
.settlement-approvals span,
.settlement-meta-grid span,
.settlement-card-head span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.settlement-approvals strong {
    display: block;
    margin-top: 5px;
    color: #0f172a;
    font-size: 13px;
}
.settlement-approvals small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}
.settlement-approvals form {
    margin-top: 10px;
}
.settlement-control-panel {
    display: grid;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.settlement-close-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #f8fafc;
}
.settlement-close-actions span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.settlement-close-actions strong {
    display: block;
    margin-top: 4px;
    color: #0f172a;
    font-size: 13px;
}
.settlement-close-actions small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}
.settlement-board {
    display: grid;
    gap: 16px;
}
.settlement-card {
    border-left: 5px solid #94a3b8;
}
.settlement-card.has-settlement {
    border-left-color: var(--orange);
}
.settlement-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.settlement-card-head h3 {
    margin: 4px 0 5px;
    font-size: 20px;
    font-weight: 500;
}
.settlement-card-head p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}
.settlement-meta-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.settlement-meta-grid div {
    padding: 11px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}
.settlement-meta-grid strong {
    display: block;
    margin-top: 4px;
    color: #0f172a;
    font-size: 13px;
}
.settlement-meta-grid small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}
.settlement-detail-line {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    padding: 12px 13px;
    border-radius: 8px;
    background: #fff7ed;
    color: #9a3412;
    font-size: 13px;
}
.settlement-approval-strip {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}
.settlement-approval-strip span {
    color: #334155;
    font-size: 12px;
    font-weight: 900;
}
.approval-meter {
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}
.approval-meter i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--green);
}
.settlement-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}
.autocomplete { position: relative; }
.autocomplete .input {
    padding-left: 40px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' viewBox='0 0 24 24'%3e%3cpath stroke='%2364758b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m21 21-4.35-4.35M19 11a8 8 0 1 1-16 0 8 8 0 0 1 16 0Z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 13px center;
}
.autocomplete-results {
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    box-shadow: 0 24px 50px rgba(15, 23, 42, .16);
    overflow: hidden;
}
.autocomplete-option {
    width: 100%;
    display: grid;
    gap: 4px;
    text-align: left;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: #fff;
    padding: 12px 14px;
    cursor: pointer;
}
.autocomplete-option:hover, .autocomplete-option:focus {
    outline: none;
    background: #eef6ff;
}
.autocomplete-option strong { color: var(--slate); }
.autocomplete-option span, .autocomplete-option small { color: var(--muted); font-size: 12px; }
.autocomplete-empty { padding: 13px 14px; color: var(--muted); font-size: 13px; }
.autocomplete-help { margin-top: 7px; color: var(--muted); font-size: 12px; }
.autocomplete-help.is-error { color: #991b1b; font-weight: 750; }
.autocomplete-help.is-success { color: #166534; font-weight: 750; }
.field-help.is-error { color: #991b1b; font-weight: 750; }
.field-help.is-success { color: #166534; font-weight: 750; }
.field-help.is-warning { color: #b45309; font-weight: 750; }
.provider-lookup-row {
    display: grid;
    grid-template-columns: minmax(210px, 280px) max-content minmax(260px, 1fr) max-content;
    align-items: end;
    gap: 12px;
    margin-bottom: 0;
}
.provider-portal-button {
    min-height: 46px;
    padding-inline: 20px;
    white-space: nowrap;
}
.provider-rut-field label {
    font-size: 16px;
    font-weight: 850;
    color: #1f2937;
}
.provider-rut-field [data-provider-rut] {
    min-height: 56px;
    font-size: 19px;
    font-weight: 750;
    letter-spacing: .01em;
    border-color: #9bbcf4;
    background: #fbfdff;
}
.provider-rut-field [data-provider-name] {
    min-height: 56px;
    font-size: 16px;
}
.provider-rut-field [data-provider-rut]:focus {
    border-color: #0f6cbd;
    box-shadow: 0 0 0 5px rgba(15, 108, 189, .16), 0 1px 2px rgba(16, 24, 40, .05);
}
.provider-rut-field .provider-portal-button {
    min-height: 56px;
}
.provider-results {
    margin-top: 10px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 16px 32px rgba(15, 23, 42, .10);
    max-height: 340px;
    overflow-y: auto;
}
.provider-result-option,
.provider-result-empty {
    width: 100%;
    display: grid;
    gap: 3px;
    padding: 11px 13px;
    border: 0;
    border-bottom: 1px solid #edf2f7;
    background: #fff;
    text-align: left;
    color: #334155;
}
.provider-result-option {
    cursor: pointer;
}
.provider-result-option:hover,
.provider-result-option:focus {
    outline: none;
    background: #eef6ff;
}
.provider-result-option strong { color: #0f172a; font-size: 13px; }
.provider-result-option span,
.provider-result-empty { color: #64748b; font-size: 12px; }
.provider-summary {
    display: grid;
    gap: 4px;
    margin-top: 10px;
    padding: 12px 14px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #334155;
    font-size: 13px;
}
.provider-summary strong {
    color: #0f172a;
    font-size: 14px;
}
.provider-summary span { color: #475569; }
.work-description-lookup {
    display: grid;
    gap: 10px;
}
.work-description-selected {
    padding: 12px 14px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #334155;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}
.contract-paper {
    position: relative;
    background: #fff;
    color: #111827;
    width: min(100%, 920px);
    max-width: 920px;
    margin: 0 auto;
    padding: 54px 58px;
    border: 1px solid #d1d5db;
    box-shadow: 0 18px 45px rgba(15, 23, 42, .10);
    font-family: Georgia, "Times New Roman", serif;
    line-height: 1.62;
}
.contract-paper.is-preview::before {
    content: "NO VALIDO";
    position: fixed;
    inset: 0;
    z-index: 3;
    display: grid;
    place-items: center;
    color: rgba(153, 27, 27, .13);
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 112px;
    font-weight: 900;
    letter-spacing: .08em;
    transform: rotate(-28deg);
    pointer-events: none;
}
.contract-invalid-ribbon {
    position: absolute;
    top: 18px;
    left: 50%;
    z-index: 4;
    transform: translateX(-50%);
    padding: 7px 18px;
    border: 1px solid #fecaca;
    border-radius: 999px;
    background: #fee2e2;
    color: #991b1b;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
}
.print-screen {
    min-height: 100vh;
    padding: 28px 18px 44px;
    background: #dfe7f1;
}
.print-toolbar {
    width: min(100%, 816px);
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 14px 30px rgba(15, 23, 42, .08);
}
.print-toolbar strong {
    display: block;
    color: #0f172a;
    font-size: 14px;
}
.print-toolbar span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
}
.print-screen > .contract-paper {
    width: min(100%, 816px);
    min-height: 1056px;
    padding: 48px 54px 150px;
}
.contract-paper h1 {
    margin: 26px 0 24px;
    text-align: center;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16pt;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}
/* Contenido del contrato: Arial 11. */
.contract-doc-body {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11pt;
    line-height: 1.5;
    color: #111827;
}
/* Títulos de cláusula: negrita y centrados. */
.contract-paper h3 {
    /* Espacio entre cláusulas (margen superior del título): el doble del anterior. */
    margin: 40px 0 10px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11pt;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    color: #0f172a;
}
.contract-doc-body p { margin: 0 0 11px; text-align: justify; font-size: 11pt; }
.contract-paper p { margin: 0 0 12px; text-align: justify; }
.contract-paper ul, .contract-paper ol { margin: 8px 0 14px 24px; padding: 0; font-size: 11pt; }
.contract-items-table {
    width: 100%;
    margin: 14px 0 18px;
    border-collapse: collapse;
    font-family: Arial, Helvetica, sans-serif;
}
.contract-items-table th,
.contract-items-table td {
    border: 1px solid #cbd5e1;
    padding: 8px 9px;
    font-size: 11px;
    line-height: 1.35;
}
.contract-items-table th {
    background: #f1f5f9;
    color: #334155;
    font-weight: 850;
    text-transform: uppercase;
}
.contract-items-table tfoot th {
    background: #eaf3ff;
}
.text-right { text-align: right; }
.contract-doc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    padding-bottom: 18px;
    border-bottom: 2px solid #0f172a;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}
.contract-doc-header img { width: 190px; max-width: 45%; height: auto; }
.contract-doc-header div { text-align: right; display: grid; gap: 3px; }
.contract-doc-header span, .contract-doc-header small { color: #64748b; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.contract-doc-header strong { color: #0755a3; font-size: 18px; }
.contract-doc-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    margin-top: 18px;
    border: 1px solid #cbd5e1;
    background: #cbd5e1;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}
.contract-doc-meta div { background: #f8fafc; padding: 11px 12px; }
.contract-doc-meta span {
    display: block;
    color: #64748b;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.contract-doc-meta strong { display: block; margin-top: 4px; font-size: 12px; line-height: 1.3; }
.contract-doc-body { min-height: 360px; }
.contract-page-continuation {
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid #cbd5e1;
    color: #64748b;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
}
.signature-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 42px;
    margin-top: 86px;
    break-inside: avoid;
}
.signature-box {
    min-height: 92px;
    padding-top: 16px;
    border-top: 1.5px solid #111827;
    text-align: center;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}
.signature-box span { display: block; color: #475569; font-size: 12px; }
.signature-box strong { display: block; margin-top: 4px; font-size: 13px; }
.signature-box small { display: block; margin-top: 3px; color: #475569; font-size: 11px; font-weight: 750; }
.print-signature-fixed { display: none; }
.print-footer { margin-top: 60px; border-top: 1px solid #111827; padding-top: 12px; font-size: 12px; color: #374151; }
.invalid-footer { color: #991b1b; font-weight: 850; }
.wysiwyg {
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
.wysiwyg-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    border-bottom: 1px solid var(--line);
    background: #f8fafc;
}
.wysiwyg-toolbar button {
    min-width: 34px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: #334155;
    cursor: pointer;
    font-size: 13px;
    font-weight: 850;
}
.wysiwyg-toolbar button:hover {
    border-color: #cbd5e1;
    background: #fff;
}
.wysiwyg-surface {
    min-height: 190px;
    padding: 14px;
    outline: 0;
    line-height: 1.6;
}
.wysiwyg-surface:focus { box-shadow: inset 0 0 0 3px rgba(13, 110, 253, .12); }
.wysiwyg-surface p { margin: 0 0 10px; }
.wysiwyg-surface h3 { margin: 16px 0 8px; font-size: 16px; }
.wysiwyg-input { display: none; }
.variable-panel {
    display: grid;
    gap: 12px;
    padding: 13px;
    margin-bottom: 16px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #f8fbff;
}
.variable-group strong {
    display: block;
    margin-bottom: 8px;
    color: #475569;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.variable-list { display: flex; flex-wrap: wrap; gap: 8px; }
.variable-chip {
    border: 1px solid #b7d4f6;
    border-radius: 999px;
    background: #eef6ff;
    color: var(--blue);
    padding: 7px 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 850;
    user-select: none;
}
.variable-chip:hover { background: #dbeafe; }
.variable-chip:active { cursor: grabbing; }
.editor-textarea {
    min-height: 180px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
.clause-list { display: grid; gap: 16px; }
.clause-editor {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.compact-check { margin: 0; }
.type-picker { width: min(360px, 100%); }
.add-clause-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 14px;
    border-top: 1px solid var(--line);
    margin-top: 16px;
    padding-top: 16px;
}
.add-clause-row .field { margin-bottom: 0; }
.draggable-row {
    padding: 16px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.draggable-row.is-dragging {
    opacity: .55;
    border-color: #9bc4ef;
}
.drag-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    cursor: grab;
    font-weight: 900;
    letter-spacing: -2px;
}
.editor-preview-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 43%);
    gap: 18px;
    align-items: start;
}
.type-version-picker {
    display: grid;
    grid-template-columns: minmax(190px, 1fr) minmax(150px, .6fr);
    gap: 10px;
    width: min(520px, 100%);
}
.version-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 16px;
}
.version-strip span {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    border: 1px solid #dbeafe;
    border-radius: 999px;
    background: #f8fbff;
    color: #475569;
    padding: 7px 11px;
    font-size: 12px;
}
.version-strip strong { color: var(--blue); }
.version-strip .status-pill-success {
    border-color: #86efac;
    background: #dcfce7;
    color: #166534;
}
.version-strip .status-pill-danger {
    border-color: #fecaca;
    background: #fee2e2;
    color: #991b1b;
}
.version-strip .status-pill-success strong,
.version-strip .status-pill-danger strong {
    color: inherit;
}
.type-status-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}
.type-status-panel .field-help { flex-basis: 100%; }
.template-builder-grid {
    display: grid;
    grid-template-columns: minmax(250px, 300px) minmax(0, 1fr) minmax(360px, 41%);
    gap: 18px;
    align-items: start;
}
.builder-library {
    position: sticky;
    top: 128px;
    max-height: calc(100vh - 150px);
    overflow: auto;
}
.library-list { display: grid; gap: 10px; }
.library-item {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: grab;
}
.library-item:hover {
    border-color: #9bc4ef;
    background: #f8fbff;
}
.library-item strong { color: #0f172a; }
.library-item span { color: var(--muted); font-size: 12px; line-height: 1.4; }
.builder-sheet-card { min-width: 0; }
.template-sheet {
    min-height: 520px;
    padding: 16px;
    border: 1px dashed #b7c6d8;
    border-radius: 8px;
    background: #f8fafc;
}
.template-part {
    box-shadow: 0 8px 22px rgba(15, 23, 42, .05);
}
.part-summary {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}
.part-edit-panel {
    display: none;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}
.template-part.is-editing .part-edit-panel { display: block; }
.sheet-empty {
    display: grid;
    place-items: center;
    min-height: 180px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    color: var(--muted);
    background: rgba(255,255,255,.72);
    font-weight: 750;
    text-align: center;
}
.contract-preview-sticky {
    position: sticky;
    top: 128px;
    display: grid;
    gap: 12px;
}
.preview-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.contract-preview-pages {
    display: grid;
    gap: 18px;
    max-height: calc(100vh - 210px);
    overflow: auto;
}
.contract-preview-paper {
    width: 100%;
    aspect-ratio: 8.5 / 11;
    padding: 34px;
    transform-origin: top center;
    min-height: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.contract-preview-paper.is-measuring {
    position: absolute;
    left: -9999px;
    top: 0;
    visibility: hidden;
    pointer-events: none;
}
.contract-preview-paper .contract-doc-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.contract-preview-paper h1 { font-size: 19px; }
.contract-preview-paper .contract-doc-header img { width: 145px; }
.contract-preview-paper .contract-doc-body {
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
}
.contract-preview-paper .signature-grid { gap: 24px; margin-top: auto; padding-top: 34px; }
.preview-clause-section { break-inside: avoid; page-break-inside: avoid; }

@media print {
    /* margin:0 en @page elimina el encabezado/pie que agrega el navegador (URL, fecha, "Página X de Y").
       Los márgenes reales del documento se aplican como padding del contenido. */
    @page { size: Letter; margin: 0; }
    body { background: #fff; }
    .print-screen { padding: 0; background: #fff; min-height: 0; }
    .no-print { display: none !important; }
    .contract-paper {
        border: 0;
        box-shadow: none;
        padding: 0;
        width: 100%;
        max-width: none;
        font-size: 10pt;
        line-height: 1.45;
    }
    /* Anula el min-height de pantalla y aplica los márgenes del documento como padding
       (porque @page va con margin:0 para quitar el encabezado/pie del navegador). */
    .print-screen > .contract-paper { min-height: 0; padding: 14mm 16mm; width: 100%; }
    .contract-paper.is-preview::before {
        position: fixed;
        color: rgba(153, 27, 27, .18);
        font-size: 58pt;
    }
    .contract-invalid-ribbon {
        position: fixed;
        top: 5mm;
        font-size: 8pt;
    }
    .contract-paper h1 { font-size: 15pt; margin: 16px 0 14px; }
    .contract-paper h3 { font-size: 11pt; font-weight: 700; text-align: center; margin: 32px 0 8px; }
    .contract-paper p { margin-bottom: 8px; }
    /* La tabla de ítems nunca se parte entre páginas; su título se queda con ella (y ningún
       título de cláusula queda huérfano al final de una página). */
    .contract-doc-body h3, .contract-paper h3 { break-after: avoid; page-break-after: avoid; }
    .contract-items-table, .contract-items-table tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    .contract-items-table th,
    .contract-items-table td {
        padding: 5px 6px;
        font-size: 7.8pt;
    }
    .contract-doc-header { padding-bottom: 10px; }
    .contract-doc-header img { width: 145px; }
    .contract-doc-header span,
    .contract-doc-header small { font-size: 7.5pt; }
    .contract-doc-header strong { font-size: 11pt; }
    .contract-doc-meta { margin-top: 10px; }
    .contract-doc-meta div { padding: 7px 8px; }
    .contract-doc-meta span { font-size: 7pt; }
    .contract-doc-meta strong { font-size: 8.5pt; }
    .contract-doc-body { min-height: 0; }
    /* La firma va en el flujo normal, al final del contenido, sin cortarse ni repetirse por página
       (usar position:fixed rompía la paginación en Chrome y perdía páginas al exportar a PDF). */
    /* Firma en flex (lado a lado) para no depender del grid, que una regla responsive
       (max-width:980px) fuerza a 1 columna al ancho de la hoja. Flex es robusto en Chrome y Safari. */
    .print-signature-block {
        display: flex !important;
        flex-direction: row;
        gap: 40px;
        /* Espacio en blanco sobre la línea para firmar a mano. */
        margin-top: 140px;
        break-inside: avoid;
        page-break-inside: avoid;
    }
    .print-signature-block .signature-box {
        flex: 1 1 0;
        min-width: 0;
        break-inside: avoid;
        page-break-inside: avoid;
    }
    .print-signature-fixed { display: none; }
    .signature-box {
        min-height: 48px;
        padding-top: 8px;
    }
    .signature-box span { font-size: 8pt; }
    .signature-box strong { font-size: 8.5pt; }
    .signature-box small { font-size: 7.5pt; }
    .print-footer {
        margin-top: 26px;
        padding-top: 6px;
        font-size: 7.5pt;
        break-inside: avoid;
        page-break-inside: avoid;
    }
    .preview-print-mode .app-shell > .sidebar,
    .preview-print-mode .topbar,
    .preview-print-mode .content > :not(.template-builder-grid),
    .preview-print-mode .template-builder-grid > :not(.contract-preview-sticky),
    .preview-print-mode .preview-actions {
        display: none !important;
    }
    .preview-print-mode .app-shell { display: block; }
    .preview-print-mode .content { padding: 0; }
    .preview-print-mode .template-builder-grid { display: block; }
    .preview-print-mode .contract-preview-sticky { position: static; display: block; }
    .preview-print-mode .contract-preview-pages {
        max-height: none;
        overflow: visible;
        display: block;
    }
    .preview-print-mode .contract-preview-paper {
        height: calc(11in - 48mm);
        min-height: calc(11in - 48mm);
        padding: 0;
        aspect-ratio: auto;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        break-after: page;
    }
    .preview-print-mode .contract-preview-paper .contract-doc-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }
    .preview-print-mode .contract-preview-paper .signature-grid {
        margin-top: auto;
        padding-top: 8mm;
    }
    .preview-print-mode .contract-preview-paper:last-child { break-after: auto; }
}

@media (max-width: 980px) {
    .auth-shell, .app-shell { grid-template-columns: 1fr; }
    .auth-visual { min-height: 360px; padding: 34px; }
    .hero-brand { letter-spacing: .4em; }
    .sidebar { position: relative; height: auto; }
	    .grid-2, .grid-3, .grid-4, .form-grid, .approval-meta-grid, .checkbox-grid, .stage-summary, .settlement-approvals, .settlement-meta-grid, .type-feature-grid { grid-template-columns: 1fr; }
	    .form-grid .span-2 { grid-column: auto; }
    .stage-head { grid-template-columns: auto minmax(0, 1fr); }
    .stage-head > .badge { grid-column: 1 / -1; justify-self: start; }
    .trace-print-row { grid-template-columns: 1fr; }
    .settlement-close-actions { align-items: flex-start; flex-direction: column; }
	    .financial-row { grid-template-columns: 1fr; }
    .content { padding: 20px; }
    .topbar { min-height: 88px; padding: 16px 20px; align-items: flex-start; }
	    .topbar h1 { font-size: 19px; }
	    .section-head { align-items: flex-start; flex-direction: column; }
	    .dashboard-filter-form { grid-template-columns: 1fr; }
	    .section-head h2 { font-size: 22px; }
	    .provider-lookup-row { grid-template-columns: 1fr; }
	    .provider-portal-button { width: 100%; }
	    .add-clause-row { grid-template-columns: 1fr; align-items: stretch; }
    .editor-preview-layout { grid-template-columns: 1fr; }
    .template-builder-grid { grid-template-columns: 1fr; }
    .builder-library { position: static; max-height: none; }
    .type-version-picker { grid-template-columns: 1fr; }
    .contract-preview-sticky { position: static; }
    .contract-doc-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .signature-grid { grid-template-columns: 1fr; }
}

/* Dashboard v2 — alertas e indicadores */
.text-danger { color: #dc2626; }
.alert-list { list-style: none; margin: 0 0 14px; padding: 0; }
.alert-list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.alert-list li:last-child { border-bottom: 0; }
.alert-list li span { color: var(--muted); font-size: 13px; }
.alert-list li strong { font-size: 18px; }

/* Listados v2 — barra de filtros */
.list-filter { margin-bottom: 16px; }
.filter-grid { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filter-grid .field { min-width: 180px; flex: 1 1 180px; margin: 0; }
.field.no-margin { margin: 0; }

/* Aprobaciones v2 — acciones secundarias */
.approval-secondary-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form .select { min-width: 160px; }

/* Mantenedores v2 */
.clause-meta { font-size: 12px; margin-bottom: 8px; }
.clause-preview { margin: 8px 0; }
.clause-preview summary { cursor: pointer; color: var(--brand, #0f6cbd); font-size: 13px; }
.clause-preview-box { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-top: 8px; background: #fafbfc; font-size: 13px; }
.sync-info { margin: 14px 0; }

/* Expediente v2 — Integración SAP y acuse de retiro */
.sap-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.withdrawal-receipt { display: flex; gap: 16px; align-items: center; margin-top: 14px; padding: 14px; border: 1px dashed var(--line); border-radius: 10px; background: #fafbfc; }
.receipt-qr { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 96px; height: 96px; border: 2px solid #111827; border-radius: 8px; text-align: center; padding: 6px; }
.receipt-qr span { font-size: 10px; letter-spacing: 1px; color: var(--muted); }
.receipt-qr strong { font-size: 12px; word-break: break-all; }
@media (max-width: 720px){ .sap-grid { grid-template-columns: 1fr 1fr; } }

/* Acuse de retiro — QR */
.receipt-qr-img { width: 110px; height: 110px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }

/* Acuse de recibo público (sin login) */
.text-ok { color: #16a34a; }
.receipt-page { background: #eef2f6; min-height: 100vh; margin: 0; }
.receipt-shell { max-width: 520px; margin: 0 auto; padding: 40px 16px; }
.receipt-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: 0 10px 30px rgba(15,23,42,.08); }
.receipt-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; margin-bottom: 20px; }
.receipt-brand img { height: 44px; }
.receipt-brand span { font-weight: 600; color: #111827; }
.receipt-detail { display: grid; gap: 10px; margin-bottom: 20px; }
.receipt-detail > div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.receipt-detail span { color: var(--muted); font-size: 13px; }
.receipt-detail strong { text-align: right; font-size: 13px; }
.receipt-lead { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.receipt-form .field { margin-bottom: 12px; }
.receipt-form .check-row { margin: 12px 0 18px; }
.receipt-form .btn { width: 100%; }
.receipt-ok { text-align: center; padding: 18px; border: 1px solid #bbf7d0; background: #f0fdf4; border-radius: 12px; }
.receipt-ok h2 { color: #16a34a; margin: 0 0 8px; }
.receipt-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* Resumen de solicitud + revisión de notaría */
.request-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.request-summary > div { display: flex; flex-direction: column; gap: 3px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.request-summary > div.span-2 { grid-column: span 3; }
.request-summary span { color: var(--muted); font-size: 12px; }
.request-summary strong { font-size: 14px; }
.notary-review { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 12px; }
@media (max-width: 820px){ .request-summary { grid-template-columns: 1fr 1fr; } .request-summary > div.span-2 { grid-column: span 2; } .notary-review { grid-template-columns: 1fr; } }

/* Bloqueo de etapas hasta la revisión de Servicios Generales */
.contract-stage-list.is-review-locked { opacity: .55; pointer-events: none; filter: grayscale(0.3); }

/* Multiempresa: barra superior con selector de empresa y logo */
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-logo { height: 40px; max-width: 160px; object-fit: contain; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.company-switcher { display: flex; align-items: center; gap: 8px; }
.company-switcher label { font-size: 12px; color: var(--muted); }
.company-switcher .select { min-width: 200px; }
.topbar-company { font-weight: 600; }
.company-head-brand { display: flex; align-items: center; gap: 12px; }
.company-logo-thumb { height: 40px; max-width: 120px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; padding: 4px; background: #fff; }

/* Badge legacy / advertencia */
.badge-warn { background: #fef3c7; color: #b45309; }

/* Menú lateral v2 — familia Contratos + CTA destacado */
.sidebar { overflow-y: auto; }
.sidebar nav { display: flex; flex-direction: column; }
.nav-title:first-of-type { margin-top: 10px; }
.nav-title { position: relative; padding-top: 14px; border-top: 1px solid var(--line); margin: 18px 12px 8px; }
.nav-cta {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--blue-2);
    color: #fff;
    font-weight: 800;
    letter-spacing: .01em;
    margin: 2px 0 6px;
    box-shadow: 0 8px 18px rgba(15, 108, 189, .30);
    transition: background .15s ease, transform .05s ease, box-shadow .15s ease;
}
.nav-cta span { flex: 1; }
.nav-cta:hover { background: var(--blue); box-shadow: 0 10px 22px rgba(7, 85, 163, .34); }
.nav-cta:active { transform: translateY(1px); }
.nav-cta.active { background: var(--blue); }
.nav-cta .nav-icon { width: 20px; height: 20px; color: #fff; opacity: .95; }

/* Chips de documento en etapas + botón/modal Const. de Sociedad */
.stage-docs { margin: 10px 0 4px; }
.trace-heading { display: inline-flex; align-items: center; gap: 7px; }
.trace-heading svg { color: var(--blue, #2f6fed); flex: 0 0 auto; }
.type-flag-note { display: inline-flex; align-items: center; gap: 8px; color: #166534; font-size: 13.5px; }
.type-flag-note svg { color: #16a34a; flex: 0 0 auto; }
.type-flag-note strong { font-weight: 800; }
.doc-chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: #f4f8ff; color: var(--blue); font-weight: 700; font-size: 13px; }
.doc-chip:hover { background: #e8f1ff; }
.doc-icon-btn { display: inline-flex; align-items: center; gap: 8px; }
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 24px; }
.modal-overlay[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 12px; width: min(920px, 100%); height: min(85vh, 900px); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(15,23,42,.35); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head strong { flex: 1; }
.modal-close { background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-doc { flex: 1; width: 100%; border: 0; }

/* Notarías/Proveedor: proveedor seleccionado desde el buscador */
.user-maintenance-card.is-selected { border: 2px solid var(--blue-2); box-shadow: 0 8px 20px rgba(15,108,189,.18); }

/* Contenido del contrato: Arial 11 (el título centrado h1 conserva su tamaño). */
.contract-doc-body,
.contract-doc-body p,
.contract-doc-body li,
.contract-doc-body td,
.contract-doc-body th,
.contract-doc-body span,
.contract-doc-body div,
.contract-doc-body h2,
.contract-doc-body h4,
.contract-doc-body strong { font-family: Arial, Helvetica, sans-serif; font-size: 11pt; line-height: 1.5; }
/* Títulos de cláusula: Arial 11, negrita y centrados. */
.contract-doc-body h3 { font-family: Arial, Helvetica, sans-serif; font-size: 11pt; line-height: 1.5; font-weight: 700; text-align: center; }

/* Filas tipo stripe (zebra) en los listados */
.table-wrap table tbody tr:nth-child(even) { background: #f7f9fc; }
.table-wrap table tbody tr:hover { background: #eef4fb; }

/* Bitácora de movimientos (trazabilidad) */
.audit-card .stage-head { margin-bottom: 14px; }
.audit-timeline { position: relative; padding-left: 6px; }
.audit-item { position: relative; display: flex; gap: 14px; padding: 0 0 16px 0; }
.audit-item:last-child { padding-bottom: 0; }
.audit-dot { position: relative; flex: 0 0 12px; width: 12px; height: 12px; border-radius: 50%; background: #2f6fed; margin-top: 4px; box-shadow: 0 0 0 3px rgba(47,111,237,.15); }
.audit-item:not(:last-child) .audit-dot::after { content: ''; position: absolute; left: 50%; top: 14px; transform: translateX(-50%); width: 2px; height: calc(100% + 18px); background: #e3e8f0; }
.audit-body { flex: 1 1 auto; min-width: 0; }
.audit-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.audit-head strong { font-size: 13.5px; color: #1f2a44; }
.audit-time { font-size: 12px; color: #6b7280; font-variant-numeric: tabular-nums; white-space: nowrap; }
.audit-detail { font-size: 12.5px; color: #3a4256; margin-top: 2px; }
.audit-meta { font-size: 11.5px; margin-top: 3px; }

/* Footer de la aplicación */
.app-footer {
    margin-top: 32px;
    padding: 18px 4px 8px;
    border-top: 1px solid #e6ebf2;
    color: var(--muted, #64748b);
    font-size: 12.5px;
    text-align: center;
}
.app-footer strong { color: #334155; font-weight: 800; }

/* Modales anchos y con scroll (listados extensos) */
.modal-box.modal-wide { width: min(960px, 94vw); }
.modal-box.modal-form { height: auto; max-height: min(85vh, 900px); }

/* Botón "Const. de Sociedad": estado según disponibilidad del documento */
.doc-icon-btn.is-checking { opacity: .7; }
.doc-icon-btn.is-empty { opacity: .55; cursor: not-allowed; }
.doc-icon-btn.is-available {
    border-color: #16a34a;
    color: #14532d;
    background: #f0fdf4;
    animation: doc-halo-pulse 1.8s ease-out infinite;
}
.doc-icon-btn.is-available:hover { background: #dcfce7; border-color: #16a34a; color: #14532d; }
.doc-icon-btn.is-available svg { stroke: #16a34a; }
@keyframes doc-halo-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(22, 163, 74, .5); }
    70%  { box-shadow: 0 0 0 12px rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .doc-icon-btn.is-available { animation: none; box-shadow: 0 0 0 3px rgba(22,163,74,.25); }
}
.doc-available-text { color: #16a34a; font-weight: 700; }
.assoc-link { color: var(--blue); font-weight: 600; }
.validated-stamp { font-size: 10.5px; color: var(--muted); margin-top: 5px; letter-spacing: .01em; }

/* Modal de asociación de notaría */
.notary-assoc-form { padding: 18px; overflow: auto; }
.notary-assoc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.notary-assoc-grid .span-2 { grid-column: 1 / -1; }
.notary-assoc-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
@media (max-width: 640px) { .notary-assoc-grid { grid-template-columns: 1fr; } }
.modal-scroll { flex: 1; overflow: auto; padding: 12px 18px 18px; }
.modal-scroll table { width: 100%; }
.modal-box.modal-form form { padding: 16px 18px 18px; overflow: auto; }

/* Popup "Adjuntar a SAP": avance paso a paso */
/* Barra de progreso real de subida (garantía). */
.upload-bar { margin-top: 12px; height: 8px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.upload-bar > span { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--blue, #0f6cbd); transition: width .15s ease; }

.sap-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.sap-steps li { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; }
.sap-step-ic { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
    font-size: 12px; font-weight: 700; line-height: 1; color: #fff; }
.sap-step-ic.ok { background: #059669; }
.sap-step-ic.fail { background: #dc2626; }
.sap-step-ic.pending { background: transparent; border: 2px solid #cbd5e1; border-top-color: #0f6cbd;
    animation: sap-spin .7s linear infinite; }
@keyframes sap-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sap-step-ic.pending { animation: none; } }

/* Modal "Gestionar obra": personas de retiro + destinatarios del aviso */
.modal-box.pickup-modal { height: auto; max-height: min(85vh, 860px); }
.pickup-mgr { flex: 1; overflow: auto; padding: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; background: #f1f5f9; align-items: start; }
@media (max-width: 820px) { .pickup-mgr { grid-template-columns: 1fr; } }
.pickup-panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.pickup-panel > header { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 14px; }
.pickup-panel-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: #eff6ff; color: #0f6cbd; flex: none; }
.pickup-panel-icon.green { background: #ecfdf5; color: #059669; }
.pickup-panel header h4 { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink, #0f172a); }
.pickup-panel header p { margin: 3px 0 0; font-size: 12px; color: var(--muted); line-height: 1.4; }
.pickup-count { margin-left: auto; background: #e2e8f0; color: #334155; border-radius: 999px; font-size: 12px; font-weight: 700; padding: 3px 11px; min-width: 28px; text-align: center; flex: none; }
.pickup-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.pickup-list li { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; transition: border-color .12s, box-shadow .12s; }
.pickup-list li:hover { border-color: #cbd5e1; box-shadow: 0 1px 3px rgba(15,23,42,.06); }
.pickup-item-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pickup-item-main strong { font-size: 13px; font-weight: 600; color: var(--ink, #0f172a); }
.pickup-item-main span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pickup-empty { justify-content: center; color: var(--muted); font-size: 12.5px; border-style: dashed !important; background: #f8fafc; text-align: center; }
.pickup-remove { background: none; border: 0; cursor: pointer; color: #94a3b8; padding: 5px; border-radius: 8px; line-height: 0; flex: none; display: grid; place-items: center; transition: background .12s, color .12s; }
.pickup-remove:hover { background: #fee2e2; color: #dc2626; }
.pickup-add { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-top: 13px; border-top: 1px dashed var(--line); }
.pickup-add .full { grid-column: 1 / -1; }
.pickup-add .input { width: 100%; margin: 0; }
.pickup-add button { grid-column: 1 / -1; justify-self: start; }

/* Data-table: filtros por columna + orden */
.dt-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.dt-sortable:hover { color: var(--blue, #2f6fed); }
.dt-sortable[data-dir]::after { content: ' ▲'; font-size: 9px; opacity: .8; }
.dt-sortable[data-dir="desc"]::after { content: ' ▼'; }
.dt-filter-row th { padding: 4px 8px 8px; background: #f7f9fc; }
.dt-filter {
    width: 100%;
    min-width: 70px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 500;
    background: #fff;
}
.dt-filter:focus { outline: none; border-color: var(--blue, #2f6fed); box-shadow: 0 0 0 3px rgba(47,111,237,.12); }

/* Pill de estado con color de fondo y texto por contraste */
.status-pill {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.4;
    white-space: nowrap;
}

/* Cabecera de acciones del expediente: utilidades a la izquierda, CTA + eliminar a la derecha */
.detail-actions { align-items: center; row-gap: 8px; }
.detail-actions .push-right { margin-left: auto; }
@media (max-width: 720px) {
    .detail-actions .push-right { margin-left: 0; }
}

/* Diálogo del sistema (confirm/alert propios) */
.app-dialog {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center; padding: 20px;
    background: rgba(15, 23, 42, .5);
    --dlg-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E");
}
.app-dialog[hidden] { display: none; }
.app-dialog-box {
    width: min(460px, 100%); background: #fff; border-radius: 14px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .35);
    padding: 22px 22px 18px;
    display: grid; grid-template-columns: auto 1fr; gap: 6px 15px;
    animation: dlgIn .16s ease;
}
@keyframes dlgIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.app-dialog-icon {
    grid-row: 1 / span 2; width: 44px; height: 44px; border-radius: 50%;
    display: grid; place-items: center; background: #eff6ff; color: #2563eb;
}
.app-dialog-icon::before {
    content: ''; width: 24px; height: 24px; background-color: currentColor;
    -webkit-mask: var(--dlg-icon) center / contain no-repeat;
    mask: var(--dlg-icon) center / contain no-repeat;
}
.app-dialog.is-danger { --dlg-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2 1 21h22L12 2zm1 15h-2v-2h2v2zm0-4h-2V9h2v4z'/%3E%3C/svg%3E"); }
.app-dialog.is-danger .app-dialog-icon { background: #fef2f2; color: #dc2626; }
.app-dialog.is-alert { --dlg-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm-1.2 14.6-4-4 1.4-1.4 2.6 2.6 5.6-5.6 1.4 1.4-7 7z'/%3E%3C/svg%3E"); }
.app-dialog.is-alert .app-dialog-icon { background: #f0fdf4; color: #16a34a; }
.app-dialog-title { grid-column: 2; margin: 3px 0 0; font-size: 16px; font-weight: 850; color: #0f172a; }
.app-dialog-message { grid-column: 2; margin: 4px 0 0; font-size: 13.5px; line-height: 1.5; color: #475569; }
.app-dialog-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

/* Fila de radios (destinatario de notificación) */
.radio-row { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 4px; }
.radio-row .check-row { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: #334155; }

/* Buscador dentro de modales (listas largas) */
.modal-searchbar { padding: 12px 18px 0; }
.modal-searchbar .input { width: 100%; }

/* Menú "Más acciones" del expediente */
.detail-actions { align-items: center; gap: 8px; }
.detail-actions > .btn, .detail-actions .action-menu > summary { padding: 9px 15px; font-size: 13.5px; }
.action-menu { position: relative; }
.action-menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu[open] > summary { background: #eef4fb; border-color: #b7d4f6; }
.action-menu-panel {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
    min-width: 210px; background: #fff; border: 1px solid var(--line);
    border-radius: 10px; box-shadow: 0 16px 40px rgba(15, 23, 42, .16);
    padding: 6px; display: grid; gap: 2px;
}
.action-menu-panel form { margin: 0; }
.action-menu-item {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; box-sizing: border-box;
    padding: 9px 12px; border-radius: 7px; font-size: 13.5px; font-weight: 650;
    color: #334155; background: none; border: 0; cursor: pointer; text-decoration: none;
}
.action-menu-item svg { width: 16px; height: 16px; flex: 0 0 auto; opacity: .8; }
.action-menu-item:hover { background: #f1f5f9; }
.action-menu-item.is-danger { color: #dc2626; }
.action-menu-item.is-danger:hover { background: #fef2f2; }
.action-menu-item.is-disabled { color: #94a3b8; cursor: default; }
.action-menu-item.is-disabled:hover { background: none; }
.action-menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }

/* Cabecera del expediente: botones arriba, luego proveedor y obra */
.detail-head { flex-direction: column; align-items: stretch; gap: 14px; }
.detail-head .detail-actions { justify-content: flex-end; flex-wrap: wrap; }
.detail-head-title h2 { margin: 0; }
.detail-head-title .muted { margin-top: 2px; }

/* Paginación (vista propia vendor/pagination/app) */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pagination-info { color: var(--muted); font-size: 13px; }
.pagination-links { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pagination-links .btn { min-width: 36px; text-align: center; }
.pagination-links .btn.is-disabled { opacity: .5; pointer-events: none; }
.pagination-dots { color: var(--muted); padding: 0 4px; }

/* =====================================================================
   GESTOR DOCUMENTAL — capa propia
   Hereda los tokens de arriba (--blue, --green, --amber, --line…) y agrega
   el lenguaje visual del explorador: lomos de color por espacio, iconos de
   archivo con banda por familia y micro-badges de estado.
   ===================================================================== */

:root {
    --violet: #7c3aed;
    --cyan: #0891b2;
    --red: #dc2626;

    /* Familias de archivo: un color por tipo, usado en la banda del icono. */
    --k-pdf: #dc2626;
    --k-word: #1d4ed8;
    --k-excel: #15803d;
    --k-powerpoint: #ea580c;
    --k-dwg: #0891b2;
    --k-image: #7c3aed;
    --k-other: #64748b;
}

/* --- Colores de espacio (tiñen el lomo de las carpetas) --- */
.sp-blue   { --space-color: var(--blue-2); }
.sp-amber  { --space-color: var(--amber); }
.sp-green  { --space-color: var(--green); }
.sp-slate  { --space-color: var(--slate); }
.sp-orange { --space-color: var(--orange); }
.sp-violet { --space-color: var(--violet); }

/* --- Migas de pan --- */
.crumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 18px;
}
.crumbs a { color: var(--muted); padding: 4px 8px; border-radius: 7px; transition: .15s; }
.crumbs a:hover { color: var(--blue); background: var(--surface-2); }
.crumbs .sep { opacity: .4; }
.crumbs .current { color: var(--text); font-weight: 600; padding: 4px 8px; }

/* --- Barra de acciones del explorador --- */
.explorer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.explorer-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Rejilla de nodos --- */
.node-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 14px;
}

.node {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.node:hover {
    transform: translateY(-2px);
    border-color: #c7dcf5;
    box-shadow: var(--shadow);
}
.node-name {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.35;
    color: var(--text);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}
.node-meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.node-meta .dot { opacity: .4; }

/* --- Iconos: el lenguaje propio ---
   Carpeta = lomo de color del espacio. Archivo = glifo de linea con banda
   inferior del color de su familia. Trazo 1.5 sobre grilla 24, igual que la
   iconografia del sistema de contratos, pero con identidad de gestor. */
.doc-icon {
    width: 44px;
    height: 44px;
    display: block;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}
.doc-icon .spine   { stroke: var(--space-color, var(--blue-2)); stroke-width: 2.5; }
.doc-icon .body    { stroke: #94a3b8; }
.doc-icon .fold    { stroke: #94a3b8; }
.doc-icon .band    { stroke: var(--kind-color, var(--k-other)); stroke-width: 2.5; }
.doc-icon .mark    { stroke: var(--kind-color, var(--k-other)); }
.doc-icon .fill-soft { fill: var(--space-color, var(--blue-2)); opacity: .10; stroke: none; }

.k-pdf        { --kind-color: var(--k-pdf); }
.k-word       { --kind-color: var(--k-word); }
.k-excel      { --kind-color: var(--k-excel); }
.k-powerpoint { --kind-color: var(--k-powerpoint); }
.k-dwg        { --kind-color: var(--k-dwg); }
.k-image      { --kind-color: var(--k-image); }
.k-other      { --kind-color: var(--k-other); }

.node-icon { position: relative; width: 44px; height: 44px; }

/* --- Micro-badges de estado sobre el icono --- */
.node-badges {
    position: absolute;
    right: -4px;
    bottom: -3px;
    display: flex;
    gap: 3px;
}
.badge-chip {
    width: 17px;
    height: 17px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--surface);
    border: 1.5px solid var(--surface);
    box-shadow: 0 1px 4px rgba(15, 23, 42, .22);
}
.badge-chip svg { width: 11px; height: 11px; stroke-width: 2.2; fill: none; }
.badge-new    { background: var(--blue-2); }
.badge-new svg    { stroke: #fff; }
.badge-lock   { background: var(--amber); }
.badge-lock svg   { stroke: #111827; }
.badge-ai     { background: var(--green); }
.badge-ai svg     { stroke: #fff; }

/* Tooltip minimo para los badges */
.badge-chip[data-tip] { cursor: help; }

/* --- Tarjeta de espacio (portada) --- */
.space-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}
.space-card {
    position: relative;
    display: block;
    padding: 22px 22px 20px 26px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    transition: transform .16s ease, box-shadow .16s ease;
}
.space-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 6px;
    background: var(--space-color, var(--blue-2));
}
.space-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.space-card h3 { margin: 12px 0 6px; font-size: 17px; }
.space-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.space-card .space-stats {
    margin-top: 16px;
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--muted);
}
.space-card .space-stats strong { color: var(--text); font-size: 15px; display: block; }

/* --- Estado vacio --- */
.empty-state {
    text-align: center;
    padding: 56px 20px;
    color: var(--muted);
}
.empty-state svg { width: 62px; height: 62px; opacity: .35; margin-bottom: 14px; stroke-width: 1.2; fill: none; stroke: currentColor; }
.empty-state p { margin: 0 0 18px; font-size: 14px; }

/* --- Ajuste de iconografia: los badges se apilan al costado derecho en vez de
   montarse sobre el glifo, y el lomo del espacio gana presencia. --- */
.doc-icon { width: 46px; height: 46px; }
.node-icon { width: 46px; height: 46px; }
.doc-icon .spine { stroke-width: 3; }
.doc-icon .body, .doc-icon .fold { stroke: #8fa3bd; }

.node-badges {
    position: absolute;
    right: -9px;
    top: -2px;
    bottom: auto;
    flex-direction: column;
    gap: 2px;
}
.badge-chip { width: 15px; height: 15px; }
.badge-chip svg { width: 10px; height: 10px; }

/* --- Subida multiple: panel de progreso y velo de arrastre --- */
.drop-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(2px);
}
.drop-overlay-box {
    background: var(--surface);
    border: 2px dashed var(--blue-2);
    border-radius: 18px;
    padding: 44px 60px;
    text-align: center;
    box-shadow: var(--shadow);
}
.drop-overlay-box svg { width: 46px; height: 46px; stroke: var(--blue-2); stroke-width: 1.5; fill: none; }
.drop-overlay-box h3 { margin: 12px 0 4px; font-size: 18px; }
.drop-overlay-box p { margin: 0; color: var(--muted); font-size: 13px; }

.upload-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 55;
    width: 380px;
    max-width: calc(100vw - 48px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.upload-panel-head {
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
    font-size: 14px;
    background: var(--surface-2);
}
.upload-list { max-height: 300px; overflow-y: auto; }
.upload-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "name state" "track track";
    gap: 5px 10px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--line);
}
.upload-row:last-child { border-bottom: none; }
.upload-name {
    grid-area: name;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.upload-state { grid-area: state; font-size: 11px; color: var(--muted); white-space: nowrap; }
.upload-track {
    grid-area: track;
    height: 4px;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
}
.upload-bar { height: 100%; width: 0; background: var(--blue-2); border-radius: 999px; transition: width .18s ease; }

.upload-row.is-creado .upload-bar { background: var(--green); }
.upload-row.is-creado .upload-state { color: var(--green); }
.upload-row.is-versionado .upload-bar { background: var(--blue-2); }
.upload-row.is-versionado .upload-state { color: var(--blue); }
.upload-row.is-duplicado .upload-bar { background: var(--amber); }
.upload-row.is-duplicado .upload-state { color: #a16207; }
.upload-row.is-error .upload-bar { background: var(--red); }
.upload-row.is-error .upload-state { color: var(--red); }

/* --- Formulario en linea de nueva carpeta --- */
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form .input { height: 34px; padding: 6px 10px; font-size: 13px; width: 190px; }

/* --- Ficha de documento --- */
.doc-header {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 20px 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    margin-bottom: 18px;
}
.doc-header-info { flex: 1 1 auto; min-width: 0; }
.doc-header-info h2 { margin: 0 0 6px; font-size: 19px; word-break: break-word; }
.doc-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.doc-summary { margin: 0 0 12px; font-size: 14px; line-height: 1.6; color: var(--text); }

.markdown-view {
    margin: 0;
    padding: 18px;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 11px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    line-height: 1.65;
    max-height: 640px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--muted);
}
.pill-green { background: #dcfce7; color: #15803d; }
.pill-red { background: #fee2e2; color: #b91c1c; }
.text-right { text-align: right; }

/* El atributo `hidden` pierde contra un `display` explicito, y el velo invisible
   terminaba interceptando todos los clics del explorador. */
.drop-overlay[hidden],
.upload-panel[hidden] { display: none; }

/* --- Etapas del pipeline dentro de cada fila de subida --- */
.upload-panel { width: 420px; }
.upload-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "name state" "track track" "steps steps";
    gap: 6px 10px;
}
.upload-steps { grid-area: steps; display: flex; gap: 4px; margin-top: 2px; }
.step {
    flex: 1 1 0;
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .02em;
    padding: 3px 4px;
    border-radius: 6px;
    background: var(--surface-2);
    color: #94a3b8;
    border: 1px solid transparent;
    transition: .18s;
    white-space: nowrap;
}
.step.is-activo {
    background: #e8f1ff;
    color: var(--blue);
    border-color: #bfdbfe;
    animation: step-pulse 1.1s ease-in-out infinite;
}
.step.is-hecho { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.step.is-fallo { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }

@keyframes step-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .55; }
}

@media (prefers-reduced-motion: reduce) {
    .step.is-activo { animation: none; }
}

/* =====================================================================
   Explorador v2: barra de herramientas, vista lista y panel de detalles
   ===================================================================== */

.explorer-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.explorer-main { min-width: 0; }

@media (max-width: 1200px) {
    .explorer-layout { grid-template-columns: minmax(0, 1fr); }
    .details-pane { display: none; }
}

.explorer-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* Botones de vista: iconos / lista */
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.segmented a { display: grid; place-items: center; width: 34px; height: 32px; transition: .15s; }
.segmented a svg { width: 17px; height: 17px; stroke: #64748b; stroke-width: 1.8; fill: none; stroke-linecap: round; }
.segmented a:hover { background: var(--surface-2); }
.segmented a.active { background: var(--blue-2); }
.segmented a.active svg { stroke: #fff; }

/* Selector de orden */
.sorter { display: inline-flex; align-items: center; gap: 7px; }
.sorter label { font-size: 12px; color: var(--muted); }
.sorter .select { height: 32px; padding: 4px 26px 4px 9px; font-size: 13px; }
.sort-dir {
    display: grid; place-items: center;
    width: 32px; height: 32px;
    border: 1px solid var(--line); border-radius: 9px;
    background: var(--surface); transition: .15s;
}
.sort-dir:hover { border-color: #b7d4f6; background: var(--surface-2); }
.sort-dir svg { width: 15px; height: 15px; stroke: #64748b; stroke-width: 1.9; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* Vista de lista */
.node-list { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.node-list-head,
.node-row {
    display: grid;
    grid-template-columns: minmax(0, 2.6fr) 70px 84px 104px 104px 110px;
    gap: 12px;
    align-items: center;
    padding: 10px 16px;
}
.node-list-head {
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}
.node-row { border-bottom: 1px solid var(--line); transition: background .14s; font-size: 13px; }
.node-row:last-child { border-bottom: none; }
.node-row:hover { background: var(--surface-2); }
.node-row .col-name { display: flex; align-items: center; gap: 11px; min-width: 0; }
.node-row .doc-icon, .node-row .node-icon { width: 30px; height: 30px; flex: 0 0 auto; }
.node-row .node-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-row .badge-chip { width: 12px; height: 12px; }
.node-row .badge-chip svg { width: 8px; height: 8px; }
.node-row .node-badges { right: -7px; gap: 1px; }
.col-size, .col-version { color: var(--muted); }
.col-date { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Seleccion (un clic) */
.node.is-selected,
.node-row.is-selected {
    background: #eff6ff;
    border-color: var(--blue-2);
    box-shadow: 0 0 0 1px var(--blue-2) inset;
}

/* --- Panel lateral de detalles --- */
.details-pane {
    position: sticky;
    top: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
}
.details-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
}
.details-title { flex: 1 1 auto; min-width: 0; }
.details-title h3 { margin: 0 0 3px; font-size: 14.5px; line-height: 1.35; word-break: break-word; }
.details-kind { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.details-close {
    background: none; border: none; cursor: pointer;
    font-size: 22px; line-height: 1; color: var(--muted); padding: 0 2px;
}
.details-close:hover { color: var(--text); }

.details-section { padding: 15px 16px; border-bottom: 1px solid var(--line); }
.details-section h4 {
    margin: 0 0 10px;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    display: flex; align-items: baseline; gap: 7px;
}
.details-hint { font-size: 10.5px; font-weight: 500; text-transform: none; letter-spacing: 0; opacity: .8; }
.details-summary { margin: 0; font-size: 12.8px; line-height: 1.62; color: var(--text); }
.details-empty { margin: 0; font-size: 12.5px; color: var(--muted); font-style: italic; }

.details-facts { margin: 0; display: grid; gap: 7px; }
.details-facts > div { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; align-items: baseline; }
.details-facts dt { font-size: 11.5px; color: var(--muted); }
.details-facts dd { margin: 0; font-size: 12.5px; font-weight: 500; word-break: break-word; }

.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.people li { display: flex; align-items: flex-start; gap: 9px; }
.avatar {
    flex: 0 0 auto;
    width: 27px; height: 27px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--blue-2); color: #fff;
    font-size: 11.5px; font-weight: 700;
}
.avatar-alarm { background: var(--amber); color: #111827; }
.people-info { flex: 1 1 auto; min-width: 0; display: block; }
.people-info strong { display: block; font-size: 12.5px; font-weight: 600; }
.people-info small { display: block; font-size: 11px; color: var(--muted); }
.pill-level { flex: 0 0 auto; align-self: center; }
.pill-owner { background: #ede9fe; color: #6d28d9; }
.pill-editor { background: #dbeafe; color: #1d4ed8; }
.pill-contributor { background: #dcfce7; color: #15803d; }
.pill-viewer { background: var(--surface-2); color: var(--muted); }

.event-chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.event-chip {
    font-size: 9.5px; font-weight: 700;
    padding: 1.5px 6px; border-radius: 999px;
    background: var(--surface-2); color: var(--muted);
    text-transform: uppercase; letter-spacing: .03em;
}
.event-actualizado { background: #dbeafe; color: #1d4ed8; }
.event-eliminado { background: #fee2e2; color: #b91c1c; }
.event-movido { background: #fef3c7; color: #a16207; }
.event-subido { background: #dcfce7; color: #15803d; }

.details-actions { padding: 14px 16px; }

.details-pane.is-loading { opacity: .55; transition: opacity .12s; }

/* El correo bajo el nombre en la lista de acceso: se recorta en vez de romper la fila. */
.people-mail {
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* El icono grande es solo el ilustrativo del estado vacio, no el del boton. */
.empty-state .btn svg { width: 16px; height: 16px; opacity: .95; margin-bottom: 0; }

/* Aviso de solo lectura donde iria el boton de subida. */
.readonly-note {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    border: 1px dashed var(--line);
    border-radius: 9px;
    background: var(--surface);
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 500;
    cursor: help;
}
.readonly-note svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* =====================================================================
   Seleccion multiple y descarga
   ===================================================================== */

/* Las tarjetas dejaron de ser <a>: el cursor lo dice igual. */
.node { cursor: pointer; }
.node-row { cursor: pointer; }

/* Casilla de seleccion */
.node-check {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 3;
    display: grid;
    place-items: center;
    cursor: pointer;
}
.node-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.node-check span {
    display: block;
    width: 17px;
    height: 17px;
    border: 1.6px solid #cbd5e1;
    border-radius: 5px;
    background: var(--surface);
    transition: .14s;
    position: relative;
}
.node-check span::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1.5px;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform .14s;
}
.node-check input:checked + span { background: var(--blue-2); border-color: var(--blue-2); }
.node-check input:checked + span::after { transform: rotate(45deg) scale(1); }
.node-check input:focus-visible + span { box-shadow: 0 0 0 3px rgba(47, 111, 237, .3); }

/* En la rejilla la casilla y la descarga aparecen al pasar el cursor o si ya esta marcada */
.node { position: relative; }
.node .node-check,
.node .node-download { opacity: 0; transition: opacity .14s; }
.node:hover .node-check,
.node:hover .node-download,
.node.is-marked .node-check,
.node:focus-within .node-check,
.node:focus-within .node-download { opacity: 1; }

.node-download {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    transition: .14s;
}
.node-download:hover { background: var(--blue-2); border-color: var(--blue-2); }
.node-download svg { width: 15px; height: 15px; stroke: #64748b; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.node-download:hover svg { stroke: #fff; }

.node.is-marked { border-color: var(--blue-2); background: #f5f9ff; }

/* Lista: columna de casilla y de acciones */
.node-list-head,
.node-row { grid-template-columns: 34px minmax(0, 2.4fr) 68px 82px 100px 100px 46px; }
.col-check { display: flex; align-items: center; justify-content: center; }
.col-check .node-check { position: static; }
.col-actions { display: flex; align-items: center; justify-content: flex-end; }

.row-download {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    transition: .14s;
}
.row-download:hover { background: var(--surface-2); }
.row-download svg { width: 15px; height: 15px; stroke: #64748b; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.row-download:hover svg { stroke: var(--blue); }
.node-row.is-marked { background: #f5f9ff; }

/* Barra inferior de seleccion */
.select-bar {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    z-index: 58;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 16px 12px 20px;
    background: var(--slate);
    color: #fff;
    border-radius: 13px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, .35);
}
.select-bar[hidden] { display: none; }
.select-count { font-size: 13px; font-weight: 600; white-space: nowrap; }
.select-actions { display: flex; gap: 8px; }
.select-bar .btn-outline { background: transparent; color: #e2e8f0; border-color: rgba(226, 232, 240, .35); }
.select-bar .btn-outline:hover { background: rgba(226, 232, 240, .12); color: #fff; border-color: rgba(226, 232, 240, .6); }
.btn-zip { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.9; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* Con el panel de subida abierto, la barra se corre para no taparlo */
.upload-panel:not([hidden]) ~ .select-bar { left: auto; right: 24px; transform: none; bottom: 24px; }

/* En pantallas tactiles no hay hover: la casilla y la descarga van siempre visibles,
   o quedarian inalcanzables en tablet. */
@media (hover: none), (pointer: coarse) {
    .node .node-check,
    .node .node-download { opacity: 1; }
}

/* --- Buscador dentro de la carpeta --- */
.searchbox { position: relative; display: flex; align-items: center; }
.searchbox .input {
    height: 34px;
    padding: 6px 30px 6px 33px;
    font-size: 13px;
    width: 250px;
    border-radius: 9px;
}
.searchbox .input::-webkit-search-cancel-button { display: none; }
.searchbox-icon {
    position: absolute;
    left: 10px;
    width: 15px;
    height: 15px;
    stroke: #94a3b8;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    pointer-events: none;
}
.searchbox .input:focus + .searchbox-clear,
.searchbox .input:focus ~ .searchbox-icon { stroke: var(--blue-2); }
.searchbox-clear {
    position: absolute;
    right: 6px;
    width: 20px;
    height: 20px;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    border-radius: 5px;
}
.searchbox-clear:hover { color: var(--text); background: var(--surface-2); }
.searchbox-clear[hidden] { display: none; }

/* Los nodos ocultos por el filtro no deben ocupar celda en la rejilla. */
[data-node][hidden] { display: none !important; }

/* --- Popup de nueva carpeta sobre el dialogo del sistema --- */
#folder-dialog .app-dialog-body { grid-column: 2; }
#folder-dialog .field { margin-top: 12px; }
#folder-dialog .field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
#folder-dialog .app-dialog-icon { background: #eff6ff; color: var(--blue-2); }
#folder-dialog .app-dialog-icon::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M4 6.5h4l1.6 2H20a1 1 0 0 1 1 1V18a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6.5Z'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M4 6.5h4l1.6 2H20a1 1 0 0 1 1 1V18a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6.5Z'/%3E%3C/svg%3E");
}

/* =====================================================================
   Visor de archivos
   ===================================================================== */

.viewer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 13px;
    margin-bottom: 14px;
}
.viewer-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.viewer-title h2 { margin: 0 0 3px; font-size: 17px; word-break: break-word; }
.viewer-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.viewer-frame {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 13px;
    overflow: hidden;
    height: calc(100vh - 265px);
    min-height: 460px;
}
.viewer-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.viewer-note { margin: 10px 2px 0; font-size: 12.5px; color: var(--muted); }

/* Escenario con zoom y arrastre (imagenes y planos) */
.viewer-stage {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 13px;
    overflow: hidden;
    height: calc(100vh - 305px);
    min-height: 420px;
    display: grid;
    place-items: center;
    cursor: grab;
    touch-action: none;
}
.viewer-stage.is-dragging { cursor: grabbing; }
.viewer-stage img {
    max-width: 100%;
    max-height: 100%;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
}
/* Los planos se leen mejor sobre fondo claro y a ancho completo */
.viewer-plan { background: #fbfcfe; }
.viewer-plan img { max-width: none; max-height: none; width: 100%; }

.zoom-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 9px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 11px;
}
.zoom-btn {
    width: 30px; height: 30px;
    display: grid; place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    transition: .14s;
}
.zoom-btn:hover { border-color: #b7d4f6; background: var(--surface-2); }
.zoom-btn svg { width: 15px; height: 15px; stroke: #475569; stroke-width: 2; fill: none; stroke-linecap: round; }
.zoom-level { font-size: 12.5px; font-weight: 600; min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; }
.zoom-hint { margin-left: auto; font-size: 11.5px; color: var(--muted); }

.viewer-empty { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; }
.viewer-error { display: inline-block; margin-top: 8px; font-size: 12px; color: #b91c1c; }

/* --- Bitacora del documento --- */
.tally {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.tally-item {
    padding: 14px 16px;
    background: var(--surface-2);
    border-radius: 11px;
    border: 1px solid var(--line);
}
.tally-item strong { display: block; font-size: 24px; line-height: 1.1; color: var(--slate); }
.tally-item span { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); margin-top: 2px; }
.tally-item small { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }

.pill-audit { font-weight: 600; }
.pill-subio, .pill-nueva_version { background: #dcfce7; color: #15803d; }
.pill-visualizo { background: var(--surface-2); color: var(--muted); }
.pill-descargo, .pill-descargo_zip { background: #dbeafe; color: #1d4ed8; }
.pill-imprimio { background: #fef3c7; color: #a16207; }
.pill-rechazado_antivirus, .pill-elimino { background: #fee2e2; color: #b91c1c; }
.nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }

.btn-print { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* Al imprimir, solo el contenido */
@media print {
    .sidebar, .topbar, .app-footer, .crumbs, .viewer-actions, .zoom-bar, .select-bar, .upload-panel { display: none !important; }
    .app-shell { display: block; }
    .viewer-frame, .viewer-stage { border: none; height: auto; min-height: 0; }
}

/* =====================================================================
   Asistente
   ===================================================================== */

.chat-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .chat-layout { grid-template-columns: minmax(0, 1fr); } .chat-history { display: none; } }

.chat-history {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 14px;
    position: sticky;
    top: 20px;
}
.chat-history-list { margin-top: 12px; display: grid; gap: 4px; }
.chat-history-item { display: block; padding: 9px 10px; border-radius: 8px; transition: .14s; }
.chat-history-item:hover { background: var(--surface-2); }
.chat-history-item.active { background: #eff6ff; }
.chat-history-item strong { display: block; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-history-item small { display: block; font-size: 11px; color: var(--muted); }

.chat-main {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 13px;
    overflow: hidden;
    height: calc(100vh - 200px);
    min-height: 480px;
}
.chat-messages { flex: 1 1 auto; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 18px; }

.chat-welcome { margin: auto; text-align: center; max-width: 470px; padding: 20px; }
.chat-welcome .nav-icon { width: 46px; height: 46px; stroke: var(--blue-2); stroke-width: 1.4; margin-bottom: 12px; }
.chat-welcome h3 { margin: 0 0 8px; font-size: 18px; }
.chat-welcome p { margin: 0 0 20px; color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.chat-examples { display: grid; gap: 8px; }
.chat-example {
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: .14s;
}
.chat-example:hover { border-color: #b7d4f6; background: var(--surface-2); color: var(--blue); }

.chat-message { display: flex; gap: 11px; align-items: flex-start; }
.chat-message.is-user { flex-direction: row-reverse; }
.chat-avatar {
    flex: 0 0 auto;
    width: 30px; height: 30px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 11px; font-weight: 700;
    background: var(--blue-2); color: #fff;
}
.chat-message.is-assistant .chat-avatar { background: var(--green); }
.chat-bubble { max-width: 74%; padding: 12px 15px; border-radius: 13px; background: var(--surface-2); }
.chat-message.is-user .chat-bubble { background: var(--blue-2); color: #fff; }
.chat-text { font-size: 13.5px; line-height: 1.62; word-break: break-word; }

.chat-cites { margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); display: grid; gap: 5px; }
.chat-cites-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.chat-cite {
    display: flex; align-items: center; gap: 7px;
    font-size: 12px; font-weight: 500;
    padding: 5px 8px; border-radius: 7px;
    background: var(--surface); border: 1px solid var(--line);
    transition: .14s;
}
.chat-cite:hover { border-color: #b7d4f6; color: var(--blue); }
.chat-cite small { color: var(--muted); font-weight: 400; }
.chat-cite-n {
    flex: 0 0 auto;
    width: 17px; height: 17px;
    border-radius: 5px;
    display: grid; place-items: center;
    background: var(--blue-2); color: #fff;
    font-size: 10px; font-weight: 700;
}
.chat-cost { margin-top: 8px; font-size: 10.5px; color: var(--muted); }

.chat-form { border-top: 1px solid var(--line); padding: 14px 18px; background: var(--surface); }
.chat-input-row { display: flex; gap: 9px; }
.chat-scope { flex: 0 0 auto; width: 175px; }
.chat-input { flex: 1 1 auto; }
.chat-note { margin: 8px 2px 0; font-size: 11.5px; color: var(--muted); }

/* Una rejilla con columna implicita se dimensiona al contenido y desbordaba el
   panel del historial sobre la conversacion. minmax(0,1fr) la obliga a respetar
   el ancho y deja que el ellipsis haga su trabajo. */
.chat-history-list { grid-template-columns: minmax(0, 1fr); }
.chat-history-item { min-width: 0; }
.chat-scope { width: 195px; }

/* --- Comentarios --- */
.viewer-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.viewer-main { min-width: 0; }
.viewer-side {
    position: sticky;
    top: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 16px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}
@media (max-width: 1250px) {
    .viewer-layout { grid-template-columns: minmax(0, 1fr); }
    .viewer-side { position: static; max-height: none; }
}

.comments-title {
    margin: 0 0 12px;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    display: flex; align-items: baseline; gap: 7px;
}
.comment-form { margin-bottom: 16px; }
.comment-input { width: 100%; resize: vertical; font-size: 13px; line-height: 1.5; min-height: 66px; }
.comment-form-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.comment-version { font-size: 11px; color: var(--muted); }

.comment-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.comment { display: flex; gap: 10px; align-items: flex-start; }
.comment-body { flex: 1 1 auto; min-width: 0; }
.comment-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.comment-head strong { font-size: 12.5px; font-weight: 600; }
.comment-head time { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; cursor: help; }
.comment-head .pill { font-size: 10px; padding: 1px 7px; }
.comment-text { margin: 4px 0 0; font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.comment-delete {
    flex: 0 0 auto;
    border: none; background: none; cursor: pointer;
    color: var(--muted); font-size: 17px; line-height: 1;
    padding: 0 3px; border-radius: 5px; opacity: 0; transition: .14s;
}
.comment:hover .comment-delete, .comment:focus-within .comment-delete { opacity: 1; }
.comment-delete:hover { color: #dc2626; background: #fef2f2; }
@media (hover: none), (pointer: coarse) { .comment-delete { opacity: 1; } }

/* --- Compartir --- */
.share-box { max-width: 560px; width: 100%; display: block; padding: 0; }
.share-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.share-head .app-dialog-title { margin: 0; }
.share-tabs { display: flex; gap: 4px; padding: 14px 20px 0; border-bottom: 1px solid var(--line); }
.share-tab {
    border: none; background: none; cursor: pointer;
    padding: 9px 13px; font-size: 13px; font-weight: 600; color: var(--muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px; transition: .14s;
}
.share-tab:hover { color: var(--text); }
.share-tab.active { color: var(--blue); border-bottom-color: var(--blue-2); }
.share-panel { padding: 18px 20px 20px; }
.share-panel[hidden] { display: none; }
.share-panel .field { margin-bottom: 14px; }
.share-panel .field > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.share-note { margin: 0 0 16px; padding: 11px 13px; background: var(--surface-2); border-radius: 9px; font-size: 12.5px; line-height: 1.55; color: #334155; }
.share-search .input { width: 100%; }

.share-results { margin-top: 6px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; max-height: 230px; overflow-y: auto; }
.share-results[hidden] { display: none; }
.share-result { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; transition: .12s; border: none; background: none; width: 100%; text-align: left; }
.share-result:hover { background: var(--surface-2); }
.share-result .people-info strong { font-size: 12.5px; }
.share-result .people-info small { font-size: 11px; }
.share-result-tag { margin-left: auto; font-size: 10.5px; color: var(--muted); }

.share-picked { margin-top: 8px; display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 9px; }
.share-picked[hidden] { display: none; }

.share-levels { display: grid; gap: 8px; }
.share-level { display: flex; align-items: flex-start; gap: 9px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: .14s; }
.share-level:hover { border-color: #b7d4f6; background: #fbfdff; }
.share-level input { margin-top: 2px; }
.share-level strong { display: block; font-size: 13px; }
.share-level small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.share-level:has(input:checked) { border-color: var(--blue-2); background: #eff6ff; }

.share-list { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.share-list h5 { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.share-list-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.share-list-row .people-info { flex: 1 1 auto; min-width: 0; }
.share-list-row .comment-delete { opacity: 1; }

/* Pagina del destinatario externo */
.shared-body { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 24px; }
.shared-card { max-width: 430px; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 34px 30px; text-align: center; box-shadow: var(--shadow); }
.shared-logo { width: 170px; margin-bottom: 24px; }
.shared-card .node-icon { margin: 0 auto 14px; }
.shared-card .doc-icon { width: 56px; height: 56px; }
.shared-card h1 { margin: 0 0 6px; font-size: 18px; word-break: break-word; }
.shared-meta { margin: 0 0 20px; font-size: 12.5px; color: var(--muted); }
.shared-message { margin: 0 0 20px; padding: 12px 14px; background: var(--surface-2); border-radius: 9px; font-size: 13px; line-height: 1.55; text-align: left; }
.shared-foot { margin: 18px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.btn-share { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* Un boton deshabilitado igual debe dejar ver su tooltip explicativo. */
.btn:disabled[title] { pointer-events: auto; cursor: help; }
.details-actions { display: grid; gap: 7px; }
.topbar-meta strong { font-weight: 600; color: var(--text); }
.topbar-meta .pill { margin-left: 6px; }

/* --- Configuracion de alarmas --- */
.details-config { margin-left: auto; font-size: 10.5px; font-weight: 600; color: var(--blue); text-transform: none; letter-spacing: 0; }
.details-config:hover { text-decoration: underline; }
.alarm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; align-items: start; }
.alarm-events { display: grid; gap: 6px; }
.alarm-follow { margin-bottom: 16px; padding: 11px 13px; background: var(--surface-2); border-radius: 9px; }
.alarm-grid .field { margin-bottom: 16px; }
.alarm-grid .field > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.shared-card-wide { max-width: 520px; }
.shared-files { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 8px; text-align: left; max-height: 300px; overflow-y: auto; }
.shared-files li { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; }
.shared-files .doc-icon, .shared-files .node-icon { width: 28px; height: 28px; }

/* --- Bandeja de avisos --- */
.nav-badge {
    margin-left: auto;
    min-width: 19px;
    height: 19px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-grid;
    place-items: center;
}
.notice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.notice { display: flex; gap: 11px; align-items: flex-start; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; }
.notice.is-unread { background: #eff6ff; border-color: #bfdbfe; }
.notice-body { flex: 1 1 auto; min-width: 0; }
.notice-head { font-size: 12.8px; line-height: 1.5; }
.notice-head strong { font-weight: 600; }
.notice-head a { color: var(--blue); font-weight: 500; }
.notice-head a:hover { text-decoration: underline; }
.notice-head time { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.notice-text { margin: 5px 0 0; font-size: 12.5px; color: #475569; line-height: 1.55; }

/* --- Aviso de nombre repetido al subir --- */
.conflict-box { max-width: 620px; width: 100%; display: block; padding: 18px 20px 20px; }
.conflict-bulk { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.conflict-list { display: grid; gap: 10px; max-height: 340px; overflow-y: auto; }
.conflict-row { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.conflict-name { font-size: 13px; font-weight: 600; word-break: break-word; }
.conflict-current { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.conflict-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
@media (max-width: 620px) { .conflict-options { grid-template-columns: 1fr; } }
.conflict-option {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
    cursor: pointer; transition: .14s; font-size: 12.5px;
}
.conflict-option:hover { border-color: #b7d4f6; background: #fbfdff; }
.conflict-option:has(input:checked) { border-color: var(--blue-2); background: #eff6ff; }
.conflict-option strong { display: block; font-size: 12.5px; }
.conflict-option small { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }

/* Familia de archivos de diseño (Illustrator, Photoshop, InDesign, TIFF) */
:root { --k-design: #db2777; }
.k-design { --kind-color: var(--k-design); }
/* Etiqueta con la extension dentro del icono, para formatos sin glifo propio */
.doc-icon .mark-text {
    fill: var(--kind-color, var(--k-other));
    stroke: none;
    font-size: 6px;
    font-weight: 800;
    letter-spacing: .02em;
    font-family: Inter, system-ui, sans-serif;
}

/* --- Ficha del formato cuando no hay vista previa --- */
.formato-card {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 26px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 13px;
    margin-top: 14px;
}
.formato-icono { flex: 0 0 auto; }
.formato-icono .doc-icon, .formato-icono .node-icon { width: 64px; height: 64px; }
.formato-info { flex: 1 1 auto; min-width: 0; }
.formato-info h3 { margin: 0 0 8px; font-size: 17px; }
.formato-resumen { margin: 0 0 10px; font-size: 13.5px; line-height: 1.62; color: #334155; max-width: 62ch; }
.formato-software { margin: 0 0 16px; font-size: 12.5px; color: var(--muted); }
.formato-software strong { color: var(--text); }

/* --- Portada de carpeta --- */
.node.has-cover { padding: 0; overflow: hidden; }
.node-cover { height: 108px; background: var(--surface-2); overflow: hidden; }
.node-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s ease; }
.node.has-cover:hover .node-cover img { transform: scale(1.04); }
.node.has-cover .node-name { padding: 12px 14px 0; }
.node.has-cover .node-meta { padding: 0 14px 14px; }
.node.has-cover .node-check { top: 10px; left: 10px; }
.node.has-cover .node-check span { box-shadow: 0 1px 5px rgba(15, 23, 42, .3); }

.details-cover { width: 100%; height: 118px; object-fit: cover; border-radius: 9px; margin-bottom: 10px; display: block; }
.cover-form { display: grid; gap: 7px; }
.cover-form .input { font-size: 11.5px; padding: 6px; }
.details-config-form { margin-left: auto; display: inline; }

/* --- Visor de planos DXF --- */
.plano-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .plano-layout { grid-template-columns: minmax(0, 1fr); } }

.plano-principal { position: relative; }
.plano-lienzo {
    height: calc(100vh - 300px);
    min-height: 460px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 13px;
    overflow: hidden;
}
.plano-lienzo canvas { display: block; }

.plano-estado {
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    padding: 11px 18px;
    background: var(--slate);
    color: #fff;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow);
}
.plano-estado[hidden] { display: none; }
.plano-estado.is-error { background: #b91c1c; max-width: 420px; text-align: center; line-height: 1.5; }

.plano-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 14px;
    position: sticky;
    top: 20px;
}
.plano-barra { display: grid; gap: 7px; margin-bottom: 14px; }
.plano-barra .zoom-hint { margin: 0; font-size: 11px; }
.plano-capas-acciones { display: flex; gap: 6px; margin-bottom: 10px; }
.plano-capas-acciones .btn { flex: 1 1 0; }
.plano-capas { max-height: calc(100vh - 470px); min-height: 180px; overflow-y: auto; display: grid; gap: 2px; }

.capa { display: flex; align-items: center; gap: 7px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.capa:hover { background: var(--surface-2); }
.capa input { flex: 0 0 auto; }
.capa-color { flex: 0 0 auto; width: 11px; height: 11px; border-radius: 3px; border: 1px solid rgba(15,23,42,.2); }
.capa-nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Visor de PDF propio (PDF.js) --- */
.pdf-layout { display: grid; grid-template-columns: 136px minmax(0, 1fr); gap: 12px; align-items: start; }
.pdf-layout:not(:has(.pdf-miniaturas)) { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 900px) { .pdf-layout { grid-template-columns: minmax(0, 1fr); } .pdf-miniaturas { display: none; } }

.pdf-miniaturas {
    display: grid; gap: 8px;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
    padding: 8px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 11px;
}
.pdf-mini {
    border: 2px solid transparent; border-radius: 7px; background: #fff;
    padding: 0; cursor: pointer; display: grid; justify-items: center; gap: 2px;
    overflow: hidden; transition: border-color .14s;
}
.pdf-mini canvas { display: block; width: 100%; height: auto; }
.pdf-mini span { font-size: 10.5px; color: var(--muted); padding-bottom: 3px; }
.pdf-mini:hover { border-color: #b7d4f6; }
.pdf-mini.active { border-color: var(--blue-2); }
.pdf-mini.active span { color: var(--blue); font-weight: 700; }

.pdf-principal { min-width: 0; }
.pdf-barra {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 12px; margin-bottom: 10px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
}
.pdf-contador { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pdf-contador strong { color: var(--text); }
.pdf-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

.pdf-lienzo-caja {
    position: relative;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 16px;
    height: calc(100vh - 330px);
    min-height: 420px;
    overflow: auto;
    display: grid;
    place-items: start center;
}
#pdf-lienzo { background: #fff; box-shadow: 0 4px 18px rgba(15, 23, 42, .12); border-radius: 3px; }

/* --- Confirmacion escrita --- */
.confirm-box { max-width: 470px; }
#confirm-dialog .app-dialog-icon { background: #fef2f2; color: #dc2626; }
#confirm-dialog .app-dialog-body { grid-column: 2; }
#confirm-dialog .field { margin-top: 14px; }
#confirm-dialog .field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
#confirm-dialog .field label strong { color: #b91c1c; letter-spacing: .06em; }
#confirm-dialog .input { text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

/* --- Panel de subida al centro --- */
.upload-overlay {
    position: fixed; inset: 0; z-index: 54;
    background: rgba(15, 23, 42, .38);
    backdrop-filter: blur(1.5px);
}
.upload-overlay[hidden] { display: none; }

.upload-panel {
    left: 50%; top: 50%; right: auto; bottom: auto;
    transform: translate(-50%, -50%);
    width: 520px;
    z-index: 56;
}
.upload-panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    font-size: 14.5px;
}
.upload-porcentaje { font-size: 17px; color: var(--blue); font-variant-numeric: tabular-nums; }
.upload-global { height: 6px; background: var(--line); }
.upload-global-bar {
    height: 100%; width: 0;
    background: linear-gradient(90deg, var(--blue-2), var(--green));
    transition: width .25s ease;
}
.upload-list { max-height: 46vh; }

/* Con el panel al centro, la barra de seleccion vuelve a su posicion normal */
.upload-panel:not([hidden]) ~ .select-bar { left: 50%; right: auto; transform: translateX(-50%); }
.shared-formato { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); }
.pdf-lienzo-caja { cursor: grab; touch-action: pan-x pan-y; }
.pdf-lienzo-caja.is-dragging { cursor: grabbing; }
.pdf-lienzo-caja canvas { user-select: none; -webkit-user-drag: none; }
.vinieta-datos { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); display: grid; gap: 8px 20px; }
.vinieta-datos > div { grid-template-columns: 92px minmax(0, 1fr); }

/* --- Espacios en el menu lateral --- */
.nav-space { display: flex; align-items: center; gap: 10px; }
.nav-space-dot {
    flex: 0 0 auto;
    width: 9px; height: 9px;
    border-radius: 3px;
    background: var(--space-color, var(--blue-2));
}
.nav-space.active .nav-space-dot { box-shadow: 0 0 0 3px rgba(15, 108, 189, .18); }
.nav-sub { font-size: 12.5px; opacity: .75; }
.nav-sub .nav-icon { width: 16px; height: 16px; }

/* --- Panel de detalles colapsable --- */
.details-close {
    display: grid; place-items: center;
    width: 26px; height: 26px;
    border: none; background: none; cursor: pointer;
    border-radius: 7px; color: var(--muted);
    font-size: 20px; line-height: 1;
    transition: .14s;
}
.details-close svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.details-close:hover { background: rgba(15, 23, 42, .07); color: var(--text); }

/* Pestaña de reapertura, pegada al borde derecho */
.panel-abrir {
    display: none;
    position: fixed;
    right: 0; top: 50%;
    transform: translateY(-50%);
    z-index: 40;
    align-items: center; gap: 6px;
    padding: 14px 8px;
    border: 1px solid var(--line); border-right: none;
    border-radius: 11px 0 0 11px;
    background: var(--surface);
    box-shadow: -3px 0 14px rgba(15, 23, 42, .08);
    cursor: pointer;
    writing-mode: vertical-rl;
    font-size: 11.5px; font-weight: 700;
    letter-spacing: .06em; text-transform: uppercase;
    color: var(--muted);
    transition: .16s;
}
.panel-abrir svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.panel-abrir:hover { color: var(--blue); border-color: #b7d4f6; padding-right: 12px; }

.explorer-layout.panel-oculto { grid-template-columns: minmax(0, 1fr); }
.explorer-layout.panel-oculto .details-pane { display: none; }
.explorer-layout.panel-oculto .panel-abrir { display: flex; }

/* Programacion de obra (Microsoft Project) */
:root { --k-project: #0f766e; }
.k-project { --kind-color: var(--k-project); }

/* --- Favoritos --- */
.nav-empty {
    margin: 0 0 6px;
    padding: 2px 12px 8px;
    font-size: 11.5px; line-height: 1.5;
    color: var(--muted);
}

.nav-favs { display: flex; flex-direction: column; }
.nav-fav { position: relative; padding-left: 26px; }
.nav-fav .nav-fav-name {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-fav-grip {
    position: absolute; left: 4px; top: 50%;
    transform: translateY(-50%);
    display: grid; place-items: center;
    width: 16px; height: 18px;
    opacity: 0; cursor: grab;
    transition: opacity .14s;
}
.nav-fav-grip svg {
    width: 14px; height: 14px;
    stroke: currentColor; stroke-width: 2.4; fill: none; stroke-linecap: round;
}
.nav-fav:hover .nav-fav-grip { opacity: .55; }
.nav-fav-grip:active { cursor: grabbing; }
.nav-fav.dragging { opacity: .45; }
.nav-favs.dragging-any .nav-fav { transition: none; }

/* Boton de la barra del explorador */
.btn-fav svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linejoin: round; }
.btn-fav.is-fav { color: #b45309; border-color: #f0cf95; background: #fffbeb; }
.btn-fav.is-fav svg { fill: #f59e0b; stroke: #d97706; }

/* Renombrar carpeta desde el panel de detalles */
.rename-form { display: flex; flex-direction: column; gap: 8px; }
.rename-form .input { font-size: 12.8px; }
.rename-form .btn { align-self: flex-start; }

/* El dialogo de confirmacion tambien sirve para acciones no destructivas */
.dialog-normal .app-dialog-icon { background: #eff6ff; color: var(--blue); }

/* --- Aviso de plano archivado en otro proyecto --- */
.alert-warn {
    border-color: #fde68a;
    border-left-color: #f59e0b;
    background: #fffbeb;
    color: #92400e;
    --alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2 1 21h22L12 2zm1 15h-2v-2h2v2zm0-4h-2V9h2v4z'/%3E%3C/svg%3E");
}
.alert-proyecto p { margin: 4px 0 0; }
.alert-proyecto small { display: block; margin-top: 6px; opacity: .82; font-size: 12.2px; }

.badge-alerta { background: #f59e0b; color: #fff; }
.badge-alerta svg { stroke: currentColor; stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.details-alerta { background: #fffbeb; border-bottom-color: #fde68a; }
.details-alerta h4 { color: #b45309; }
.details-alerta .details-summary { color: #92400e; }
.avatar-sistema { background: #f59e0b; color: #fff; font-weight: 700; }

/* --- Etiquetas de clasificacion --- */
.tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 11px; font-weight: 600; line-height: 1.6;
    white-space: nowrap;
    cursor: pointer;
    transition: .13s;
}
.tag form { display: inline-flex; }
.tag form button {
    border: none; background: none; cursor: pointer;
    padding: 0; margin-right: -2px;
    font-size: 14px; line-height: 1;
    color: inherit; opacity: .5;
}
.tag form button:hover { opacity: 1; }

.tag-azul   { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.tag-verde  { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.tag-ambar  { background: #fffbeb; border-color: #fde68a; color: #b45309; }
.tag-rojo   { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.tag-morado { background: #f5f3ff; border-color: #ddd6fe; color: #6d28d9; }
.tag-cian   { background: #ecfeff; border-color: #a5f3fc; color: #0e7490; }
.tag-rosa   { background: #fdf2f8; border-color: #fbcfe8; color: #be185d; }
.tag-gris   { background: #f1f5f9; border-color: #e2e8f0; color: #475569; }

.node-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; justify-content: center; }
.node-list .node-tags { margin: 0 0 0 8px; justify-content: flex-start; }
.node-tags .tag:hover { filter: brightness(.96); transform: translateY(-1px); }

.tag-list { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.tag-list .tag { cursor: default; }

.tag-form { display: flex; gap: 7px; }
.tag-form .input { flex: 1 1 auto; min-width: 0; font-size: 12.5px; }
.viewer-tags { margin: 7px 0 0; }

/* Aviso dentro del panel de subida cuando la cola no corre */
.upload-cola-detenida { margin: 0 14px 12px; font-size: 12.5px; padding: 11px 13px; }
.upload-cola-detenida p { margin: 3px 0 0; }
.details-config.is-off { color: var(--muted); opacity: .6; cursor: not-allowed; }

/* --- ¿Va en esta carpeta el plano? --- */
.project-box { max-width: 520px; }
.app-dialog-icon-warn { background: #fffbeb; color: #b45309; }
.project-compare {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    margin: 14px 0 10px;
}
.project-compare div {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-2, #f8fafc);
    min-width: 0;
}
.project-compare dt {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted); margin-bottom: 4px;
}
.project-compare dd { margin: 0; font-size: 13px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.project-compare div:first-child { border-color: #fde68a; background: #fffbeb; }
.project-compare div:first-child dd { color: #92400e; }

.project-nota { margin: 0; font-size: 12.2px; line-height: 1.5; color: var(--muted); }
.project-actions { flex-wrap: wrap; gap: 8px; }
.project-sin-destino { flex: 1 1 100%; font-size: 11.8px; color: var(--muted); text-align: right; }

/* --- Red de seguridad para [hidden] ---
   `hidden` es una regla del navegador y cualquier clase con display propio le
   gana: .btn { display: inline-flex } dejaba visible un boton oculto. Ya paso
   antes con la capa de arrastre. Se cierra el problema de una vez. */
[hidden] { display: none !important; }

/* El destino puede ser una ruta larga: se apila bajo la etiqueta */
.btn-mover {
    flex-direction: column; align-items: flex-start; gap: 2px;
    text-align: left; padding: 9px 14px; flex: 1 1 100%;
}
.btn-mover-label { font-size: 12.5px; }
.btn-mover-ruta { font-size: 11px; font-weight: 500; opacity: .85; line-height: 1.35; }

/* Alcance y cupo del asistente */
.chat-alcance { font-size: 12.5px; color: var(--muted); margin-top: -4px; }
.chat-cupo { color: var(--muted); }
.chat-cupo.is-bajo { color: #b45309; font-weight: 600; }

/* --- El corpóreo de Santolaya IA --- */
.chat-avatar-ia {
    /* Grande y con la cara encuadrada: a 30 px y de cuerpo entero el corporeo
       no se reconocia, que es justamente el punto de ponerlo. */
    width: 52px; height: 52px;
    padding: 0;
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 1px 5px rgba(15, 23, 42, .07);
}
.chat-avatar-ia img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}

.chat-corporeo {
    width: 190px; height: auto;
    margin: 0 auto 4px;
    display: block;
    /* La foto viene con fondo blanco: una sombra suave la asienta sobre el
       panel sin tener que recortarla. */
    filter: drop-shadow(0 8px 18px rgba(15, 23, 42, .12));
}

.chat-pensando { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13.5px; }
.chat-puntos { display: inline-flex; gap: 3px; }
.chat-puntos i {
    width: 5px; height: 5px; border-radius: 50%;
    background: currentColor; opacity: .35;
    animation: chat-latido 1.1s infinite ease-in-out;
}
.chat-puntos i:nth-child(2) { animation-delay: .18s; }
.chat-puntos i:nth-child(3) { animation-delay: .36s; }
@keyframes chat-latido {
    0%, 60%, 100% { opacity: .25; transform: translateY(0); }
    30%           { opacity: .9;  transform: translateY(-3px); }
}

/* Quien prefiere no ver movimiento, no lo ve. */
@media (prefers-reduced-motion: reduce) {
    .chat-puntos i { animation: none; }
}
.chat-cite.is-ayuda { cursor: default; background: #f8fafc; }
.chat-cite.is-ayuda .chat-cite-n { background: var(--muted); }

/* --- Borrar una conversación del asistente --- */
.chat-history-row {
    display: flex; align-items: center; gap: 2px;
    border-radius: 8px;
    transition: background .14s;
}
.chat-history-row:hover { background: var(--surface-2); }
.chat-history-row.active { background: #eff6ff; }
/* El fondo lo pinta la fila: si no, se ven dos rectangulos encajados. */
.chat-history-row .chat-history-item { flex: 1 1 auto; min-width: 0; background: none; }
.chat-history-row .chat-history-item:hover { background: none; }

.chat-history-borrar {
    flex: 0 0 auto;
    display: grid; place-items: center;
    width: 28px; height: 28px;
    margin-right: 5px;
    border: none; background: none; cursor: pointer;
    border-radius: 7px;
    color: var(--muted);
    /* Oculto hasta que se apunta la fila: una papelera por conversación
       compite con el título, que es lo que uno viene a leer. */
    opacity: 0;
    transition: .14s;
}
.chat-history-borrar svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.chat-history-row:hover .chat-history-borrar { opacity: .65; }
.chat-history-borrar:hover { opacity: 1 !important; background: #fee2e2; color: #b91c1c; }
/* Con teclado tambien se llega: si solo apareciera al pasar el mouse, no. */
.chat-history-borrar:focus-visible { opacity: 1; outline: 2px solid var(--blue); outline-offset: 1px; }
