:root {
    --bg: #0f172a;
    --card: #1e293b;
    --card-2: #243044;
    --primary: #3b82f6;
    --primary-soft: #1e3a8a;
    --text: #f8fafc;
    --muted: #94a3b8;
    --line: #334155;
    --ok: #10b981;
    --warn: #f59e0b;
    --bad: #ef4444;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
    --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body {
    background:
        radial-gradient(1200px 500px at 10% -10%, rgba(59, 130, 246, 0.18), transparent 55%),
        radial-gradient(900px 400px at 100% 0%, rgba(16, 185, 129, 0.08), transparent 50%),
        var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, sans-serif;
}

a { color: inherit; }

img {
    display: block;
    object-position: center;
}

header {
    background: rgba(30, 41, 59, 0.92);
    backdrop-filter: blur(10px);
    padding: 0.9rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-start {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.55rem;
    min-width: 0;
}
.header-scenes {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}
.header-scenes .btn,
.header-scenes .btn-ghost {
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
}
.header-end {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    min-width: min(260px, 46vw);
    max-width: 420px;
    flex: 1 1 220px;
}
.header-end .search-box {
    max-width: none;
    width: 100%;
    flex-grow: 0;
}
.header-auth {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    min-width: 150px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, #3b82f6, #1d4ed8);
    font-size: 1.35rem;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}

.brand strong { display: block; color: var(--primary); letter-spacing: 0.02em; }
.brand small { display: block; color: var(--muted); font-size: 0.72rem; }

.search-box { flex-grow: 1; max-width: 540px; position: relative; }

.search-box input,
.form-group input,
.form-group textarea,
.form-group select,
.lib-toolbar input {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #0f172a;
    color: var(--text);
    outline: none;
    font-size: 1rem;
}

.search-box input:focus,
.form-group input:focus,
.form-group textarea:focus,
.lib-toolbar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn-login,
.btn,
.btn-ghost {
    background: var(--primary);
    color: white;
    padding: 0.6rem 1.1rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-size: 0.95rem;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text);
}

.btn-danger { background: var(--bad); color: #fff; }
.btn-ok { background: var(--ok); color: #052e1c; }
.btn-block { width: 100%; padding: 0.8rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.header-actions { display: flex; gap: 0.6rem; align-items: center; }

#searchResults {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    max-height: 360px;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.tree-kit-block { border-bottom: 1px solid var(--line); }
.tree-item { padding: 0.8rem 1rem; cursor: pointer; }
.tree-item:hover { background: #334155; }
.tree-kit { font-weight: 800; color: var(--primary); }
.tree-comp {
    padding: 0.45rem 1rem 0.7rem 2rem;
    font-size: 0.92rem;
    color: var(--muted);
    cursor: pointer;
}
.tree-comp:hover { color: var(--text); background: #334155; }

.container { padding: 1.6rem; max-width: 1180px; margin: auto; }
.container.home-full {
    max-width: none;
    width: 100%;
    padding-left: clamp(0.9rem, 2vw, 2rem);
    padding-right: clamp(0.9rem, 2vw, 2rem);
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 1.4rem;
}
.hero-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.7rem;
}

.hero h1 { font-size: clamp(1.5rem, 3vw, 2rem); }
.muted { color: var(--muted); }

.legend {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--muted);
}

.legend span { display: flex; align-items: center; gap: 0.3rem; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1.2rem;
}

.kit-card,
.dash-card,
.comp-card,
.card-panel {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid transparent;
    box-shadow: var(--shadow);
}

.kit-card,
.dash-card {
    display: flex;
    flex-direction: column;
}

.kit-card { cursor: pointer; transition: transform 0.18s ease, border-color 0.18s ease; }
.kit-card:hover { transform: translateY(-6px); border-color: var(--primary); }

.thumb,
.kit-card > img,
.dash-card > img,
.dash-card .thumb,
.kit-card .kit-ph,
.dash-card .kit-ph,
.thumb-ph {
    width: 100%;
    height: 180px;
    object-fit: cover;
    object-position: center;
    flex-shrink: 0;
    background: #334155;
}

.card-media {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #0f172a;
    flex-shrink: 0;
    min-width: 0;
    min-height: 0;
}
.card-media img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    min-width: 0;
    min-height: 0;
    object-fit: contain;
    object-position: center;
}
.card-media.kit-ph,
.kit-card .card-media.kit-ph {
    display: grid;
    place-items: center;
    font-size: 3.2rem;
    background: linear-gradient(160deg, #1e3a8a, #0f172a);
}

.thumb-ph, .kit-ph {
    display: grid;
    place-items: center;
    font-size: 3.2rem;
    background: linear-gradient(160deg, #1e3a8a, #0f172a);
}

.kit-info, .dash-card .kit-info { padding: 1rem; }
.kit-info h3 { margin-bottom: 0.35rem; font-size: 1.05rem; }
.meta { font-size: 0.85rem; color: var(--muted); display: flex; gap: 0.7rem; flex-wrap: wrap; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: #0f172a;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    font-size: 0.78rem;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 6, 23, 0.72);
    justify-content: center;
    align-items: center;
    z-index: 200;
    padding: 1rem;
}

.modal.active { display: flex; }

.modal-content {
    background: var(--card);
    padding: 1.4rem;
    border-radius: 18px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    position: relative;
}

.modal-content.wide { max-width: 720px; }
.modal-content.full {
    max-width: calc(100vw - 1.2rem);
    width: 100%;
    max-height: 94vh;
}
.modal-content.kit-modal {
    max-width: min(1120px, calc(100vw - 1.5rem));
}

.close-btn {
    position: absolute;
    top: 0.7rem;
    right: 0.9rem;
    cursor: pointer;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--muted);
    line-height: 1;
    z-index: 2;
}

.kit-hero {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin-bottom: 0.2rem;
}
.kit-hero-media {
    min-width: 0;
}
.kit-hero-info h2 {
    margin: 0 2.2rem 0.45rem 0;
    font-size: 1.4rem;
    line-height: 1.25;
}
.kit-hero-info .legend { margin: 0.55rem 0 0.15rem; }
.kit-section-title {
    margin: 1rem 0 0.5rem;
    font-size: 1.05rem;
}
.kit-modal .comp-list {
    margin-top: 1rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--line);
}

.gallery-main {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #020617;
    border-radius: 12px;
    overflow: hidden;
    margin: 0 0 0.55rem;
    min-height: 180px;
}
.gallery-main img,
.gallery-main .gallery-ph {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}
.gallery-main .gallery-ph {
    display: grid;
    place-items: center;
    font-size: 3.2rem;
    background: linear-gradient(160deg, #1e3a8a, #0f172a);
}
.gallery-thumbs { display: flex; gap: 0.45rem; flex-wrap: wrap; margin-bottom: 0.2rem; }
.gallery-thumbs button {
    position: relative;
    border: 2px solid transparent;
    padding: 0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: none;
    width: 56px;
    height: 56px;
}
.gallery-thumbs button.active, .gallery-thumbs button:hover { border-color: var(--primary); }
.gallery-thumbs img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.comp-list { margin-top: 0.8rem; display: flex; flex-direction: column; gap: 0.55rem; }

.comp-box, .comp-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.75rem;
    background: #0f172a;
    border-radius: 12px;
    border-left: 5px solid var(--line);
}

.comp-box { overflow: hidden; }
.comp-side { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.comp-media,
.comp-ph {
    display: grid;
    place-items: center;
    position: relative;
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    max-width: 56px;
    max-height: 56px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: #0f172a;
    isolation: isolate;
}
.comp-media img {
    display: block;
    position: static;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    min-width: 0;
    min-height: 0;
    object-fit: contain;
    object-position: center;
}
.comp-ph {
    display: grid;
    place-items: center;
    font-size: 1.3rem;
}

.status-icon { font-size: 1.35rem; }
.Confirmado { border-left-color: var(--ok); }
.Falta-confirmar { border-left-color: var(--warn); }
.Falta-en-el-equipo { border-left-color: var(--bad); }

.comp-box.highlight {
    background: var(--primary-soft);
    box-shadow: 0 0 0 2px var(--primary);
    animation: pulseHighlight 1.15s ease-in-out 3;
}

@keyframes pulseHighlight {
    0%, 100% { box-shadow: 0 0 0 2px var(--primary); }
    50% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.18); }
}

.form-group { margin-bottom: 0.95rem; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
    color: var(--muted);
}
.form-group textarea { min-height: 90px; resize: vertical; }

.form-msg { margin: 0.4rem 0 0.8rem; font-size: 0.9rem; }
.form-msg.ok { color: var(--ok); }
.form-msg.err { color: #fca5a5; }
.link-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 0.9rem;
    width: 100%;
}

.empty-state, .empty-grid {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 0.6rem; }
.empty-grid {
    grid-column: 1 / -1;
    background: var(--card);
    border-radius: var(--radius);
    border: 2px dashed var(--line);
}

.dash-card { cursor: pointer; transition: transform 0.18s ease, border-color 0.18s ease; }
.dash-card:hover { transform: translateY(-5px); border-color: var(--primary); }

.card-add {
    min-height: 0;
    aspect-ratio: 4 / 3;
    display: grid;
    place-items: center;
    border: 2px dashed var(--primary);
    background: rgba(59, 130, 246, 0.08);
    cursor: pointer;
    color: var(--primary);
    font-weight: 800;
    text-align: center;
    padding: 1rem;
}
.card-add:hover { background: rgba(59, 130, 246, 0.16); }
.plus { font-size: 2.4rem; display: block; margin-bottom: 0.3rem; }

.workspace-top {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.status-picker { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem; }
.status-opt {
    background: #0f172a;
    border: 2px solid var(--line);
    border-radius: 12px;
    padding: 0.7rem 0.4rem;
    cursor: pointer;
    text-align: center;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}
.status-opt input { display: none; }
.status-opt span { display: block; font-size: 1.4rem; margin-bottom: 0.2rem; }
.status-opt.active, .status-opt:has(input:checked) {
    border-color: var(--primary);
    color: var(--text);
    background: var(--primary-soft);
}

.gallery-edit { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.6rem 0 1rem; }
.gallery-edit.dragover {
    outline: 2px dashed var(--primary);
    outline-offset: 6px;
    border-radius: 12px;
}
.pic-chip {
    position: relative;
    width: 84px;
    height: 84px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
}
.pic-chip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}
.pic-chip button {
    position: absolute;
    top: 4px;
    right: 4px;
    border: none;
    background: rgba(0, 0, 0, 0.65);
    color: white;
    border-radius: 999px;
    width: 22px;
    height: 22px;
    cursor: pointer;
}

.hidden { display: none !important; }
[hidden] { display: none !important; }
.card-panel { padding: 1.4rem; }
.reset-wrap { max-width: 460px; padding-top: 2.5rem; }

.toast-wrap {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    min-width: 220px;
}
.toast.ok { border-left: 4px solid var(--ok); }
.toast.err { border-left: 4px solid var(--bad); }
body.view-library .toast-wrap { bottom: 5.2rem; }

.fab {
    position: fixed;
    right: 1.15rem;
    bottom: 1.15rem;
    z-index: 90;
    width: 58px;
    height: 58px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    box-shadow: 0 10px 24px rgba(59, 130, 246, 0.45);
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
}
.fab:hover { filter: brightness(1.08); }
.fab[hidden] { display: none !important; }

.lib-toolbar {
    position: sticky;
    top: 4.55rem;
    z-index: 80;
    display: flex;
    gap: 0.65rem;
    align-items: center;
    flex-wrap: wrap;
    margin: 0 0 1rem;
    padding: 0.6rem 0.7rem;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
}
.lib-toolbar input { flex: 1; min-width: 160px; width: auto; }

.comp-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }
.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--card);
    cursor: pointer;
    font-size: 1rem;
}

.user-chip {
    color: var(--muted);
    font-size: 0.9rem;
    display: none;
}

.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }

.text-notes { white-space: pre-wrap; }

.busy-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.72);
    z-index: 500;
    display: none;
    place-items: center;
    padding: 1rem;
}
.busy-overlay.active { display: grid; }
.busy-box {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 1.4rem 1.6rem;
    text-align: center;
    min-width: 240px;
    box-shadow: var(--shadow);
}
.busy-emoji { font-size: 2rem; margin: 0.4rem 0 0.2rem; }
.busy-text { color: var(--muted); }
.busy-spin {
    width: 36px;
    height: 36px;
    margin: 0 auto;
    border-radius: 50%;
    border: 4px solid #334155;
    border-top-color: var(--primary);
    animation: busySpin 0.8s linear infinite;
}
@keyframes busySpin { to { transform: rotate(360deg); } }

.comp-tree { display: flex; flex-direction: column; gap: 0.45rem; }
.comp-children {
    margin: 0.4rem 0 0.15rem 0.85rem;
    padding-left: 0.75rem;
    border-left: 2px dashed #334155;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.comp-children.collapsed { display: none; }
.toggle-kids {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--card-2);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
    font-weight: 800;
}
.hint-bar {
    background: #0f172a;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.65rem 0.8rem;
    margin-bottom: 0.9rem;
    color: var(--muted);
    font-size: 0.9rem;
}
.tree-path { font-size: 0.78rem; color: #64748b; margin-top: 0.15rem; }
.comp-kicker {
    font-weight: 800;
    color: var(--primary);
    font-size: 0.92rem;
    margin-bottom: 0.12rem;
    line-height: 1.25;
}
.search-wait { padding: 0.8rem 1rem; color: var(--muted); }

.viewer {
    position: fixed;
    inset: 0;
    z-index: 450;
    display: none;
    background: rgba(2, 6, 23, 0.92);
    padding: 0.55rem;
    box-sizing: border-box;
}
.viewer.active {
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
    width: 100%;
}
.viewer-shell {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    position: relative;
}
.viewer-close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    font-size: 1.6rem;
    cursor: pointer;
}
.viewer-layout {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
@media (min-width: 860px) {
    .viewer.single .viewer-layout {
        flex-direction: row;
        align-items: stretch;
    }
    .viewer.single .viewer-info {
        width: min(320px, 34vw);
        flex: 0 0 min(320px, 34vw);
        max-height: none;
        overflow: auto;
    }
}
.viewer-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 50vh;
    height: auto;
    background: #020617;
    border-radius: 16px;
    overflow: hidden;
}
.viewer-frame {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: none;
    cursor: grab;
}
.viewer-frame img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center center;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
}
.viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.8);
    color: #fff;
    font-size: 1.8rem;
    cursor: pointer;
    z-index: 2;
}
.viewer-nav.prev { left: 8px; }
.viewer-nav.next { right: 8px; }
.viewer-info {
    background: var(--card);
    border-radius: 16px;
    padding: 0.9rem 1rem;
    overflow: auto;
    max-height: 32vh;
    flex-shrink: 0;
}
@media (min-width: 860px) {
    .viewer.single .viewer-info { max-height: none; }
    .viewer.multi .viewer-info { max-height: 26vh; }
}
.viewer-info h2 { margin-bottom: 0.5rem; font-size: 1.15rem; }
.viewer-status { margin: 0.3rem 0; }
.viewer-tools {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    align-items: center;
    flex-shrink: 0;
}
.viewer-tools button {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.45rem 0.7rem;
    cursor: pointer;
    font-weight: 700;
}
.viewer-count { color: var(--muted); margin-left: auto; }
.viewer-thumbs {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    padding-bottom: 0.2rem;
    flex-shrink: 0;
}
.viewer-thumbs button {
    border: 2px solid transparent;
    padding: 0;
    border-radius: 8px;
    overflow: hidden;
    width: 58px;
    height: 58px;
    background: none;
    cursor: pointer;
    flex-shrink: 0;
}
.viewer-thumbs button.active, .viewer-thumbs button:hover { border-color: var(--primary); }
.viewer-thumbs img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.drop-zone {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 92px;
    padding: 0.85rem 1rem;
    border: 2px dashed var(--line);
    border-radius: 14px;
    background: #0f172a;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.12);
}
.drop-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
.drop-hint {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    pointer-events: none;
}
.drop-zone.dragover .drop-hint { color: var(--text); }
.preview-chip {
    position: relative;
    width: 92px;
    background: #0f172a;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}
.preview-chip img {
    width: 100%;
    height: 72px;
    object-fit: cover;
    object-position: center;
    cursor: zoom-in;
}
.preview-chip .chip-tools {
    display: flex;
    justify-content: space-between;
}
.preview-chip .chip-tools button {
    flex: 1;
    border: none;
    background: #1e293b;
    color: #fff;
    cursor: pointer;
    padding: 0.2rem;
}
.lib-picker-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.lib-picker-bar input { flex: 1; min-width: 0; }
.lib-drag-handle {
    position: absolute;
    top: 0.4rem;
    left: 0.4rem;
    z-index: 3;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 9px;
    background: rgba(15, 23, 42, 0.82);
    color: #fff;
    cursor: grab;
    font-size: 0.95rem;
    line-height: 1;
    touch-action: none;
}
.lib-drag-handle:active { cursor: grabbing; }
.lib-sort-card {
    position: relative;
}
.lib-sort-card.dragging {
    opacity: 0.55;
    outline: 2px dashed var(--primary);
}
.lib-sort-card img { -webkit-user-drag: none; user-select: none; }

.lib-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 0.7rem;
    margin-top: 0.7rem;
}
.lib-card {
    display: flex;
    flex-direction: column;
    background: #0f172a;
    border: 2px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    text-align: left;
    color: inherit;
    padding: 0;
}
.lib-card.selected, .lib-card:hover { border-color: var(--primary); }
.lib-card.in-kit:hover { border-color: var(--ok); }
.lib-card.in-kit.selected {
    border-color: var(--ok);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.45);
}
.lib-card.in-other, .lib-card.in-other:hover { border-color: #b45309; }
.lib-card.in-other.selected {
    border-color: #b45309;
    box-shadow: 0 0 0 2px rgba(180, 83, 9, 0.45);
}
.lib-card-media {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 4 / 3;
    min-height: 110px;
    overflow: hidden;
    background: #020617;
    flex-shrink: 0;
}
.lib-card-media img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
}
.lib-card-media .kit-ph {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    font-size: 2rem;
    background: linear-gradient(160deg, #1e3a8a, #0f172a);
}
.lib-zoom {
    position: absolute;
    right: 0.4rem;
    bottom: 0.4rem;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.88);
    color: #fff;
    font-size: 0.95rem;
    line-height: 1;
    cursor: zoom-in;
    opacity: 0;
    transition: opacity 0.15s ease;
    display: grid;
    place-items: center;
    z-index: 2;
}
.lib-card:hover .lib-zoom,
.lib-card:focus-within .lib-zoom {
    opacity: 1;
}
@media (hover: none) {
    .lib-zoom { opacity: 1; }
}
.lib-peek {
    position: fixed;
    z-index: 260;
    width: min(340px, 72vw);
    background: #0f172a;
    border: 2px solid var(--primary);
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
    padding: 0.55rem;
    pointer-events: none;
}
.lib-peek img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 280px;
    object-fit: contain;
    object-position: center;
    background: #020617;
    border-radius: 10px;
}
.lib-peek strong {
    display: block;
    margin-top: 0.45rem;
    font-size: 0.88rem;
    padding: 0 0.15rem;
}
.lib-flag {
    display: block;
    background: var(--ok);
    color: #052e1c;
    font-size: 0.72rem;
    font-weight: 800;
    text-align: center;
    line-height: 1.3;
    padding: 0.3rem 0.45rem;
}
.lib-flag.other,
.lib-flag.both {
    background: #b45309;
    color: #fff7ed;
}
.lib-edit-summary {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    background: #0f172a;
    border: 2px solid var(--ok);
    border-radius: 14px;
    padding: 0.75rem;
    margin-bottom: 1rem;
}
.lib-edit-summary img,
.lib-edit-summary .acc-ph {
    width: 72px;
    height: 72px;
    object-fit: cover;
    object-position: center;
    border-radius: 10px;
    flex-shrink: 0;
}
.lib-edit-summary strong { display: block; margin: 0.25rem 0 0.15rem; }
.comp-kind-tabs {
    display: flex;
    gap: 0.45rem;
    margin: 0 0 1rem;
    padding: 0.3rem;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid var(--line);
    border-radius: 14px;
    width: fit-content;
    max-width: 100%;
    flex-wrap: wrap;
}
.comp-promote-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.55rem;
}
.lib-card p { padding: 0.45rem 0.55rem; font-size: 0.85rem; font-weight: 700; }

.comp-side img, .gallery-main img, .pic-chip img, .kit-card img, .dash-card img {
    cursor: zoom-in;
}

@media (min-width: 700px) {
    .user-chip { display: inline; }
}

@media (max-width: 720px) {
    header { flex-wrap: nowrap; gap: 0.65rem; }
    .header-end { min-width: 0; max-width: none; flex: 1 1 42%; }
    .header-scenes .btn,
    .header-scenes .btn-ghost { padding: 0.35rem 0.65rem; font-size: 0.78rem; }
    .search-box { max-width: none; width: 100%; }
    .hero { flex-direction: column; align-items: flex-start; }
    .hero-actions { align-items: flex-start; }
    .status-picker { grid-template-columns: 1fr; }
    .comp-children { margin-left: 0.45rem; }
    .lib-toolbar { top: 7.4rem; }
    .fab { width: 54px; height: 54px; right: 1rem; bottom: 1rem; }
}

.home-tabs {
    display: flex;
    gap: 0.45rem;
    margin: 0 0 1.1rem;
    padding: 0.3rem;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid var(--line);
    border-radius: 14px;
    width: fit-content;
    max-width: 100%;
    flex-wrap: wrap;
}
.home-tab {
    background: transparent;
    color: var(--muted);
    border: none;
    border-radius: 10px;
    padding: 0.55rem 1rem;
    font-weight: 800;
    cursor: pointer;
}
.home-tab.active {
    background: var(--primary);
    color: #fff;
}
.usage-list { margin-top: 0.8rem; display: flex; flex-direction: column; gap: 0.45rem; }
.usage-row {
    display: flex;
    justify-content: space-between;
    gap: 0.7rem;
    align-items: center;
    background: #0f172a;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.7rem 0.85rem;
    cursor: pointer;
}
.usage-row:hover { border-color: var(--primary); }
.usage-row strong { display: block; }
.qty-big {
    font-weight: 800;
    color: var(--primary);
    white-space: nowrap;
}

.acc-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    width: 100%;
}
.acc-item {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    width: 100%;
    box-shadow: var(--shadow);
}
.acc-head,
.acc-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font: inherit;
    padding: 0.8rem 0.95rem;
}
.acc-head:hover,
.acc-row:hover { background: rgba(59, 130, 246, 0.08); }
.acc-head > div,
.acc-row > div { flex: 1; min-width: 0; }
.acc-head-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-end;
    max-width: 46%;
}
.acc-chevron {
    flex-shrink: 0;
    color: var(--primary);
    transition: transform 0.15s ease;
    width: 1.1rem;
}
.acc-item.open .acc-chevron { transform: rotate(90deg); }
.acc-media,
.acc-ph {
    position: relative;
    width: 84px;
    height: 84px;
    min-width: 84px;
    min-height: 84px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    background: #0f172a;
    display: grid;
    place-items: center;
}
.acc-media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}
@media (min-width: 860px) {
    .acc-media,
    .acc-ph {
        width: 110px;
        height: 110px;
        min-width: 110px;
        min-height: 110px;
    }
}
.acc-body {
    display: none;
    border-top: 1px solid var(--line);
    flex-direction: column;
}
.acc-item.open .acc-body { display: flex; }
.acc-row {
    border-top: 1px solid var(--line);
    border-radius: 0;
}
.acc-row:first-child { border-top: none; }

@media (max-width: 720px) {
    .acc-head,
    .acc-row { flex-wrap: wrap; }
    .acc-head-meta,
    .acc-row .qty-big {
        width: 100%;
        max-width: none;
        justify-content: flex-start;
        margin-left: 1.8rem;
    }
    .piece-cards {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

.grid > .kit-card,
.grid > .dash-card {
    min-width: 0;
}

.img-card {
    position: relative;
    cursor: pointer;
}
.img-card .card-media {
    aspect-ratio: 4 / 3;
}
.kit-card.img-card:hover,
.dash-card.img-card:hover,
.piece-card.img-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}
.img-card img { cursor: pointer; }
.card-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    padding: 2.1rem 0.8rem 0.7rem;
    background: linear-gradient(180deg, transparent, rgba(2, 6, 23, 0.92) 58%);
    pointer-events: none;
}
.card-caption strong {
    display: block;
    font-size: 0.95rem;
    line-height: 1.25;
}
.card-caption small {
    display: block;
    margin-top: 0.18rem;
    color: #cbd5e1;
    font-size: 0.78rem;
    font-weight: 600;
}

#pieceModal { z-index: 220; }
#kitFormModal,
#compFormModal,
#libraryFormModal { z-index: 240; }

.piece-view-tabs {
    margin: 0.4rem 0 0;
}
.workspace-top .piece-view-tabs {
    margin: 0.35rem 0 0;
}

.piece-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    width: 100%;
}
.piece-card {
    min-width: 0;
}
.piece-card.Confirmado { border-color: var(--ok); }
.piece-card.Falta-confirmar { border-color: var(--warn); }
.piece-card.Falta-en-el-equipo { border-color: var(--bad); }
.piece-card.highlight {
    box-shadow: 0 0 0 2px var(--primary);
}
.piece-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.55rem;
}

@media (min-width: 860px) {
    .kit-hero {
        display: grid;
        grid-template-columns: minmax(280px, 1.15fr) minmax(240px, 0.85fr);
        gap: 1.25rem;
        align-items: stretch;
    }
    .kit-hero-media {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    .kit-hero-media .gallery-main {
        flex: 1 1 auto;
        min-height: 280px;
        aspect-ratio: 4 / 3;
        margin-bottom: 0.5rem;
    }
    .kit-hero-info {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        gap: 0.4rem;
        padding-top: 0.15rem;
    }
    .kit-hero-info h2 { margin-right: 1.6rem; }
}

.site-credit {
    margin: 2.4rem auto 1.2rem;
    padding: 1.15rem 1.2rem 0.4rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
    text-align: center;
    max-width: 1100px;
}
.site-credit p { margin: 0.15rem 0; }
.site-credit strong { color: var(--text); font-weight: 700; }

.gap-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    align-items: center;
    justify-content: space-between;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.55rem;
}
.gap-row label { display: flex; gap: 0.35rem; align-items: center; }


