/* SGI — componentes compartidos (Programa Premium P1) */

.sgi-sync-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.875rem;
    margin-bottom: 1rem;
    background: #fff;
    border: 1px solid var(--sgi-border, #e2e8f0);
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
    font-size: 13px;
    color: #475569;
}

.sgi-sync-bar-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.sgi-sync-bar-icon {
    color: var(--sgi-accent-ui, #c80000);
    flex-shrink: 0;
}

.sgi-sync-time {
    color: #0f172a;
    font-weight: 600;
}

.sgi-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.sgi-page-header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
    margin: 0;
}

.sgi-page-header-sub {
    font-size: 13px;
    color: #64748b;
    margin: 0.25rem 0 0;
}

.sgi-card {
    background: #fff;
    border: 1px solid var(--sgi-border, #e2e8f0);
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.05);
}

.sgi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.sgi-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f8fafc;
    text-align: left;
    font-weight: 600;
    color: #334155;
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid #e2e8f0;
}

.sgi-table tbody td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.sgi-table tbody td.p-4 {
    padding: 0.4rem 0.6rem;
}

.sgi-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.45rem;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
}

.sgi-badge--activo { background: #dcfce7; color: #166534; }
.sgi-badge--pausado { background: #fef3c7; color: #92400e; }
.sgi-badge--retirado { background: #fee2e2; color: #991b1b; }
.sgi-badge--neutral { background: #f1f5f9; color: #475569; }

.sgi-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    padding: 0.45rem 0.875rem;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.sgi-btn:disabled,
.sgi-btn[aria-busy="true"] {
    opacity: 0.72;
    cursor: not-allowed;
}

body.sgi-module-page button:disabled,
body.sgi-module-page .btn-primary:disabled,
body.sgi-main-page button:disabled,
body.sgi-main-page .btn-primary:disabled {
    opacity: 0.72;
    cursor: not-allowed;
}

.sgi-btn-primary {
    background: var(--sgi-accent-ui, #c80000);
    color: #fff;
}

.sgi-btn-primary:hover:not(:disabled) {
    background: var(--sgi-accent, #a80000);
}

.sgi-btn-secondary {
    background: #fff;
    color: #334155;
    border-color: #cbd5e1;
}

.sgi-btn-secondary:hover:not(:disabled) {
    background: #f8fafc;
}

.sgi-btn-loading-inner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.sgi-btn-spinner {
    display: inline-block;
    width: 0.875rem;
    height: 0.875rem;
    flex-shrink: 0;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: sgi-spin 0.65s linear infinite;
}

@keyframes sgi-spin {
    to { transform: rotate(360deg); }
}

.sgi-skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: sgi-shimmer 1.2s ease-in-out infinite;
    border-radius: 0.25rem;
}

@keyframes sgi-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.sgi-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: #64748b;
    font-size: 13px;
}

.sgi-empty-icon {
    font-size: 1.75rem;
    color: #cbd5e1;
    margin-bottom: 0.5rem;
}

/* KPIs dashboard */
.sgi-metric-card {
    background: #fff;
    border: 1px solid var(--sgi-border, #e2e8f0);
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
}
.sgi-metric-card-label {
    font-size: 12px;
    color: #64748b;
    margin: 0;
}
.sgi-metric-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 0.15rem 0 0;
}
.sgi-metric-card-body {
    min-height: 2rem;
    display: flex;
    align-items: center;
    margin-top: 0.15rem;
}
.sgi-metric-card-loader {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 1.75rem;
}
.sgi-metric-card-loader.hidden {
    display: none;
}
.sgi-metric-spinner {
    width: 1.35rem;
    height: 1.35rem;
    border-width: 3px;
}
#metrics-grid.sgi-metrics-loading .sgi-metric-card {
    opacity: 0.92;
}
.sgi-metric-card--blue .sgi-metric-card-value { color: #2563eb; }
.sgi-metric-card--green .sgi-metric-card-value { color: #16a34a; }
.sgi-metric-card--amber .sgi-metric-card-value { color: #d97706; }
.sgi-metric-card--violet .sgi-metric-card-value { color: #7c3aed; }

.sgi-quick-action {
    background: #fff;
    border: 1px solid var(--sgi-border, #e2e8f0);
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
    transition: background 0.15s, border-color 0.15s;
    cursor: pointer;
}
.sgi-quick-action:hover {
    background: #fef2f2;
    border-color: #fecaca;
}
.sgi-quick-action i {
    color: var(--sgi-accent-ui, #c80000);
    font-size: 1.75rem;
}
.sgi-quick-action p {
    margin-top: 0.5rem;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.sgi-list-item {
    padding: 0.65rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    background: #f8fafc;
    font-size: 13px;
}
.sgi-list-item:hover {
    background: #f1f5f9;
}

/* --- Tablas: celdas compactas sin saltos indeseados --- */
.sgi-col-horario,
.sgi-table .sgi-col-horario {
    white-space: nowrap;
    min-width: 10.5rem;
    max-width: 14rem;
    font-size: 12px;
    letter-spacing: -0.01em;
}

.sgi-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sgi-filter-panel {
    background: #f8fafc;
    border: 1px solid var(--sgi-border, #e2e8f0);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.sgi-input,
body.sgi-module-page input[type="text"],
body.sgi-module-page input[type="email"],
body.sgi-module-page input[type="password"],
body.sgi-module-page input[type="number"],
body.sgi-module-page input[type="date"],
body.sgi-module-page select,
body.sgi-module-page textarea {
    font-size: 13px;
    border-radius: 0.375rem;
    border: 1px solid #cbd5e1;
    padding: 0.45rem 0.6rem;
}

.sgi-input:focus,
body.sgi-module-page input:focus,
body.sgi-module-page select:focus,
body.sgi-module-page textarea:focus {
    border-color: var(--sgi-accent-ui, #c80000) !important;
    box-shadow: 0 0 0 2px rgba(200, 0, 0, 0.12) !important;
    outline: none;
}

.sgi-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgb(15 23 42 / 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 1rem;
}

.sgi-modal {
    background: #fff;
    border: 1px solid var(--sgi-border, #e2e8f0);
    border-radius: 0.75rem;
    box-shadow: 0 8px 30px rgb(15 23 42 / 0.12);
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.sgi-login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sgi-surface-bg, #f1f5f9);
    padding: 2rem 1rem;
}

.sgi-login-card {
    width: 100%;
    max-width: 26rem;
    padding: 2rem;
    background: #fff;
    border: 1px solid var(--sgi-border, #e2e8f0);
    border-radius: 0.75rem;
    box-shadow: 0 4px 24px rgb(15 23 42 / 0.08);
}

.sgi-login-card h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

/* === Banner post-mantenimiento: limpiar caché === */
.sgi-cache-clear-banner {
    overflow: hidden;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.45s ease, transform 0.45s ease;
}

.sgi-cache-clear-banner--show {
    opacity: 1;
    transform: translateY(0);
}

.sgi-cache-clear-banner__shell {
    position: relative;
    border-radius: 0.875rem;
    padding: 1px;
    background: linear-gradient(135deg, rgba(200, 0, 0, 0.35), rgba(59, 130, 246, 0.35), rgba(200, 0, 0, 0.2));
    box-shadow: 0 8px 32px rgb(15 23 42 / 0.1), 0 2px 8px rgb(200 0 0 / 0.06);
}

.sgi-cache-clear-banner--app {
    width: 100%;
    align-self: stretch;
}

.sgi-cache-clear-banner--app .sgi-cache-clear-banner__shell {
    width: 100%;
    border-radius: 0;
    background: linear-gradient(90deg, rgba(200, 0, 0, 0.12), rgba(59, 130, 246, 0.1), rgba(200, 0, 0, 0.08));
    box-shadow: 0 4px 20px rgb(15 23 42 / 0.06);
}

.sgi-cache-clear-banner__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.25rem;
    padding: 1rem 1.25rem;
    border-radius: calc(0.875rem - 1px);
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 55%, #fef2f2 100%);
}

.sgi-cache-clear-banner--app .sgi-cache-clear-banner__inner {
    border-radius: 0;
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0.875rem 1.5rem;
}

.sgi-cache-clear-banner__icon {
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.75rem;
    background: linear-gradient(145deg, #c80000, #991b1b);
    color: #fff;
    font-size: 1.1rem;
    box-shadow: 0 4px 14px rgb(200 0 0 / 0.28);
}

.sgi-cache-clear-banner__body {
    flex: 1;
    min-width: 12rem;
}

.sgi-cache-clear-banner__eyebrow {
    margin: 0;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #c80000;
}

.sgi-cache-clear-banner__title {
    margin: 0.15rem 0 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

.sgi-cache-clear-banner__text {
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #475569;
}

.sgi-cache-clear-banner__text kbd {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    font-size: 0.7rem;
    font-family: ui-monospace, monospace;
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-radius: 0.25rem;
    color: #334155;
}

.sgi-cache-clear-banner__btn {
    flex-shrink: 0;
    padding: 0.5rem 1.125rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(145deg, #c80000, #a30000);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgb(200 0 0 / 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.sgi-cache-clear-banner__btn:hover {
    filter: brightness(1.06);
    box-shadow: 0 4px 12px rgb(200 0 0 / 0.32);
}

.sgi-cache-clear-banner__btn:active {
    transform: scale(0.98);
}

/* === Unificación visual: legacy → design system v1 === */
body.sgi-module-page .card,
body.sgi-main-page .card {
    background: #fff;
    border: 1px solid var(--sgi-border, #e2e8f0);
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.05);
}

body.sgi-module-page .btn-primary,
body.sgi-main-page .btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-size: 13px;
    font-weight: 600;
    padding: 0.45rem 0.875rem;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    background: var(--sgi-accent-ui, #c80000);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
}

body.sgi-module-page .btn-primary:hover:not(:disabled),
body.sgi-main-page .btn-primary:hover:not(:disabled) {
    background: var(--sgi-accent-hover, #991b1b);
}

body.sgi-module-page .sgi-module-title,
body.sgi-module-page .sgi-page-header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

body.sgi-module-page table:not(.sgi-table) {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

body.sgi-module-page table:not(.sgi-table) thead th {
    background: #f8fafc;
    font-weight: 600;
    color: #334155;
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

body.sgi-module-page table:not(.sgi-table) tbody td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

body.sgi-module-page table:not(.sgi-table) tbody tr:hover {
    background: #f8fafc;
}

body.sgi-module-page .status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.45rem;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

body.sgi-module-page .calc-section,
body.sgi-module-page .calc-panel {
    background: #fff;
    border: 1px solid var(--sgi-border, #e2e8f0);
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgb(15 23 42 / 0.06);
    margin-top: 0;
    padding: 1.25rem 1.35rem;
}

body.sgi-module-page .calc-section .calc-btn-primary,
body.sgi-module-page .calc-submit-btn {
    background: var(--sgi-accent-ui, #c80000);
    border-radius: 0.375rem;
    font-weight: 600;
    min-height: 2.5rem;
}

.calc-workspace {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.calc-row {
    display: grid;
    gap: 1.25rem;
    align-items: stretch;
}

@media (min-width: 1024px) {
    .calc-row--primary,
    .calc-row--secondary {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}

.calc-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.calc-row--primary .calc-panel {
    min-height: 26rem;
}

.calc-panel-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 1rem;
    letter-spacing: -0.01em;
}

.calc-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid #e2e8f0;
}

.calc-panel-head .calc-panel-title {
    margin: 0;
}

.calc-panel--output .calc-panel-head {
    margin-bottom: 0.25rem;
    padding-bottom: 0.35rem;
}

.calc-panel--output .feedback-message:empty {
    display: none;
    margin: 0;
    padding: 0;
}

.calc-panel--output .feedback-message:not(:empty) {
    margin-top: 0.35rem;
    margin-bottom: 0.25rem;
}

.calc-panel--output .calc-result-box {
    padding-top: 0;
}

.calc-form {
    display: flex;
    flex-direction: column;
    flex: 1;
}

body.sgi-module-page .calc-form label {
    display: block;
    margin: 0.65rem 0 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

body.sgi-module-page .calc-form input[type="date"],
body.sgi-module-page .calc-form input[type="number"],
body.sgi-module-page .calc-form select {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: #fff;
}

body.sgi-module-page .calc-form input:focus,
body.sgi-module-page .calc-form select:focus {
    outline: none;
    border-color: #c80000;
    box-shadow: 0 0 0 2px rgb(200 0 0 / 0.12);
}

.calc-form-actions {
    margin-top: auto;
    padding-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.calc-submit-btn {
    flex: 1 1 12rem;
}

.calc-btn-clear {
    flex: 0 0 auto;
    font-size: 0.8125rem;
}

.calc-output-stack {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-height: 100%;
}

body.sgi-module-page .calc-panel .hidden-field,
body.sgi-module-page .calc-form .hidden-field {
    display: none !important;
}

.calc-result-box {
    flex: 1;
    min-height: 18rem;
    overflow: auto;
    font-size: 0.8125rem;
    line-height: 1.55;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0.15rem 0;
}

.calc-result-box--compact {
    min-height: 7.5rem;
    max-height: 11rem;
}

.calc-result-box:empty::before {
    content: "Aquí aparecerán los resultados…";
    color: #94a3b8;
    font-style: italic;
}

body.sgi-module-page .calc-panel .feedback-message {
    margin-top: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
}

body.sgi-module-page .copy-btn-inline.copied {
    color: #059669;
    border-color: #a7f3d0;
}

body.sgi-module-page .card.bg-gray-50,
body.sgi-module-page .sgi-filter-panel {
    background: #f8fafc !important;
}

body.sgi-module-page button.bg-gray-200,
body.sgi-module-page .sgi-btn-clear {
    background: #fff;
    color: #334155;
    border: 1px solid #cbd5e1;
    font-size: 13px;
    font-weight: 600;
    padding: 0.45rem 0.875rem;
    border-radius: 0.375rem;
}

body.sgi-module-page button.bg-gray-200:hover {
    background: #f8fafc;
}

