:root {
    color-scheme: light;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-alt: #eef1f8;
    --text: #1f2933;
    --muted: #5f6b7b;
    --primary: #2563eb;
    --primary-soft: #dbeafe;
    --danger: #dc2626;
    --success: #059669;
    --warning: #d97706;
    --border: #e2e8f0;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
}

.hidden {
    display: none !important;
}

[hidden] {
    display: none !important;
}

.layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px;
    background: linear-gradient(135deg, #f8fafc, #dbeafe);
}

.login-card {
    background: #fff;
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.15);
    max-width: 420px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.login-heading {
    display: flex;
    align-items: center;
    gap: 16px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-error {
    color: var(--danger);
    min-height: 20px;
    margin: 0;
}

.turnstile-container {
    min-height: 65px;
}

.sidebar {
    background: #e8ecfb;
    color: #1f2933;
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 24px;
    border-right: 1px solid var(--border);
}

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

.logo {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: #d7def5;
    display: grid;
    place-items: center;
    font-weight: 600;
    color: var(--primary);
}

.logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo.has-image {
    background: transparent;
}

.label {
    margin: 0;
    font-weight: 600;
}

.sidebar small {
    color: rgba(31, 41, 51, 0.6);
}

.module-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.module-menu button {
    background: #f9fbff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 10px;
    color: inherit;
    text-align: left;
    padding: 12px 14px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.module-menu button.active,
.module-menu button:hover {
    background: #ffffff;
    border-color: var(--primary-soft);
    color: var(--primary);
}

.module-menu button.logout {
    margin-top: 12px;
    background: #fff5f5;
    border-color: rgba(220, 38, 38, 0.25);
    color: #b91c1c;
}

.module-menu button.logout:hover,
.module-menu button.logout:focus {
    background: #fee2e2;
    color: #991b1b;
}

.menu-placeholder {
    background: #f3f4f6;
    border: 1px dashed rgba(15, 23, 42, 0.15);
    border-radius: 10px;
    color: rgba(15, 23, 42, 0.6);
    text-align: left;
    padding: 12px 14px;
    font-size: 0.95rem;
    cursor: not-allowed;
}

.menu-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.menu-group-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    border: none;
    color: inherit;
    font-weight: 600;
    padding: 8px 4px;
    cursor: pointer;
}

.menu-group-toggle .caret {
    font-size: 0.8rem;
    opacity: 0.7;
}

.menu-group-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 8px;
}

.workspace {
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.panel-header {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.panel-header h1 {
    margin: 0;
    font-size: 1.8rem;
}

.header-user {
    font-size: 0.95rem;
    color: var(--muted);
    min-height: 32px;
    text-align: right;
}

.header-user strong {
    color: var(--text);
}

.eyebrow {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    margin: 0 0 4px;
    color: var(--muted);
}

.muted {
    color: var(--muted);
    margin: 4px 0 0;
}

.header-actions {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.date-filter {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.date-filter .input-label input {
    min-width: 150px;
}

.header-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-label {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    color: var(--muted);
}

.input-label input,
.input-label select {
    margin-top: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    min-width: 180px;
}

.primary {
    background: var(--primary);
    border: none;
    color: #fff;
    padding: 12px 18px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

.secondary {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
}

.ghost {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

.primary,
.secondary,
.ghost {
    font-family: inherit;
    line-height: 1.2;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.primary:hover {
    filter: brightness(0.95);
}

.secondary:hover,
.ghost:hover {
    background: #e2e8f0;
}

.primary:focus-visible,
.secondary:focus-visible,
.ghost:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.primary:disabled,
.secondary:disabled,
.ghost:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.file-input {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.file-input::file-selector-button,
.file-input::-webkit-file-upload-button {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 600;
}

.dashboard {
    background: var(--surface);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.1);
}

.dashboard-cards {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 16px;
}

.dashboard-group {
    margin-top: 0;
}

.dashboard-group h3 {
    margin: 0 0 10px;
    font-size: 1rem;
}

.dashboard-period {
    margin-top: 16px;
}

.dashboard-group .cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    overflow: visible;
}

.dashboard-group .cards .card {
    min-width: 0;
}

.dashboard-wide-card {
    width: 100%;
    box-sizing: border-box;
}

.dashboard-criteria-card .muted {
    margin: 0 0 8px;
}

.dashboard-criteria-card .muted:last-child {
    margin-bottom: 0;
}

.dashboard-criteria-card .muted strong {
    display: inline;
    font-size: inherit;
}

.dashboard-bank-detail {
    grid-column: span 2;
}

@media (max-width: 920px) {
    .dashboard-bank-detail {
        grid-column: span 1;
    }
}

@media (max-width: 1200px) {
    .dashboard-group .cards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 920px) {
    .dashboard-group .cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .dashboard-group .cards {
        grid-template-columns: minmax(0, 1fr);
    }

    .inline-actions {
        grid-template-columns: minmax(0, 1fr);
    }
}

.config-card {
    display: flex;
    gap: 24px;
    align-items: center;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface-alt);
}

.config-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.update-preview {
    display: grid;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-alt);
}

.update-preview strong {
    color: var(--text);
}

.update-preview span,
.update-preview small {
    display: block;
}

.danger-text {
    color: var(--danger);
    font-weight: 600;
}

.config-card.stack {
    flex-direction: column;
    align-items: stretch;
}

.config-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}

.config-logo-wrapper {
    width: 96px;
    height: 96px;
    display: grid;
    place-items: center;
    background: #fff;
    border-radius: 24px;
    border: 1px solid var(--border);
}

.config-card img {
    max-width: 80px;
    max-height: 80px;
    object-fit: contain;
}

.config-card .logo {
    background: var(--primary-soft);
    color: var(--primary);
}

.config-values {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px 16px;
    margin: 0;
    padding: 0;
}

.config-values dt {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin: 0;
}

.config-values dd {
    margin: 0;
    font-weight: 600;
}

.inline-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
}

.inline-actions input {
    min-width: 0;
}

.config-card input[type="text"],
.config-card input[type="number"],
.config-card input[type="email"],
.config-card input[type="url"],
.config-card input[type="password"],
.config-card select,
.config-card textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    min-height: 42px;
    background: #fff;
    color: var(--text);
    font-size: 0.95rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.config-card input[readonly] {
    background: #f8fafc;
    color: var(--muted);
}

.config-card input:focus,
.config-card select:focus,
.config-card textarea:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.compact-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.condiciones-html {
    width: 100%;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    line-height: 1.6;
}

.condiciones-html ul,
.condiciones-html ol {
    padding-left: 20px;
    margin: 0;
}

.condiciones-html li {
    margin: 4px 0;
}

.config-assets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    overflow-x: hidden;
    margin-top: 16px;
}

.asset-upload {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
}

.asset-header h4 {
    margin: 0;
}

.asset-header .muted {
    margin: 4px 0 0;
}

.asset-preview {
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
    padding: 12px;
    min-height: 120px;
    display: grid;
    place-items: center;
    background: var(--surface-alt);
    width: 100%;
}

.asset-preview img {
    max-width: 100%;
    max-height: 220px;
    object-fit: contain;
}

.asset-preview.plantilla img {
    max-height: 320px;
}

.branding-upload-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

.branding-upload-form input[type="file"] {
    width: 100%;
}

.branding-upload-form input[type='file'] {
    flex: 1;
}

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

.card {
    padding: 16px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: var(--surface-alt);
}

.dashboard-drill-card {
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.dashboard-drill-card:hover,
.dashboard-drill-card:focus {
    border-color: #2563eb;
    box-shadow: 0 8px 20px rgba(37, 99, 235, .12);
    outline: none;
    transform: translateY(-1px);
}

.drilldown-hint {
    display: inline-block;
    margin-top: 8px;
    font-size: 12px;
    color: #2563eb;
    font-weight: 700;
}

.card strong {
    display: block;
    font-size: 1.4rem;
}

.card .muted {
    margin-top: 4px;
    line-height: 1.35;
}

.card > .badge {
    margin-top: 10px;
    display: inline-flex;
}

.card.destaque {
    background: #f0f6ff;
    border-color: rgba(37, 99, 235, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 6px;
}

.module {
    background: var(--surface);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}


.module-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    min-height: 32px;
    margin-bottom: 20px;
}

.module-filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.module-filter-bar label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 150px;
    font-size: 0.78rem;
    color: var(--muted);
}

.module-filter-bar select {
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 10px;
    background: var(--surface);
    color: var(--text);
}

.module-filter-bar .primary,
.module-filter-bar .ghost {
    min-height: 38px;
}

.meta-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 160px;
}

.meta-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.meta-tools {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.meta-pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.meta-tools .icon-button {
    width: 36px;
    height: 36px;
}

.segmented {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.segmented button {
    min-height: 32px;
    border: 0;
    border-radius: 6px;
    padding: 0 12px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.segmented button.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.meta-page {
    font-weight: 500;
}

.meta-actions {
    display: flex;
    gap: 8px;
}

.meta-actions .ghost {
    border: 1px solid var(--border);
    background: transparent;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
}

.meta-actions .ghost:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

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

.list-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.list-summary article {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    background: #f8fafc;
}

.list-summary span,
.list-summary small {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
}

.list-summary strong {
    display: block;
    margin-top: 4px;
    color: var(--text);
    font-size: 1.05rem;
}

.module-loading,
.empty-state {
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 22px;
    background: #f8fafc;
    color: var(--muted);
}

.module-loading {
    display: flex;
    align-items: center;
    gap: 10px;
}

.module-loading p,
.empty-state p {
    margin: 0;
}

.empty-state strong {
    display: block;
    color: var(--text);
    margin-bottom: 6px;
}

.loading-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #2563eb;
    animation: pulse-dot 1s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: .35; transform: scale(.85); }
    50% { opacity: 1; transform: scale(1.1); }
}

.trace-modal {
    max-width: 720px;
}

.trace-chain {
    display: grid;
    gap: 10px;
}

.trace-step {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
}

.trace-step.active {
    border-color: #2563eb;
    background: #eff6ff;
}

.trace-index {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #334155;
    font-weight: 700;
}

.trace-step p {
    margin: 2px 0 0;
    color: var(--muted);
}

.table-pagination {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
    color: var(--muted);
}

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

th, td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 0.92rem;
}

th {
    color: var(--muted);
    font-weight: 500;
}

.sort-button {
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    cursor: pointer;
    width: 100%;
    justify-content: flex-start;
}

.sort-button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.sort-label {
    flex: 1;
}

.sort-icon {
    font-size: 0.8rem;
    color: var(--muted);
}

tr:hover {
    background: var(--surface-alt);
}

.panel-footer {
    margin-top: auto;
    padding: 8px 0 0;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
}

.badge.pendiente { background: #fef3c7; color: #92400e; }
.badge.pagado { background: #dcfce7; color: #166534; }
.badge.sin_facturar { background: #ede9fe; color: #5b21b6; }
.badge.sin_ejecutar { background: #e2e8f0; color: #1e293b; }
.badge.pagada { background: #d1fae5; color: #065f46; }
.badge.vencida { background: #fee2e2; color: #b91c1c; }
.badge.activo { background: #dcfce7; color: #166534; }
.badge.inactivo { background: #fee2e2; color: #b91c1c; }
.badge.neutral { background: #e2e8f0; color: #334155; }

.chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 500;
}

.chip-ok { background: #dcfce7; color: #166534; }
.chip-alerta { background: #fef3c7; color: #92400e; }
.chip-error { background: #fee2e2; color: #b91c1c; }
.chip-neutral { background: rgba(15, 23, 42, 0.08); color: #0f172a; }
.chip-pagada { background: #bbf7d0; color: #166534; }

.icon-button {
    border: none;
    border-radius: 12px;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease, background 0.15s ease;
}
.icon-button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}
.icon-button span[aria-hidden="true"] {
    font-size: 1.1rem;
}

.icon-button.ghost {
    background: var(--surface-alt);
    color: var(--text);
}

.icon-button.ghost:hover {
    background: var(--surface);
}
.icon-button.attachment-trigger {
    color: var(--primary);
}

.icon-button.danger {
    background: var(--danger);
    color: #fff;
}

.icon-button.danger:hover {
    background: #991b1b;
}

.icon-badge {
    position: absolute;
    top: -6px;
    left: -6px;
    min-width: 22px;
    height: 22px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.table-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-start;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

th.col-nowrap,
td.col-nowrap {
    white-space: nowrap;
}

.drawer {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 40px;
    transition: opacity 0.2s ease;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
    overflow-y: auto;
}

.drawer.as-page {
    position: static;
    inset: auto;
    background: transparent;
    display: block;
    padding: 0;
    opacity: 1;
    pointer-events: all;
}

.drawer.visible {
    opacity: 1;
    pointer-events: all;
}

.drawer-card {
    width: min(480px, 100%);
    background: #fff;
    border-radius: 24px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.drawer.as-page .drawer-card {
    width: 100%;
    max-width: 100%;
    max-height: none;
    margin: 0 0 24px;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px 20px 24px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 15;
}

.modal-card {
    background: var(--surface);
    border-radius: 18px;
    padding: 24px;
    width: min(520px, 100%);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal.visible {
    opacity: 1;
    pointer-events: all;
}


.selector-modal-body {
    display: flex;
    flex-direction: column;
}

.selector-select-wrap {
    margin-top: 12px;
}

.selector-select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.95rem;
    color: var(--text);
    background-color: #fff;
}

.selector-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.confirm-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 14px;
    line-height: 1.5;
}

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

.attachments-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.attachments-list {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
    max-height: 260px;
    overflow-y: auto;
}

.attachment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.attachment-item:last-child {
    border-bottom: none;
}

.attachment-item strong {
    display: block;
}

.attachment-actions {
    display: flex;
    gap: 8px;
}

.attachment-actions a,
.attachment-actions button {
    border: none;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.attachment-actions a {
    background: var(--surface-alt);
    color: var(--primary);
    text-decoration: none;
}

.attachment-actions button {
    background: var(--danger);
    color: #fff;
}

.attachment-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.import-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.import-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.import-results {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    min-height: 80px;
    background: var(--surface-alt);
}

.import-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
}

.import-summary span {
    font-size: 0.9rem;
    font-weight: 600;
}

.import-errors {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.import-errors li {
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.drawer-card header,
.modal-card header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.drawer-card .icon,
.modal-card .icon {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

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

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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


.form-section-title {
    grid-column: 1 / -1;
    margin-top: 8px;
    gap: 8px;
}

.form-section-title h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text);
}

.form-section-title hr {
    width: 100%;
    border: 0;
    border-top: 1px solid var(--border);
    margin: 0;
}


.form-field input,
.form-field select,
.form-field textarea {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    font-size: 0.95rem;
}

.richtext-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.richtext-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.richtext-toolbar button {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
}

.richtext-toolbar .richtext-color {
    width: 34px;
    min-width: 34px;
    padding: 6px;
    display: inline-grid;
    place-items: center;
}

.richtext-toolbar .richtext-icon {
    width: 34px;
    min-width: 34px;
    padding: 6px;
    display: inline-grid;
    place-items: center;
}

.richtext-toolbar .richtext-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    display: block;
}

.richtext-toolbar .richtext-color span {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.16);
    display: block;
}

.richtext-area {
    min-height: 160px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    background: #fff;
    font-weight: 400;
    font-style: normal;
    text-align: left;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
}

.richtext-area,
.richtext-area div,
.richtext-area p,
.richtext-area li,
.richtext-area span {
    font-weight: 400;
}

.richtext-area b,
.richtext-area strong,
.richtext-area b *,
.richtext-area strong * {
    font-weight: 700;
}

.richtext-area[data-user-bold="0"] b,
.richtext-area[data-user-bold="0"] strong,
.richtext-area[data-user-bold="0"] b *,
.richtext-area[data-user-bold="0"] strong * {
    font-weight: 400 !important;
}

.richtext-area:empty,
.richtext-area:empty:focus {
    font-weight: 400;
    font-style: normal;
    text-align: left;
}

.richtext-area:empty:before {
    content: attr(data-placeholder);
    color: var(--muted);
    pointer-events: none;
}

.richtext-area:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.richtext-hidden {
    display: none;
}

.tercero-combobox {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tercero-combobox .tercero-search {
    width: 100%;
}

.items-field {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.items-list .simple-table {
    width: 100%;
}

.items-list .simple-table th,
.items-list .simple-table td {
    padding: 6px 8px;
    text-align: left;
}

.item-name {
    font-weight: 600;
}

.item-description {
    color: var(--muted);
    font-size: 0.9rem;
    white-space: pre-line;
    margin-top: 2px;
}

.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
    padding: 4px 0;
}

.permission-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.permission-option input {
    margin: 0;
}

textarea {
    min-height: 120px;
}

.form-actions {
    margin-top: 16px;
    display: flex;
    gap: 12px;
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text);
    color: #fff;
    padding: 14px 20px;
    border-radius: 999px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 60;
    pointer-events: none;
}

.toast.visible {
    opacity: 1;
}

.budget-editor {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px 20px 28px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.05);
}

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

.budget-summary {
    display: none;
}

.budget-chip {
    background: #f4f7fb;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    text-align: center;
}

.budget-chip h4 {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
}

.budget-chip p {
    margin: 2px 0 0;
    font-size: 16px;
    font-weight: 600;
}

.budget-form .form-grid {
    margin-bottom: 16px;
}

.budget-form textarea[name="condiciones_comerciales"] {
    min-height: 140px;
}

.items-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    background: #fafbff;
}

.items-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.items-card__header #budget-add-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    min-height: 38px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
    border: none;
    color: #fff;
    background: var(--primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    transition: background 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
}

.items-card__header #budget-add-item:hover {
    background: var(--primary-strong);
}

.items-card__header #budget-add-item:active {
    transform: translateY(1px);
}

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

.items-card__body th,
.items-card__body td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.items-card__body th:last-child,
.items-card__body td:last-child {
    text-align: right;
}

.items-card__body .table-actions {
    justify-content: flex-end;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.budget-item-card {
    max-height: min(88vh, 820px);
    overflow: hidden;
}

.budget-item-card .modal-form {
    min-height: 0;
    overflow: visible;
}

.budget-item-card .richtext-area {
    height: clamp(160px, 30vh, 260px);
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    border-color: var(--border);
    outline: none;
}

.budget-item-card .form-actions {
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.budget-item-card .richtext-area:focus {
    border-color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary), 0 0 0 2px rgba(37, 99, 235, 0.12);
    outline: none;
}

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

.budget-empty {
    margin: 0;
    color: var(--muted);
}

.budget-totals {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}

.budget-total-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
}

.budget-total-card p {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 13px;
}

.budget-total-card strong {
    font-size: 16px;
}

.lookup-combobox {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lookup-input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    width: 100%;
}

.badge.task {
    background: #eef2ff;
    color: #1d4ed8;
}

.badge.task.completada {
    background: #ecfdf3;
    color: #166534;
}

.badge.task.cancelada {
    background: #fef2f2;
    color: #991b1b;
}

.badge.priority {
    background: #f1f5f9;
    color: #0f172a;
}

.badge.priority.critical {
    background: #fef2f2;
    color: #991b1b;
}

.badge.priority.high {
    background: #fff7ed;
    color: #c2410c;
}

.badge.priority.low {
    background: #ecfeff;
    color: #0f766e;
}

.calendar-popup__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.calendar-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f8fafc;
}

.calendar-item .title {
    margin: 4px 0;
    font-weight: 600;
}

.calendar-popup .modal-card {
    max-width: 720px;
}

.calendar-panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    margin-top: 8px;
}

.calendar-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: #fff;
}

.calendar-card__header {
    margin-bottom: 8px;
}

.calendar-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.calendar-note {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    background: #f8fafc;
}

.product-history-panel {
    grid-column: 1 / -1;
}

.product-history-panel .full-width {
    grid-column: 1 / -1;
}

.product-history-note {
    display: grid;
    gap: 8px;
}

.product-history-toolbar,
.history-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 10px;
}

.product-history-toolbar .compact {
    min-width: 150px;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    color: var(--muted);
    font-size: 0.86rem;
}

.history-summary {
    align-items: center;
    color: var(--muted);
    font-size: 0.84rem;
}

.history-summary span {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 9px;
    background: #f8fafc;
}

.history-alert {
    margin: 0;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 8px;
    background: #fef2f2;
    color: #991b1b;
    font-weight: 700;
    font-size: 0.84rem;
}

.history-note__header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.history-diff {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin: 0;
}

.history-diff div {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    background: #fff;
}

.history-diff dt {
    margin: 0 0 3px;
    color: var(--muted);
    font-size: 0.72rem;
}

.history-diff dd {
    margin: 0;
    color: var(--text);
    font-weight: 700;
    font-size: 0.84rem;
}

.calendar-comment-form .form-actions.inline {
    justify-content: flex-start;
}

.calendar-month {
    min-width: 980px;
}

.calendar-month-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 14px;
}

.calendar-month-toolbar h2 {
    margin: 2px 0 0;
    font-size: 1.25rem;
}

.calendar-month-controls {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.calendar-month-controls .compact {
    min-width: 190px;
}

.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 0.82rem;
}

.calendar-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #64748b;
    margin-right: -6px;
}

.calendar-dot.tarea { background: #2563eb; }
.calendar-dot.cxc { background: #16a34a; }
.calendar-dot.cxp { background: #dc2626; }
.calendar-dot.servicio { background: #7c3aed; }
.calendar-dot.informe { background: #0f766e; }
.calendar-dot.contrato { background: #c2410c; }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--border);
    gap: 1px;
}

.calendar-weekday,
.calendar-day {
    background: var(--surface);
}

.calendar-weekday {
    padding: 10px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.calendar-day {
    min-height: 138px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.calendar-day.is-outside {
    background: #f8fafc;
    color: #94a3b8;
}

.calendar-day.is-today {
    box-shadow: inset 0 0 0 2px #2563eb;
}

.calendar-day.is-drop-target {
    background: #eff6ff;
    box-shadow: inset 0 0 0 2px #2563eb;
}

.calendar-day header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 700;
}

.calendar-day header strong {
    min-width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: #e2e8f0;
    color: #334155;
    font-size: 0.72rem;
}

.calendar-events {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.calendar-event {
    width: 100%;
    border: 0;
    border-left: 3px solid #64748b;
    border-radius: 6px;
    padding: 6px 7px;
    background: #f1f5f9;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    display: grid;
    gap: 2px;
}

.calendar-event span,
.calendar-event small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-event span {
    font-size: 0.78rem;
    font-weight: 700;
}

.calendar-event small {
    color: var(--muted);
    font-size: 0.7rem;
}

.calendar-event:hover {
    background: #e2e8f0;
}

.calendar-event[draggable="true"] {
    cursor: grab;
}

.calendar-event[draggable="true"]:active {
    cursor: grabbing;
}

.calendar-event.is-recurring {
    background: #eef2ff;
}

.calendar-event.tarea { border-left-color: #2563eb; }
.calendar-event.cxc { border-left-color: #16a34a; }
.calendar-event.cxp { border-left-color: #dc2626; }
.calendar-event.servicio { border-left-color: #7c3aed; }
.calendar-event.informe { border-left-color: #0f766e; }
.calendar-event.contrato { border-left-color: #c2410c; }

.calendar-more {
    color: var(--muted);
    font-size: 0.74rem;
}

@media (max-width: 960px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 16px;
    }
    .module-menu {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

@media (max-width: 640px) {
    .header-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .modal-card {
        padding: 16px;
    }

    .calendar-month {
        min-width: 0;
    }

    .calendar-month-toolbar,
    .calendar-month-controls {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        align-items: stretch;
        justify-content: stretch;
    }

    .calendar-month-controls .secondary,
    .calendar-month-controls .compact,
    .calendar-month-controls select {
        width: 100%;
    }

    .calendar-legend {
        font-size: 0.78rem;
    }

    .calendar-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
        border: 0;
        background: transparent;
        overflow: visible;
    }

    .calendar-weekday,
    .calendar-day.is-outside {
        display: none;
    }

    .calendar-day {
        min-height: 0;
        border: 1px solid var(--border);
        border-radius: 10px;
    }

    .calendar-event span,
    .calendar-event small {
        white-space: normal;
    }
}

.informe-fotos-input {
    display: none;
}

.informe-fotos-field {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.informe-fotos-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.informe-fotos-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    background: var(--surface-alt);
}

.informe-fotos-item span {
    font-size: 0.9rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.informe-fotos-preview {
    width: 100%;
    max-height: 180px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
}

.informe-fotos-observacion {
    width: 100%;
    min-height: 68px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.88rem;
    resize: vertical;
    font-family: inherit;
}

.primary.danger {
    background: var(--danger);
}

.primary.danger:hover {
    filter: brightness(0.95);
}

.informe-fotos-field {
    align-items: flex-start;
}

.informe-fotos-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}

.informe-fotos-item {
    min-width: 180px;
    max-width: 320px;
}

.menu-section-label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(15, 23, 42, 0.65);
    padding: 8px 10px 2px;
}

.price-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

#budget-item-price-selector {
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 1rem;
}

#budget-item-price-selector:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.permissions-matrix {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    width: 100%;
}

.permission-matrix-row {
    display: grid;
    grid-template-columns: minmax(180px, 240px) repeat(4, minmax(85px, 1fr));
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--line, #dfe3ea);
    border-radius: 8px;
    min-width: 0;
}

.permission-matrix-row strong {
    font-size: 0.9rem;
    line-height: 1.2;
}

.permission-matrix-row .permission-option {
    min-width: 0;
    white-space: nowrap;
}

@media (max-width: 1100px) {
    .permission-matrix-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

    .permission-matrix-row .permission-option {
        display: inline-flex;
        margin-right: 14px;
    }
}


tr.row-no-pagada td {
  color: #b91c1c;
  text-decoration: line-through;
}

.mobile-topbar,
.mobile-menu-backdrop,
.mobile-menu-close {
    display: none;
}

@media (max-width: 960px) {
    body.mobile-menu-open {
        overflow: hidden;
    }

    .layout {
        display: block;
        min-height: 100vh;
    }

    .mobile-topbar {
        position: fixed;
        inset: 0 0 auto 0;
        z-index: 30;
        height: 64px;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 14px;
        background: rgba(255, 255, 255, 0.96);
        border-bottom: 1px solid var(--border);
        box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
        backdrop-filter: blur(14px);
    }

    .mobile-menu-button {
        width: 44px;
        height: 44px;
        display: inline-grid;
        place-items: center;
        flex: 0 0 auto;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: #fff;
        cursor: pointer;
    }

    .mobile-menu-button span,
    .mobile-menu-button::before,
    .mobile-menu-button::after {
        content: "";
        width: 18px;
        height: 2px;
        display: block;
        border-radius: 999px;
        background: var(--text);
    }

    .mobile-menu-button span {
        box-shadow: 0 -6px 0 var(--text), 0 6px 0 var(--text);
    }

    .mobile-menu-button::before,
    .mobile-menu-button::after {
        display: none;
    }

    .mobile-brand {
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 2px;
        line-height: 1.1;
    }

    .mobile-brand strong,
    .mobile-brand small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-brand strong {
        font-size: 0.95rem;
    }

    .mobile-brand small {
        color: var(--muted);
        font-size: 0.78rem;
    }

    .mobile-menu-backdrop {
        position: fixed;
        inset: 0;
        z-index: 34;
        display: block;
        background: rgba(15, 23, 42, 0.48);
        opacity: 0;
        transition: opacity 0.2s ease;
    }

    .mobile-menu-backdrop[hidden] {
        display: none;
    }

    body.mobile-menu-open .mobile-menu-backdrop {
        opacity: 1;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 35;
        width: min(88vw, 340px);
        height: 100dvh;
        flex-direction: column;
        flex-wrap: nowrap;
        padding: 18px 16px 20px;
        gap: 16px;
        overflow-y: auto;
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        box-shadow: 18px 0 40px rgba(15, 23, 42, 0.2);
        border-right: 1px solid rgba(15, 23, 42, 0.12);
    }

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

    .branding {
        position: sticky;
        top: -18px;
        z-index: 1;
        margin: -18px -16px 0;
        padding: 18px 16px 14px;
        background: #e8ecfb;
        border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    }

    .branding .logo {
        width: 42px;
        height: 42px;
        border-radius: 12px;
    }

    .branding > div:nth-child(2) {
        min-width: 0;
        flex: 1;
    }

    .branding .label,
    .branding small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-menu-close {
        width: 38px;
        height: 38px;
        display: inline-grid;
        place-items: center;
        flex: 0 0 auto;
        border: 1px solid rgba(15, 23, 42, 0.1);
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.75);
        color: var(--text);
        font-size: 1.4rem;
        line-height: 1;
        cursor: pointer;
    }

    .module-menu {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 8px;
        padding-bottom: 12px;
    }

    .module-menu button,
    .menu-placeholder {
        width: 100%;
        min-height: 44px;
        border-radius: 12px;
        padding: 11px 12px;
        font-size: 0.94rem;
    }

    .menu-group {
        gap: 6px;
    }

    .menu-group-toggle {
        min-height: 42px;
        padding: 10px 8px;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.38);
    }

    .menu-group-items {
        gap: 7px;
        padding-left: 10px;
        border-left: 2px solid rgba(37, 99, 235, 0.18);
    }

    .menu-section-label {
        padding: 8px 4px 0;
    }

    .workspace {
        padding: 82px 16px 22px;
        gap: 18px;
    }

    .panel-header {
        gap: 12px;
    }

    .header-top {
        align-items: flex-start;
        gap: 8px;
    }

    .panel-header h1 {
        font-size: 1.35rem;
        line-height: 1.2;
    }

    .header-user {
        width: 100%;
        min-height: auto;
        text-align: left;
        font-size: 0.84rem;
    }

    .header-actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
        align-items: stretch;
        width: 100%;
    }

    .header-actions .input-label,
    .date-filter,
    .header-buttons {
        width: 100%;
    }

    .date-filter {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        max-width: 100%;
        min-width: 0;
    }

    .date-filter .input-label,
    .date-filter .input-label span {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .date-filter .input-label input,
    .input-label input,
    .input-label select,
    .primary,
    .secondary,
    .file-input {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        min-height: 44px;
    }

    .date-filter input[type="date"] {
        appearance: none;
        -webkit-appearance: none;
        box-sizing: border-box;
    }

    .header-buttons {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

    .dashboard,
    .module,
    .budget-editor {
        border-radius: 16px;
        padding: 16px;
        box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
    }

    .dashboard h2,
    .budget-header h2 {
        font-size: 1.12rem;
        line-height: 1.25;
    }

    .module-meta,
    .meta-controls,
    .meta-pagination,
    .meta-tools,
    .meta-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .module-filter-bar {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        padding: 10px;
    }

    .module-filter-bar label,
    .module-filter-bar select {
        width: 100%;
        min-width: 0;
    }

    .table-wrapper {
        width: calc(100% + 32px);
        margin-inline: -16px;
        padding-inline: 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-inline: contain;
    }

    table {
        min-width: 680px;
    }

    th,
    td {
        padding: 10px 8px;
        font-size: 0.86rem;
    }

    .list-summary {
        grid-template-columns: minmax(0, 1fr);
    }

    .trace-step {
        grid-template-columns: 28px minmax(0, 1fr);
    }

    .trace-step .primary,
    .trace-step .secondary,
    .trace-step .ghost {
        grid-column: 2;
        width: auto;
    }

    .drawer {
        align-items: flex-end;
        justify-content: center;
        padding: 0;
        z-index: 40;
    }

    .drawer-card {
        width: 100%;
        max-height: 92dvh;
        border-radius: 18px 18px 0 0;
        padding: 18px 16px 20px;
    }

    .drawer.as-page .drawer-card {
        border-radius: 16px;
        padding: 16px;
    }

    .modal {
        align-items: flex-end;
        padding: 0;
        z-index: 45;
    }

    .modal-card {
        width: 100%;
        max-height: 92dvh;
        border-radius: 18px 18px 0 0;
        padding: 18px 16px 20px;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .budget-item-card {
        overflow: hidden;
    }

    .budget-item-card .modal-form {
        max-height: none;
        overflow: visible;
    }

    .budget-item-card .richtext-area {
        height: clamp(150px, 32dvh, 240px);
        overflow-y: auto;
    }

    .form-grid,
    .modal-grid,
    .calendar-panels {
        grid-template-columns: minmax(0, 1fr);
    }

    .form-actions,
    .confirm-actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

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

    .config-card,
    .items-card,
    .asset-upload {
        border-radius: 12px;
        padding: 14px;
    }

    .config-card-header,
    .budget-header,
    .items-card__header {
        align-items: flex-start;
        flex-direction: column;
    }

    .modal-card,
    .drawer-card,
    .budget-editor,
    .module,
    .dashboard {
        max-width: 100%;
    }
}

@media (max-width: 640px) {
    .date-filter {
        grid-template-columns: minmax(0, 1fr);
    }

    table {
        min-width: 620px;
    }
}

@media (max-width: 420px) {
    .workspace {
        padding-inline: 12px;
    }

    .dashboard,
    .module,
    .budget-editor {
        padding: 14px;
    }

    .table-wrapper {
        width: calc(100% + 28px);
        margin-inline: -14px;
        padding-inline: 14px;
    }
}

/* UX operativa 2026-05-21: ajustes visuales transversales */
.sidebar {
    background: #e9eefc;
}

.module-menu {
    gap: 7px;
}

.module-menu button {
    border-color: rgba(37, 99, 235, 0.08);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.module-menu button.active {
    background: #ffffff;
    border-color: rgba(37, 99, 235, 0.42);
    color: var(--primary);
    box-shadow: inset 4px 0 0 var(--primary), 0 8px 18px rgba(37, 99, 235, 0.1);
    font-weight: 700;
}

.module-menu button:hover:not(.active) {
    border-color: rgba(37, 99, 235, 0.22);
    background: #fdfefe;
}

.menu-group-toggle {
    color: #334155;
    letter-spacing: 0.01em;
}

.menu-group-items {
    border-left: 2px solid rgba(37, 99, 235, 0.12);
    padding-left: 10px;
}

.menu-section-label {
    color: #64748b;
}

.table-wrapper {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.table-wrapper table {
    margin: 0;
}

th {
    background: #f8fafc;
    color: #475569;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

td {
    vertical-align: middle;
}

tbody tr {
    transition: background 0.12s ease;
}

tbody tr:hover {
    background: #f8fbff;
}

.badge,
.chip {
    min-height: 24px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.icon-button {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    flex: 0 0 42px;
    padding: 0;
    border: 1px solid transparent;
    line-height: 1;
}

.icon-button svg {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
}

.icon-button.ghost {
    padding: 0;
    border-color: var(--border);
    background: #f8fafc;
    color: #334155;
}

.icon-button.ghost:hover {
    background: #eef6ff;
    border-color: rgba(37, 99, 235, 0.28);
    color: var(--primary);
}

.icon-button.danger {
    padding: 0;
    border-color: rgba(220, 38, 38, 0.12);
}

.icon-button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.table-actions {
    align-items: center;
    gap: 8px;
    min-width: max-content;
    white-space: nowrap;
}

td:has(.table-actions) {
    width: 1%;
    white-space: nowrap;
}

.module-loading,
.empty-state {
    margin: 0;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(180deg, #f8fafc, #ffffff);
}

.empty-state {
    display: grid;
    gap: 4px;
    min-height: 112px;
    align-content: center;
}

.module-filter-bar {
    border-radius: 12px;
}

.module-filter-bar select,
.module-filter-bar input,
.input-label input,
.input-label select,
textarea {
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.module-filter-bar select:focus,
.module-filter-bar input:focus,
.input-label input:focus,
.input-label select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.drawer-card,
.modal-card {
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.form-actions {
    border-top: 1px solid var(--border);
    padding-top: 14px;
}

@media (max-width: 960px) {
    .table-wrapper {
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }

    .table-actions {
        gap: 10px;
    }

    .icon-button {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        flex-basis: 44px;
    }

    .icon-button svg {
        width: 21px;
        height: 21px;
    }
}

/* UX spacing hotfix 2026-05-21: separar contenedores internos del marco general */
.module > .table-wrapper,
.module > .config-stack,
.module > .config-card {
    width: auto;
    margin-left: 6px;
    margin-right: 6px;
}

.table-wrapper {
    padding: 12px 14px 14px;
}

.table-wrapper > table {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.table-wrapper th:first-child,
.table-wrapper td:first-child {
    padding-left: 14px;
}

.table-wrapper th:last-child,
.table-wrapper td:last-child {
    padding-right: 14px;
}

.table-pagination {
    margin-top: 0;
    padding: 14px 2px 0;
    align-items: center;
    gap: 10px;
}

.table-pagination .secondary,
.table-pagination .ghost,
.table-pagination button {
    min-height: 36px;
}

.config-card.stack {
    gap: 18px;
    padding: 22px;
}

.config-assets {
    margin-top: 4px;
    padding: 4px;
}

.config-stack {
    gap: 18px;
}

.config-stack > .config-card {
    margin-left: 0;
    margin-right: 0;
}

.asset-upload,
.config-card {
    background-clip: padding-box;
}

@media (max-width: 960px) {
    .module > .table-wrapper,
    .module > .config-stack,
    .module > .config-card {
        margin-left: 0;
        margin-right: 0;
    }

    .table-wrapper {
        padding: 10px 12px 12px;
        width: 100%;
        margin-inline: 0;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
        border-radius: 12px;
    }

    .table-pagination {
        justify-content: flex-start;
        flex-wrap: wrap;
        padding-top: 12px;
    }

    .config-card.stack {
        padding: 16px;
    }

    .config-assets {
        padding: 2px;
    }
}
