/* _core/css/theme_master.css */
/* JC Signature, JC Black y JC Gold — El Recetario de JC */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root,
html[data-theme="dark"],
html[data-theme="tierra-oro"] {
    color-scheme: dark;
    /* Refuerzo mínimo del trazo para que CATERING conserve la I al reducirse. */
    --logo-filter: brightness(0) invert(1) drop-shadow(0 0 0.3px #ffffff);
    --tagline-filter: invert(1) hue-rotate(180deg) saturate(2) brightness(0.9);
    --text-on-status: #221310;
    --bg-body: #13100b;
    --bg-card: #1d1811;
    --bg-input: #272017;
    --bg-panel-soft: rgba(39, 32, 23, 0.72);
    --bg-panel-subtle: rgba(29, 24, 17, 0.5);
    --bg-panel-solid: #17120d;
    --bg-sidebar: linear-gradient(180deg, rgba(28, 22, 15, 0.99), rgba(20, 16, 10, 0.99));
    --bg-body-gradient-start: rgba(201, 168, 76, 0.09);
    --bg-body-gradient-end: rgba(201, 168, 76, 0.055);

    --border-color: rgba(201, 168, 76, 0.28);
    --border-strong: rgba(201, 168, 76, 0.48);

    --text-primary: #faf3e4;
    --text-secondary: #efe6cf;
    --text-tertiary: #d8cbab;
    --text-on-primary: #13100b;

    --surface-ghost: rgba(255, 255, 255, 0.04);
    --surface-ghost-hover: rgba(255, 255, 255, 0.07);
    --surface-overlay: rgba(0, 0, 0, 0.68);

    --primary: #c9a84c;
    --primary-hover: #b8932e;
    --primary-soft: #e8c97a;
    --primary-soft-strong: #f0d99a;
    --primary-tint-subtle: rgba(201, 168, 76, 0.08);
    --primary-tint-soft: rgba(201, 168, 76, 0.14);
    --primary-tint: rgba(201, 168, 76, 0.18);
    --primary-tint-strong: rgba(201, 168, 76, 0.24);
    --primary-ring: rgba(201, 168, 76, 0.28);
    --primary-shadow: rgba(201, 168, 76, 0.35);
    --primary-shadow-strong: rgba(201, 168, 76, 0.45);

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #38bdf8;
    --purple: #a78bfa;

    --success-soft-bg: rgba(16, 185, 129, 0.16);
    --success-soft-border: rgba(16, 185, 129, 0.26);
    --success-soft-text: #86efac;
    --warning-soft-bg: rgba(245, 158, 11, 0.16);
    --warning-soft-border: rgba(245, 158, 11, 0.26);
    --warning-soft-text: #fde68a;
    --danger-soft-bg: rgba(239, 68, 68, 0.16);
    --danger-soft-border: rgba(239, 68, 68, 0.26);
    --danger-soft-text: #fecaca;
    --info-soft-bg: rgba(56, 189, 248, 0.16);
    --info-soft-border: rgba(56, 189, 248, 0.24);
    --info-soft-text: #bae6fd;
    --purple-soft-bg: rgba(167, 139, 250, 0.16);
    --purple-soft-border: rgba(167, 139, 250, 0.24);
    --purple-soft-text: #ddd6fe;
    --neutral-soft-bg: rgba(148, 163, 184, 0.14);
    --neutral-soft-border: rgba(148, 163, 184, 0.22);
    --neutral-soft-text: #cbd5e1;

    --chart-grid: rgba(255, 255, 255, 0.06);
    --chart-grid-soft: rgba(255, 255, 255, 0.04);
    --chart-ticks: #9c8e72;
    --chart-legend: #c9b88f;

    --card-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
    --card-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.03);

    --sidebar-width: 260px;
    --header-height: 70px;
    --radius: 0.75rem;

    --text-muted: var(--text-secondary);
    --text-main: var(--text-primary);
    --bg-main: var(--bg-body);
    --bg-dark: var(--bg-card);
    --card-bg: var(--bg-card);
    --accent: var(--primary);
    --field-disabled-bg: rgba(148, 163, 184, 0.12);
    --field-disabled-text: #9fb0bf;
    --table-row-border: rgba(255, 255, 255, 0.06);
    --table-row-hover: rgba(255, 255, 255, 0.04);
}

/* Variantes JC. Signature es la opción principal; Gold conserva su paleta. */
:root:not([data-theme]),
html[data-theme="vino"] {
    font-size: 100%;
    color-scheme: dark;
    --bg-body: #211d1f;
    --bg-card: #2d272a;
    --bg-input: #383034;
    --bg-panel-soft: #352d31;
    --bg-panel-subtle: #30292c;
    --bg-panel-solid: #30272c;
    --bg-sidebar: #302329;
    --bg-body-gradient-start: transparent;
    --bg-body-gradient-end: transparent;
    --border-color: #65565e;
    --border-strong: #ad929e;
    --text-primary: #ffffff;
    --text-secondary: #efefef;
    --text-tertiary: #dedede;
    --text-on-primary: #252226;
    --surface-ghost: rgba(255, 255, 255, 0.04);
    --surface-ghost-hover: rgba(255, 255, 255, 0.09);
    --surface-overlay: rgba(17, 14, 16, 0.72);
    --primary: #ffffff;
    --primary-hover: #e7e7e7;
    --primary-soft: #f0f0f0;
    --primary-soft-strong: #ffffff;
    --primary-tint-subtle: rgba(255, 255, 255, 0.05);
    --primary-tint-soft: rgba(255, 255, 255, 0.09);
    --primary-tint: rgba(255, 255, 255, 0.13);
    --primary-tint-strong: rgba(255, 255, 255, 0.18);
    --primary-ring: rgba(255, 255, 255, 0.42);
    --primary-shadow: rgba(0, 0, 0, 0.12);
    --primary-shadow-strong: rgba(0, 0, 0, 0.18);
    --chart-grid: rgba(255, 255, 255, 0.14);
    --chart-grid-soft: rgba(255, 255, 255, 0.07);
    --chart-ticks: #dedede;
    --chart-legend: #efefef;
    --card-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    --field-disabled-bg: #302a2d;
    --field-disabled-text: #b7a8b0;
    --table-row-border: #55474f;
    --table-row-hover: rgba(255, 255, 255, 0.06);
}

/* JC Black: grises neutros inspirados en Carbon Gray 100, con acento azul suave. */
html[data-theme="black"] {
    font-size: 100%;
    color-scheme: dark;
    --bg-body: #161616;
    --bg-card: #262626;
    --bg-input: #393939;
    --bg-panel-soft: #303030;
    --bg-panel-subtle: #202020;
    --bg-panel-solid: #262626;
    --bg-sidebar: #1c1c1c;
    --bg-body-gradient-start: transparent;
    --bg-body-gradient-end: transparent;
    --border-color: #6f6f6f;
    --border-strong: #a8a8a8;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-tertiary: #c6c6c6;
    --text-on-primary: #161616;
    --surface-ghost: rgba(255, 255, 255, 0.04);
    --surface-ghost-hover: rgba(255, 255, 255, 0.09);
    --surface-overlay: rgba(0, 0, 0, 0.72);
    --primary: #a6c8ff;
    --primary-hover: #c6dcff;
    --primary-soft: #c6dcff;
    --primary-soft-strong: #e0ebff;
    --primary-tint-subtle: rgba(166, 200, 255, 0.05);
    --primary-tint-soft: rgba(166, 200, 255, 0.09);
    --primary-tint: rgba(166, 200, 255, 0.13);
    --primary-tint-strong: rgba(166, 200, 255, 0.18);
    --primary-ring: rgba(166, 200, 255, 0.55);
    --primary-shadow: rgba(0, 0, 0, 0.12);
    --primary-shadow-strong: rgba(0, 0, 0, 0.18);
    --chart-grid: rgba(255, 255, 255, 0.14);
    --chart-grid-soft: rgba(255, 255, 255, 0.07);
    --chart-ticks: #c6c6c6;
    --chart-legend: #e0e0e0;
    --card-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    --field-disabled-bg: #303030;
    --field-disabled-text: #a8a8a8;
    --table-row-border: #525252;
    --table-row-hover: rgba(255, 255, 255, 0.06);
}

/* --- RESET BÁSICO --- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    background-image:
        radial-gradient(circle at top left, var(--bg-body-gradient-start), transparent 34%),
        radial-gradient(circle at bottom right, var(--bg-body-gradient-end), transparent 28%);
    color: var(--text-primary);
    margin: 0;
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- RESPONSIVO: Ajustes para pantallas pequeñas --- */
@media (max-width: 1400px) {
    :root {
        font-size: 14px;
    }

    .app-sidebar {
        width: 220px;
        padding: 15px;
    }

    .app-main {
        padding: 20px;
    }
}

@media (max-width: 1200px) {
    :root {
        font-size: 13px;
    }

    .app-sidebar {
        width: 200px;
        padding: 12px;
    }

    .nav-link {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
}

/* --- BARRA LATERAL (SIDEBAR) --- */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
    flex-shrink: 0;
    box-shadow: var(--card-highlight);
}

.app-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    text-decoration: none;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
    text-align: center;
    flex-shrink: 0;
}

.app-logo .brand-icon {
    flex-shrink: 0;
}

.app-logo .brand-name {
    min-width: 0;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--text-on-primary);
    flex-shrink: 0;
}

.brand-name {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-primary);
    text-align: left;
    line-height: 1.1;
}

.brand-name span {
    display: block;
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-section-label {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--primary);
    padding: 6px 16px 8px;
    margin-top: 10px;
}

.app-sidebar nav,
.app-sidebar .sidebar-nav,
#sidebar-nav {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    margin-bottom: 10px;
    padding-top: 16px;
    padding-right: 5px;
    position: relative;
    z-index: 1;
}

/* Scrollbar fina para el sidebar */
.app-sidebar nav::-webkit-scrollbar,
.app-sidebar .sidebar-nav::-webkit-scrollbar,
#sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.app-sidebar nav::-webkit-scrollbar-track,
.app-sidebar .sidebar-nav::-webkit-scrollbar-track,
#sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.app-sidebar nav::-webkit-scrollbar-thumb,
.app-sidebar .sidebar-nav::-webkit-scrollbar-thumb,
#sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* --- SECCIÓN USUARIO EN SIDEBAR --- */
.sidebar-user-section {
    margin-top: auto;
    padding: 15px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.theme-settings {
    position: relative;
}

.theme-settings-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--surface-ghost);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-settings-btn:hover,
.theme-settings.is-open .theme-settings-btn {
    border-color: var(--primary-ring);
    background: var(--primary-tint-subtle);
}

.theme-settings-btn i {
    width: 20px;
    text-align: center;
    color: var(--primary-soft);
}

.theme-settings-popover {
    position: fixed;
    left: 16px;
    top: 16px;
    width: 290px;
    max-width: calc(100vw - 32px);
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--bg-card) 94%, transparent);
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(14px);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1200;
}

.theme-settings-popover.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.theme-settings-head {
    margin-bottom: 12px;
}

.theme-settings-head strong {
    display: block;
    color: var(--text-primary);
    font-size: 0.92rem;
    margin-bottom: 4px;
}

.theme-settings-head span {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.theme-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: var(--surface-ghost);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.theme-option:hover {
    border-color: var(--primary-ring);
    background: var(--surface-ghost-hover);
}

.theme-option.active {
    border-color: var(--primary-ring);
    background: var(--primary-tint-subtle);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.theme-option-swatch {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.theme-option-swatch.theme-dark {
    background: linear-gradient(135deg, #1d1811, #c9a84c);
}

.theme-option-swatch.theme-vino {
    background: linear-gradient(135deg, #211d1f 50%, #2d272a 50%, #2d272a 80%, #fafafa 80%);
}

.theme-option-swatch.theme-black {
    background: linear-gradient(135deg, #161616 50%, #393939 50%, #393939 80%, #a6c8ff 80%);
    border-color: #6f6f6f;
}

.theme-option-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.theme-option-copy strong {
    color: var(--text-primary);
    font-size: 0.88rem;
}

.theme-option-copy small {
    color: var(--text-secondary);
    font-size: 0.76rem;
}

.btn-logout-sidebar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--danger-soft-bg);
    border: 1px solid var(--danger-soft-border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    text-align: left;
}

.btn-logout-sidebar:hover {
    background: color-mix(in srgb, var(--danger-soft-bg) 72%, transparent);
    border-color: var(--danger);
    box-shadow: var(--card-highlight);
}

.btn-logout-sidebar i {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-user-info {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.sidebar-logout-btn {
    width: 100%;
    padding: 10px;
    background: var(--danger-soft-bg);
    border: 1px solid var(--danger-soft-border);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.sidebar-logout-btn:hover {
    background: color-mix(in srgb, var(--danger-soft-bg) 70%, transparent);
    box-shadow: var(--card-highlight);
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 13px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    margin-bottom: 6px;
    transition: all 0.2s ease;
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

.nav-link:hover,
.nav-link.active {
    background-color: color-mix(in srgb, var(--primary) 14%, transparent);
    color: var(--text-primary);
    box-shadow:
        var(--card-highlight),
        inset 0 0 0 1px color-mix(in srgb, var(--primary) 55%, transparent);
}

.nav-icon {
    margin-right: 12px;
    width: 24px;
    text-align: center;
    font-size: 1.1rem;
}

/* --- ÁREA PRINCIPAL --- */
.app-main {
    flex-grow: 1;
    overflow-y: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* --- TARJETAS (CARDS) --- */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--card-shadow), var(--card-highlight);
}

h1,
h2,
h3 {
    margin-top: 0;
}

.page-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0;
}

/* --- FORMULARIOS & INPUTS (ESTILO DARK) --- */
label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.05em;
}

input,
select,
textarea {
    width: 100%;
    background-color: var(--bg-panel-soft);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-tertiary);
    opacity: 1;
}

input:disabled,
select:disabled,
textarea:disabled {
    background: var(--field-disabled-bg);
    color: var(--field-disabled-text);
    opacity: 1;
    cursor: not-allowed;
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-ring);
}

/* --- BOTONES --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform 0.1s, box-shadow 0.2s;
    text-decoration: none;
    font-size: 0.9rem;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background-color: var(--primary);
    color: var(--text-on-primary);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px var(--primary-shadow);
}

.btn-success {
    background-color: var(--success);
    color: var(--text-on-status);
}

.btn-danger {
    background-color: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.btn-danger:hover {
    background-color: var(--danger);
    color: var(--text-on-status);
}

/* --- TABLAS OSCURAS --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    table-layout: fixed;
}

thead th {
    text-align: center;
    padding: 15px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody td {
    text-align: center;
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.025);
}

/* --- UTILIDADES VISUALES --- */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-active {
    background-color: var(--success-soft-bg);
    color: var(--success-soft-text);
    border: 1px solid var(--success-soft-border);
}

.badge-inactive {
    background-color: var(--danger-soft-bg);
    color: var(--danger-soft-text);
    border: 1px solid var(--danger-soft-border);
}

/* --- PESTAÑAS (TABS) --- */
.tabs-container {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    display: flex;
    gap: 20px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 10px 0;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* --- MODAL --- */
.modal-overlay {
    background: var(--surface-overlay);
    backdrop-filter: blur(4px);
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* --- TOAST MODAL (Reemplazo de alert/confirm nativos) --- */
.toast-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--surface-overlay);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.toast-modal-overlay.active {
    display: flex;
}

.toast-modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 30px 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    animation: toastSlideIn 0.3s ease-out;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.toast-modal-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.toast-modal-icon.success {
    color: var(--success);
}

.toast-modal-icon.error {
    color: var(--danger);
}

.toast-modal-icon.warning {
    color: var(--warning);
}

.toast-modal-icon.question {
    color: var(--primary);
}

.toast-modal-message {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 25px;
    line-height: 1.5;
}

.toast-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.toast-modal-buttons .btn {
    min-width: 100px;
    padding: 12px 24px;
}

/* ==========================================
   DESKTOP - Sidebar collapsible toggle
   ========================================== */

/* Smooth transition for sidebar and main */
.app-sidebar {
    transition: width 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Subtle sidebar scrollbar */
.app-sidebar::-webkit-scrollbar {
    width: 4px;
}

.app-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.app-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.app-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.app-main {
    transition: margin-left 0.3s ease;
}

/* Toggle button at bottom of sidebar */
.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px;
    background: var(--primary-tint-soft);
    border: 1px solid var(--primary-ring);
    border-radius: 8px;
    color: var(--primary-soft-strong);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
}

.sidebar-toggle-btn:hover {
    background: var(--primary-tint-strong);
    border-color: var(--primary);
}

/* Nav link text wrapper for hide/show */
.nav-text {
    transition: opacity 0.2s ease, width 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
}

/* Sidebar user section text */
.sidebar-user-section {
    transition: opacity 0.2s ease;
}

/* --- COLLAPSED STATE --- */
body.sidebar-collapsed .app-sidebar {
    width: 60px;
    padding: 10px 8px;
}

body.sidebar-collapsed .app-logo {
    gap: 0;
    justify-content: center;
    align-items: center;
    padding-bottom: 10px;
    margin-bottom: 15px;
    width: 100%;
    text-align: center;
}

body.sidebar-collapsed .app-logo .brand-name {
    display: none !important;
}

body.sidebar-collapsed .app-logo .brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

body.sidebar-collapsed .app-logo .brand-icon i {
    font-size: 1rem;
    margin: 0;
}

body.sidebar-collapsed .sidebar-header-mobile {
    justify-content: center;
    margin: 0 auto;
}

body.sidebar-collapsed .nav-link {
    padding: 12px;
    justify-content: center;
    margin-bottom: 4px;
}

body.sidebar-collapsed .nav-text {
    display: none;
}

body.sidebar-collapsed .nav-section-label {
    display: none;
}

body.sidebar-collapsed .nav-icon {
    margin-right: 0;
    width: auto;
    font-size: 1.15rem;
}

body.sidebar-collapsed .sidebar-user-section {
    opacity: 0;
    pointer-events: none;
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

body.sidebar-collapsed .sidebar-toggle-btn {
    padding: 8px;
    font-size: 0.9rem;
}

body.sidebar-collapsed .btn-logout-sidebar {
    justify-content: center;
    padding: 12px;
}

body.sidebar-collapsed .btn-logout-sidebar .nav-text {
    display: none;
}

body.sidebar-collapsed .btn-logout-sidebar i {
    width: auto;
}

body.sidebar-collapsed .theme-settings-btn {
    justify-content: center;
    padding: 12px;
}

body.sidebar-collapsed .theme-settings-btn-label {
    display: none;
}

body.sidebar-collapsed .theme-settings-btn i {
    width: auto;
}

body.sidebar-collapsed .sidebar-close-btn {
    display: none;
}

/* Tooltip on hover when collapsed */
body.sidebar-collapsed .nav-link {
    position: relative;
}

body.sidebar-collapsed .nav-link:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 10px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

/* ==========================================
   MOBILE RESPONSIVE - Sidebar colapsable
   ========================================== */

/* Botón hamburguesa INLINE (dentro del header) - oculto por defecto */
.mobile-menu-btn-inline {
    display: none;
    width: 40px;
    height: 40px;
    background: var(--primary);
    border: none;
    border-radius: 8px;
    color: var(--text-on-primary);
    font-size: 1.1rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}



/* ========== HEADER SIDEBAR + LOGO BRANDING ========== */
.sidebar-header-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px 0 16px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 2;
    isolation: isolate;
    overflow: hidden;
}

.sidebar-header-mobile .app-logo {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
    border-bottom: none !important;
}

/* Contenedor directo del logo */
.app-logo.app-logo-brand-image {
    width: 100% !important;
}

/* =========================================================
   SEARCHABLE SELECT CUSTOM (VANILLA) — TEMA TIERRA Y ORO
   Aspecto IDÉNTICO a .field-input y .field-xs.
   ========================================================= */

/* ---------- Wrapper base (display + dropdown) ---------- */
.ss-wrapper {
    position: relative;
    display: block;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
}

.ss-wrapper *,
.ss-wrapper *::before,
.ss-wrapper *::after {
    box-sizing: border-box;
}

/* ---------- Display (zona visible) ---------- */
.ss-display {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    padding: 11px 44px 11px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-panel-soft);
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23c9a84c' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 12px;
    font-size: 0.92rem;
    line-height: 1.4;
    overflow: hidden;
}

.ss-display:hover {
    border-color: var(--border-strong);
}

.ss-wrapper.ss-focus .ss-display,
.ss-wrapper.ss-open .ss-display {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-ring);
    outline: none;
}

/* Variante compacta field-xs */
.ss-wrapper.ss-xs .ss-display {
    min-height: 34px;
    padding: 7px 38px 7px 12px;
    font-size: 0.82rem;
    background-position: right 12px center;
    background-size: 10px 10px;
}

/* Disabled */
.ss-wrapper.ss-disabled .ss-display {
    opacity: 0.55;
    cursor: not-allowed;
    background-color: var(--bg-panel-soft);
    pointer-events: none;
}

/* ---------- Label / placeholder / search input ---------- */
.ss-label,
.ss-placeholder {
    display: block;
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.ss-label {
    color: var(--text-primary);
    font-weight: 450;
    display: none; /* se activa al tener valor */
}

.ss-placeholder {
    color: var(--text-muted);
    font-style: normal;
}

.ss-wrapper.ss-has-value .ss-label {
    display: block;
}
.ss-wrapper.ss-has-value .ss-placeholder {
    display: none;
}

/* Search input embebido (sólo visible mientras dropdown está abierto) */
.ss-search-input {
    position: absolute !important;
    inset: 0 0 0 0;
    width: 100%;
    height: 100%;
    padding: 11px 44px 11px 14px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    outline: none;
    box-shadow: none;
    margin: 0;
}
.ss-wrapper.ss-xs .ss-search-input {
    padding: 7px 38px 7px 12px;
    font-size: 0.82rem;
}
.ss-search-input::placeholder {
    color: var(--text-muted);
    opacity: 1;
}
.ss-search-input::-webkit-search-cancel-button,
.ss-search-input::-webkit-search-decoration,
.ss-search-input::-webkit-search-results-button,
.ss-search-input::-webkit-search-results-decoration {
    display: none;
}

/* ---------- Dropdown ---------- */
.ss-dropdown[role="listbox"] {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 2147000000;
    max-height: 260px;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0,0,0,0.25);
    padding: 6px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-sizing: border-box;
}

.ss-wrapper.ss-dropup .ss-dropdown[role="listbox"] {
    box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.5), 0 -2px 6px rgba(0,0,0,0.25);
}

/* Scrollbar elegante */
.ss-dropdown::-webkit-scrollbar {
    width: 6px;
}
.ss-dropdown::-webkit-scrollbar-track {
    background: transparent;
}
.ss-dropdown::-webkit-scrollbar-thumb {
    background: var(--primary-ring);
    border-radius: 3px;
}
.ss-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

/* ---------- Opciones ---------- */
.ss-option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.92rem;
    line-height: 1.4;
    transition: background-color 0.12s ease, color 0.12s ease;
}
.ss-option + .ss-option {
    margin-top: 2px;
}
.ss-option-text {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ss-option-check {
    flex: 0 0 auto;
    color: var(--primary-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.15s ease, transform 0.15s ease;
    font-weight: 800;
}
.ss-option-check svg {
    display: block;
    width: 16px;
    height: 16px;
}

.ss-option:hover,
.ss-option.is-active {
    background: var(--primary-tint-subtle);
    color: var(--text-primary);
}

.ss-option.selected {
    background: var(--primary-tint-soft);
    color: var(--primary-soft-strong);
    font-weight: 600;
}
.ss-option.selected .ss-option-check {
    opacity: 1;
    transform: scale(1);
}

/* ---------- Sin resultados ---------- */
.ss-no-results {
    padding: 16px 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.86rem;
    font-style: italic;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .ss-display {
        min-height: 42px;
        padding: 10px 40px 10px 12px;
        font-size: 0.9rem;
    }
    .ss-wrapper.ss-xs .ss-display {
        min-height: 32px;
        padding: 6px 34px 6px 10px;
        font-size: 0.8rem;
    }
    .ss-dropdown {
        border-radius: 10px;
        padding: 5px;
        max-height: 220px;
    }
    .ss-option {
        padding: 9px 11px;
    }
}


/* ===== LOGO COMPLETO — visible cuando sidebar está ABIERTA ===== */
.brand-image-full {
    display: block;
    max-width: 100%;
    width: auto;
    max-height: 80px;
    object-fit: contain;
    margin: 0 auto;
    filter: var(--logo-filter);
    transition: opacity 0.22s ease, max-height 0.22s ease;
}

/* ===== LOGO PEQUEÑO — oculto cuando sidebar está ABIERTA ===== */
.brand-image-collapsed {
    display: none;
    width: 44px;
    height: 44px;
    object-fit: contain;
    margin: 0 auto;
    filter: var(--logo-filter);
    transition: opacity 0.22s ease;
}

/* ===== ESTADO COLAPSADO: intercambio de imágenes ===== */
body.sidebar-collapsed .sidebar-header-mobile {
    padding: 12px 0;
    justify-content: center;
}

body.sidebar-collapsed .brand-image-full {
    display: none;
}

body.sidebar-collapsed .brand-image-collapsed {
    display: block;
}

/* ===== MEDIA QUERIES ===== */
@media (max-width: 960px) {
    .brand-image-full {
        max-height: 68px;
    }
}

@media (max-width: 768px) {
    .brand-image-full {
        max-height: 60px;
    }
}

@media (max-width: 480px) {
    .brand-image-full {
        max-height: 52px;
    }
}

/* Botón cerrar sidebar - oculto en desktop */
.sidebar-close-btn {
    display: none;
    width: 36px;
    height: 36px;
    background: var(--danger-soft-bg);
    border: 1px solid var(--danger-soft-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex: 0 0 auto;
    margin-left: 0;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.sidebar-close-btn:hover {
    background: color-mix(in srgb, var(--danger-soft-bg) 70%, transparent);
}

/* Overlay para cerrar sidebar en móvil */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

.sidebar-overlay.active {
    display: block;
}

/* Clase para ocultar en móvil */
.hide-on-mobile {
    display: inline;
}

@media (max-width: 768px) {

    /* Mostrar botón hamburguesa INLINE */
    .mobile-menu-btn-inline {
        display: flex;
    }

    .sidebar-close-btn {
        display: none !important;
    }

    /* Ocultar elementos en móvil */
    .hide-on-mobile {
        display: none !important;
    }

    /* Sidebar se convierte en overlay */
    .app-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        height: 100vh;
        width: 280px;
        z-index: 999;
        transition: left 0.3s ease;
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.5);
        padding-bottom: 34px;
    }

    .app-sidebar.mobile-open {
        left: 0;
    }

    /* Main content ocupa todo el ancho */
    .app-main {
        width: 100%;
        padding: 20px 15px;
    }

    .sidebar-toggle-btn {
        margin-bottom: 12px;
    }

    /* Ajustes generales para móvil */
    body {
        flex-direction: column;
    }

    .page-title {
        font-size: 1.4rem;
    }

    .card {
        padding: 15px;
    }

    /* Grid de tablas responsive */
    .table-container {
        overflow-x: auto;
    }

    table {
        min-width: 600px;
    }
}

/* Legibilidad JC: tamaño estable, texto neutro y controles con jerarquía clara.
   Se aplica a Signature y Black; Gold conserva su referencia. */
html:is([data-theme="vino"], [data-theme="black"]) body {
    line-height: 1.55;
}
html:is([data-theme="vino"], [data-theme="black"]) :is(button, input, select, textarea) {
    font-family: inherit;
}
html:is([data-theme="vino"], [data-theme="black"]) :is(input, select, textarea, .ss-display, .ss-search-input) {
    font-size: 0.9375rem;
    line-height: 1.5;
}
html:is([data-theme="vino"], [data-theme="black"]) :is(.btn, .btn-submit, .nav-link, .theme-settings-btn, .btn-logout-sidebar) {
    font-size: 0.9375rem;
    font-weight: 600;
}
html:is([data-theme="vino"], [data-theme="black"]) .nav-section-label {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}
html:is([data-theme="vino"], [data-theme="black"]) :is(label, .field-label, th) {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.5;
}
html:is([data-theme="vino"], [data-theme="black"]) :is(.hint, .muted, .is-muted, .text-muted, .theme-option-copy small, .theme-settings-head span, td small) {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.6;
}
html:is([data-theme="vino"], [data-theme="black"]) :is(.theme-settings-popover, .ss-dropdown) {
    background: var(--bg-card);
    backdrop-filter: none;
}
html:is([data-theme="vino"], [data-theme="black"]) :is(button, a, input, select, textarea):focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

/* Signature y Black: lectura uniforme sobre superficies oscuras. */
html:is([data-theme="vino"], [data-theme="black"]) :is(.module-card-body, .phase-copy p) {
    font-size: 0.9375rem;
    color: var(--text-primary);
}

html:is([data-theme="vino"], [data-theme="black"]) :is(.module-card-title span, .phase-status, .module-card-foot .phase-label, .phase-badge small) {
    font-size: 0.8125rem;
    line-height: 1.5;
    letter-spacing: 0.02em;
}
