*,
*::before,
*::after {
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

:root {
    --bg: #f4f4f9;
    --text: #1f2937;
    --card-bg: #ffffff;
    --muted: #6b7280;
    --border: #d9dde5;
    --input-bg: #ffffff;
    --sidebar-bg: #333333;
    --sidebar-text: #ffffff;
    --tab-hover: #e9ecef;
    --row-hover: #f1f1f1;
    --hint-bg: #eef4ff;
    --hint-border: #cddfff;
    --content-max-width: 1920px;
    --btn-std-width: 190px;
    --btn-std-height: 40px;
}

html.theme-dark,
body.theme-dark {
    --bg: #0f172a;
    --text: #e5e7eb;
    --card-bg: #111827;
    --muted: #94a3b8;
    --border: #334155;
    --input-bg: #0b1220;
    --sidebar-bg: #020617;
    --sidebar-text: #e5e7eb;
    --tab-hover: #1f2937;
    --row-hover: #172133;
    --hint-bg: #0b2545;
    --hint-border: #1d4f91;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

html {
    overflow-x: hidden;
}

/* Hide numeric stepper controls; users type values directly. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

body.boot-loading {
    overflow: hidden;
}

body.boot-loading>*:not(.boot-loader) {
    visibility: hidden;
}

.boot-loader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(244, 244, 249, 0.97);
    transition: opacity 0.22s ease;
}

html.theme-dark .boot-loader,
body.theme-dark .boot-loader {
    background: rgba(15, 23, 42, 0.96);
}

html.theme-dark img[src*="simple-icons"],
body.theme-dark img[src*="simple-icons"] {
    filter: invert(1) brightness(1.2);
}

html.theme-dark #grace-accept-modal>div,
body.theme-dark #grace-accept-modal>div {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

html.theme-dark #grace-accept-modal h2,
body.theme-dark #grace-accept-modal h2 {
    color: #f8fafc !important;
}

html.theme-dark #grace-accept-text,
body.theme-dark #grace-accept-text {
    color: #cbd5e1 !important;
}

body.boot-ready .boot-loader {
    opacity: 0;
    pointer-events: none;
}

.boot-loader-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 18px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
}

.boot-loader-card p {
    margin: 0;
    color: var(--text);
    font-weight: 600;
}

.boot-loader-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0, 123, 255, 0.2);
    border-top-color: #007bff;
    border-radius: 50%;
    animation: boot-spin 0.8s linear infinite;
}

@keyframes boot-spin {
    to {
        transform: rotate(360deg);
    }
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding-top: 10px;
}

header h1 {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.2;
}

.app-brand-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    flex: 0 0 auto;
}

.sidebar-brand {
    padding: 10px 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin: 5px 0 10px 0;
    min-height: 50px;
}

.sidebar-brand img {
    max-width: 100%;
    max-height: 40px;
    /* Mas pequeño para no estorbar */
    object-fit: contain;
}

/* Kill-switch para branding en area de acceso */
body.is-access-page .sidebar-brand,
body.is-access-page .app-brand-logo {
    display: none !important;
}

/* Landing Page Branding */
.landing-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #fff;
    margin-bottom: 16px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.landing-title {
    text-align: center;
    margin-bottom: 24px;
    font-size: 2.2rem;
    color: var(--text);
}

.role-entry-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 14000;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

.role-entry-modal-card {
    width: 100%;
    max-width: 440px;
    background: var(--card-bg);
    color: var(--text);
    border-radius: 16px;
    padding: 32px;
    border: 1px solid var(--border);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
    text-align: center;
}

@media (max-width: 480px) {
    .role-entry-modal-card {
        padding: 24px 16px;
    }

    .role-entry-grid {
        gap: 8px;
    }
}

.role-entry-modal-card h2 {
    margin: 0 0 12px 0;
    font-size: 1.5rem;
}

.role-entry-modal-card p {
    margin: 0 0 24px 0;
    color: var(--muted);
    font-size: 1rem;
}

.role-entry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
}

.role-entry-grid button {
    margin: 0 !important;
    height: 48px;
    font-size: 1rem;
    font-weight: 600;
    width: 100% !important;
    min-width: 10px !important;
    /* Anular min-width de 190px */
    max-width: none !important;
    padding: 0 4px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-brand img {
    max-width: 100%;
    max-height: 50px;
    object-fit: contain;
}

.sidebar.collapsed .sidebar-brand {
    padding: 10px 5px;
}

.header-controls {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-controls .notifications-bell {
    margin-right: 0;
    display: flex;
    align-items: center;
}

.header-user-menu {
    position: relative;
    margin-left: 2px;
}

.header-user-btn {
    width: auto;
    margin: 0;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.header-user-brand-icon {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--border);
}

.header-user-btn:hover {
    background: var(--tab-hover);
}

.header-user-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
    padding: 6px;
    display: none;
    z-index: 1200;
}

.header-user-dropdown.open {
    display: block;
}

.header-user-dropdown button {
    width: 100%;
    margin: 0;
    text-align: left;
}

.btn-theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.btn-theme-toggle:hover {
    background: var(--tab-hover);
}

.password-field-wrap {
    position: relative;
    display: block;
    width: 100%;
}

.password-field-wrap input {
    width: 100%;
    box-sizing: border-box;
    padding-right: 52px;
}

.password-field-wrap .password-toggle-btn {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    min-width: 30px;
    margin: 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 0;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.password-field-wrap .password-toggle-btn:hover {
    color: var(--text);
    background: var(--tab-hover);
}

.password-field-wrap .password-toggle-btn:focus-visible {
    outline: none;
    color: var(--text);
    border-color: var(--border);
    background: var(--tab-hover);
}

.password-field-wrap .password-toggle-btn svg {
    width: 18px;
    height: 18px;
    display: block;
    fill: currentColor;
}

.password-field-wrap input::-ms-reveal {
    display: none;
}

/* sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 220px;
    height: 100vh;
    height: 100dvh;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    transition: width 0.3s, transform 0.3s ease;
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.sidebar.collapsed {
    width: 64px;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 48px 0 0 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0;
    padding-bottom: 12px;
    overscroll-behavior: contain;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.sidebar ul.is-drag-scroll {
    cursor: grab;
}

.sidebar ul.is-dragging {
    cursor: grabbing;
    user-select: none;
}

.sidebar::-webkit-scrollbar,
.sidebar ul::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.sidebar li {
    padding: 15px;
}

.sidebar li a {
    color: var(--sidebar-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    border-radius: 6px;
    padding: 8px 10px;
}

.sidebar li .menu-btn {
    color: var(--sidebar-text);
    background: transparent;
    border: none;
    appearance: none;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    border-radius: 6px;
    padding: 8px 10px;
    width: 100%;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.sidebar li .menu-btn:hover,
.sidebar li a:hover {
    background: rgba(255, 255, 255, 0.12);
}

.sidebar li .menu-btn:focus,
.sidebar li .menu-btn:active {
    background: rgba(255, 255, 255, 0.12);
    outline: none;
}

.menu-icon {
    min-width: 20px;
    text-align: center;
}

.menu-label {
    display: inline-block;
}

.sidebar li a.menu-link-active {
    background-color: #0d6efd;
    border-radius: 4px;
}

.sidebar.collapsed .menu-label {
    display: none;
}

#toggle-btn {
    position: relative;
    top: 0;
    right: 0;
    background: var(--sidebar-bg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--sidebar-text);
    font-size: 20px;
    cursor: pointer;
    width: calc(100% - 20px);
    height: 36px;
    margin: 10px;
    border-radius: 6px;
    z-index: 1100;
}

#mobile-toggle-btn {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    width: 42px;
    height: 42px;
    margin: 0;
    padding: 0;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 1301;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.main-content {
    margin-left: 220px;
    transition: margin-left 0.3s;
    padding: 10px;
}

.main-content.collapsed {
    margin-left: 64px;
}

.container {
    max-width: var(--content-max-width);
    width: 100%;
    margin: 0 auto;
    padding-inline: 4px;
    box-sizing: border-box;
}

h1 {
    text-align: center;
    color: var(--text);
    margin: 0;
}

.card {
    background: var(--card-bg);
    color: var(--text);
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

.form-group {
    margin-bottom: 15px;
}

.photo-area {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    min-width: 0;
}

.branding-logo-preview-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.branding-logo-preview {
    width: 92px;
    height: 92px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.filters-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.filters-row>input,
.filters-row>select,
.filters-row>button {
    flex: 1;
    min-width: 150px;
}

.filters-row>datalist {
    display: none;
}

#venta-top-sold.top-sold-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    align-items: stretch;
}

#venta-top-sold.top-sold-grid .top-sold-btn {
    width: 100%;
    min-width: 0;
    margin: 0;
    min-height: 52px;
    height: 52px;
    padding: 6px 10px;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.2;
    text-align: center;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cuadre-filters-row {
    align-items: flex-end;
}

.cuadre-filters-row .cuadre-field {
    flex: 1 1 180px;
    min-width: 180px;
}

.cuadre-filters-row .cuadre-actions {
    flex: 0 0 auto;
    min-width: 140px;
}

.cuadre-filters-row .cuadre-actions .btn-save {
    width: auto;
    min-width: 140px;
    margin-top: 0;
}

.efu-grid {
    display: grid;
    gap: 8px;
    align-items: end;
    min-width: 0;
}

.efu-grid-header {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.efu-grid-goal {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.efu-grid-med {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.efu-grid-med .efu-field {
    margin-bottom: 0;
    min-width: 0;
}

.efu-grid-med .efu-field label {
    margin-bottom: 4px;
}

.efu-grid-med .efu-field .efu-control {
    width: 100%;
}

.efu-grid-range {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.efu-grid-compare {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.efu-control {
    height: var(--btn-std-height);
    min-height: var(--btn-std-height);
    box-sizing: border-box;
    min-width: 0;
    width: 100%;
}

.efu-control-btn {
    min-height: var(--btn-std-height);
    height: var(--btn-std-height);
    margin-top: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    min-width: 0 !important;
    width: 100%;
}

/* Evita que botones globales con min-width fijo provoquen scroll lateral en medidas */
.efu-grid .btn-save,
.efu-grid .btn-edit,
.efu-grid .btn-cancel {
    min-width: 0 !important;
    width: 100%;
}

.efu-state {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid transparent;
}

.efu-state-up {
    background: #e6f9ee;
    color: #166534;
    border-color: #86efac;
}

.efu-state-down {
    background: #feecec;
    color: #991b1b;
    border-color: #fca5a5;
}

.efu-state-neutral {
    background: #eff6ff;
    color: #1e3a8a;
    border-color: #93c5fd;
}

.efu-metric-chip {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--input-bg);
    color: var(--text);
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
}

.efu-metric-chip.is-active {
    background: #dbeafe;
    border-color: #60a5fa;
    color: #1e3a8a;
}

.efu-bars-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-weight: 600;
}

.efu-bars-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
}

.efu-bar-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 8px;
    background: var(--card-bg);
}

.efu-bar-head,
.efu-bar-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
}

.efu-bar-track {
    position: relative;
    height: 14px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
    margin: 6px 0;
}

.efu-bar-fill {
    position: absolute;
    left: 0;
    top: 1px;
    height: 12px;
    border-radius: 999px;
}

.efu-bar-base {
    z-index: 1;
    opacity: 0.58;
}

.efu-bar-top {
    top: 4px;
    height: 6px;
    z-index: 3;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.28);
}

.efu-bar-previous {
    background: rgba(245, 158, 11, 0.95);
}

.efu-bar-up {
    background: #16a34a;
}

.efu-bar-down {
    background: #dc2626;
}

.efu-bar-neutral {
    background: #2563eb;
}

tbody[id$="-metrics-body"] tr.efu-row-up {
    background: rgba(22, 163, 74, 0.12);
}

tbody[id$="-metrics-body"] tr.efu-row-down {
    background: rgba(220, 38, 38, 0.12);
}

tbody[id$="-metrics-body"] tr.efu-row-neutral {
    background: rgba(37, 99, 235, 0.08);
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

input,
select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    border-radius: 4px;
    box-sizing: border-box;
    /* Importante para el padding */
}

textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    border-radius: 4px;
    box-sizing: border-box;
}

.btn-save {
    background-color: #28a745;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    font-size: 16px;
}

.btn-save:hover {
    background-color: #218838;
}

.btn-save,
.btn-cancel {
    margin-top: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    min-width: 0;
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background-color: #007bff;
    color: white;
}

tr:hover {
    background-color: var(--row-hover);
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.menu-tree-editor-host {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    min-height: 220px;
    background: var(--card-bg);
}

.menu-tree-root {
    list-style: none;
    padding-left: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}

.menu-tree-main {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: var(--card-bg);
    transition: transform 120ms ease, box-shadow 120ms ease;
}

.menu-tree-main-header {
    display: flex;
    gap: 12px;
    align-items: center;
    min-height: 34px;
}

.menu-tree-meta {
    opacity: 0.75;
    color: var(--muted);
}

.menu-tree-children {
    list-style: none;
    margin: 12px 0 0 0;
    padding-left: 18px;
    display: grid;
    gap: 10px;
}

.menu-tree-child {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    border: 1px dashed var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    background: var(--tab-hover);
    transition: transform 120ms ease, box-shadow 120ms ease;
}

.menu-tree-actions {
    justify-self: end;
    display: grid;
    grid-template-columns: 32px;
    grid-template-rows: 28px 28px;
    gap: 4px;
}

.menu-tree-actions .btn-edit {
    margin-right: 0;
    width: 32px;
    min-width: 32px;
    height: 28px;
    padding: 0;
    line-height: 1;
}

.menu-tree-actions .btn-edit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.menu-tree-detached {
    border: 1px dashed #f59e0b;
    border-radius: 8px;
    padding: 12px;
    background: var(--tab-hover);
    transition: transform 120ms ease, box-shadow 120ms ease;
}

.menu-tree-detached-row {
    display: flex;
    gap: 12px;
    align-items: center;
    min-height: 34px;
}

.menu-tree-label {
    flex: 1 1 auto;
}

.menu-tree-drag-handle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 13px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-weight: 700;
    line-height: 1.2;
    cursor: grab;
    user-select: none;
}

.menu-tree-drag-handle-main {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
}

.menu-tree-drag-handle-main:hover {
    filter: brightness(1.08);
}

.menu-tree-drag-handle-sub {
    background: #f59e0b;
    color: #1f2937;
    border-color: #d97706;
    box-shadow: 0 2px 6px rgba(217, 119, 6, 0.25);
}

.menu-tree-drag-handle-sub:hover {
    background: #fbbf24;
}

.menu-tree-drag-handle-main::before,
.menu-tree-drag-handle-sub::before {
    display: inline-block;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
    border-radius: 999px;
    padding: 2px 6px;
}

.menu-tree-drag-handle-main::before {
    content: "MENU";
    background: rgba(255, 255, 255, 0.2);
    color: var(--sidebar-text);
}

.menu-tree-drag-handle-sub::before {
    content: "SUB";
    background: rgba(31, 41, 55, 0.16);
    color: #1f2937;
}

.menu-tree-dragging .menu-tree-drag-handle,
.menu-tree-drag-handle:active {
    cursor: grabbing;
}

.menu-tree-dragging {
    opacity: 0.6;
}

.menu-tree-drop-before {
    box-shadow: inset 0 3px 0 #22c55e;
    transform: translateY(4px);
}

.menu-tree-drop-after {
    box-shadow: inset 0 -3px 0 #22c55e;
    transform: translateY(-4px);
}

.menu-tree-drop-placeholder {
    list-style: none;
    border: 2px dashed #22c55e;
    border-radius: 8px;
    background: var(--tab-hover);
    margin: 8px 0;
}

.table-wrap-sm {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 12px;
}

.btn-pay {
    background-color: #007bff;
    color: white;
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-pay:hover {
    background-color: #0069d9;
}

.btn-logout {
    background-color: #dc3545;
    color: white;
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-logout:hover {
    background-color: #c82333;
}

.btn-edit,
.btn-delete {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: white;
    margin-right: 5px;
}

.btn-edit {
    background-color: #1f6feb;
}

.btn-edit:hover {
    background-color: #1558b0;
}

.btn-delete {
    background-color: #dc3545;
}

.btn-delete:hover {
    background-color: #c82333;
}

.btn-icon-action {
    min-width: var(--btn-std-height);
    width: calc(var(--btn-std-height) + 8px);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
    border: 2px solid rgba(255, 255, 255, 0.75);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25);
}

.btn-icon-action .btn-icon-symbol {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-1px);
}

.btn-icon-edit {
    background: linear-gradient(135deg, #0ea5e9 0%, #1d4ed8 100%);
}

.btn-icon-edit:hover {
    background: linear-gradient(135deg, #0284c7 0%, #1e40af 100%);
}

.btn-icon-reprint {
    background: linear-gradient(135deg, #f97316 0%, #dc2626 100%);
}

.btn-icon-reprint:hover {
    background: linear-gradient(135deg, #ea580c 0%, #b91c1c 100%);
}

.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.btn-cancel {
    background-color: #6c757d;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    font-size: 16px;
    margin-top: 10px;
}

.btn-cancel:hover {
    background-color: #5a6268;
}

#form-branding #btn-reset-branding,
#form-branding #btn-reset-db-total {
    display: block;
    width: 100%;
    margin-top: 8px;
    margin-right: 0;
}

#form-branding .branding-danger-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

#form-branding .branding-danger-actions #btn-reset-branding,
#form-branding .branding-danger-actions #btn-reset-db-total {
    width: 100%;
    margin-top: 0;
}

/* Estandar global de dimensiones para botones principales. */
.btn-save,
.btn-cancel,
.btn-edit,
.btn-delete,
.btn-pay,
.btn-logout {
    min-width: var(--btn-std-width);
    min-height: var(--btn-std-height);
    height: var(--btn-std-height);
    padding: 0 12px;
    font-size: 16px;
    line-height: 1;
    box-sizing: border-box;
}

/* Estilos para el Sub-menú de pestañas */
.sub-menu {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #ddd;
    padding-bottom: 10px;
}

.tab-btn {
    background: none;
    border: none;
    font-size: 16px;
    padding: 10px 20px;
    cursor: pointer;
    color: var(--muted);
    font-weight: bold;
    border-radius: 4px;
}

#perfil-tabs .tab-label-short {
    display: none;
}

.tab-btn:hover {
    background-color: var(--tab-hover);
}

.tab-btn.active {
    background-color: #007bff;
    color: white;
}

.card-acceso {
    max-width: 1200px;
    /* Expandido para sincronizar con el modo hibrido */
    margin-left: auto;
    margin-right: auto;
}

.form-acceso-main {
    display: grid;
    gap: 12px;
}

.form-acceso-main #acceso-busqueda {
    min-height: 56px;
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.4px;
}

.form-acceso-main .btn-save {
    min-height: 52px;
    font-size: 22px;
    font-weight: 700;
}

.resultado-acceso {
    margin-top: 18px;
    min-height: 200px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--input-bg);
    padding: 16px 18px;
    font-size: 24px;
    line-height: 1.35;
}

.resultado-acceso p {
    margin: 0 0 8px 0;
}

.hidden {
    display: none !important;
}

.hint-box {
    background: var(--hint-bg);
    border: 1px solid var(--hint-border);
    border-radius: 6px;
    padding: 10px;
    margin-top: 10px;
}

.app-modal {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: rgba(2, 6, 23, 0.75);
    backdrop-filter: blur(4px);
}

.app-modal-card {
    width: 100%;
    max-width: 700px;
    max-height: 95vh;
    overflow: hidden;
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
}

.app-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
}

.app-modal-head h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
}

.app-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.app-modal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,0.02);
}

.app-modal-close {
    min-width: 32px !important;
    height: 36px !important;
    padding: 0 16px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px !important;
    background: #ef4444 !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.4);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3) !important;
    z-index: 10;
}

/* Si es solo un ícono (sin texto), mantener forma circular */
.app-modal-close:empty {
    width: 32px;
    padding: 0;
    border-radius: 50%;
}

.app-modal-close i {
    pointer-events: none;
}

.theme-dark .app-modal-close {
    border-color: rgba(255, 255, 255, 0.1);
}

.app-modal-close:hover {
    background: #dc2626;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.app-modal-user-list {
    margin-top: 0;
    max-height: 72vh;
    overflow: auto;
    padding: 8px 10px;
}

/* Modal de servicios: scroll sutil */
#service-detail-modal-body {
    overflow-y: auto;
    overflow-x: hidden;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#service-detail-modal-body::-webkit-scrollbar {
    width: 0;
    height: 0;
}

#service-detail-modal .app-modal-card {
    width: min(1320px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    max-height: min(94vh, 980px);
}

#service-detail-modal .app-modal-user-list {
    max-height: 84vh;
    padding: 8px 6px 12px;
    background: var(--bg);
    border-radius: 8px;
}

#service-detail-modal-body>.card {
    margin-bottom: 0;
    border: 1px solid var(--border);
    box-shadow: none;
}

.sp-detail-header {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
        "photo"
        "name"
        "redes"
        "desc";
    gap: 14px;
    align-items: center;
    justify-items: center;
}

.sp-detail-photo-wrap {
    grid-area: photo;
    display: flex;
    justify-content: center;
}

.sp-detail-photo {
    width: 96px;
    height: 96px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--border);
}

.sp-detail-redes {
    grid-area: redes;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
}

.sp-detail-red-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid var(--border);
    text-decoration: none;
}

.sp-detail-name {
    margin: 0 0 4px 0;
}

.sp-detail-name-wrap {
    grid-area: name;
    min-width: 0;
    text-align: center;
    width: 100%;
}

.sp-detail-description {
    grid-area: desc;
    margin-top: 8px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.sp-detail-services-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    align-items: start;
}

.sp-detail-service-card {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    margin-bottom: 2px;
}

.app-modal-actions {
    gap: 8px;
    margin-top: 0;
}

.app-modal-actions .btn-edit,
.app-modal-actions .btn-cancel,
.app-modal-actions .btn-save {
    width: auto;
    margin-top: 0;
}

/* Ajustes de alineacion para botones/filas en el modal de perfil */
.clickable-id, .activity-id a {
    color: var(--primary, #007bff) !important;
    font-weight: bold !important;
    text-decoration: underline !important;
    cursor: pointer !important;
    display: inline-block;
}
.clickable-id:hover, .activity-id a:hover {
    text-decoration: none !important;
    opacity: 0.8 !important;
}

#self-profile-modal .btn-edit,
#self-profile-modal .btn-cancel,
#self-profile-modal .btn-save {
    min-width: 0;
    width: auto;
    height: 36px;
    min-height: 36px;
    margin-top: 0;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#self-profile-modal .sp-profile-photo-actions,
#self-profile-modal .sp-serv-photo-actions,
#self-profile-modal .app-modal-actions {
    align-items: center;
}

#self-profile-modal .sp-red-row {
    grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr) auto !important;
}

#self-profile-modal .sp-serv-head {
    grid-template-columns: minmax(0, 1fr) auto !important;
}

#self-profile-modal .sp-serv-media {
    grid-template-columns: 110px minmax(0, 1fr) !important;
}

@media (max-width: 768px) {
    #self-profile-modal .sp-red-row {
        grid-template-columns: 30px minmax(0, 1fr) !important;
    }

    #self-profile-modal .sp-red-url {
        grid-column: 1 / -1;
    }

    #self-profile-modal .sp-red-remove {
        grid-column: 1 / -1;
        justify-self: start;
    }

    #self-profile-modal .sp-serv-media {
        grid-template-columns: 1fr !important;
    }

    #self-profile-modal .sp-serv-photo-actions,
    .serv-photo-actions {
        grid-template-columns: 1fr !important;
    }

    /* Evita desborde horizontal en modal de perfil/estado fisico en mobile */
    #self-profile-modal {
        padding: 8px !important;
        align-items: flex-start;
    }

    #self-profile-modal .app-modal-card {
        width: calc(100vw - 16px) !important;
        max-width: calc(100vw - 16px) !important;
        padding: 12px !important;
        overflow-x: hidden !important;
    }

    #self-profile-modal .app-modal-user-list {
        overflow-x: hidden !important;
    }

    #self-profile-modal .app-modal-user-list>div:first-child {
        grid-template-columns: 1fr !important;
        min-width: 0 !important;
    }

    #self-profile-modal section,
    #self-profile-modal .card,
    #self-profile-modal .hint-box {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    #self-profile-modal input,
    #self-profile-modal select,
    #self-profile-modal textarea {
        min-width: 0 !important;
    }

    #service-detail-modal {
        padding: 0;
        align-items: flex-end;
    }

    #service-detail-modal .app-modal-card {
        width: 100vw !important;
        max-height: 96dvh;
        border-radius: 16px 16px 0 0;
        padding: 12px;
    }

    #service-detail-modal .app-modal-user-list {
        max-height: 78dvh;
        padding: 8px 6px 16px;
    }

    .sp-detail-header {
        grid-template-columns: 1fr;
        grid-template-areas:
            "photo"
            "name"
            "redes"
            "desc";
        gap: 10px;
    }

    .sp-detail-redes {
        justify-content: center;
        max-width: 100%;
    }

    .sp-detail-services-grid {
        grid-template-columns: 1fr;
    }
}

#btn-cuadre-select-all,
#btn-cuadre-clear-all,
#btn-print-cuadre-all,
#btn-print-cuadre-none {
    width: 190px;
    min-width: 190px;
    max-width: 190px;
    height: 40px;
    min-height: 40px;
    max-height: 40px;
    padding: 0 12px;
    margin-top: 0;
    margin-right: 0;
    font-size: 16px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 190px;
    text-align: center;
}

#btn-open-cuadre-user-modal,
#btn-open-cuadre-print-modal,
#btn-open-gastos-user-modal {
    width: 100%;
    margin-top: 0;
    margin-right: 0;
    padding: 10px;
    min-height: 42px;
    font-size: 16px;
    box-sizing: border-box;
}

body.modal-open {
    overflow: hidden;
}

.option-check-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 40px;
    padding: 6px 4px;
    margin: 0;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 8px;
    background: rgba(148, 163, 184, 0.08);
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.option-check-row+.option-check-row {
    margin-top: 4px;
}

.option-check-row span {
    flex: 1 1 auto;
}

.option-check-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    margin: 0;
    padding: 0;
    flex: 0 0 18px;
    accent-color: #16a34a;
}

/* Modales de cuadre/mobile: centrado y ancho seguro dentro del viewport. */
#modal-cuadre-print-options .app-modal-card,
#modal-cuadre-usuarios .app-modal-card,
#modal-gastos-usuarios .app-modal-card {
    width: min(980px, 100%);
    max-width: 100%;
    max-height: calc(100vh - 24px);
    margin: 0 auto;
    box-sizing: border-box;
}

#modal-cuadre-print-options.app-modal,
#modal-cuadre-usuarios.app-modal,
#modal-gastos-usuarios.app-modal {
    padding: 12px;
    box-sizing: border-box;
}

#modal-cuadre-print-options .app-modal-user-list,
#modal-cuadre-usuarios .app-modal-user-list,
#modal-gastos-usuarios .app-modal-user-list {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

#modal-cuadre-print-options #btn-print-cuadre-all,
#modal-cuadre-print-options #btn-print-cuadre-none,
#modal-cuadre-print-options #btn-cuadre-apply-print-options,
#modal-cuadre-usuarios #btn-cuadre-select-all,
#modal-cuadre-usuarios #btn-cuadre-clear-all,
#modal-cuadre-usuarios #btn-cuadre-apply-users,
#modal-gastos-usuarios #btn-gastos-select-all,
#modal-gastos-usuarios #btn-gastos-clear-all,
#modal-gastos-usuarios #btn-gastos-apply-users {
    width: 100%;
    min-width: 0;
    max-width: none;
    flex: 1 1 auto;
}

.option-check-row:hover {
    border-color: rgba(22, 163, 74, 0.45);
}

.option-check-row:has(input[type="checkbox"]:checked) {
    border-color: rgba(22, 163, 74, 0.85);
    background: rgba(22, 163, 74, 0.14);
    box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.25);
}

html.theme-dark .option-check-row,
body.theme-dark .option-check-row {
    border-color: rgba(100, 116, 139, 0.45);
    background: rgba(51, 65, 85, 0.35);
}

html.theme-dark .option-check-row:has(input[type="checkbox"]:checked),
body.theme-dark .option-check-row:has(input[type="checkbox"]:checked) {
    border-color: rgba(34, 197, 94, 0.9);
    background: rgba(22, 163, 74, 0.24);
    box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.3);
}

.perm-tree {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 12px;
    margin-top: 8px;
    align-items: start;
}

.perm-area {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card-bg);
    overflow: hidden;
}

.perm-area-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    background: var(--tab-hover);
    border-bottom: 1px solid var(--border);
}

.perm-parent {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    margin: 0;
}

.perm-toggle {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text);
    width: 30px;
    height: 28px;
    cursor: pointer;
    line-height: 1;
    font-size: 14px;
}

.perm-toggle:hover {
    background: var(--tab-hover);
}

.perm-children {
    padding: 8px 12px 12px 32px;
    display: grid;
    gap: 6px;
}

.perm-area.collapsed .perm-children {
    display: none;
}

.perm-child {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    margin: 0;
}

.perm-parent input[type="checkbox"],
.perm-child input[type="checkbox"] {
    width: auto;
}

.activity-log {
    display: grid;
    gap: 10px;
    color: var(--text);
}

#activity-log-container {
    color: var(--text);
    background: transparent;
}

.activity-item {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    grid-template-rows: auto auto;
    grid-template-areas:
        "icon time id"
        "icon desc desc";
    gap: 2px 12px;
    align-items: start;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
}

.activity-icon {
    grid-area: icon;
    font-size: 20px;
    text-align: center;
    align-self: center;
}

.activity-time {
    grid-area: time;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85em;
}

.activity-id {
    grid-area: id;
    font-weight: 700;
    font-size: 0.85em;
    color: var(--muted);
    text-align: right;
}

.activity-desc {
    grid-area: desc;
    color: var(--text);
    word-break: break-word;
    margin-top: 2px;
    line-height: 1.4;
}

.empty-state {
    color: var(--muted);
    margin: 8px 0 0;
}

html.theme-dark .activity-item,
body.theme-dark .activity-item {
    background: #0b1220;
    border-color: #334155;
}

html.theme-dark .activity-time,
body.theme-dark .activity-time {
    color: #93c5fd;
}

html.theme-dark #activity-log-container,
body.theme-dark #activity-log-container {
    color: #e5e7eb;
}

html.theme-dark .activity-desc,
html.theme-dark .empty-state,
body.theme-dark .activity-desc,
body.theme-dark .empty-state {
    color: #cbd5e1;
}

.muted {
    color: var(--muted);
}

.dashboard-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.dashboard-quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* En el topbar del dashboard, los botones no deben ocupar todo el ancho */
.dashboard-quick-actions .btn-save,
.dashboard-quick-actions .btn-cancel,
.dashboard-quick-actions .btn-edit {
    width: auto;
    margin-top: 0;
}

.dashboard-main-widget {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 10px;
    min-height: 0;
}

.dashboard-main-widget-head {
    display: grid;
    gap: 4px;
}

.dashboard-main-widget-title {
    margin: 0;
}

.dashboard-main-widget-time {
    margin: 0;
}

.dashboard-main-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-content: start;
    min-height: 0;
}

.dashboard-main-actions .btn-save,
.dashboard-main-actions .btn-cancel,
.dashboard-main-actions .btn-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 var(--btn-std-width);
    width: var(--btn-std-width);
    max-width: var(--btn-std-width);
    box-sizing: border-box;
    margin: 0;
    min-width: var(--btn-std-width);
    min-height: var(--btn-std-height);
    height: auto;
    padding: 8px 10px;
    font-size: 14px;
    line-height: 1.2;
    white-space: normal;
    text-align: center;
    overflow-wrap: anywhere;
}

.dashboard-main-actions #btn-dashboard-refresh,
.dashboard-main-actions a[href="cobros.html"],
.dashboard-main-actions a[href="actividad.html"] {
    flex-basis: 100%;
    width: 100%;
    min-width: 0;
}

.dashboard-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    grid-auto-rows: auto;
    align-content: start;
    gap: 12px;
    margin-bottom: 0;
    min-height: 0;
}

#dashboard-widgets {
    --dashboard-columns: 12;
    display: grid;
    grid-template-columns: repeat(var(--dashboard-columns), minmax(0, 1fr));
    grid-auto-rows: 56px;
    grid-auto-flow: row dense;
    align-items: stretch;
    gap: 12px;
}

#dashboard-widgets>[data-widget] {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

#dashboard-widgets>[data-widget]>.card {
    margin-bottom: 0;
    height: 100%;
    overflow: auto;
}

body.dashboard-designer-preview-mode #dashboard-widgets>[data-widget]:not([data-widget="kpis"])>.card {
    border: 2px dashed #60a5fa;
}

html.theme-dark body.dashboard-designer-preview-mode #dashboard-widgets>[data-widget]:not([data-widget="kpis"])>.card,
body.theme-dark.dashboard-designer-preview-mode #dashboard-widgets>[data-widget]:not([data-widget="kpis"])>.card {
    border-color: #3b82f6;
}

.dashboard-kpi {
    margin: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    overflow: hidden;
}

.dashboard-kpi span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.dashboard-kpi strong {
    font-size: 24px;
}

.dashboard-kpi small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.calendar-day-head {
    text-align: center;
    font-weight: bold;
    padding: 10px;
    background: var(--card-bg);
    border-radius: 4px;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.calendar-day {
    aspect-ratio: 1;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

.calendar-day:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: var(--primary);
}

.calendar-day.empty {
    background: transparent;
    border: none;
}

.calendar-day.today {
    border: 2px solid var(--primary);
}

.calendar-day-num {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 4px;
}

.calendar-day-venc {
    font-size: 11px;
    background: #ef4444;
    color: white;
    padding: 2px 6px;
    border-radius: 12px;
    font-weight: 600;
    margin-top: auto;
}

.calendar-day-venc.zero {
    background: var(--muted);
    opacity: 0.5;
}

.calendar-main-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.dashboard-main-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.dashboard-button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(var(--btn-std-width), 100%), 1fr));
    gap: 8px;
}

.dashboard-button-grid a,
.dashboard-button-grid button {
    display: block;
    box-sizing: border-box;
    text-align: center;
    margin-top: 0;
    width: 100%;
    min-width: 0;
    min-height: var(--btn-std-height);
    height: auto;
    padding: 8px 10px;
    font-size: 14px;
    line-height: 1.2;
    white-space: normal;
    overflow-wrap: anywhere;
}

.dashboard-list {
    display: grid;
    gap: 6px;
}

.dashboard-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    font-size: 13px;
    overflow-wrap: anywhere;
}

#tabla-vencer-hoy .dashboard-row,
#tabla-vencer-manana .dashboard-row,
#tabla-vencidos .dashboard-row,
#tabla-vencer-semana .dashboard-row {
    grid-template-columns: 80px 2fr 1.4fr 1fr;
}

#dashboard-actividad .dashboard-row {
    grid-template-columns: 1.5fr 1fr 2fr;
}

.dashboard-alerts {
    display: grid;
    gap: 8px;
}

.dashboard-alert-item {
    width: 100%;
}

.dashboard-alert-item .dash-badge {
    display: block;
    width: 100%;
    box-sizing: border-box;
}

.dash-badge {
    display: inline-block;
    padding: 8px 10px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    line-height: 1.35;
    border: 1px solid transparent;
}

.dash-badge-warning {
    background: #fff4db;
    border-color: #f7c46c;
    color: #5f3b00;
}

.dash-badge-info {
    background: #e7f2ff;
    border-color: #9cc5ff;
    color: #07357f;
}

.dash-badge-error {
    background: #ffe6e6;
    border-color: #f2aaaa;
    color: #7f1111;
}

html.theme-dark .dash-badge-warning,
body.theme-dark .dash-badge-warning {
    background: #3f3111;
    border-color: #8d6c2e;
    color: #ffd98a;
}

html.theme-dark .dash-badge-info,
body.theme-dark .dash-badge-info {
    background: #0e2545;
    border-color: #275a9d;
    color: #bfdbfe;
}

html.theme-dark .dash-badge-error,
body.theme-dark .dash-badge-error {
    background: #3f1c24;
    border-color: #7f3342;
    color: #fecaca;
}

.mini-bars {
    display: grid;
    gap: 6px;
}

.mini-bar-row {
    display: grid;
    grid-template-columns: 48px 1fr max-content;
    align-items: center;
    gap: 8px;
}

.mini-bar-row strong {
    white-space: nowrap;
    text-align: right;
}

.mini-bar-track {
    height: 8px;
    border-radius: 99px;
    background: #dbe4ef;
    overflow: hidden;
}

.mini-bar-fill {
    height: 100%;
    background: #0d6efd;
    border-radius: 99px;
}

html.theme-dark .mini-bar-track,
body.theme-dark .mini-bar-track {
    background: #1f2b3f;
}

.ui-presenter-cards {
    display: none;
    gap: 10px;
    margin-top: 10px;
}

.ui-presenter-card {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
    background: #ffffff;
}

.ui-presenter-title {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #0f172a;
}

.ui-presenter-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.ui-presenter-label {
    color: #475569;
    font-size: 12px;
}

.ui-presenter-value {
    font-weight: 600;
    color: #0f172a;
    text-align: right;
}

.ui-presenter-toggle {
    margin-top: 6px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #0f172a;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
}

.ui-presenter-cards.is-disabled {
    display: none !important;
}

.ui-presenter-row-clickable td {
    cursor: pointer;
}

.ui-presenter-modal {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.62);
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    box-sizing: border-box;
    overflow: auto;
    overscroll-behavior: contain;
    padding:
        max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.ui-presenter-modal.hidden {
    display: none;
}

.ui-presenter-modal-card {
    width: min(980px, calc(100vw - 28px));
    width: min(980px, calc(100dvw - 28px));
    max-width: calc(100vw - 28px);
    max-width: calc(100dvw - 28px);
    max-height: calc(100vh - 28px);
    max-height: calc(100dvh - 28px);
    background: #fff;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    min-width: 0;
    margin: auto;
}

.ui-presenter-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
}

.ui-presenter-modal-head h3 {
    margin: 0;
    font-size: 15px;
    color: #0f172a;
}

.ui-presenter-modal-head button {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #0f172a;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
}

.ui-presenter-modal-body {
    padding: 10px 12px;
    overflow: auto;
    min-width: 0;
}

.ui-presenter-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.ui-presenter-modal-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3px;
    padding: 8px 0;
    border-bottom: 1px dashed #e2e8f0;
    min-width: 0;
}

.ui-presenter-modal-label {
    color: #475569;
    font-size: 12px;
}

.ui-presenter-modal-value {
    color: #0f172a;
    font-weight: 700;
    font-size: 13px;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ui-presenter-modal-body * {
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-height: 820px) {
    .sidebar {
        height: 100vh;
        height: 100dvh;
        overflow-y: auto;
    }

    .sidebar ul {
        margin-top: 48px;
        max-height: none;
        height: calc(100dvh - 56px);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 900px) {

    .app-modal:not(.hidden),
    .ui-presenter-modal:not(.hidden) {
        display: flex !important;
        padding: 8px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    .app-modal:not(.hidden) .app-modal-card,
    .ui-presenter-modal:not(.hidden) .ui-presenter-modal-card {
        position: relative !important;
        margin: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: calc(100vh - 16px) !important;
        max-height: calc(100dvh - 16px) !important;
    }

    body {
        padding: 0;
    }

    .sidebar {
        width: 240px;
        transform: translateX(-100%);
        overflow-x: hidden;
        overflow-y: auto;
        height: 100dvh;
    }

    .sidebar ul {
        max-height: none;
        height: calc(100dvh - 56px);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        width: 64px;
    }

    .sidebar.collapsed.mobile-open {
        width: 64px;
    }

    #toggle-btn {
        display: none;
    }

    #mobile-toggle-btn {
        display: inline-flex;
        position: static;
        top: auto;
        left: auto;
        margin: 0;
        box-shadow: none;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
    }

    .main-content,
    .main-content.collapsed {
        margin-left: 0;
        padding: 8px 6px;
    }

    header {
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        row-gap: 6px;
    }

    header h1 {
        display: block;
        order: 2;
        flex: 1 0 100%;
        width: 100%;
        margin: 0;
        text-align: left;
        font-size: clamp(1rem, 4.6vw, 1.2rem);
        line-height: 1.15;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .btn-logout {
        min-width: 0;
        width: auto;
    }

    .header-controls {
        order: 1;
        margin-left: auto;
        width: auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
    }

    .app-brand-logo,
    #mobile-toggle-btn {
        order: 1;
    }

    .container {
        max-width: 100%;
        padding-inline: 2px;
        overflow-x: hidden;
    }

    .photo-area {
        gap: 10px;
        justify-content: center;
    }

    .photo-area img {
        margin-bottom: 10px;
    }

    .photo-area button {
        flex: 1 1 120px;
        min-width: 0;
    }

    table {
        min-width: 0 !important;
    }

    .table-wrap table {
        min-width: 600px !important;
    }

    .card {
        padding: 14px;
        overflow: hidden;
    }

    /* Regla global mobile para tablas:
       - Sin scroll horizontal
       - Ajuste a ancho de pantalla
       - Mostrar solo 4 columnas clave */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-inline: -4px;
        padding-inline: 4px;
    }

    .table-wrap table {
        min-width: 500px !important;
        width: 100%;
        table-layout: auto;
    }

    .table-wrap table th,
    .table-wrap table td {
        font-size: 11px;
        padding: 7px 6px;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    th,
    td {
        padding: 8px;
        font-size: 12px;
    }

    .sub-menu {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        gap: 6px;
        margin-top: 8px;
        padding-bottom: 4px;
    }

    .tab-btn {
        width: auto;
        flex: 0 0 auto;
        min-width: 0;
        white-space: nowrap;
        font-size: 14px;
        padding: 8px 12px;
    }

    /* Tabs de perfil: sin scroll horizontal, etiquetas largas parten linea */
    #perfil-tabs.sub-menu {
        overflow-x: hidden !important;
        flex-wrap: nowrap !important;
        gap: 6px;
    }

    #perfil-tabs .tab-btn {
        flex: 1 1 0;
        min-width: 0;
        white-space: nowrap;
        text-align: center;
        font-size: 12px;
        line-height: 1.2;
        padding: 8px 6px;
    }

    #perfil-tabs .tab-label-full {
        display: none;
    }

    #perfil-tabs .tab-label-short {
        display: inline;
    }

    tbody[id$="-metrics-body"] tr.efu-row-up td {
        background: rgba(22, 163, 74, 0.14) !important;
    }

    tbody[id$="-metrics-body"] tr.efu-row-down td {
        background: rgba(220, 38, 38, 0.14) !important;
    }

    tbody[id$="-metrics-body"] tr.efu-row-neutral td {
        background: rgba(37, 99, 235, 0.1) !important;
    }

    .card-acceso {
        max-width: 100%;
    }

    .form-acceso-main #acceso-busqueda {
        min-height: 48px;
        font-size: 22px;
    }

    .form-acceso-main .btn-save {
        min-height: 46px;
        font-size: 18px;
    }

    .resultado-acceso {
        min-height: 150px;
        font-size: 18px;
        padding: 12px;
    }

    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }

    .cuadre-filters-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        align-items: end;
    }

    .cuadre-filters-row .cuadre-field {
        min-width: 0;
        width: 100%;
    }

    .cuadre-filters-row .cuadre-actions {
        grid-column: 1 / -1;
    }

    .header-user-btn {
        font-size: 12px;
        padding: 7px 8px;
    }

    .cuadre-filters-row .cuadre-actions,
    .cuadre-filters-row .cuadre-actions .btn-save {
        width: 100%;
        min-width: 0;
    }

    .perm-tree {
        grid-template-columns: 1fr;
    }

    .dashboard-main-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-button-grid {
        grid-template-columns: 1fr;
    }

    #dashboard-widgets {
        grid-template-columns: 1fr !important;
        grid-auto-rows: auto;
    }

    #dashboard-widgets>[data-widget] {
        grid-column: 1 / -1 !important;
        overflow: visible;
    }

    #dashboard-widgets>[data-widget]>.card {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    body.page-servicios .main-content {
        padding-top: 8px;
    }

    body.page-servicios header {
        align-items: center;
        gap: 8px;
    }

    body.page-servicios .header-controls {
        width: auto;
        margin-left: auto;
        gap: 6px;
    }

    body.page-servicios .app-brand-logo {
        width: 34px;
        height: 34px;
    }

    body.page-servicios #mobile-toggle-btn {
        width: 36px;
        height: 36px;
    }

    .dashboard-row,
    #tabla-vencer-hoy .dashboard-row,
    #tabla-vencer-manana .dashboard-row,
    #tabla-vencidos .dashboard-row,
    #dashboard-actividad .dashboard-row {
        grid-template-columns: 1fr;
    }

    #tabla-ultimos-pagos .dashboard-row,
    #tabla-ultimas-ventas .dashboard-row {
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: 10px;
        row-gap: 6px;
        align-items: center;
    }

    #tabla-ultimos-pagos .dashboard-row>span:nth-child(1),
    #tabla-ultimas-ventas .dashboard-row>span:nth-child(1) {
        grid-column: 1;
        font-weight: 700;
    }

    #tabla-ultimos-pagos .dashboard-row>span:nth-child(4),
    #tabla-ultimas-ventas .dashboard-row>span:nth-child(4) {
        grid-column: 2;
        justify-self: end;
        text-align: right;
        font-weight: 700;
    }

    #tabla-ultimos-pagos .dashboard-row>span:nth-child(2),
    #tabla-ultimas-ventas .dashboard-row>span:nth-child(2) {
        grid-column: 1 / -1;
    }

    #tabla-ultimos-pagos .dashboard-row>span:nth-child(3),
    #tabla-ultimas-ventas .dashboard-row>span:nth-child(3) {
        grid-column: 1;
    }

    #tabla-ultimos-pagos .dashboard-row>span:nth-child(5),
    #tabla-ultimas-ventas .dashboard-row>span:nth-child(5) {
        grid-column: 2;
        justify-self: end;
        text-align: right;
        opacity: 0.9;
        font-size: 12px;
    }

    #tabla-vencer-hoy .dashboard-row,
    #tabla-vencer-manana .dashboard-row,
    #tabla-vencer-semana .dashboard-row {
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: 10px;
        row-gap: 6px;
        align-items: center;
    }

    #tabla-vencer-hoy .dashboard-row>span:nth-child(1),
    #tabla-vencer-manana .dashboard-row>span:nth-child(1),
    #tabla-vencer-semana .dashboard-row>span:nth-child(1) {
        grid-column: 1;
        font-weight: 700;
    }

    #tabla-vencer-hoy .dashboard-row>span:nth-child(4),
    #tabla-vencer-manana .dashboard-row>span:nth-child(4),
    #tabla-vencer-semana .dashboard-row>span:nth-child(4) {
        grid-column: 2;
        justify-self: end;
        text-align: right;
        opacity: 0.9;
        font-size: 12px;
    }

    #tabla-vencer-hoy .dashboard-row>span:nth-child(2),
    #tabla-vencer-manana .dashboard-row>span:nth-child(2),
    #tabla-vencer-semana .dashboard-row>span:nth-child(2) {
        grid-column: 1 / -1;
    }

    #tabla-vencer-hoy .dashboard-row>span:nth-child(3),
    #tabla-vencer-manana .dashboard-row>span:nth-child(3),
    #tabla-vencer-semana .dashboard-row>span:nth-child(3) {
        grid-column: 1 / -1;
    }

    body.page-cuadre .table-wrap {
        overflow-x: hidden;
    }

    body.page-cuadre #tabla-cuadre-pagos,
    body.page-cuadre #tabla-cuadre-ventas,
    body.page-cuadre #tabla-cuadre-gastos {
        min-width: 100% !important;
        width: 100%;
        table-layout: fixed;
    }

    body.page-cuadre #tabla-cuadre-pagos th,
    body.page-cuadre #tabla-cuadre-pagos td,
    body.page-cuadre #tabla-cuadre-ventas th,
    body.page-cuadre #tabla-cuadre-ventas td,
    body.page-cuadre #tabla-cuadre-gastos th,
    body.page-cuadre #tabla-cuadre-gastos td {
        font-size: 11px;
        padding: 7px 6px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .ui-presenter-cards {
        display: grid;
    }

    .ui-presenter-mobile-fit {
        min-width: 100% !important;
        width: 100%;
        table-layout: fixed;
    }

    .ui-presenter-mobile-hidden-cell {
        display: none;
    }


}

@media (min-width: 901px) {
    .mobile-only-action {
        display: none !important;
    }

    #tabla-miembros tbody tr,
    #tabla-usuarios tbody tr {
        cursor: pointer;
        transition: background-color 0.15s ease;
    }

    #tabla-miembros tbody tr:hover,
    #tabla-usuarios tbody tr:hover {
        background-color: var(--row-hover);
    }
}

.row-loading {
    opacity: 0.6;
    filter: grayscale(1);
    background-color: var(--tab-hover) !important;
    pointer-events: none;
    cursor: wait !important;
}

/* Contenedor estandarizado de acciones de formulario */
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.form-actions button {
    margin: 0 !important;
    width: auto;
    min-width: 140px;
    /* Ancho base comodo */
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: 1;
}

@media (max-width: 900px) {
    .form-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .form-actions button {
        width: 100% !important;
        min-width: 0;
    }

    .form-actions button:nth-child(3) {
        grid-column: 1 / -1;
    }

    .efu-grid-med {
        grid-template-columns: 1fr;
    }
}

/* Processing Overlay */
.processing-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.processing-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.processing-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 90%;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.processing-overlay.visible .processing-card {
    transform: scale(1);
}

.processing-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: #007bff;
    border-radius: 50%;
    animation: processing-spin 1s cubic-bezier(0.53, 0.21, 0.29, 0.67) infinite;
}

.processing-message {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    text-align: center;
}

@keyframes processing-spin {
    to {
        transform: rotate(360deg);
    }
}

html.theme-dark .processing-card {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
}

html.theme-dark .processing-overlay {
    background: rgba(2, 6, 23, 0.6);
}

/* AI Model Loading Overlay */
.facial-loader-overlay {
    position: fixed;
    inset: 0;
    z-index: 20000;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.facial-loader-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.facial-loader-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    max-width: 400px;
    width: 90%;
    transform: scale(0.95);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.facial-loader-overlay.active .facial-loader-card {
    transform: scale(1);
}

.facial-loader-icon-wrap {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
}

.facial-loader-ring {
    position: absolute;
    inset: 0;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: facial-spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.facial-loader-inner-ring {
    position: absolute;
    inset: 12px;
    border: 4px solid rgba(16, 185, 129, 0.2);
    border-bottom-color: #10b981;
    border-radius: 50%;
    animation: facial-spin-reverse 1.8s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.facial-loader-scan-line {
    position: absolute;
    top: 50%;
    left: 20%;
    right: 20%;
    height: 2px;
    background: #3b82f6;
    box-shadow: 0 0 15px #3b82f6;
    animation: facial-scan 2s ease-in-out infinite;
    opacity: 0.6;
}

@keyframes facial-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes facial-spin-reverse {
    from {
        transform: rotate(360deg);
    }

    to {
        transform: rotate(0deg);
    }
}

@keyframes facial-scan {

    0%,
    100% {
        transform: translateY(-30px);
        opacity: 0;
    }

    50% {
        transform: translateY(30px);
        opacity: 1;
    }
}

.facial-loader-text h3 {
    margin: 0 0 8px 0;
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 700;
}

.facial-loader-text p {
    margin: 0;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.5;
}

.facial-loader-progress {
    margin-top: 24px;
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.facial-loader-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3b82f6, #10b981);
    transition: width 0.3s ease;
}

/* --- Hybrid Access Styles (Updated for Sketch) --- */
.hybrid-access-panel {
    display: block;
    /* Desactivamos el grid aqui para que no desplace a los hijos */
    width: 100%;
    margin-top: 20px;
}

@media (max-width: 991px) {
    .hybrid-access-panel {
        /* Se mantiene block por defecto */
    }
}

.hybrid-top-row {
    grid-column: 1 / -1;
    margin-bottom: 10px;
}

.hybrid-video-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
    order: 2;
    /* Mover a la derecha en desktop */
}

@media (max-width: 991px) {
    .hybrid-video-column {
        order: 1;
        /* En movil la camara suele ir arriba o segun flujo */
    }
}

.hybrid-video-container {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 4 / 3;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
}

.hybrid-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hybrid-video-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.hybrid-status-badge {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    color: #fff;
    border-radius: 6px;
    font-size: 11px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 600;
}

.hybrid-info-column,
.hybrid-video-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    /* Asegurar que ocupen el mismo espacio */
    width: 100%;
}

.hybrid-info-column {
    order: 1;
    /* Mover a la izquierda en desktop */
}

.hybrid-top-row {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    width: 100%;
}

.hybrid-form-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 1200px;
}

.hybrid-form-group {
    display: flex;
    justify-content: center;
}

.hybrid-input {
    width: 100%;
    background: var(--input-bg);
    color: var(--text);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    font-size: 1.5em;
    font-weight: 700;
    text-align: center;
    transition: all 0.2s ease;
}

.hybrid-input:focus {
    border-color: #3b82f6;
    background: var(--card-bg);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2), inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.hybrid-result-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 480px;
    transition: all 0.3s ease;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    color: var(--text);
    width: 100% !important;
}

.hybrid-result-card.access-granted {
    border-color: #10b981;
    background: linear-gradient(to bottom, #064e3b, #0f172a);
    box-shadow: 0 10px 40px rgba(16, 185, 129, 0.2);
}

.hybrid-result-card.access-denied {
    border-color: #ef4444;
    background: linear-gradient(to bottom, #7f1d1d, #0f172a);
    box-shadow: 0 10px 40px rgba(239, 68, 68, 0.2);
}

.hybrid-result-card.access-warning {
    border-color: #f59e0b;
    background: linear-gradient(to bottom, #78350f, #0f172a);
    box-shadow: 0 10px 40px rgba(245, 158, 11, 0.2);
}

.hybrid-photo-wrap {
    width: 180px;
    height: 180px;
    border-radius: 20px;
    /* Square with rounded corners for more surface */
    overflow: hidden;
    margin-bottom: 25px;
    border: 6px solid #fff;
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.12);
    transform: rotate(-2deg);
    transition: transform 0.3s ease;
}

.hybrid-result-card.access-granted .hybrid-photo-wrap {
    transform: rotate(0deg) scale(1.05);
}

.hybrid-photo-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hybrid-result-text h3 {
    font-size: 2em;
    margin: 10px 0;
    font-weight: 800;
    color: #ffffff;
    /* Blanco */
    line-height: 1.1;
}

.hybrid-result-text .plan-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 999px;
    background: #334155;
    /* Fondo oscuro badge */
    color: #cbd5e1;
    /* Texto claro */
    font-size: 13px;
    font-weight: 700;
    margin: 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hybrid-result-text .status-msg {
    font-size: 1.3em;
    font-weight: 800;
    margin-top: 15px;
    text-transform: uppercase;
    color: #3b82f6;
    /* Azul brillante para el estado */
}

.hybrid-score-badge {
    position: absolute;
    top: 20px;
    left: 20px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- NUEVAS REGLAS DE LAYOUT HIBRIDO --- */
.hybrid-main-body {
    margin-top: 30px;
    width: 100%;
    max-width: 1200px;
    /* Igual al form-card */
    margin-left: auto !important;
    margin-right: auto !important;
    display: block;
    clear: both;
    padding: 0;
    /* Eliminar padding que pueda mover el borde */
}

.hybrid-main-body.facial-mode {
    display: grid !important;
    grid-template-columns: 1.6fr 1fr !important;
    /* Mas ancho el de Info como en el dibujo */
    gap: 20px !important;
    align-items: start;
}

.hybrid-main-body.id-mode {
    display: flex !important;
    justify-content: center !important;
    width: 100% !important;
}

.hybrid-main-body.id-mode .hybrid-video-column {
    display: none !important;
}

.hybrid-main-body.id-mode .hybrid-info-column {
    width: 100% !important;
    max-width: 1200px !important;
    /* Mismo max-width que el form-card */
    margin: 0 auto !important;
    order: unset !important;
}

.hybrid-info-column,
.hybrid-video-column {
    display: flex;
    flex-direction: column;
}

.hybrid-result-card,
.hybrid-video-container {
    height: 480px !important;
    /* Altura fija IGUAL para ambos */
    width: 100% !important;
    box-sizing: border-box;
}

.hybrid-video-container {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 3px solid #334155;
}

.hybrid-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (max-width: 992px) {
    .hybrid-main-body.facial-mode {
        grid-template-columns: 1fr !important;
    }

    .hybrid-result-card,
    .hybrid-video-container {
        height: auto !important;
        min-height: 400px;
    }
}

/* Global utilities */
.hidden {
    display: none !important;
}