/* =============================================
   SUSTAINABILITY HUB - MOBILE-FIRST DESIGN
   ============================================= */

:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --success: #059669;
    --success-light: #10b981;
    --warning: #d97706;
    --warning-light: #f59e0b;
    --danger: #dc2626;
    --secondary: #64748b;
    --secondary-light: #94a3b8;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --background: #ffffff;
    --background-secondary: #f8fafc;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

/* =============================================
   BASE STYLES (MOBILE FIRST)
   ============================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 16px;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.025em;
    line-height: 1.2;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

h1:focus { outline: none; }

a, .btn-link {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover, .btn-link:hover {
    color: var(--primary-dark);
}

/* =============================================
   BUTTONS (MOBILE FIRST)
   ============================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.9375rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
    width: 100%;
    text-align: center;
}

.btn-sm {
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 1rem 1.5rem;
    font-size: 1.0625rem;
}

.btn-primary {
    color: white;
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--background);
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--background-secondary);
    color: var(--text-primary);
    border-color: var(--secondary-light);
}

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-success:hover {
    background: var(--success-light);
    border-color: var(--success-light);
}

.btn-outline-primary {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: white;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--background-secondary);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-icon.btn-danger:hover {
    background: #fef2f2;
    border-color: var(--danger);
    color: var(--danger);
}

.btn:focus, .btn:active:focus {
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
    outline: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* =============================================
   ROLES & PRIVILEGIOS - MODERNO
   ============================================= */

.roles-page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-bottom: 2rem;
}

.roles-page__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.roles-page__header-text {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.roles-page__title {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.roles-page__subtitle {
    color: var(--text-muted);
    font-size: 0.975rem;
}

.roles-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--background);
    color: var(--text-primary);
}

.roles-button svg,
.roles-button__icon {
    width: 1rem;
    height: 1rem;
}

.roles-button--primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.roles-button--primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.roles-button--outline {
    background: var(--background);
    border-color: var(--border);
    color: var(--text-secondary);
}

.roles-button--outline:hover {
    background: var(--background-secondary);
    color: var(--text-primary);
}

.roles-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.roles-alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.925rem;
    border: 1px solid transparent;
}

.roles-alert--error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.roles-alert--success {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #047857;
}

.roles-alert--compact {
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
}

.roles-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.roles-search {
    position: relative;
    flex: 1;
    min-width: 240px;
}

.roles-search__icon {
    position: absolute;
    top: 50%;
    left: 0.85rem;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    color: var(--text-muted);
}

.roles-search__input {
    width: 100%;
    padding: 0.65rem 1rem 0.65rem 2.4rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--background);
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    color: var(--text-primary);
}

.roles-search__input::placeholder {
    color: var(--text-muted);
}

.roles-search__input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.12);
}

.roles-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.roles-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.roles-empty--compact {
    padding: 1.25rem;
    font-size: 0.9rem;
    text-align: center;
}

.roles-table__wrapper {
    width: 100%;
    overflow-x: auto;
}

.roles-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    min-width: 640px;
}

.roles-table thead {
    background: var(--background-secondary);
}

.roles-table__header {
    padding: 0.85rem 1rem;
    text-align: left;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.roles-table__header--center {
    text-align: center;
}

.roles-table__header--right {
    text-align: right;
}

.roles-table__row {
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.2s ease;
}

.roles-table__row:hover {
    background: var(--background-secondary);
}

.roles-table__cell {
    padding: 0.85rem 1rem;
    vertical-align: middle;
}

.roles-table__cell--left {
    text-align: left;
}

.roles-table__cell--center {
    text-align: center;
}

.roles-table__cell--actions {
    text-align: right;
}

.roles-table__cell--strong {
    font-weight: 600;
    color: var(--text-primary);
}

.roles-table__cell--muted {
    color: var(--text-muted);
    max-width: 320px;
}

.roles-table__cell--status {
    min-width: 120px;
}

.roles-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid transparent;
    gap: 0.25rem;
}

.roles-chip--secondary {
    background: #e2e8f0;
    color: #1e293b;
}

.roles-chip--global {
    background: rgba(37, 99, 235, 0.12);
    color: var(--primary);
    border-color: rgba(37, 99, 235, 0.3);
}

.roles-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.roles-status--active {
    background: rgba(16, 185, 129, 0.15);
    color: #047857;
    border-color: rgba(16, 185, 129, 0.3);
}

.roles-status--inactive {
    background: rgba(148, 163, 184, 0.15);
    color: #475569;
    border-color: rgba(148, 163, 184, 0.3);
}

.roles-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.roles-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text-secondary);
    transition: all 0.2s ease;
    cursor: pointer;
}

.roles-action:hover {
    background: var(--background-secondary);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow);
}

.roles-switch {
    position: relative;
    width: 46px;
    height: 26px;
    display: inline-flex;
    align-items: center;
}

.roles-switch input {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    margin: 0;
}

.roles-switch__track {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 999px;
    background: var(--border);
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    padding: 3px;
}

.roles-switch__thumb {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: var(--background);
    box-shadow: var(--shadow);
    transition: transform 0.2s ease;
    transform: translateX(0);
}

.roles-switch input:checked + .roles-switch__track {
    background: var(--primary);
}

.roles-switch input:checked + .roles-switch__track .roles-switch__thumb {
    transform: translateX(20px);
}

.roles-switch input:focus-visible + .roles-switch__track {
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.2);
}

.roles-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 94;
}

.roles-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 2rem);
    max-width: 960px;
    background: var(--background);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    z-index: 95;
}

.roles-modal--info {
    max-width: 720px;
}

.roles-modal__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: var(--radius);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.roles-modal__close:hover {
    background: var(--background-secondary);
    color: var(--text-primary);
}

.roles-modal__form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-height: 70vh;
}

.roles-modal__validation {
    font-size: 0.85rem;
}

.roles-modal__header {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.roles-modal__title {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-primary);
}

.roles-modal__subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.roles-modal__body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding-right: 0.35rem;
    overflow-y: auto;
}

.roles-modal__body--scroll {
    max-height: 60vh;
}

.roles-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.roles-field__label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.roles-field__hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.roles-field__input,
.roles-field__textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.85rem;
    font-size: 0.95rem;
    background: var(--background);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.roles-field__textarea {
    min-height: 120px;
}

.roles-field__input:focus,
.roles-field__textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.12);
}

.roles-field__validation {
    color: #dc2626;
    font-size: 0.8rem;
}

.roles-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.roles-chip-toggle {
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--background);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.roles-chip-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.roles-chip-toggle--active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: var(--shadow);
}

.roles-matrix {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: auto;
    max-height: 500px;
    background: var(--background);
}

.roles-matrix__table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
    font-size: 0.9rem;
}

.roles-matrix__table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--background-secondary);
}

.roles-matrix__header {
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--background-secondary);
    white-space: nowrap;
}

.roles-matrix__header--module {
    text-align: left;
}

.roles-matrix__header--all {
    width: 110px;
}

.roles-matrix__module {
    padding: 0.85rem;
    border-bottom: 1px solid var(--border-light);
    width: 220px;
}

.roles-matrix__module-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
}

.roles-matrix__module-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.roles-matrix__cell {
    text-align: center;
    padding: 0.7rem;
    border-bottom: 1px solid var(--border-light);
}

.roles-matrix__cell--all {
    min-width: 110px;
}

.roles-checkbox {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 1.5px solid var(--border);
    background: var(--background);
    cursor: pointer;
    transition: all 0.2s ease;
}

.roles-checkbox span {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: transparent;
    transition: background-color 0.2s ease;
}

.roles-checkbox--checked {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.12);
}

.roles-checkbox--checked span {
    background: var(--primary);
}

.roles-matrix__all {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--background);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.roles-matrix__all:hover,
.roles-matrix__all--active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
}

.roles-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.roles-modal__footer--single {
    justify-content: flex-end;
}

.roles-detail__header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.roles-detail__title {
    font-size: 1.2rem;
    font-weight: 600;
}

.roles-detail__description {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.roles-detail__stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.roles-detail__stat {
    padding: 0.85rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--background-secondary);
}

.roles-detail__stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.roles-detail__stat-value {
    display: block;
    margin-top: 0.35rem;
    font-weight: 600;
    color: var(--text-primary);
}

.roles-detail__section {
    margin-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.roles-detail__section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.roles-detail__empty {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.roles-detail__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.roles-detail__modules {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.roles-detail__module-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background-secondary);
    padding: 0.85rem;
}

.roles-detail__module-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.roles-detail__module-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding-left: 1rem;
}

.roles-detail__module-list li {
    list-style: disc;
}

.roles-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

@media (max-width: 768px) {
    .roles-modal {
        padding: 1.5rem;
    }

    .roles-modal__footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .roles-button {
        width: 100%;
        justify-content: center;
    }

    .roles-actions {
        justify-content: flex-start;
    }

    .roles-search {
        min-width: 100%;
    }
}

/* =============================================
   FORMS (MOBILE FIRST)
   ============================================= */

.form-control, .form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: var(--background);
    color: var(--text-primary);
    width: 100%;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group label.required::after {
    content: " *";
    color: var(--danger);
}

.form-check {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem;
    border-radius: var(--radius);
    transition: background-color 0.2s ease;
}

.form-check:hover {
    background: var(--background-secondary);
}

.form-check input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    margin-top: 2px;
    border-radius: 4px;
    border: 2px solid var(--border);
    cursor: pointer;
}

.form-check label {
    cursor: pointer;
    margin-bottom: 0;
    flex: 1;
}

.form-text {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.form-text.text-danger {
    color: var(--danger);
}

.validation-message {
    color: var(--danger);
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: 0.375rem;
    display: block;
}

.valid.modified:not([type=checkbox]) {
    border-color: var(--success);
    box-shadow: 0 0 0 3px rgb(5 150 105 / 0.1);
}

.invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgb(220 38 38 / 0.1);
}

/* =============================================
   CONTAINER & LAYOUT (MOBILE FIRST)
   ============================================= */

.container {
    width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -0.5rem;
}

.col {
    flex: 1;
    padding: 0 0.5rem;
    width: 100%;
}

/* =============================================
   CARDS (MOBILE FIRST)
   ============================================= */

.card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    background: var(--background-secondary);
    border-bottom: 1px solid var(--border-light);
    padding: 1rem;
}

.card-body {
    padding: 1rem;
}

/* =============================================
   ALERTS (MOBILE FIRST)
   ============================================= */

.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.9375rem;
}

.alert svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-error svg {
    color: inherit;
}

.validation-summary,
.validation-summary div {
    color: #991b1b;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.detail-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-item dt {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.detail-item dd {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 0.375rem;
    cursor: help;
    color: var(--primary);
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    max-width: 220px;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    background: rgba(17, 24, 39, 0.9);
    color: white;
    font-size: 0.75rem;
    line-height: 1.25;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
    white-space: normal;
    z-index: 100;
}

.tooltip::before {
    content: "";
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: rgba(17, 24, 39, 0.9) transparent transparent transparent;
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
}

.tooltip:hover::after,
.tooltip:hover::before {
    opacity: 1;
}

/* =============================================
   BADGES (MOBILE FIRST)
   ============================================= */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-primary {
    background: #dbeafe;
    color: #1e40af;
}

.badge-secondary {
    background: var(--background-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.badge-light {
    background: #f1f5f9;
    color: #64748b;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.875rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-badge.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.status-inactive {
    background: #fee2e2;
    color: #991b1b;
}

/* =============================================
   DATA TABLE (MOBILE FIRST - RESPONSIVE)
   ============================================= */

.data-table-container {
    background: var(--background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 1rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

.data-table thead {
    background: var(--background-secondary);
    border-bottom: 2px solid var(--border);
}

.data-table th {
    padding: 0.875rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.2s ease;
}

.data-table tbody tr:hover {
    background: var(--background-secondary);
}

.data-table td {
    padding: 0.875rem;
    font-size: 0.9375rem;
}

.data-table td.font-medium {
    font-weight: 500;
    color: var(--text-primary);
}

.data-table td.text-secondary {
    color: var(--text-secondary);
}

/* =============================================
   FILTERS (MOBILE FIRST)
   ============================================= */

.filters-card {
    background: var(--background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-top: 1rem;
}

.filters-card .macro-filter {
    grid-column: 1 / -1;
}

.filters-card .macro-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.filters-card .toggle-switch-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.filters-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-item label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* =============================================
   PAGINATION (MOBILE FIRST)
   ============================================= */

.pagination {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-top: 1px solid var(--border-light);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
}

.pagination .actions {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    justify-content: center;
}

.pagination .actions .btn {
    flex: 1;
    max-width: 140px;
}

/* =============================================
   MODAL (MOBILE FIRST)
   ============================================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
}

.modal-content {
    background: var(--background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: fadeInScale 0.3s ease-out;
    position: relative;
    z-index: 10000;
}

.modal-container {
    background: var(--background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: fadeInScale 0.3s ease-out;
    position: relative;
    z-index: 10000;
}

.modal-container.modal-sm {
    max-width: 400px;
}

/* Asegurar que los modales se vean correctamente */
.modal-overlay {
    backdrop-filter: blur(2px);
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 9999 !important;
    padding: 1rem !important;
}

.modal-container {
    margin: 0 !important;
    transform: none !important;
    position: relative !important;
    z-index: 10000 !important;
    background: var(--background) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    width: 100% !important;
    max-width: 500px !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--background);
    z-index: 1;
}

.modal-header-content {
    display: flex;
    gap: 1rem;
    flex: 1;
}

.modal-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.modal-title-group h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.modal-title-group p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    margin: -0.5rem -0.5rem -0.5rem 0.5rem;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--background-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.25rem 1rem;
}

.modal-footer {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
    position: sticky;
    bottom: 0;
    background: var(--background);
}

.modal-footer .btn {
    width: 100%;
}

/* =============================================
   FORM LAYOUTS (MOBILE FIRST)
   ============================================= */

.form-container {
    width: 100%;
    margin: 1rem auto;
    padding: 0;
}

.form-card {
    background: var(--background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.form-section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-light);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.form-row-2col {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .form-row-2col {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem 0;
}

.form-actions .btn {
    width: 100%;
}

.roles-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.roles-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.role-description {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: normal;
    margin-top: 0.25rem;
}

/* =============================================
   EMPTY STATE (MOBILE FIRST)
   ============================================= */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    background: var(--background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-top: 1rem;
}

.empty-state svg {
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    font-size: 0.9375rem;
}

/* =============================================
   LOADING (MOBILE FIRST)
   ============================================= */

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    background: var(--background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-top: 1rem;
}

.spinner {
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-container p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.loading-small {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.spinner-small {
    border: 2px solid var(--border);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

/* =============================================
   LOGIN (MOBILE FIRST)
   ============================================= */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: var(--background);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    padding: 2rem 1.5rem;
    width: 100%;
    max-width: 440px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    width: 90px;
    height: 90px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0rem;
}

.login-logo img.login-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: inherit;
}


.login-logo svg,
.login-logo .login-logo-fallback {
    color: white;
}

.login-logo .brand-logo-hidden {
    display: none !important;
}

.login-header h1 {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.login-header p {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

.login-form .form-group:last-of-type {
    margin-bottom: 2rem;
}

.login-form label {
    font-weight: 500;
    color: var(--text-primary);
}

.login-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.login-actions .btn {
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
}

.login-footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.login-footer p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.login-footer .login-version {
    font-size: 0.8125rem;
    margin-top: 0.25rem;
    opacity: 0.9;
}

/* =============================================
   ACTIONS (MOBILE FIRST)
   ============================================= */

.actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* =============================================
   UTILITIES
   ============================================= */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }

.bg-primary { background-color: var(--primary) !important; }
.bg-secondary { background-color: var(--secondary) !important; }
.bg-light { background-color: var(--background-secondary) !important; }

.border { border: 1px solid var(--border) !important; }
.border-0 { border: 0 !important; }

.rounded { border-radius: var(--radius) !important; }
.rounded-lg { border-radius: var(--radius-lg) !important; }

.shadow { box-shadow: var(--shadow) !important; }
.shadow-md { box-shadow: var(--shadow-md) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }

.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-block { display: block !important; }
.d-none { display: none !important; }

.flex-column { flex-direction: column !important; }
.flex-row { flex-direction: row !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-between { justify-content: space-between !important; }
.align-items-center { align-items: center !important; }
.align-items-start { align-items: flex-start !important; }
.align-items-end { align-items: flex-end !important; }

.font-medium { font-weight: 500 !important; }
.font-semibold { font-weight: 600 !important; }

/* =============================================
   ERROR BOUNDARY
   ============================================= */

.blazor-error-boundary {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    padding: 1rem;
    color: #991b1b;
    border-radius: var(--radius);
    border: 1px solid #fecaca;
    margin: 1rem;
    font-weight: 500;
    font-size: 0.9375rem;
}

.blazor-error-boundary::after {
    content: "Ha ocurrido un error en la aplicación."
}

/* =============================================
   FOCUS STYLES (ACCESSIBILITY)
   ============================================= */

button:focus,
input:focus,
select:focus,
textarea:focus,
a:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* =============================================
   SCROLLBAR (WEBKIT)
   ============================================= */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-light);
}

/* =============================================
   ANIMATIONS
   ============================================= */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

/* =============================================
   RESPONSIVE: TABLET (576px+)
   ============================================= */

@media (min-width: 576px) {
    .container {
        padding: 0 1.5rem;
    }

    .btn {
        width: auto;
    }

    .filters-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .pagination {
        flex-direction: row;
        justify-content: space-between;
    }

    .pagination .actions {
        width: auto;
    }

    .modal-overlay {
        align-items: center !important;
        padding: 1rem !important;
    }

    .modal-content {
        border-radius: var(--radius-lg) !important;
        max-width: 500px !important;
    }

    .modal-container {
        max-width: 500px !important;
    }

    .modal-container.modal-sm {
        max-width: 400px !important;
    }

    .modal-footer {
        flex-direction: row;
        justify-content: flex-end;
    }

    .modal-footer .btn {
        width: auto;
    }

    .form-actions {
        flex-direction: row;
        justify-content: flex-end;
    }

    .form-actions .btn {
        width: auto;
    }

    .login-card {
        padding: 2.5rem 2rem;
    }
}

/* =============================================
   RESPONSIVE: DESKTOP SMALL (768px+)
   ============================================= */

@media (min-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }

    .container {
        max-width: 1200px;
    }

    .filters-card {
        padding: 1.5rem;
    }

    .filters-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }

.form-container {
    max-width: 900px;
    margin: 2rem auto;
}

.form-card {
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.form-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

    .roles-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .modal-content {
        max-width: 600px;
    }

    .data-table th {
        padding: 1rem;
        font-size: 0.875rem;
    }

    .data-table td {
        padding: 1rem;
    }

    .card-header {
        padding: 1.25rem 1.5rem;
    }

    .card-body {
        padding: 1.5rem;
    }

    .login-card {
        padding: 3rem;
    }

    .login-logo {
        width: 90px;
        height: 90px;
        border-radius: 16px;
        margin-bottom: 1.5rem;
    }

    .login-header h1 {
        font-size: 1.75rem;
    }
}

/* =============================================
   RESPONSIVE: DESKTOP LARGE (992px+)
   ============================================= */

@media (min-width: 992px) {
    .filters-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.roles-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }

    .data-table {
        min-width: 100%;
    }
}

/* =============================================
   MEDIA QUERIES (ACCESSIBILITY)
   ============================================= */

@media (prefers-contrast: high) {
    :root {
        --border: #000000;
        --text-muted: #000000;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Ocultar overlay de reconexión de Blazor Server cuando se está offline */
#components-reconnect-modal,
.components-reconnect-show,
.components-reconnect-hide,
.components-reconnect-failed {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

@media print {
    .no-print {
        display: none !important;
    }
}

/* =============================================
   PAGE HEADER (MOBILE FIRST)
   ============================================= */

.page-header {
    background: var(--background);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.page-header .container {
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
}

.header-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.header-left,
.header-right {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.header-title-box h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.header-title-box p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.header-right .btn {
    width: 100%;
}

@media (min-width: 576px) {
    .header-content {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .header-right {
        flex-direction: row;
        align-items: center;
    }

    .header-right .btn {
        width: auto;
    }
}

@media (min-width: 768px) {
    .page-header .container {
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
    }

    .header-title-box h1 {
        font-size: 1.75rem;
    }

    .header-title-box p {
        font-size: 0.9375rem;
    }
}

@media (min-width: 992px) {
    .page-header .container {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }

    .header-title-box h1 {
        font-size: 2rem;
    }
}

/* =============================================
   RESPONSIVE INPUT FIELDS
   ============================================= */

.form-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-label svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.form-label .required {
    color: var(--danger);
    font-weight: 600;
}

.form-label .optional {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 400;
}

.form-hint {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.form-input, .form-textarea {
    width: 100%;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.input-with-icon {
    position: relative;
}

.input-with-icon .form-select {
    padding-right: 2.5rem;
}

.input-with-icon .select-icon {
    position: absolute;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-muted);
}

/* =============================================
   MODAL IMPROVEMENTS (ZONES)
   ============================================= */

.modal-zona {
    max-width: 540px;
}

@media (min-width: 768px) {
    .modal-zona {
        max-width: 600px;
    }
}

/* ===== CAPTURA DE MEDICIÓN ===== */
.form-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 24px;
    margin-bottom: 24px;
}

.form-section {
    margin-bottom: 20px;
}

.form-section:last-child {
    margin-bottom: 0;
}

.form-section h3 {
    color: #1f2937;
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 640px) {
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .form-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
}

.required {
    color: #dc2626;
    font-weight: 600;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb;
}

@media (min-width: 640px) {
    .form-actions {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
    }
}

.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

.data-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.data-header h3 {
    color: #1f2937;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #6b7280;
}

.empty-state svg {
    color: #d1d5db;
    margin-bottom: 16px;
}

.empty-state h4 {
    color: #374151;
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 8px 0;
}

.empty-state p {
    color: #6b7280;
    font-size: 14px;
    margin: 0;
}

/* Mejoras específicas para inputs de medición */
.form-control[type="number"] {
    text-align: right;
}

.form-control[type="date"] {
    position: relative;
}

.form-control[type="date"]::-webkit-calendar-picker-indicator {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
}

/* Estados de validación */
.form-control.is-invalid {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.form-control.is-valid {
    border-color: #16a34a;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

/* Animaciones suaves */
.form-card {
    transition: box-shadow 0.2s ease;
}

.form-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.form-section h3 {
    transition: color 0.2s ease;
}

.form-section:hover h3 {
    color: #111827;
}

/* ===== LISTADO DE MEDICIONES ===== */
.bulk-actions {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.bulk-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.selected-count {
    background: #3b82f6;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.bulk-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.data-stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.stat-item {
    color: #6b7280;
    font-size: 14px;
}

.stat-item strong {
    color: #1f2937;
    font-weight: 600;
}

.checkbox-column {
    width: 50px;
    text-align: center;
}

.actions-column {
    width: 100px;
    text-align: center;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fbbf24;
}

.status-review {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #3b82f6;
}

.status-approved {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.status-rejected {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.status-cancelled {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #9ca3af;
}

.status-default {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #d1d5db;
}

.data-table tr.selected {
    background: #eff6ff;
    border-left: 3px solid #3b82f6;
}

.data-table tr.selected td {
    border-color: #dbeafe;
}

.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb;
    flex-wrap: wrap;
    gap: 16px;
}

.pagination-info {
    color: #6b7280;
    font-size: 14px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-pages {
    display: flex;
    gap: 4px;
}

.pagination-pages .btn {
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive para listado */
@media (max-width: 768px) {
    .bulk-actions {
    flex-direction: column;
        align-items: stretch;
    }
    
    .bulk-buttons {
        justify-content: center;
    }
    
    .data-stats {
        flex-direction: column;
        gap: 8px;
    }
    
    .pagination-container {
        flex-direction: column;
        text-align: center;
    }
    
    .pagination-controls {
        justify-content: center;
    }
    
    .pagination-pages {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .data-table {
        font-size: 14px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 4px;
    }
    
    .actions-column {
        width: 80px;
    }
    
    .btn-sm {
        padding: 4px 8px;
        font-size: 12px;
    }
}

@media (max-width: 640px) {
    .bulk-buttons {
        flex-direction: column;
    }
    
    .bulk-buttons .btn {
    width: 100%;
        justify-content: center;
    }
    
    .data-table th:nth-child(n+5),
    .data-table td:nth-child(n+5) {
        display: none;
    }
    
    .data-table th:nth-child(4),
    .data-table td:nth-child(4) {
        border-right: none;
    }
}

/* Animaciones para acciones en lote */
.bulk-actions {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Estados de carga para botones */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn:disabled svg {
    animation: spin 1s linear infinite;
}

/* Mejoras en la tabla */
.data-table tbody tr:hover {
    background: #f9fafb;
}

.data-table tbody tr.selected:hover {
    background: #dbeafe;
}

/* Indicadores visuales */
.text-end {
    text-align: right;
}

.form-check-input {
    margin: 0;
    cursor: pointer;
}

.form-check-input:checked {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

/* ===== CARGA DE IMÁGENES ===== */
.upload-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.upload-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.upload-btn {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.upload-placeholder {
    text-align: center;
    padding: 48px 24px;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    background: #f9fafb;
}

.upload-placeholder svg {
    color: #d1d5db;
    margin-bottom: 16px;
}

.upload-placeholder p {
    color: #374151;
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 8px 0;
}

.upload-placeholder small {
    color: #6b7280;
    font-size: 14px;
}

.images-preview {
    display: flex;
        flex-direction: column;
    gap: 16px;
}

.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

@media (min-width: 640px) {
    .images-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (min-width: 1024px) {
    .images-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

.image-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #e5e7eb;
    background: white;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.image-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.image-item img {
        width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.btn-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.btn-remove:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.btn-remove:active {
    transform: scale(0.95);
}

.image-info {
    padding: 8px;
    background: #f9fafb;
    display: flex;
        flex-direction: column;
    gap: 4px;
}

.image-name {
    font-size: 12px;
    color: #374151;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-size {
    font-size: 11px;
    color: #6b7280;
}

.images-summary {
    padding: 12px;
    background: #eff6ff;
    border-radius: 8px;
    text-align: center;
    color: #1e40af;
    font-size: 14px;
    font-weight: 500;
}

/* Responsive para upload */
@media (max-width: 640px) {
    .upload-buttons {
        flex-direction: column;
    }
    
    .upload-btn {
        width: 100%;
        min-width: auto;
    }
    
    .images-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .image-item img {
        height: 150px;
    }
}

/* Animación para nuevas imágenes */
.image-item {
    animation: fadeInScale 0.3s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== MODAL DE CÁMARA WEB ===== */
.webcam-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.webcam-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.webcam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.webcam-header h3 {
    margin: 0;
    color: #1f2937;
    font-size: 20px;
    font-weight: 600;
}

.btn-close-webcam {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close-webcam:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.webcam-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.video-container {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.webcam-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.webcam-controls .btn {
    display: flex;
    align-items: center;
    gap: 8px;
}

.webcam-controls .btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* Animaciones para el modal */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive para modal de cámara */
@media (max-width: 640px) {
    .webcam-modal {
        padding: 0;
    }
    
    .webcam-content {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .video-container {
        border-radius: 0;
        aspect-ratio: 4 / 3;
    }
    
    .webcam-controls {
        flex-direction: column;
    }
    
    .webcam-controls .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Efecto de captura */
.video-container.capturing {
    animation: flash 0.3s ease;
}

@keyframes flash {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
        transform: scale(0.98);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* =============================================
   COMPONENTES BLAZOR - ESTILOS ESPECÍFICOS
   ============================================= */

/* SOLUCIÓN DEFINITIVA: Aplicar estilos directamente a todos los inputs y textareas */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
textarea,
select {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    padding: 0.875rem !important;
    font-size: 1rem !important;
    transition: all 0.2s ease !important;
    background: var(--background) !important;
    color: var(--text-primary) !important;
    width: 100% !important;
    box-sizing: border-box !important;
    font-family: inherit !important;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1) !important;
    outline: none !important;
}

input[type="text"]::placeholder,
input[type="number"]::placeholder,
input[type="email"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder {
    color: var(--text-muted) !important;
}

/* Estilos específicos para textarea */
textarea {
    resize: vertical !important;
    min-height: 80px !important;
}

/* Estilos específicos para InputNumber */
input[type="number"] {
    text-align: right !important;
}

/* Estilos para ValidationMessage */
.validation-message {
    color: #dc2626 !important;
    font-size: 0.8125rem !important;
    margin-top: 0.25rem !important;
    display: block !important;
}

/* Estilos para form-hint */
.form-hint {
    color: var(--text-muted) !important;
    font-size: 0.8125rem !important;
    margin-top: 0.25rem !important;
    display: block !important;
}

/* Asegurar que los labels tengan el estilo correcto */
.form-label {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    font-size: 0.9375rem !important;
    font-weight: 500 !important;
    color: var(--text-secondary) !important;
    margin-bottom: 0.5rem !important;
}

.form-label svg {
    width: 16px !important;
    height: 16px !important;
    color: var(--text-muted) !important;
}

.form-label .required {
    color: var(--danger) !important;
    font-weight: 600 !important;
}

.form-label .optional {
    font-size: 0.8125rem !important;
    color: var(--text-muted) !important;
    font-weight: 400 !important;
}

/* Estilos específicos para campos de Nombre en modales */
.modal-content input[type="text"],
.modal-content input[type="number"],
.modal-content textarea {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    padding: 0.875rem !important;
    font-size: 1rem !important;
    transition: all 0.2s ease !important;
    background: var(--background) !important;
    color: var(--text-primary) !important;
    width: 100% !important;
    box-sizing: border-box !important;
    font-family: inherit !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
}

.modal-content input[type="text"]:focus,
.modal-content input[type="number"]:focus,
.modal-content textarea:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1) !important;
    outline: none !important;
}

.modal-content input[type="text"]::placeholder,
.modal-content input[type="number"]::placeholder,
.modal-content textarea::placeholder {
    color: var(--text-muted) !important;
}

/* Forzar estilos en todos los inputs dentro de modales */
.modal-content * input,
.modal-content * textarea {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    padding: 0.875rem !important;
    font-size: 1rem !important;
    transition: all 0.2s ease !important;
    background: var(--background) !important;
    color: var(--text-primary) !important;
    width: 100% !important;
    box-sizing: border-box !important;
    font-family: inherit !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
}

.modal-content * input:focus,
.modal-content * textarea:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1) !important;
    outline: none !important;
}

/* Estilos para formularios en fila */
.form-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 1rem !important;
    margin-bottom: 1rem !important;
}

/* Media query removido para mantener diseño de 2 columnas */

/* Estilos para toggle switch */
.form-toggle {
    display: flex !important;
    align-items: center !important;
    gap: 0.75rem !important;
    margin-top: 0.5rem !important;
}

.toggle {
    position: relative !important;
    display: inline-block !important;
    width: 3rem !important;
    height: 1.5rem !important;
}

.toggle input {
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
}

.toggle-slider {
    position: absolute !important;
    cursor: pointer !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background-color: var(--border) !important;
    transition: 0.2s ease !important;
    border-radius: 1.5rem !important;
}

.toggle-slider:before {
    position: absolute !important;
    content: "" !important;
    height: 1.125rem !important;
    width: 1.125rem !important;
    left: 0.1875rem !important;
    bottom: 0.1875rem !important;
    background-color: white !important;
    transition: 0.2s ease !important;
    border-radius: 50% !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

.toggle input:checked + .toggle-slider {
    background-color: var(--primary) !important;
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(1.5rem) !important;
}

.toggle-label {
    font-size: 0.9375rem !important;
    font-weight: 500 !important;
    color: var(--text-secondary) !important;
}

/* Estilos para información de umbrales en tabla */
.umbrales-info {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.25rem !important;
}

.umbral-item {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 0.8125rem !important;
}

.umbral-label {
    color: var(--text-muted) !important;
    font-weight: 500 !important;
}

.umbral-value {
    color: var(--text-primary) !important;
    font-weight: 600 !important;
    background: var(--background-secondary) !important;
    padding: 0.125rem 0.375rem !important;
    border-radius: var(--radius) !important;
    font-size: 0.75rem !important;
}

/* Estilos para grupo de estados */
.status-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.25rem !important;
}

.status-group .status-badge {
    font-size: 0.75rem !important;
    padding: 0.125rem 0.375rem !important;
}

/* Estilos para secciones de formulario */
.form-section {
    margin-top: 1.5rem !important;
    padding-top: 1.5rem !important;
    border-top: 1px solid var(--border) !important;
}

.form-section-title {
    font-size: 1.125rem !important;
    font-weight: 600 !important;
    color: var(--text-primary) !important;
    margin-bottom: 1rem !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
}

.form-section-title::before {
    content: "" !important;
    width: 4px !important;
    height: 1.125rem !important;
    background: var(--primary) !important;
    border-radius: 2px !important;
}

/* Estilos para información de metas en tabla */
.metas-info {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.25rem !important;
}

.meta-item {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 0.8125rem !important;
}

.meta-label {
    color: var(--text-muted) !important;
    font-weight: 500 !important;
}

.meta-value {
    color: var(--text-primary) !important;
    font-weight: 600 !important;
    background: var(--background-secondary) !important;
    padding: 0.125rem 0.375rem !important;
    border-radius: var(--radius) !important;
    font-size: 0.75rem !important;
}

.roles-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem 1rem;
}

.roles-checkbox-option {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.roles-checkbox-option input[type="checkbox"] {
    margin: 0;
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.detail-label {
    font-weight: 600;
    color: var(--text-muted);
}

.detail-value {
    color: var(--text-primary);
    flex: 1;
}

.detail-roles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
