:root {
    --bg-color: #0d0e12;
    --text-color: #f5f5f7;
    --column-bg: rgba(26, 29, 36, 0.68);
    --card-bg: rgba(40, 44, 54, 0.78);
    --card-hover: rgba(50, 56, 70, 0.90);
    --accent: #0a84ff;
    --accent-hover: #0070e0;
    --danger: #ff453a;
    --border-color: rgba(255, 255, 255, 0.11);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: #0d0e12;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: transparent;
    color: var(--text-color);
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    max-width: none;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    overscroll-behavior: none;
}

/* Contenedor Principal de la Aplicación: Atmósfera teñida estilo macOS Dark Mode */
.app-layout {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse 90% 55% at 50% -10%, rgba(52, 64, 88, 0.28) 0%, transparent 70%),
        radial-gradient(ellipse 70% 50% at 85% 90%, rgba(32, 38, 54, 0.22) 0%, transparent 60%),
        linear-gradient(180deg, #16171d 0%, #0d0e12 100%);
    overflow: hidden;
}

/* ======================================================== */
/* ██  BARRA LATERAL IZQUIERDA (SIDEBAR)                   */
/* ======================================================== */
.app-sidebar {
    width: 250px;
    min-width: 250px;
    height: 100%;
    position: sticky;
    top: 0;
    background: rgba(18, 20, 26, 0.85);
    backdrop-filter: blur(35px) saturate(190%);
    -webkit-backdrop-filter: blur(35px) saturate(190%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: margin 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-layout.sidebar-collapsed .app-sidebar {
    margin-left: -250px;
    pointer-events: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.15rem 1rem 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    object-fit: cover;
    display: block;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #f5f5f7;
    letter-spacing: -0.3px;
}

.sidebar-close-btn {
    display: none;
    background: transparent;
    border: none;
    color: #86868b;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
}
.sidebar-close-btn:hover {
    color: #f5f5f7;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-actions {
    padding: 1rem 1rem 0.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-btn-primary,
.sidebar-btn-secondary,
.sidebar-action-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.09);
    color: #f5f5f7;
    padding: 0.6rem 0.85rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    box-sizing: border-box;
}

.sidebar-btn-primary:hover,
.sidebar-btn-secondary:hover,
.sidebar-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

.sidebar-btn-primary:active,
.sidebar-btn-secondary:active,
.sidebar-action-btn:active {
    transform: translateY(1px);
}

.sidebar-btn-label-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-kbd {
    font-family: -apple-system, BlinkMacSystemFont, monospace;
    font-size: 0.68rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 1px 5px;
    border-radius: 4px;
    color: #86868b;
}

.sidebar-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar-scrollable::-webkit-scrollbar {
    width: 4px;
}
.sidebar-scrollable::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.sidebar-section {
    margin-bottom: 1.25rem;
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.5rem 0.4rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 700;
    color: #86868b;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.sidebar-section-action {
    background: none;
    border: none;
    color: #86868b;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s ease, background 0.15s ease;
}

.sidebar-section-action:hover {
    color: #f5f5f7;
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.48rem 0.65rem;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: #c7c7cc;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    gap: 10px;
}

.sidebar-nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.sidebar-nav-item.active {
    background: rgba(10, 132, 255, 0.15);
    color: #0a84ff;
    font-weight: 600;
    border-color: rgba(10, 132, 255, 0.25);
}

.sidebar-nav-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-area-bullet {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-nav-count {
    font-size: 0.72rem;
    color: #86868b;
    background: rgba(255, 255, 255, 0.06);
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.sidebar-nav-item.active .sidebar-nav-count {
    background: rgba(10, 132, 255, 0.25);
    color: #0a84ff;
}

.sidebar-nav-badge {
    font-size: 0.66rem;
    color: #86868b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1px 5px;
    border-radius: 4px;
}

.sidebar-nav-badge.active {
    color: #34c759;
    border-color: rgba(52, 199, 89, 0.3);
    background: rgba(52, 199, 89, 0.12);
}

.sidebar-footer {
    padding: 0.85rem 1rem;
    padding-bottom: max(0.85rem, calc(env(safe-area-inset-bottom) + 0.35rem));
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
}

/* ======================================================== */
/* ██  ÁREA PRINCIPAL (MAIN VIEW)                          */
/* ======================================================== */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
    padding: 1.25rem 2rem 1.25rem 2rem;
    max-width: 1700px;
    margin: 0 auto;
    width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #86868b;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
}

.current-view-info h1 {
    font-size: 1.45rem;
    font-weight: 700;
    color: #f5f5f7;
    letter-spacing: -0.3px;
}

.app-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-header-right .search-container {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0 0.65rem;
    display: flex;
    align-items: center;
}

.app-header-right .search-input {
    background: transparent;
    border: none;
    color: #f5f5f7;
    font-size: 0.88rem;
    padding: 0.45rem 0.25rem;
    outline: none;
    width: 180px;
    transition: width 0.2s ease;
}

.app-header-right .search-input:focus {
    width: 240px;
}

/* Backdrop para móviles */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 190;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

button {
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-family: inherit;
}
button:active {
    transform: scale(0.96);
}

.primary-btn {
    background: var(--accent);
    color: white;
}
.primary-btn:hover {
    background: var(--accent-hover);
}

.secondary-btn {
    background: rgba(255,255,255,0.1);
    color: white;
}
.secondary-btn:hover {
    background: rgba(255,255,255,0.2);
}

.kanban-board {
    display: flex;
    gap: 1.25rem;
    flex: 1 1 0%;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.25rem;
}

.column {
    flex: 1;
    min-width: 320px;
    background: var(--column-bg);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border-radius: 16px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    min-height: 0;
    height: 100%;
    box-sizing: border-box;
}

.column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-shrink: 0;
}

.column h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f5f5f7;
}

.task-count {
    background: rgba(255,255,255,0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.tag-custom {
    background: rgba(10, 132, 255, 0.15) !important;
    color: #64d2ff !important;
    border: 1px solid rgba(10, 132, 255, 0.3);
}

/* ========== ETIQUETAS AVANZADAS ========== */
.tags-input-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 6px 8px;
    min-height: 44px;
    align-items: center;
    cursor: text;
}

.tags-input-container:focus-within {
    border-color: #0a84ff;
}

.tag-badge {
    background: rgba(10, 132, 255, 0.2);
    color: #64d2ff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(10, 132, 255, 0.4);
}

.tag-badge .tag-remove {
    cursor: pointer;
    color: #64d2ff;
    font-weight: bold;
    font-size: 0.8rem;
    opacity: 0.7;
}

.tag-badge .tag-remove:hover {
    opacity: 1;
}

.tags-input-container input {
    background: transparent !important;
    border: none !important;
    color: #f5f5f7 !important;
    outline: none !important;
    flex: 1;
    min-width: 10px; /* Reducido para evitar saltos de línea innecesarios */
    padding: 0 !important;
    font-size: 0.85rem !important;
}

.tag-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #2c2c2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    max-height: 150px;
    overflow-y: auto;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    margin-top: 4px;
}

.tag-suggestion-item {
    padding: 8px 12px;
    color: #d2d2d7;
    font-size: 0.85rem;
    cursor: pointer;
}

.tag-suggestion-item:hover, .tag-suggestion-item.active {
    background: #0a84ff;
    color: white;
}
/* ======================================= */

.task-list {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-right: 0.5rem;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

.task-list::-webkit-scrollbar {
    width: 6px;
}
.task-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
}

.task-card {
    flex-shrink: 0;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 1.25rem;
    border-radius: 12px;
    cursor: grab;
    transition: background 0.2s, transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.task-card:hover {
    background: var(--card-hover);
}

.task-card:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.task-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    color: #86868b;
}

.task-title {
    font-weight: 500;
    font-size: 1.05rem;
    margin-bottom: 1rem;
    line-height: 1.4;
    color: #ffffff;
}

.task-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tag {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-weight: 500;
    background: rgba(255,255,255,0.1);
    color: #d2d2d7;
    border: 1px solid rgba(255,255,255,0.1);
}

.due-date {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    color: #a1a1a6; 
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.1); 
    margin-top: 0.2rem;
}
.due-date svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.due-date.overdue {
    color: var(--danger);
    border: 1px dashed rgba(255, 105, 97, 0.6);
}
.due-date.overdue svg {
    opacity: 0.9;
}

.today-badge {
    background: rgba(255, 159, 10, 0.2);
    color: #ff9f0a;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 0.4rem;
    letter-spacing: 0.5px;
}

.drag-over {
    background: rgba(255,255,255,0.05) !important;
    border: 2px dashed var(--accent) !important;
}

/* Bloqueo del fondo cuando hay modales abiertos para evitar scroll fantasma de fondo */
html.modal-locked,
body.modal-open,
body.note-modal-active {
    overflow: hidden !important;
    overflow-y: hidden !important;
    overscroll-behavior: none !important;
}

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 5000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: rgba(28, 28, 32, 0.88);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    width: 450px;
    max-width: 90%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.modal-small {
    width: 350px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.editable-modal-title {
    background: transparent;
    border: 1px solid transparent;
    color: #f5f5f7;
    font-size: 1.5rem;
    font-weight: 600;
    width: 100%;
    outline: none;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-family: inherit;
    margin-left: -0.6rem; /* Alinea visualmente con el margen */
    margin-right: auto;
}

.editable-modal-title:hover {
    background: rgba(255, 255, 255, 0.05);
}

.editable-modal-title:focus {
    background: rgba(0, 0, 0, 0.3);
    border-color: var(--primary-color);
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.close-btn {
    background: transparent;
    color: #86868b;
    padding: 0.5rem;
    margin: 0;
    font-size: 1.2rem;
}
.close-btn:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.flex-1 {
    flex: 1;
}

.form-group label {
    font-size: 0.85rem;
    color: #86868b;
    font-weight: 500;
}

.form-group input, .form-group select, .form-group textarea {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 0.75rem;
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

.form-group input, .form-group select {
    min-height: 44px;
}

.form-group select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' 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 1rem center;
    background-size: 1em;
    padding-right: 2.5rem;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--accent);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-ios-back-btn {
    display: none;
}

.modal-footer-united,
.modal-footer-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.modal-footer button,
.modal-footer-united button,
.modal-footer-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0.55rem 1.05rem;
    border-radius: 9px;
    font-size: 0.86rem;
    font-weight: 500;
    line-height: 1;
    min-height: 38px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-sizing: border-box;
    font-family: inherit;
}

.modal-footer button svg,
.modal-footer-actions button svg {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
}

.modal-footer button:active,
.modal-footer-actions button:active {
    transform: scale(0.98);
}

/* 1. Botón Guardar (Primary) */
.modal-footer .primary-btn,
.modal-footer-actions .primary-btn {
    background: var(--accent);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(10, 132, 255, 0.25);
}

.modal-footer .primary-btn:hover,
.modal-footer-actions .primary-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(10, 132, 255, 0.35);
    color: #ffffff;
}

/* 2. Botón Cancelar (Secondary Neutral) */
.modal-footer .secondary-btn:not(#delete-task-btn):not(.btn-danger),
.modal-footer-actions .secondary-btn {
    background: rgba(255, 255, 255, 0.06);
    color: #f5f5f7;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.modal-footer .secondary-btn:not(#delete-task-btn):not(.btn-danger):hover,
.modal-footer-actions .secondary-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* 3. Botón Eliminar (Danger) */
#delete-task-btn,
.modal-footer .btn-danger {
    background: rgba(255, 69, 58, 0.1);
    color: #ff453a;
    border: 1px solid rgba(255, 69, 58, 0.28);
}

#delete-task-btn:hover,
.modal-footer .btn-danger:hover {
    background: rgba(255, 69, 58, 0.2);
    border-color: rgba(255, 69, 58, 0.5);
    color: #ff6961;
}

.area-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

/* Estilos de Administración de Usuarios Autorizados */
.badge-admin {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(10, 132, 255, 0.18);
    color: #0a84ff;
    border: 1px solid rgba(10, 132, 255, 0.35);
}

.admin-user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.65rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    font-size: 0.85rem;
    transition: background 0.15s ease;
}
.admin-user-row:hover {
    background: rgba(255, 255, 255, 0.07);
}
.admin-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.admin-user-email {
    color: #f5f5f7;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-btn-remove {
    background: transparent;
    border: none;
    color: #ff453a;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}
.admin-btn-remove:hover {
    background: rgba(255, 69, 58, 0.15);
}

/* Modal de 3 columnas */
.modal-large {
    width: 1150px;
    max-width: 95vw;
    max-height: 90vh;
    position: relative;
    overflow: hidden !important;
}

.modal-body {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.5rem;
    padding-top: 1rem;
    height: calc(90vh - 120px);
    overflow: hidden; /* El scroll ahora lo manejan los hijos */
    padding-right: 0.5rem;
}

.modal-left, .modal-center {
    min-width: 0; /* Crucial para evitar que el grid se ensanche por nombres largos */
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.2rem;
    background: rgba(0, 0, 0, 0.2); /* Sutil contraste para separar el modal del fondo */
    overflow-y: auto; /* Scroll independiente para cada columna */
}

.modal-left::-webkit-scrollbar, .modal-center::-webkit-scrollbar {
    width: 6px;
}
.modal-left::-webkit-scrollbar-thumb, .modal-center::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
}

.modal-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.modal-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.attachments-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.attachments-list::-webkit-scrollbar {
    width: 4px;
}
.attachments-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
}

.image-preview-container {
    flex: 1;
    min-height: 200px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    border: 1px dashed var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 0.5rem;
}

.image-preview-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

#preview-placeholder {
    color: #86868b;
    font-size: 0.85rem;
}

/* Modal Expandido a pantalla completa */
.image-preview-container.fullscreen-active {
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    width: 100% !important; height: 100% !important;
    z-index: 100000 !important;
    border-radius: 0 !important;
    border: none;
    background: rgba(19, 19, 22, 0.98) !important;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    overflow: hidden !important;
}
.image-preview-container.fullscreen-active #preview-wrapper {
    width: 100%; height: 100%;
}
.image-preview-container.fullscreen-active #preview-controls {
    top: max(20px, env(safe-area-inset-top)) !important; right: 20px !important;
}

/* Estilos de elementos de la lista para prevenir overflow de botones */
.att-info {
    flex: 1; 
    display: flex; 
    align-items: center; 
    overflow: hidden; 
    margin-right: 0.5rem;
    min-width: 0;
}
.att-type-badge {
    font-size: 0.65rem;
    background: rgba(255,255,255,0.1);
    color: #86868b;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    margin-right: 0.5rem;
    text-transform: uppercase;
    flex-shrink: 0;
}
.att-link {
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    cursor: pointer; 
    color:#0a84ff; 
    text-decoration:none;
    display: block;
    width: 100%;
}
.att-actions {
    flex-shrink: 0; 
    display: flex; 
    align-items: center;
}
.attachment-item.selected {
    background: rgba(10, 132, 255, 0.15) !important;
    border-left: 2px solid #0a84ff;
    padding-left: calc(0.5rem - 2px);
}

/* Color del icono del calendario en modo oscuro y alineación a la izquierda en iPhone / Safari */
input[type="date"],
input[type="datetime-local"],
input[type="time"] {
    text-align: left !important;
    text-align: start !important;
    -webkit-text-align: left !important;
}

input[type="date"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value {
    text-align: left !important;
    text-align: start !important;
    -webkit-text-align: left !important;
    min-height: 1.2em;
    margin: 0 !important;
    padding: 0 !important;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
    cursor: pointer;
}

/* Estilos para Notas (Quill y Lista) */
.note-item {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 0.8rem;
    padding: 0.8rem;
    cursor: grab;
    transition: all 0.2s ease;
}
.note-item:active {
    cursor: grabbing;
}
.note-drag-over {
    border-top: 2px solid #0a84ff;
    background: rgba(10, 132, 255, 0.1);
}
.note-item:hover {
    background: rgba(255,255,255,0.1);
}
.note-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    font-size: 0.75rem;
    color: #86868b;
}
.note-item-preview {
    font-size: 0.85rem;
    color: #f5f5f7;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
    height: 2.8em; /* Forzar exactamente 2 renglones de altura */
    margin-top: 0.4rem;
}

/* Checkbox de Notas */
.note-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: all 0.2s ease;
    padding: 0;
    margin-top: 2px;
}
.note-checkbox:hover {
    border-color: #34c759;
}
.note-resolved .note-checkbox {
    background: #34c759;
    border-color: #34c759;
    color: white;
}

/* Estado de Nota Resuelta (Sin cambios de color ni tachado según preferencia) */
.note-resolved {
    /* Mantenemos la clase por si se requiere en el futuro, pero sin efectos visuales */
}

/* Ajustes Quill para modo oscuro */
.ql-toolbar.ql-snow {
    background: #f5f5f7;
    border-radius: 8px 8px 0 0;
    border: none !important;
    border-bottom: 1px solid #ccc !important;
}
.ql-container.ql-snow {
    border: none !important;
    border-radius: 0 0 8px 8px;
    background: #ffffff;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.ql-editor {
    flex: 1;
    font-size: 0.95rem;
    color: #1c1c1e;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ========== LISTAS QUILL 2.0 ========== */
/* Quill 2.0 usa data-list="bullet/ordered" + .ql-ui::before para los marcadores */
.ql-editor ol,
.ql-editor ul {
    padding-left: 1.5em;
    list-style: none !important;
}

/* Bullet list (•) */
.ql-editor li[data-list="bullet"] > .ql-ui::before {
    content: '•' !important;
    margin-right: 0.5em;
    color: #1c1c1e;
}

/* Ordered list (1. 2. 3.) — Quill lo gestiona con counter */
.ql-editor li[data-list="ordered"] {
    counter-increment: list-0;
}
.ql-editor li[data-list="ordered"] > .ql-ui::before {
    content: counter(list-0, decimal) '. ' !important;
    margin-right: 0.3em;
    color: #1c1c1e;
}
/* Reset counter al inicio de cada grupo ordenado */
.ql-editor li[data-list="ordered"]:first-child,
.ql-editor li[data-list="bullet"] + li[data-list="ordered"],
.ql-editor p + li[data-list="ordered"] {
    counter-reset: list-0;
}


/* ========== VISIBILIDAD DE CHECKLIST QUILL 2.0 ========== */
/* Sobrescribir el estilo por defecto para hacerlo mucho más visible y azul */
.ql-editor li[data-list="check"] > .ql-ui::before,
.ql-editor li[data-list="unchecked"] > .ql-ui::before,
.ql-editor li[data-list="checked"] > .ql-ui::before {
    content: '' !important;
    display: inline-block !important;
    width: 1.1em !important;
    height: 1.1em !important;
    background-size: 70% !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    border: 2px solid #0a84ff !important;
    border-radius: 4px !important;
    background-image: none !important;
    margin-right: 0.8em !important;
    transform: translateY(0.15em);
    cursor: pointer;
}

.ql-editor li[data-list="checked"] > .ql-ui::before {
    background-color: #0a84ff !important;
    border-color: #0a84ff !important;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E") !important;
}

/* ========== ESTILOS DE TABLAS QUILL ========== */
.ql-editor table {
    border-collapse: collapse !important;
    width: 100% !important;
    margin: 1rem 0 !important;
    border: 1px solid #999999 !important;
}
.ql-editor td, .ql-editor th {
    border: 1px solid #999999 !important;
    padding: 8px 12px !important;
    min-width: 50px !important;
}

/* ========== DOCUMENTOS INCRUSTADOS EN NOTAS ========== */
.inline-file-attachment {
    display: inline-block !important;
    background: rgba(10, 132, 255, 0.15) !important;
    padding: 4px 8px !important;
    border-radius: 6px !important;
    color: #0a84ff !important;
    text-decoration: none !important;
    font-weight: 500 !important;
    margin: 2px 4px !important;
    border: 1px solid rgba(10, 132, 255, 0.3) !important;
    cursor: pointer !important;
    font-size: 0.9em;
}
.inline-file-attachment:hover {
    background: rgba(10, 132, 255, 0.25) !important;
}

/* =========================================
   Componentes Específicos para Vistas Móviles
========================================= */
.mobile-column-tabs {
    display: none;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 1rem;
    gap: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.mobile-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.55rem 0.6rem;
    border-radius: 8px;
    background: transparent;
    color: #86868b;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-height: 40px;
}
.mobile-tab-btn.active {
    background: var(--card-bg, rgba(44, 44, 46, 0.95));
    color: #f5f5f7;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.mobile-tab-btn .tab-badge {
    background: rgba(255, 255, 255, 0.12);
    color: #f5f5f7;
    font-size: 0.72rem;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
}
.mobile-tab-btn.active .tab-badge {
    background: var(--accent, #0a84ff);
    color: #ffffff;
}

/* Modal de Edición de Notas (Quill Modal) */
#quill-modal {
    display: none;
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #1e1e22;
    border-radius: 16px;
    z-index: 20000;
    flex-direction: column;
    padding: 1.5rem;
    box-sizing: border-box;
    overflow: hidden !important;
}
.quill-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1.2rem;
    gap: 0.75rem;
    width: 100%;
    box-sizing: border-box;
}
.quill-title-input {
    background: transparent;
    border: 1px solid transparent;
    color: #f5f5f7;
    font-size: 1.5rem;
    font-weight: 600;
    flex: 1;
    min-width: 0;
    outline: none;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-family: inherit;
    cursor: text;
    margin-left: -0.2rem;
    margin-right: auto;
}
.quill-title-input:hover {
    background: rgba(255, 255, 255, 0.05);
}
.quill-title-input:focus {
    background: rgba(0, 0, 0, 0.3);
    border-color: var(--primary-color);
}
.quill-drawer-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #f5f5f7;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
    transition: all 0.15s ease;
    box-sizing: border-box;
}
.quill-drawer-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}
.quill-drawer-toggle-btn:active {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(0.95);
}
.quill-header-controls,
.quill-mobile-close-btn,
.quill-desktop-close-btn {
    display: none !important;
}

/* ─── Drawer Lateral Izquierdo de Herramientas de la Nota (Desktop y Móvil) ─── */
#note-drawer-backdrop {
    display: block !important;
    position: absolute !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    border-radius: 16px !important;
    z-index: 100 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.25s ease, visibility 0.25s ease !important;
}

#quill-modal.drawer-open #note-drawer-backdrop {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

#note-tools-drawer {
    display: flex !important;
    flex-direction: column !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: auto !important;
    bottom: 0 !important;
    width: 320px !important;
    max-width: 86% !important;
    height: 100% !important;
    background: #1e1e22 !important;
    border-right: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-left: none !important;
    border-top-left-radius: 16px !important;
    border-bottom-left-radius: 16px !important;
    z-index: 101 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s !important;
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.7) !important;
    box-sizing: border-box !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

#quill-modal.drawer-open #note-tools-drawer {
    transform: translateX(0) !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.drawer-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: max(0.85rem, env(safe-area-inset-top)) 1rem 0.85rem 1rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: rgba(28, 28, 30, 0.95) !important;
}

.drawer-header-title {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    color: #f5f5f7 !important;
}

.drawer-close-btn {
    display: none !important;
}

.drawer-body {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 1rem !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 1.15rem !important;
    -webkit-overflow-scrolling: touch !important;
}

.drawer-section {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
}

.drawer-section-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.drawer-section-title {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #86868b !important;
}

.drawer-date-box {
    display: flex !important;
    gap: 6px !important;
    align-items: center !important;
}

.drawer-date-input {
    flex: 1 !important;
    padding: 0.55rem 0.7rem !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #f5f5f7 !important;
    font-size: 0.88rem !important;
    outline: none !important;
    text-align: left !important;
}

.drawer-btn-clear-date {
    padding: 0.55rem 0.7rem !important;
    border-radius: 8px !important;
    background: rgba(255, 69, 58, 0.12) !important;
    border: 1px solid rgba(255, 69, 58, 0.25) !important;
    color: #ff453a !important;
    font-size: 0.78rem !important;
    font-weight: 500 !important;
    cursor: pointer !important;
}

.drawer-action-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.4rem !important;
}

.drawer-action-item {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 10px !important;
    padding: 0.65rem 0.75rem !important;
    color: #f5f5f7 !important;
    font-size: 0.88rem !important;
    cursor: pointer !important;
    width: 100% !important;
    text-align: left !important;
    transition: all 0.15s ease !important;
}

.drawer-action-item:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}

.drawer-action-item-left {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

.drawer-icon-box {
    width: 26px !important;
    height: 26px !important;
    border-radius: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.drawer-icon-box.bg-purple {
    background: rgba(175, 82, 222, 0.2) !important;
    color: #af52de !important;
}

.drawer-icon-box.bg-blue {
    background: rgba(10, 132, 255, 0.2) !important;
    color: #0a84ff !important;
}

#drawer-templates-dropdown {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 0.5rem;
    margin-top: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.task-card-delete-btn {
    background: transparent;
    border: none;
    color: #86868b;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
    opacity: 0.55;
    flex-shrink: 0;
}
.task-card-delete-btn:hover {
    color: #ff453a;
    background: rgba(255, 69, 58, 0.15);
    opacity: 1;
}
.task-card-delete-btn:active {
    transform: scale(0.92);
}
.quill-mobile-tabs {
    display: none;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 0.75rem;
    gap: 4px;
}
.quill-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.5rem;
    border-radius: 6px;
    background: transparent;
    color: #86868b;
    border: none;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.quill-tab-btn.active {
    background: #2c2c2e;
    color: #f5f5f7;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.quill-modal-content-wrapper {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 1.5rem;
}
.quill-editor-wrapper {
    flex: 2;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #f5f5f7;
    border-radius: 8px;
    overflow: hidden;
}
#quill-editor-container {
    flex: 1;
    color: #1c1c1e;
    border: none;
    border-top: 1px solid #ccc;
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.quill-attachments-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
    border: none;
    padding: 0;
    overflow-y: auto;
    gap: 0.9rem;
}

/* Card unificada estándar para secciones de documentos */
.quill-doc-card {
    background: #1e1e22;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    box-sizing: border-box;
}

.quill-doc-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.45rem;
}

.quill-doc-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #f5f5f7;
    margin: 0;
    letter-spacing: -0.01em;
}

/* Template Manager Styles */
.template-manager-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.template-manager-body {
    display: flex;
    flex: 1;
    min-height: 0;
}
.template-manager-left {
    width: 240px;
    flex-shrink: 0;
    border-right: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 0.5rem;
    overflow-y: auto;
}
.template-manager-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.2rem;
    gap: 0.8rem;
    min-height: 0;
}
.template-back-mobile-btn {
    display: none;
}

/* Modal Footer Actions */
.modal-footer-actions {
    display: flex;
    gap: 0.5rem;
}

/* =========================================
   Responsive Design (Mobile & Tablets)
========================================= */
@media (max-width: 900px) {
    body {
        padding: 0;
        background: transparent; /* Transparent for vibrancy — app-layout provides the tinted glass */
    }

    /* Sidebar Drawer para Móvil con Safe Area */
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        height: 100%;
        transform: translateX(-100%);
        box-shadow: 12px 0 32px rgba(0, 0, 0, 0.6);
        z-index: 500;
        padding-top: max(0rem, env(safe-area-inset-top));
        padding-bottom: 0;
        box-sizing: border-box;
    }

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

    .sidebar-backdrop {
        z-index: 490;
    }

    .sidebar-close-btn {
        display: none !important;
    }

    .app-layout.sidebar-collapsed .app-sidebar {
        margin-left: 0;
    }

    /* Área Principal Móvil: Respeta notch y Dynamic Island de iPhone */
    .app-main {
        padding-top: max(0.85rem, calc(env(safe-area-inset-top) + 0.5rem)) !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        /* Bottom padding must account for safe area to avoid black gap */
        padding-bottom: max(0.75rem, calc(env(safe-area-inset-bottom) + 0.15rem)) !important;
        box-sizing: border-box !important;
        height: 100% !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        min-height: 0 !important;
    }


    .app-header {
        margin-bottom: 0.55rem !important;
        padding-bottom: 0.45rem !important;
        flex-shrink: 0 !important;
    }

    .current-view-info h1 {
        font-size: 1.25rem;
    }

    .app-header-right {
        gap: 6px;
    }

    .app-header-right .search-input {
        width: 100px;
        font-size: 16px !important; /* Previene auto-zoom en iOS Safari */
    }

    .app-header-right .search-input:focus {
        width: 130px;
    }

    /* Selector de pestañas de columnas en móvil */
    .mobile-column-tabs {
        display: flex !important;
        flex-shrink: 0 !important;
        margin-bottom: 0.6rem !important;
    }

    /* Kanban Board Mobile View (Gesto horizontal bloqueado - sincronía 100% con pestañas) */
    .kanban-board {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        height: auto !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        touch-action: pan-y !important;
        scroll-snap-type: none !important;
        padding: 0 !important;
        margin: 0 !important;
        gap: 0 !important;
        -webkit-overflow-scrolling: auto !important;
    }
    
    .kanban-board::-webkit-scrollbar {
        display: none !important;
    }
    
    .kanban-board > .column {
        display: none !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        height: 100% !important;
        max-height: none !important; /* Se ajusta exactamente hasta abajo */
        margin: 0 !important;
        padding: 0.9rem 0.85rem !important;
        border-radius: 16px !important;
        box-sizing: border-box !important;
        scroll-snap-align: none !important;
    }

    .kanban-board > .column.mobile-col-active {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        height: 100% !important;
    }

    .kanban-board > .column .column-header {
        flex-shrink: 0 !important;
        margin-bottom: 0.65rem !important;
    }

    .kanban-board > .column .task-list {
        flex: 1 1 0% !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior-y: contain !important;
        padding-right: 4px !important;
        padding-bottom: max(0.5rem, calc(env(safe-area-inset-bottom) * 0.75)) !important;
    }

    /* Formulario general en móvil: previene auto-zoom de iOS */
    .form-group input, 
    .form-group select, 
    .form-group textarea,
    .editable-modal-title,
    .quill-title-input {
        font-size: 16px !important;
    }

    /* Modales generales en móvil */
    .modal-small, .template-modal-card {
        width: 100% !important;
        max-width: 100vw !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        padding: 1rem !important;
        gap: 0.75rem !important;
    }

    /* ======================================================== */
    /* 📱 VISTA DE TAREA EN IPHONE (DISEÑO NATIVO iOS)         */
    /* ======================================================== */

    #task-modal {
        display: none;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background: rgba(13, 13, 16, 0.82) !important;
        backdrop-filter: blur(24px) saturate(180%) !important;
        -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        padding: 0 !important;
        overflow-y: auto !important; /* UN SOLO SCROLLBAR GLOBAL */
        -webkit-overflow-scrolling: touch;
        z-index: 5000 !important;
    }

    #task-modal.active,
    #task-modal[style*="display: flex"] {
        display: block !important;
    }

    #task-modal .modal-large {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 100% !important;
        height: auto !important;
        max-height: none !important;
        border: none !important;
        border-radius: 0 !important;
        /* Safe area bottom: push last content above home indicator, background fills the gap */
        padding: 0 0 max(1.5rem, env(safe-area-inset-bottom)) 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: visible !important;
        gap: 0 !important;
    }

    /* Ocultar y aislar totalmente contenido de tarea cuando el editor de nota está activo */
    body.note-modal-active #task-modal {
        overflow: hidden !important;
        overflow-y: hidden !important;
        overflow-x: hidden !important;
        pointer-events: none !important;
        background: rgba(13, 13, 16, 0.82) !important;
        height: 100% !important;
        max-height: 100% !important;
        overscroll-behavior: none !important;
    }
    body.note-modal-active #task-modal > .modal-large {
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        overflow: hidden !important;
        overflow-y: hidden !important;
        overflow-x: hidden !important;
        height: 100% !important;
        max-height: 100% !important;
        min-height: 0 !important;
        pointer-events: none !important;
    }
    body.note-modal-active #task-modal > .modal-large > .modal-header,
    body.note-modal-active #task-modal > .modal-large > .modal-body {
        display: none !important;
    }
    body.note-modal-active #quill-modal {
        pointer-events: auto !important;
    }

    /* Cabecera Móvil de Tarea: Título a la izquierda, X a la derecha */
    #task-modal .modal-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 30 !important;
        background: rgba(20, 22, 28, 0.90) !important;
        backdrop-filter: blur(25px) !important;
        -webkit-backdrop-filter: blur(25px) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
        padding: max(0.75rem, env(safe-area-inset-top)) 1rem 0.75rem 1rem !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 0.75rem !important;
    }

    #task-modal .modal-ios-back-btn {
        display: none !important;
    }

    #task-modal .editable-modal-title {
        font-size: 1.25rem !important;
        font-weight: 700 !important;
        color: #ffffff !important;
        background: transparent !important;
        border: none !important;
        outline: none !important;
        padding: 0.2rem 0 !important;
        margin: 0 !important;
        flex: 1 !important;
        min-width: 0 !important;
        letter-spacing: -0.02em !important;
    }

    #task-modal .task-close-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: rgba(255, 255, 255, 0.08) !important;
        border: 1px solid rgba(255, 255, 255, 0.12) !important;
        color: #f5f5f7 !important;
        font-size: 1.15rem !important;
        width: 36px !important;
        height: 36px !important;
        border-radius: 50% !important;
        cursor: pointer !important;
        flex-shrink: 0 !important;
        padding: 0 !important;
        line-height: 1 !important;
        transition: all 0.15s ease !important;
    }
    #task-modal .task-close-btn:active {
        background: rgba(255, 255, 255, 0.2) !important;
        transform: scale(0.95) !important;
    }

    /* 3. Cuerpo de Secciones Agrupadas (Cards estilo iOS) */
    #task-modal .modal-body {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.9rem !important;
        padding: 0.9rem 1rem !important;
        height: auto !important;
        max-height: none !important;
        min-height: auto !important;
        overflow: visible !important; /* Cero scrollbars internos */
    }

    #task-modal .modal-left,
    #task-modal .modal-center {
        overflow: visible !important; /* Cero scrollbars internos */
        max-height: none !important;
        height: auto !important;
        min-height: auto !important;
        background: rgba(26, 29, 38, 0.78) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border: 1px solid rgba(255, 255, 255, 0.09) !important;
        border-radius: 14px !important;
        padding: 1rem !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.07) !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 0.85rem !important;
    }

    #task-modal #modal-notes-list {
        overflow: visible !important; /* Cero scrollbars internos */
        max-height: none !important;
        height: auto !important;
        flex: none !important;
    }

    /* Alineación a la izquierda de Fecha Límite e inputs de fecha en móvil / iPhone */
    #task-modal #modal-task-date,
    #quill-note-due-drawer,
    #smart-task-date,
    .drawer-date-input,
    .form-group input[type="date"] {
        text-align: left !important;
        text-align: start !important;
        -webkit-text-align: left !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    #task-modal #modal-task-date::-webkit-date-and-time-value,
    #quill-note-due-drawer::-webkit-date-and-time-value,
    #smart-task-date::-webkit-date-and-time-value,
    .drawer-date-input::-webkit-date-and-time-value,
    .form-group input[type="date"]::-webkit-date-and-time-value {
        text-align: left !important;
        text-align: start !important;
        -webkit-text-align: left !important;
        min-height: 1.2em;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    #task-modal .modal-center .form-group {
        height: auto !important;
        min-height: auto !important;
        flex: none !important;
    }

    /* 4. Ocultar footer de tarea ya que ahora guarda y regresa automáticamente */
    #task-modal .modal-footer {
        display: none !important;
    }

    /* Modal Quill en Móvil: Pantalla Completa Limpia + Drawer Izquierdo */
    #quill-modal {
        position: fixed !important;
        inset: 0 !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        padding: 0 !important;
        background: rgba(13, 13, 16, 0.82) !important;
        backdrop-filter: blur(24px) saturate(180%) !important;
        -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
        z-index: 99999 !important;
        display: none;
        flex-direction: column !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    /* Cabecera Móvil de Nota: Mismo tono, línea divisoria, altura y estilo que Tarea */
    .quill-modal-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 30 !important;
        background: rgba(22, 22, 26, 0.95) !important;
        backdrop-filter: blur(25px) !important;
        -webkit-backdrop-filter: blur(25px) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
        padding: max(0.75rem, env(safe-area-inset-top)) 1rem 0.75rem 1rem !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        margin-bottom: 0 !important;
        gap: 0.75rem !important;
        flex-wrap: nowrap !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Botón de opciones a la izquierda con el icono del home */
    .quill-drawer-toggle-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 36px !important;
        height: 36px !important;
        border-radius: 50% !important;
        background: rgba(255, 255, 255, 0.08) !important;
        border: 1px solid rgba(255, 255, 255, 0.12) !important;
        color: #f5f5f7 !important;
        cursor: pointer !important;
        flex-shrink: 0 !important;
        padding: 0 !important;
        line-height: 1 !important;
        transition: all 0.15s ease !important;
    }
    .quill-drawer-toggle-btn:active {
        background: rgba(255, 255, 255, 0.2) !important;
        transform: scale(0.95) !important;
    }

    .quill-title-input {
        font-size: 1.25rem !important;
        font-weight: 700 !important;
        color: #ffffff !important;
        background: transparent !important;
        border: none !important;
        outline: none !important;
        padding: 0.2rem 0 !important;
        margin: 0 !important;
        flex: 1 !important;
        min-width: 0 !important;
        letter-spacing: -0.02em !important;
        font-family: inherit !important;
    }

    /* Botón X para cerrar/guardar nota en móvil a la derecha */
    .quill-mobile-close-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: rgba(255, 255, 255, 0.08) !important;
        border: 1px solid rgba(255, 255, 255, 0.12) !important;
        color: #f5f5f7 !important;
        font-size: 1.15rem !important;
        width: 36px !important;
        height: 36px !important;
        border-radius: 50% !important;
        cursor: pointer !important;
        flex-shrink: 0 !important;
        padding: 0 !important;
        line-height: 1 !important;
        transition: all 0.15s ease !important;
    }
    .quill-mobile-close-btn:active {
        background: rgba(255, 255, 255, 0.2) !important;
        transform: scale(0.95) !important;
    }

    /* Ocultar controles de escritorio en móvil */
    .quill-header-controls {
        display: none !important;
    }

    /* Mostrar pestañas móviles para el Editor de Notas */
    .quill-mobile-tabs {
        display: flex !important;
        margin: 0.65rem 1rem 0.45rem 1rem !important;
        background: rgba(255, 255, 255, 0.08) !important;
        border: 1px solid rgba(255, 255, 255, 0.06) !important;
        border-radius: 10px !important;
        padding: 4px !important;
        gap: 4px !important;
        flex-shrink: 0 !important;
    }

    /* Tab 1: Nota activa por defecto */
    #quill-modal:not(.show-attachments) .quill-editor-wrapper {
        display: flex !important;
        flex: 1 !important;
    }
    #quill-modal:not(.show-attachments) .quill-attachments-wrapper {
        display: none !important;
    }

    /* Tab 2: Documentos (Hojas de cálculo, Documentos adjuntos, Previsualizar) */
    #quill-modal.show-attachments .quill-editor-wrapper {
        display: none !important;
    }
    #quill-modal.show-attachments .quill-attachments-wrapper {
        display: flex !important;
        flex: 1 !important;
        flex-direction: column !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        background: transparent !important;
        border: none !important;
        padding: 0.5rem 1rem max(1rem, env(safe-area-inset-bottom)) 1rem !important;
        gap: 0.9rem !important;
        box-sizing: border-box !important;
    }

    #quill-modal .quill-doc-card {
        background: #1e1e22 !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        border-radius: 14px !important;
        padding: 1rem !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25) !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 0.85rem !important;
        margin-bottom: 0.85rem !important;
        box-sizing: border-box !important;
    }

    /* Contenedor central del modal de notas: cero scrollbars externos */
    .quill-modal-content-wrapper {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        min-height: 0 !important;
        height: 100% !important;
        gap: 0 !important;
        overflow: hidden !important;
        overflow-y: hidden !important;
        box-sizing: border-box !important;
    }

    /* Panel blanco donde se escribe la nota:
       Mismas dimensiones exactas, márgenes y bordes redondeados que las secciones de Documentos */
    .quill-editor-wrapper {
        display: flex !important;
        flex: 1 !important;
        flex-direction: column !important;
        min-height: 0 !important;
        height: 100% !important;
        margin: 0.5rem 1rem max(1rem, env(safe-area-inset-bottom)) 1rem !important;
        padding: 0 !important;
        background: #ffffff !important;
        border-radius: 14px !important;
        border: 1px solid rgba(255, 255, 255, 0.12) !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25) !important;
        overflow: hidden !important;
        overflow-y: hidden !important;
        box-sizing: border-box !important;
    }

    /* Barra de herramientas Quill integrada elegantemente al panel blanco */
    .quill-editor-wrapper .ql-toolbar.ql-snow {
        background: #f5f5f7 !important;
        border: none !important;
        border-bottom: 1px solid #e5e5ea !important;
        border-radius: 14px 14px 0 0 !important;
        padding: 6px 8px !important;
        flex-shrink: 0 !important;
    }

    #quill-editor-container {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        min-height: 0 !important;
        height: 100% !important;
        overflow: hidden !important;
        overflow-y: hidden !important;
        background: #ffffff !important;
        border: none !important;
        border-radius: 0 0 14px 14px !important;
    }

    #quill-editor-container .ql-container.ql-snow {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        min-height: 0 !important;
        height: 100% !important;
        border: none !important;
        overflow: hidden !important;
        overflow-y: hidden !important;
        background: #ffffff !important;
        border-radius: 0 0 14px 14px !important;
    }

    /* Único scrollbar de la nota: solo el texto hace scroll con inercia nativa de iOS */
    #quill-editor-container .ql-editor {
        flex: 1 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 0.85rem 1rem !important;
        font-size: 16px !important;
        color: #1c1c1e !important;
        box-sizing: border-box !important;
    }

    /* ─── Drawer Lateral Izquierdo de Herramientas de la Nota (Móvil) ─── */
    #note-drawer-backdrop {
        border-radius: 0 !important;
    }

    #note-tools-drawer {
        width: 86vw !important;
        max-width: 320px !important;
        border-top-left-radius: 0 !important;
        border-bottom-left-radius: 0 !important;
    }

    /* Barra de herramientas Quill compacta */
    .ql-toolbar.ql-snow {
        padding: 4px 6px !important;
        overflow-x: auto;
        white-space: nowrap;
    }
    .ql-toolbar.ql-snow .ql-formats {
        margin-right: 6px !important;
    }

    /* Gestor de Plantillas en Móvil */
    .template-manager-header {
        padding: 0.8rem 1rem;
    }
    .template-manager-body {
        flex-direction: column;
    }
    #template-manager-modal.mobile-editing .template-manager-left {
        display: none !important;
    }
    #template-manager-modal.mobile-editing .template-back-mobile-btn {
        display: inline-flex !important;
    }
    #template-manager-modal:not(.mobile-editing) .template-manager-right {
        display: none !important;
    }
    #template-manager-modal:not(.mobile-editing) .template-manager-left {
        width: 100% !important;
        border-right: none !important;
    }
}

/* =========================================
   Responsive Design (Tablets: 769px - 1024px)
========================================= */
@media (min-width: 769px) and (max-width: 1024px) {
    body {
        padding: 1.25rem;
    }
    .kanban-board {
        overflow-x: auto;
        padding-bottom: 1rem;
        scroll-snap-type: x mandatory;
        gap: 1rem;
    }
    .kanban-board > .column {
        flex: 0 0 45vw; /* Dos columnas visibles a la vez en tablet */
        scroll-snap-align: start;
    }
    .modal-large {
        width: 95vw;
        max-height: 94vh;
    }
    .modal-body {
        grid-template-columns: 260px 1fr;
    }
}

/* =========================================
/* =========================================
   Teams-Style Code Blocks (Quill 2.0)
========================================= */
.ql-snow .ql-editor .ql-code-block-container {
    background-color: #000000 !important;
    color: #5ac8fa !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 8px !important;
    padding: 44px 16px 16px 16px !important; /* Espacio superior para el menú desplegable */ 
    margin-top: 1.5em !important;
    margin-bottom: 1.5em !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
    position: relative !important;
}

/* El menú desplegable de Quill 2.0 */
.ql-snow .ql-editor .ql-code-block-container select.ql-ui {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    background-color: #323236 !important;
    color: #aaaaaa !important;
    border: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
    height: 34px;
    padding: 0 12px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 500;
    border-radius: 8px 8px 0 0;
    box-sizing: border-box;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Espaciado para cada línea de código */
.ql-snow .ql-editor .ql-code-block-container .ql-code-block {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.5 !important;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    background: transparent !important;
}

/* Pseudo-elemento visual para el ícono de desplegable */
.ql-snow .ql-editor .ql-code-block-container::after {
    content: "";
    position: absolute;
    top: 10px;
    right: 12px;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23aaaaaa' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    opacity: 0.6;
    pointer-events: none;
}

/* =========================================
   Custom Syntax Palette (Navicat Style)
========================================= */
.ql-snow .ql-editor .ql-code-block {
    color: #74FDFF !important; /* Common text */
}
.ql-snow .ql-editor .ql-code-block [class*="keyword"],
.ql-snow .ql-editor .ql-code-block [class*="selector-tag"],
.ql-snow .ql-editor .ql-code-block [class*="literal"],
.ql-snow .ql-editor .ql-code-block [class*="type"],
.ql-snow .ql-editor .ql-code-block [class*="built_in"] {
    color: #0096FF !important; /* Keyword */
}
.ql-snow .ql-editor .ql-code-block [class*="comment"],
.ql-snow .ql-editor .ql-code-block [class*="quote"] {
    color: #686868 !important; /* Comment */
}
.ql-snow .ql-editor .ql-code-block [class*="string"],
.ql-snow .ql-editor .ql-code-block [class*="regexp"],
.ql-snow .ql-editor .ql-code-block [class*="addition"],
.ql-snow .ql-editor .ql-code-block [class*="attribute"],
.ql-snow .ql-editor .ql-code-block [class*="meta-string"],
.ql-snow .ql-editor .ql-code-block [class*="meta"] {
    color: #FF2501 !important; /* String */
}
.ql-snow .ql-editor .ql-code-block [class*="number"],
.ql-snow .ql-editor .ql-code-block [class*="attr"],
.ql-snow .ql-editor .ql-code-block [class*="symbol"],
.ql-snow .ql-editor .ql-code-block [class*="bullet"],
.ql-snow .ql-editor .ql-code-block [class*="link"] {
    color: #AAFF6B !important; /* Number */
}

/* =========================================
   Estilo de Adjuntos Inline (Caja Azul)
========================================= */
.inline-file-attachment {
    display: inline-flex;
    align-items: center;
    background-color: #e3f2fd;
    border: 1px solid #90caf9;
    color: #1e88e5 !important;
    border-radius: 6px;
    padding: 2px 8px;
    margin: 2px 4px;
    font-size: 0.9em;
    font-weight: 500;
    text-decoration: none !important;
    cursor: pointer;
    vertical-align: middle;
}
.inline-file-attachment * {
    color: inherit !important;
    text-decoration: none !important;
}
.inline-file-attachment svg {
    margin-right: 6px;
}

.ql-tooltip {
    z-index: 21000 !important; /* Ensure it is above the modal */
    background-color: #fff !important;
    border: 1px solid #ccc !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
    color: #333 !important;
}
.ql-tooltip input[type="text"] {
    background-color: #fff !important;
    color: #333 !important;
    border: 1px solid #ccc !important;
    padding: 2px 4px !important;
}
.ql-tooltip a {
    color: #06c !important;
}

/* ========== TEMPLATE MODULE ========== */
.template-list-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #ebebf5cc;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s;
    user-select: none;
}
.template-list-item:hover {
    background: rgba(255,255,255,0.07);
}
.template-list-item.active {
    background: rgba(10,132,255,0.15);
    border-color: rgba(10,132,255,0.35);
    color: #0a84ff;
    font-weight: 600;
}
.template-list-item .tpl-icon {
    font-size: 1rem;
    flex-shrink: 0;
}
.template-list-item .tpl-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dropdown selector en el editor de notas */
.tpl-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.7rem;
    border-radius: 7px;
    cursor: pointer;
    font-size: 0.87rem;
    color: #f5f5f7;
    transition: background 0.12s;
}
.tpl-dropdown-item:hover {
    background: rgba(255,255,255,0.1);
}
.tpl-dropdown-empty {
    padding: 0.8rem;
    text-align: center;
    color: #86868b;
    font-size: 0.83rem;
}

/* Icon picker grid */
.icon-picker-btn {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    color: #f5f5f7;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s;
}
.icon-picker-btn:hover {
    background: rgba(255,255,255,0.1);
}

/* Modal Mover / Copiar Nota */
.move-action-btn {
    background: transparent;
    color: #86868b;
}
.move-action-btn:hover {
    color: #f5f5f7;
    background: rgba(255, 255, 255, 0.04);
}
.move-action-btn.active {
    background: var(--primary-color, #0071e3) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* =========================================
   Modal de Captura Inteligente (Minimalista / Apple Dark Mode)
   ========================================= */
.smart-capture-content {
    width: 600px;
    max-width: 94vw;
    background: rgba(30, 30, 30, 0.88);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 1.5rem 1.75rem;
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    max-height: 90vh;
    overflow-y: auto;
}

.smart-capture-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.85rem;
    margin-bottom: 0.1rem;
}

.smart-capture-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #f5f5f7;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
}

.smart-capture-subtitle {
    margin: 4px 0 0 0;
    font-size: 0.78rem;
    color: #86868b;
    font-weight: 400;
}

/* Tarjeta Multimodal de Entrada */
.smart-intake-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.smart-intake-card:focus-within {
    border-color: rgba(10, 132, 255, 0.55);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.15);
}

.smart-paste-box {
    position: relative;
    min-height: 110px;
}

#smart-text-input {
    width: 100%;
    min-height: 110px;
    background: transparent;
    border: none;
    outline: none;
    padding: 0.85rem 1rem;
    color: #f5f5f7;
    font-family: inherit;
    font-size: 0.88rem;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
}

#smart-text-input::placeholder {
    color: #636366;
    font-weight: 400;
}

.smart-drop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 132, 255, 0.2);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    color: #0a84ff;
    font-weight: 600;
    font-size: 0.88rem;
    pointer-events: none;
    border: 2px dashed rgba(10, 132, 255, 0.6);
    border-radius: 12px;
}

.smart-drop-overlay.active {
    display: flex !important;
}

.smart-intake-footer {
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0.45rem 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    flex-wrap: wrap;
}

.smart-attachments-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    flex: 1;
}

.smart-file-chip {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.74rem;
    color: #f5f5f7;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 190px;
}

.smart-file-chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.smart-file-chip-del {
    background: transparent;
    border: none;
    color: #86868b;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.15s ease;
}

.smart-file-chip-del:hover {
    color: #ff453a;
}

.smart-attach-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.smart-attach-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f5f5f7;
    border-radius: 6px;
    padding: 0.32rem 0.65rem;
    font-size: 0.76rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease;
}

.smart-attach-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.smart-intake-summary {
    font-size: 0.74rem;
    color: #86868b;
}

/* Banner predictivo minimalista */
.smart-suggestion-pill {
    background: rgba(10, 132, 255, 0.1);
    border: 1px solid rgba(10, 132, 255, 0.25);
    border-radius: 8px;
    padding: 0.45rem 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.8rem;
    color: #f5f5f7;
    animation: fadeIn 0.2s ease;
}

.smart-suggestion-text-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.smart-sparkle-icon {
    font-size: 0.95rem;
    flex-shrink: 0;
}

.smart-suggestion-accept-btn {
    background: #0a84ff;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 3px 9px;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.smart-suggestion-accept-btn:hover {
    background: #0071e3;
}

/* Segmented Control de Niveles (Estilo macOS / iOS) */
.smart-destination-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.smart-control-label {
    font-size: 0.76rem;
    color: #86868b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.smart-segmented-control {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 9px;
    padding: 3px;
    gap: 3px;
}

.smart-segment-btn {
    border: none;
    background: transparent;
    color: #86868b;
    padding: 0.5rem 0.4rem;
    border-radius: 7px;
    font-size: 0.82rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.smart-segment-btn:hover {
    color: #f5f5f7;
    background: rgba(255, 255, 255, 0.04);
}

.smart-segment-btn.active {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

/* Campos de formulario contextuales por nivel */
.smart-level-config {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 0.85rem;
}

.smart-level-config .form-group label {
    font-size: 0.78rem;
    color: #86868b;
    margin-bottom: 0.3rem;
    display: block;
    font-weight: 500;
}

.smart-level-config input[type="text"],
.smart-level-config input[type="date"],
.smart-level-config select {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    color: #f5f5f7;
    font-size: 0.85rem;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

.smart-level-config input[type="text"]:focus,
.smart-level-config input[type="date"]:focus,
.smart-level-config select:focus {
    border-color: #0a84ff;
    outline: none;
}

.smart-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.6rem;
}

.smart-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

@media (max-width: 580px) {
    .smart-grid-3,
    .smart-grid-2 {
        grid-template-columns: 1fr;
    }
}

.smart-checkbox-label {
    font-size: 0.78rem;
    color: #86868b;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    margin-top: 0.4rem;
    user-select: none;
}

.smart-checkbox-label input[type="checkbox"] {
    accent-color: #0a84ff;
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.smart-capture-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 0.85rem;
    margin-top: 0.2rem;
}

/* ==========================================================================
   Botón de cierre circular estandarizado (36px, estilo iOS/macOS)
   ========================================================================== */
.circular-close-btn,
.quill-close-btn,
.quill-mobile-close-btn,
#task-modal .task-close-btn,
#settings-modal .close-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #f5f5f7 !important;
    font-size: 1.15rem !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
    transition: all 0.15s ease !important;
    box-sizing: border-box !important;
}

.circular-close-btn:hover,
.quill-close-btn:hover,
.quill-mobile-close-btn:hover,
#task-modal .task-close-btn:hover,
#settings-modal .close-btn:hover {
    background: rgba(255, 255, 255, 0.16) !important;
    color: #ffffff !important;
}

.circular-close-btn:active,
.quill-close-btn:active,
.quill-mobile-close-btn:active,
#task-modal .task-close-btn:active,
#settings-modal .close-btn:active {
    background: rgba(255, 255, 255, 0.25) !important;
    transform: scale(0.95) !important;
}

/* ==========================================================================
   Modal de Configuración Estandarizado (Secciones tipo card, cero botones de pie)
   ========================================================================== */
#settings-modal {
    overscroll-behavior: contain;
}

#settings-modal .modal-content.modal-settings-dialog {
    background: #18181c !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 18px !important;
    padding: 1.25rem 1.4rem 1rem 1.4rem !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7) !important;
    width: 470px !important;
    max-width: 92vw !important;
    max-height: 85vh !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

#settings-modal .modal-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding-bottom: 0.8rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    margin-bottom: 0.2rem !important;
    flex-shrink: 0 !important;
}

#settings-modal .modal-header h2 {
    font-size: 1.15rem !important;
    font-weight: 600 !important;
    color: #f5f5f7 !important;
    margin: 0 !important;
    letter-spacing: -0.02em !important;
}

#settings-modal .modal-body,
#settings-modal .settings-modal-body {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.9rem !important;
    padding: 0.8rem 6px 0.8rem 0 !important;
    overflow-y: auto !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overscroll-behavior: contain !important;
    scrollbar-width: thin !important;
    scrollbar-color: rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.05) !important;
}

/* Barra de desplazamiento visible y moderna para Configuración */
#settings-modal .modal-body::-webkit-scrollbar,
#settings-modal .settings-modal-body::-webkit-scrollbar {
    width: 7px !important;
    display: block !important;
}

#settings-modal .modal-body::-webkit-scrollbar-track,
#settings-modal .settings-modal-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04) !important;
    border-radius: 10px !important;
}

#settings-modal .modal-body::-webkit-scrollbar-thumb,
#settings-modal .settings-modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3) !important;
    border-radius: 10px !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
}

#settings-modal .modal-body::-webkit-scrollbar-thumb:hover,
#settings-modal .settings-modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5) !important;
}

#settings-modal .quill-doc-card {
    background: #1e1e22 !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 14px !important;
    padding: 1rem !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
}

@media (max-width: 900px) {
    #settings-modal {
        overflow: hidden !important;
        overflow-y: hidden !important;
        touch-action: pan-y !important;
    }

    #settings-modal .modal-content.modal-settings-dialog {
        width: calc(100vw - 2rem) !important;
        max-width: 440px !important;
        max-height: 90vh !important;
        border-radius: 18px !important;
        padding: 1.15rem 1.1rem !important;
    }
}

/* ==========================================================================
   Estilos de Inteligencia Artificial (Gemini) en Captura y Configuración
   ========================================================================== */
.smart-ai-interpret-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #9333ea 100%) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    padding: 0.4rem 0.85rem !important;
    border-radius: 20px !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
    box-shadow: 0 2px 10px rgba(124, 58, 237, 0.35) !important;
}

.smart-ai-interpret-btn:hover {
    background: linear-gradient(135deg, #4338ca 0%, #6d28d9 50%, #7e22ce 100%) !important;
    transform: translateY(-1px) scale(1.02) !important;
    box-shadow: 0 4px 16px rgba(147, 51, 234, 0.5) !important;
}

.smart-ai-interpret-btn:active {
    transform: translateY(0) scale(0.98) !important;
}

.smart-ai-sparkle {
    font-size: 0.95rem !important;
    display: inline-block !important;
}

.smart-ai-pill {
    background: rgba(124, 58, 237, 0.12) !important;
    border: 1px solid rgba(147, 51, 234, 0.3) !important;
    border-radius: 12px !important;
    padding: 0.6rem 0.9rem !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-top: 0.65rem !important;
    margin-bottom: 0.4rem !important;
    animation: fadeIn 0.25s ease-out !important;
}

.smart-ai-text-wrap {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-size: 0.82rem !important;
    color: #d8b4fe !important;
    font-weight: 500 !important;
}

.smart-ai-sparkle-anim {
    display: inline-block !important;
    animation: aiSparklePulse 1.4s ease-in-out infinite alternate !important;
}

@keyframes aiSparklePulse {
    0% { transform: scale(1) rotate(0deg); opacity: 0.7; }
    50% { transform: scale(1.25) rotate(10deg); opacity: 1; filter: drop-shadow(0 0 6px #c084fc); }
    100% { transform: scale(1) rotate(-5deg); opacity: 0.7; }
}

.smart-ai-revert-btn {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #e9d5ff !important;
    padding: 0.25rem 0.6rem !important;
    border-radius: 6px !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
}

.smart-ai-revert-btn:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}

.smart-ai-pill.success {
    background: rgba(34, 197, 94, 0.12) !important;
    border-color: rgba(34, 197, 94, 0.35) !important;
}

.smart-ai-pill.success .smart-ai-text-wrap {
    color: #86efac !important;
}

.smart-ai-pill.loading {
    background: rgba(147, 51, 234, 0.18) !important;
    border-color: rgba(147, 51, 234, 0.5) !important;
}

.smart-ai-interpret-btn.loading {
    opacity: 0.85 !important;
    cursor: wait !important;
    pointer-events: none !important;
}

/* ─── Apple-style Splash Screen & Loading Animations ─── */
@keyframes iosSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#app-splash-screen {
    user-select: none;
    -webkit-user-select: none;
}

#gdrive-onboarding-modal {
    animation: fadeInModal 0.25s ease-out;
}

@keyframes fadeInModal {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}
