:root {
    --bg: #0f1419;
    --bg-elevated: #1a222d;
    --bg-muted: #243042;
    --border: #2d3b52;
    --text: #e8eef7;
    --muted: #94a3b8;
    --accent: #38bdf8;
    --accent-2: #a78bfa;
    --danger: #f87171;
    --success: #4ade80;
    --warning: #fbbf24;
    --radius: 12px;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: radial-gradient(1200px 600px at 10% -10%, rgba(56, 189, 248, 0.12), transparent),
        radial-gradient(900px 500px at 100% 0%, rgba(167, 139, 250, 0.1), transparent),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* App: solo el panel principal hace scroll; la barra lateral queda fija. */
body.is-app {
    height: 100vh;
    overflow: hidden;
}

html:has(body.is-app) {
    height: 100%;
}

body.is-login {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-screen {
    width: min(440px, 100%);
}

.login-card {
    padding: 28px;
}

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.brand {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 24px;
}

.brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(167, 139, 250, 0.25));
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    font-size: 1.4rem;
    color: var(--accent);
}

.brand h1 {
    margin: 0;
    font-size: 1.35rem;
}

.muted {
    color: var(--muted);
}

.tiny {
    font-size: 0.78rem;
}

#k-sync-state {
    display: none !important;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.field span {
    font-size: 0.85rem;
    color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="date"],
select,
textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 10px;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.35);
}

.password-wrap {
    position: relative;
    display: block;
}

.password-wrap input {
    width: 100%;
    padding-right: 44px;
}

.password-wrap .icon-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 999px;
    background: transparent;
}

.password-wrap .icon-btn:hover {
    transform: translateY(-50%);
    background: rgba(56, 189, 248, 0.12);
}

.btn {
    border: 1px solid var(--border);
    background: var(--bg-muted);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.08s ease, background 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn.primary {
    background: linear-gradient(135deg, #38bdf8, #6366f1);
    border-color: transparent;
    color: #0b1220;
}

.btn.secondary {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.35);
    color: var(--text);
}

.btn.ghost {
    background: transparent;
}

.btn.small {
    padding: 8px 10px;
    font-size: 0.85rem;
}

.btn.wide {
    width: 100%;
    justify-content: center;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.form-error {
    color: var(--danger);
    font-size: 0.88rem;
}

.layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: 100%;
    min-height: 0;
    max-height: 100vh;
    overflow: hidden;
}

.sidebar {
    background: rgba(26, 34, 45, 0.92);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    padding: 22px 18px;
    font-weight: 700;
    display: flex;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    color: var(--accent);
}

.nav {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.nav-item {
    text-align: left;
    padding: 12px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 0.95rem;
}

.nav-item:hover {
    background: rgba(56, 189, 248, 0.08);
}

.nav-item.active {
    border-color: rgba(56, 189, 248, 0.35);
    background: rgba(56, 189, 248, 0.12);
}

.hidden {
    display: none !important;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.user-block {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--bg-muted);
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
}

.user-name {
    font-weight: 600;
}

.pill {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(167, 139, 250, 0.15);
    border: 1px solid rgba(167, 139, 250, 0.35);
    color: #ddd6fe;
}

.footer-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.main {
    padding: 20px 26px 32px;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    flex-shrink: 0;
}

.topbar-start {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.topbar h2 {
    margin: 0;
    font-size: 1.25rem;
}

.mobile-nav-toggle {
    display: none;
}

.panel-filters-toggle {
    display: none;
}

.panel-filters-body {
    display: contents;
}

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

.panel.active {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

#panel-kanban.active {
    overflow: hidden;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.inline {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--muted);
}

.kanban {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    flex: 1;
    min-height: 0;
    align-content: stretch;
}

.kan-col {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    max-height: 100%;
}

.kan-col h3 {
    margin: 0 0 12px;
    font-size: 0.95rem;
    color: var(--muted);
    flex-shrink: 0;
}

.kan-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

.kan-list.drag-over {
    outline: 2px dashed rgba(56, 189, 248, 0.45);
    border-radius: 10px;
}

.task-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    cursor: grab;
}

.task-card.dragging {
    opacity: 0.65;
}

.task-card h4 {
    margin: 0 0 8px;
    font-size: 0.98rem;
}

.task-meta {
    font-size: 0.78rem;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 0.72rem;
}

.task-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.task-progress {
    margin-top: 8px;
}

.task-progress-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.76rem;
    color: var(--muted);
    margin-bottom: 5px;
}

.task-progress-label strong {
    color: #dbeafe;
    font-size: 0.8rem;
}

.task-progress-track {
    height: 8px;
    width: 100%;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
    border: 1px solid rgba(148, 163, 184, 0.25);
    overflow: hidden;
}

.task-progress-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #38bdf8, #22c55e);
    transition: width 0.25s ease;
}

.status-pendiente {
    border-left: 3px solid var(--warning);
}

.status-en_proceso {
    border-left: 3px solid var(--accent);
}

.status-completado {
    border-left: 3px solid var(--success);
}

.gantt-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    margin-bottom: 12px;
    padding: 10px 16px;
    font-size: 0.85rem;
    color: var(--muted);
}

.gantt-legend-title {
    font-weight: 600;
    color: var(--text);
    margin-right: 4px;
}

.gantt-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.gantt-wrap {
    padding: 16px;
    overflow-x: hidden;
}

.gantt-head {
    display: grid;
    grid-template-columns: 220px 1fr 54px;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: var(--muted);
}

.gantt-row {
    display: grid;
    grid-template-columns: 220px 1fr 54px;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
}

.gantt-bar-track {
    position: relative;
    height: 36px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.2) 0%, var(--bg) 40%, var(--bg) 100%);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.35);
}

.gantt-bar {
    position: absolute;
    top: 3px;
    bottom: 3px;
    z-index: 5;
    border-radius: 8px;
    border: 1px solid color-mix(in srgb, var(--gantt-bar-color, var(--accent)) 70%, white);
    transition:
        box-shadow 0.25s ease,
        filter 0.25s ease,
        transform 0.2s ease;
    filter: saturate(1.25) brightness(1.1);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.35),
        inset 0 -2px 4px rgba(0, 0, 0, 0.25),
        0 0 10px color-mix(in srgb, var(--gantt-bar-color, var(--accent)) 55%, transparent);
}

.gantt-bar:hover {
    filter: saturate(1.4) brightness(1.18);
    transform: scaleY(1.04);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.45),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2),
        0 0 16px color-mix(in srgb, var(--gantt-bar-color, var(--accent)) 80%, transparent),
        0 0 32px color-mix(in srgb, var(--gantt-bar-color, var(--accent)) 45%, transparent) !important;
}

.gantt-bar-track[data-area-tip]:hover::after {
    content: attr(data-area-tip);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    padding: 10px 16px;
    border-radius: 10px;
    border: 2px solid rgba(56, 189, 248, 0.75);
    background: rgba(15, 23, 42, 0.97);
    color: #f8fafc;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: 0.02em;
    white-space: nowrap;
    max-width: min(320px, 92vw);
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.5),
        0 12px 36px rgba(0, 0, 0, 0.75);
    pointer-events: none;
}

.gantt-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    box-shadow: 0 0 0 1px rgba(2, 6, 23, 0.45);
}

.gantt-dot-head {
    text-align: center;
}

.gantt-dot-cell {
    display: flex;
    justify-content: center;
    align-items: center;
}

.gantt-status-dot.dot-pendiente {
    background: #ff1744;
    box-shadow: 0 0 8px rgba(255, 23, 68, 0.85);
}

.gantt-status-dot.dot-en_proceso {
    background: #ffee00;
    box-shadow: 0 0 8px rgba(255, 238, 0, 0.85);
}

.gantt-status-dot.dot-completado {
    background: #b3cc19;
    box-shadow: 0 0 8px rgba(179, 204, 25, 0.9);
}

.gantt-label-cell {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
}

.gantt-label-text {
    min-width: 0;
    flex: 1;
    overflow: visible;
    cursor: pointer;
}

.gantt-label-title,
.gantt-label-meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Cortina: sable clásico — color uniforme + núcleo blanco (ref. sable verde) */
.gantt-bar-curtain {
    --saber-r: 255;
    --saber-g: 19;
    --saber-b: 0;
    --saber-color: #ff1744;
    position: absolute;
    inset: 0;
    z-index: 15;
    display: flex;
    align-items: center;
    padding: 0 14px 0 16px;
    border-radius: 9px;
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--saber-color) 72%, #000) 0%,
        var(--saber-color) 18%,
        var(--saber-color) 82%,
        color-mix(in srgb, var(--saber-color) 72%, #000) 100%
    );
    filter: saturate(1.55) brightness(1.08);
    border: none;
    overflow: hidden;
    clip-path: inset(0 100% 0 0 round 9px);
    opacity: 0;
    visibility: hidden;
    box-shadow: inset 11px 0 10px -5px rgba(0, 0, 0, 0.55);
    transition:
        clip-path 0.95s cubic-bezier(0.06, 0.85, 0.15, 1),
        opacity 0.4s ease 0.05s,
        visibility 0s linear 0.95s,
        box-shadow 0.4s ease;
    pointer-events: none;
}

/* Núcleo blanco uniforme a lo largo de toda la hoja */
.gantt-bar-curtain::before {
    content: '';
    position: absolute;
    left: 10px;
    right: 0;
    top: 50%;
    height: 28%;
    transform: translateY(-50%);
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.28) 35%,
        rgba(255, 255, 255, 0.42) 50%,
        rgba(255, 255, 255, 0.28) 65%,
        rgba(255, 255, 255, 0) 100%
    );
    pointer-events: none;
}

.gantt-bar-curtain::after {
    content: none;
}

.gantt-bar-curtain-text {
    position: relative;
    z-index: 2;
    color: #0c1018;
    font-size: 0.94rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0.04em;
    -webkit-text-stroke: 0.35px rgba(255, 255, 255, 0.75);
    paint-order: stroke fill;
    text-shadow:
        0 1px 0 rgba(255, 255, 255, 0.95),
        0 0 8px rgba(255, 255, 255, 0.8),
        0 0 2px rgba(0, 0, 0, 0.5);
}

/* Rojo neón: más contorno claro para que el texto no se pierda */
.gantt-saber--pendiente .gantt-bar-curtain-text {
    color: #050608;
    -webkit-text-stroke: 0.45px rgba(255, 255, 255, 0.95);
    text-shadow:
        0 1px 0 #fff,
        0 0 10px rgba(255, 255, 255, 0.95),
        0 0 3px rgba(0, 0, 0, 0.65);
}

.gantt-row:has(.gantt-label-text:hover) .gantt-bar-curtain {
    clip-path: inset(0 0 0 0 round 9px);
    opacity: 1;
    visibility: visible;
    box-shadow: inset 11px 0 10px -5px rgba(0, 0, 0, 0.55);
    transition:
        clip-path 0.95s cubic-bezier(0.06, 0.85, 0.15, 1),
        opacity 0.35s ease 0.1s,
        visibility 0s,
        box-shadow 0.45s ease 0.15s;
}

/* Aura del sable hacia fuera de la pista (no recortada) */
.gantt-row:has(.gantt-label-text:hover) .gantt-bar-track {
    overflow: visible;
    filter: drop-shadow(0 0 6px color-mix(in srgb, var(--saber-color) 95%, transparent))
        drop-shadow(0 0 14px color-mix(in srgb, var(--saber-color) 80%, transparent))
        drop-shadow(0 0 28px color-mix(in srgb, var(--saber-color) 55%, transparent))
        drop-shadow(0 0 48px color-mix(in srgb, var(--saber-color) 35%, transparent));
}

/* Sobre la barra: mostrar área, ocultar cortina de tarea */
.gantt-bar-track:hover .gantt-bar-curtain {
    clip-path: inset(0 100% 0 0 round 9px);
    opacity: 0;
    visibility: hidden;
    transition:
        clip-path 0.6s cubic-bezier(0.55, 0.05, 0.95, 0.45),
        opacity 0.25s ease,
        visibility 0s linear 0.6s;
}

.gantt-row:has(.gantt-bar-track:hover) .gantt-bar-track {
    filter: none;
}

@media (prefers-reduced-motion: reduce) {
    .gantt-bar-curtain,
    .gantt-row:has(.gantt-label-text:hover) .gantt-bar-curtain,
    .gantt-bar-track:hover .gantt-bar-curtain {
        clip-path: none;
        transition: opacity 0.15s ease, visibility 0.15s ease;
    }

    .gantt-row:has(.gantt-label-text:hover) .gantt-bar-track {
        filter: none;
    }

    .gantt-bar:hover {
        transform: none;
    }

    .panel-filters-body.is-open {
        animation: none;
    }
}

.gantt-toggle,
.gantt-toggle-spacer {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
}

.gantt-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.gantt-toggle:hover {
    color: var(--text);
    border-color: var(--accent);
    background: rgba(56, 189, 248, 0.08);
}

.gantt-toggle i {
    font-size: 0.65rem;
    transition: transform 0.15s;
}

.gantt-toggle[aria-expanded='true'] i {
    transform: rotate(90deg);
}

.gantt-row-subtask .gantt-label-cell {
    padding-left: 1.75rem;
}

.gantt-row-subtask .gantt-label-text {
    padding-left: 0.85rem;
    border-left: 2px solid rgba(148, 163, 184, 0.45);
}

.gantt-row-subtask .gantt-label-title {
    font-weight: 500;
    font-size: 0.88rem;
    color: var(--muted);
}

.gantt-row-subtask .gantt-label-meta {
    color: rgba(148, 163, 184, 0.85);
}

.gantt-bar-subtask {
    top: 11px;
    bottom: 11px;
    filter: saturate(1.1) brightness(1.05);
    opacity: 0.95;
}

.table-card {
    overflow: auto;
}

.users-tables-card {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: auto;
    overflow-y: auto;
    padding: 18px 20px 22px;
}

#panel-users.active {
    overflow: hidden;
    gap: 18px;
}

#panel-users > .form-inline,
#panel-users > .users-filters-card {
    flex-shrink: 0;
}

#panel-users > .form-inline {
    margin-bottom: 0;
}

.users-filters-card {
    padding: 22px 22px 24px;
    margin-top: 2px;
}

.users-section-title {
    margin: 0 auto 14px;
    width: fit-content;
    padding: 6px 12px;
    border-radius: 999px;
    text-align: center;
    letter-spacing: 0.03em;
    font-size: 1.02rem;
    font-weight: 700;
    color: #dbeafe;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.35);
}

.users-section-title.muted {
    color: #cbd5e1;
    background: rgba(148, 163, 184, 0.14);
    border-color: rgba(148, 163, 184, 0.32);
}

.users-filters {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) 260px;
    gap: 14px;
    margin: 0;
    padding: 6px 8px 2px;
}

.users-filters .field {
    margin-bottom: 0;
}

.users-search-wrap {
    position: relative;
    width: 100%;
}

.users-search-wrap input {
    width: 100%;
    padding-right: 38px;
}

.users-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #60a5fa;
    background: transparent;
}

.users-search-clear:hover {
    background: rgba(96, 165, 250, 0.12);
}

.users-inactive-block {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.data-table-muted tbody tr {
    opacity: 0.88;
}

.areas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.area-card {
    padding: 18px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-height: 88px;
    border-left: 4px solid var(--accent);
    transition: box-shadow 0.15s ease, transform 0.08s ease;
}

.area-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.area-card-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.25);
    display: grid;
    place-items: center;
    color: var(--accent);
    font-size: 1.1rem;
}

.field-color input[type='color'] {
    width: 100%;
    height: 44px;
    padding: 4px;
    cursor: pointer;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
}

.area-card-name {
    font-weight: 600;
    font-size: 0.98rem;
    line-height: 1.35;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.data-table th {
    color: var(--muted);
    font-weight: 600;
}

.form-inline {
    padding: 18px;
    margin-bottom: 16px;
}

.form-inline h3 {
    margin-top: 0;
}

.subtasks-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.subtask-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.subtask-row .subtask-input {
    flex: 1;
}

.subtask-row .btn-subtask-done {
    flex-shrink: 0;
    min-width: 130px;
    justify-content: center;
}

.subtask-row.is-done .subtask-input {
    text-decoration: line-through;
    opacity: 0.8;
}

.subtask-row .btn-remove-subtask {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
}

.assign-self-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.assign-self-wrap #t-assignee {
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

.assign-self-wrap #t-assign-self {
    flex-shrink: 0;
    white-space: nowrap;
}

.grid-2 .t-area-field,
.grid-2 .t-assignee-field,
.grid-2 .t-multi-assignee-field {
    grid-column: 1 / -1;
}

.inline-check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.inline-check input[type='checkbox'] {
    width: 16px;
    height: 16px;
}

.assignees-checklist {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    min-height: 112px;
    max-height: 180px;
    overflow-y: auto;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.assignee-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text);
}

.assignee-item input[type='checkbox'] {
    width: 15px;
    height: 15px;
    margin: 0;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal.show {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 10, 16, 0.72);
    backdrop-filter: blur(4px);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(560px, 94vw);
    padding: 20px;
    max-height: 92vh;
    overflow: hidden;
}

.modal-card.small {
    width: min(420px, 94vw);
}

.modal-card header h3 {
    margin: 0 0 12px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 12px;
}

#modal-task .modal-card {
    display: flex;
    flex-direction: column;
}

#modal-task #form-task {
    overflow-y: auto;
    padding-right: 4px;
}

#modal-task .modal-actions {
    position: sticky;
    bottom: 0;
    padding-top: 12px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0), rgba(15, 23, 42, 0.95) 28%);
}

.ranking-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    flex: 1 1 auto;
    min-height: 0;
}

.ranking-grid > .card {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.ranking-grid > .card h3 {
    margin: 0 0 14px;
    flex-shrink: 0;
}

#panel-ranking.active {
    overflow: hidden;
}

#panel-ranking .toolbar {
    flex-shrink: 0;
}

.rank-list {
    margin: 0;
    padding-left: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

.rank-item {
    display: grid;
    grid-template-columns: 42px 1fr auto auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(2, 10, 23, 0.95));
}

.rank-item-empty {
    grid-template-columns: 1fr;
    color: var(--muted);
    text-align: center;
}

.rank-position {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #bfdbfe;
    background: rgba(56, 189, 248, 0.16);
    border: 1px solid rgba(56, 189, 248, 0.35);
}

.rank-item.top-1 {
    border-color: rgba(251, 191, 36, 0.5);
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.15) inset;
}

.rank-item.top-1 .rank-position {
    color: #f59e0b;
    background: rgba(251, 191, 36, 0.16);
    border-color: rgba(251, 191, 36, 0.45);
}

.rank-item.top-2 {
    border-color: rgba(148, 163, 184, 0.55);
}

.rank-item.top-2 .rank-position {
    color: #cbd5e1;
    background: rgba(148, 163, 184, 0.16);
    border-color: rgba(148, 163, 184, 0.45);
}

.rank-item.top-3 {
    border-color: rgba(251, 146, 60, 0.5);
}

.rank-item.top-3 .rank-position {
    color: #fb923c;
    background: rgba(251, 146, 60, 0.16);
    border-color: rgba(251, 146, 60, 0.45);
}

.rank-user {
    font-weight: 700;
    letter-spacing: 0.01em;
}

.rank-role {
    font-size: 0.76rem;
    padding: 4px 8px;
    border-radius: 999px;
    color: #bfdbfe;
    border: 1px solid rgba(56, 189, 248, 0.35);
    background: rgba(56, 189, 248, 0.1);
}

.rank-xp {
    font-weight: 700;
    color: #86efac;
    font-variant-numeric: tabular-nums;
}

/* Vista móvil única (≤768px). Escritorio (>768px) usa estilos base sin cambios. */
@media (max-width: 768px) {
    body.is-app {
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    .layout {
        grid-template-columns: 1fr;
        height: auto;
        max-height: none;
        min-height: min-content;
        overflow: visible;
    }

    .main {
        min-height: 0;
        overflow-x: hidden;
        overflow-y: visible;
        padding: 16px 14px 24px;
    }

    #panel-users.active {
        overflow: visible;
    }

    #panel-users .users-tables-card {
        flex: none;
        min-height: auto;
        overflow-x: auto;
        overflow-y: visible;
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .users-filters {
        grid-template-columns: 1fr;
    }

    .ranking-grid {
        grid-template-columns: 1fr;
    }

    .rank-item {
        grid-template-columns: 34px 1fr auto;
        row-gap: 6px;
    }

    .rank-role {
        grid-column: 2 / 4;
        width: fit-content;
    }

    .mobile-nav-toggle {
        display: inline-flex;
        flex-shrink: 0;
    }

    .mobile-nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 90;
        background: rgba(8, 12, 18, 0.68);
        backdrop-filter: blur(2px);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition:
            opacity 0.25s ease,
            visibility 0.25s ease;
    }

    body.mobile-nav-open .mobile-nav-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    body.mobile-nav-open {
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(280px, 88vw);
        z-index: 100;
        flex-direction: column;
        flex-wrap: nowrap;
        height: 100%;
        max-height: 100vh;
        transform: translateX(-105%);
        transition: transform 0.28s ease;
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
    }

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

    .topbar-start h2 {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar {
        gap: 10px;
    }

    /* Filtros colapsables en todas las pestañas */
    .toolbar-collapsible,
    .users-filters-card.toolbar-collapsible {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .toolbar-collapsible {
        margin-bottom: 12px;
    }

    .users-filters-card.toolbar-collapsible {
        padding: 12px 14px;
    }

    .panel-filters-toggle {
        display: flex;
        width: 100%;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 11px 14px 11px 12px;
        border-radius: 14px;
        background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(99, 102, 241, 0.12));
        border: 1px solid rgba(56, 189, 248, 0.32);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.06),
            0 6px 20px rgba(0, 0, 0, 0.22);
        font-size: 0.94rem;
        letter-spacing: 0.01em;
        transition:
            border-color 0.2s ease,
            background 0.2s ease,
            box-shadow 0.2s ease,
            transform 0.15s ease;
    }

    .panel-filters-toggle:active {
        transform: scale(0.985);
    }

    .panel-filters-toggle.is-open {
        border-color: rgba(56, 189, 248, 0.52);
        background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(99, 102, 241, 0.2));
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.08),
            0 0 0 1px rgba(56, 189, 248, 0.14),
            0 8px 24px rgba(56, 189, 248, 0.12);
    }

    .panel-filters-label {
        display: inline-flex;
        align-items: center;
        gap: 11px;
        font-weight: 600;
        color: var(--text);
    }

    .panel-filters-label > i {
        width: 34px;
        height: 34px;
        display: grid;
        place-items: center;
        border-radius: 10px;
        background: rgba(56, 189, 248, 0.16);
        border: 1px solid rgba(56, 189, 248, 0.35);
        color: #7dd3fc;
        font-size: 0.9rem;
        flex-shrink: 0;
        box-shadow: 0 2px 8px rgba(56, 189, 248, 0.15);
    }

    .panel-filters-toggle.is-open .panel-filters-label > i {
        background: rgba(56, 189, 248, 0.24);
        color: #bae6fd;
    }

    .panel-filters-chevron {
        width: 30px;
        height: 30px;
        display: grid;
        place-items: center;
        border-radius: 9px;
        background: rgba(148, 163, 184, 0.14);
        border: 1px solid rgba(148, 163, 184, 0.22);
        font-size: 0.72rem;
        color: #94a3b8;
        flex-shrink: 0;
        transition:
            transform 0.25s ease,
            background 0.2s ease,
            border-color 0.2s ease,
            color 0.2s ease;
    }

    .panel-filters-toggle.is-open .panel-filters-chevron {
        transform: rotate(180deg);
        background: rgba(56, 189, 248, 0.2);
        border-color: rgba(56, 189, 248, 0.35);
        color: #7dd3fc;
    }

    .panel-filters-body {
        display: none;
        flex-wrap: wrap;
        gap: 12px;
        align-items: flex-end;
        padding-top: 12px;
    }

    .panel-filters-body.is-open {
        display: flex;
        animation: panel-filters-reveal 0.22s ease;
    }

    @keyframes panel-filters-reveal {
        from {
            opacity: 0;
            transform: translateY(-6px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    #panel-users .panel-filters-body.is-open {
        display: block;
    }

    .panel-filters-body .inline {
        flex: 1 1 calc(50% - 6px);
        min-width: 130px;
    }

    .panel-filters-body .btn,
    .panel-filters-body .muted,
    .panel-filters-body #k-sync-state {
        flex: 1 1 auto;
    }

    /* Kanban móvil: secciones en filas, tareas horizontales */
    #panel-kanban.active {
        overflow: visible;
        min-height: 0;
    }

    #panel-kanban .kanban {
        display: flex;
        flex-direction: column;
        gap: 18px;
        flex: none;
        min-height: auto;
        overflow: visible;
    }

    #panel-kanban .kan-col {
        flex: none;
        width: 100%;
        min-width: 0;
        max-height: none;
        min-height: auto;
    }

    #panel-kanban .kan-list {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 12px;
        overflow-x: auto;
        overflow-y: hidden;
        min-height: 148px;
        padding-bottom: 6px;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        align-items: stretch;
    }

    #panel-kanban .kan-list.drag-over {
        outline-offset: 2px;
    }

    #panel-kanban .task-card {
        flex: 0 0 min(85vw, 300px);
        width: min(85vw, 300px);
        min-width: min(85vw, 300px);
        scroll-snap-align: start;
    }
}

.toast-host {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 200;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 12px;
    min-width: 300px;
    max-width: min(440px, calc(100vw - 40px));
    font-size: 0.98rem;
    font-weight: 600;
    line-height: 1.4;
    border: 2px solid transparent;
    box-shadow:
        0 18px 50px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.08);
    opacity: 0;
    transform: translateX(28px) scale(0.96);
    transition:
        opacity 0.3s ease,
        transform 0.3s ease;
    pointer-events: auto;
}

.toast.show {
    opacity: 1;
    transform: translateX(0) scale(1);
}

.toast.hide {
    opacity: 0;
    transform: translateX(28px) scale(0.96);
}

.toast-icon {
    flex-shrink: 0;
    font-size: 1.4rem;
    margin-top: 1px;
}

.toast-msg {
    flex: 1;
    min-width: 0;
}

.toast.ok {
    background: linear-gradient(135deg, #166534 0%, #15803d 55%, #14532d 100%);
    border-color: #4ade80;
    color: #ecfdf5;
    box-shadow:
        0 18px 50px rgba(0, 0, 0, 0.5),
        0 0 28px rgba(74, 222, 128, 0.35);
}

.toast.ok .toast-icon {
    color: #bbf7d0;
}

.toast.err {
    background: linear-gradient(135deg, #991b1b 0%, #b91c1c 55%, #7f1d1d 100%);
    border-color: #f87171;
    color: #fef2f2;
    box-shadow:
        0 18px 50px rgba(0, 0, 0, 0.5),
        0 0 28px rgba(248, 113, 113, 0.35);
}

.toast.err .toast-icon {
    color: #fecaca;
}

/* Bloqueo visual durante peticiones (anti doble clic) */
.btn.is-busy {
    cursor: wait;
    opacity: 0.88;
    pointer-events: none;
}

form.is-submitting {
    pointer-events: none;
}

form.is-submitting .btn[type='submit'] {
    cursor: wait;
}
