/* =============================================================================
   ADMIN PAGE - Full Screen Desktop Layout
   ============================================================================= */

.admin-container {
    padding: 0;
    margin: 0;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Important for flex children */
}

    /* =============================================================================
   MAIN LAYOUT - Sidebar + Content (Full Width)
   ============================================================================= */
    .admin-container > .admin-layout {
        display: grid;
        grid-template-columns: 280px 1fr;
        flex: 1;
        width: 100%;
        min-height: 0; /* Important for nested flex/grid */
        overflow: hidden;
    }

/* =============================================================================
   SIDEBAR
   ============================================================================= */
.admin-sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.05);
    overflow-y: auto;
    min-height: 0;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.sidebar-icon {
    width: 3rem;
    height: 3rem;
    background: linear-gradient(135deg, var(--accent), #3b82f6);
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .sidebar-icon .material-symbols-outlined {
        font-size: 1.5rem;
        color: #fff;
    }

.sidebar-title h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.sidebar-title p {
    margin: 0.15rem 0 0;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.6);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: transparent;
    border: none;
    border-radius: 0.75rem;
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
    flex-shrink: 0;
}

    .sidebar-link:hover {
        background: rgba(255,255,255,0.08);
        color: #fff;
    }

    .sidebar-link.active {
        background: rgba(37, 99, 235, 0.25);
        color: #fff;
        box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.5);
    }

    .sidebar-link .material-symbols-outlined {
        font-size: 1.25rem;
        opacity: 0.85;
    }

    .sidebar-link.active .material-symbols-outlined {
        opacity: 1;
    }

.link-text {
    flex: 1;
}

.link-badge {
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.9);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    min-width: 1.5rem;
    text-align: center;
}

.sidebar-link.active .link-badge {
    background: rgba(59, 130, 246, 0.5);
    color: #fff;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.storage-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
}

    .storage-indicator .material-symbols-outlined {
        font-size: 1.1rem;
    }

/* Home Link - styled as anchor */
.sidebar-link.home-link {
    text-decoration: none;
    color: rgba(255,255,255,0.7);
}

    .sidebar-link.home-link:hover {
        background: rgba(16, 185, 129, 0.2);
        color: #fff;
    }

    .sidebar-link.home-link .material-symbols-outlined {
        color: #10b981;
    }

/* Sidebar Divider */
.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 0.5rem 0.75rem;
}
/* =============================================================================
   MAIN CONTENT AREA
   ============================================================================= */
.admin-main {
    padding: 2rem 3rem;
    overflow-y: auto;
    background: var(--background);
    min-height: 0;
    display: flex;
    flex-direction: column;
}

    /* When tagging is active, disable scrolling on main */
    .admin-main.tagging-active {
        overflow: hidden;
        padding: 1.5rem 2rem;
    }

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

    .tab-content.active {
        display: block;
    }

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =============================================================================
   CONTENT HEADER
   ============================================================================= */
.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.header-info h2 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-dark);
}

.header-info p {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* =============================================================================
   STATS ROW
   ============================================================================= */
.stats-row {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-item {
    background: var(--surface);
    border-radius: 1rem;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    min-width: 160px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

    .stat-item::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 4px;
    }

    .stat-item.blue::before {
        background: linear-gradient(90deg, #3b82f6, #2563eb);
    }

    .stat-item.green::before {
        background: linear-gradient(90deg, #10b981, #059669);
    }

    .stat-item.purple::before {
        background: linear-gradient(90deg, #8b5cf6, #7c3aed);
    }

    .stat-item.orange::before {
        background: linear-gradient(90deg, #f97316, #ea580c);
    }

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-dark);
    line-height: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* =============================================================================
   TOOLBAR
   ============================================================================= */
.toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-box {
    flex: 1;
    max-width: 500px;
    position: relative;
}

    .search-box .material-symbols-outlined {
        position: absolute;
        left: 1rem;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-muted);
        font-size: 1.25rem;
    }

    .search-box input {
        width: 100%;
        padding: 0.9rem 1rem 0.9rem 3rem;
        border: 1.5px solid #e2e8f0;
        border-radius: 0.75rem;
        font-size: 0.95rem;
        background: var(--surface);
        transition: all 0.2s ease;
    }

        .search-box input:focus {
            outline: none;
            border-color: var(--accent);
            box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        }

.toolbar-actions {
    display: flex;
    gap: 0.5rem;
}

.tool-btn {
    width: 2.75rem;
    height: 2.75rem;
    border: 1.5px solid #e2e8f0;
    background: var(--surface);
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

    .tool-btn:hover {
        border-color: var(--accent);
        color: var(--accent);
        background: rgba(37, 99, 235, 0.05);
    }

/* =============================================================================
   DATA CARD
   ============================================================================= */
.data-card {
    background: var(--surface);
    border-radius: 1rem;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.card-header-inline {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

    .card-header-inline h3 {
        margin: 0;
        font-size: 1rem;
        font-weight: 600;
        color: var(--text-dark);
    }

.card-body {
    padding: 1.5rem;
}

/* =============================================================================
   DATA TABLE
   ============================================================================= */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

    .data-table th {
        padding: 1rem 1.5rem;
        text-align: left;
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
        background: #f8fafc;
        border-bottom: 2px solid #e2e8f0;
        white-space: nowrap;
    }

    .data-table td {
        padding: 1.1rem 1.5rem;
        border-bottom: 1px solid #e2e8f0;
        vertical-align: middle;
    }

    .data-table tbody tr {
        transition: background 0.15s ease;
    }

        .data-table tbody tr:hover {
            background: rgba(37, 99, 235, 0.03);
        }

        .data-table tbody tr:last-child td {
            border-bottom: none;
        }

.cell-id code {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(37, 99, 235, 0.05));
    color: var(--accent);
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: "SF Mono", "Consolas", monospace;
}

.cell-name strong {
    color: var(--text-dark);
    font-weight: 600;
    font-size: 0.95rem;
}

.cell-address {
    color: var(--text-muted);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-date {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.cell-actions {
    white-space: nowrap;
}

.col-actions {
    width: 160px;
    text-align: center;
}

/* Icon Buttons */
.icon-btn {
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
}

    .icon-btn:hover {
        color: var(--accent);
        background: rgba(37, 99, 235, 0.1);
    }

    .icon-btn.danger:hover {
        color: #ef4444;
        background: rgba(239, 68, 68, 0.1);
    }

    .icon-btn .material-symbols-outlined {
        font-size: 1.25rem;
    }

.icon-btn-sm {
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 0.375rem;
    transition: all 0.15s ease;
}

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

    .icon-btn-sm.danger:hover {
        color: #ef4444;
    }

    .icon-btn-sm .material-symbols-outlined {
        font-size: 1.1rem;
    }

/* =============================================================================
   CODES GRID
   ============================================================================= */
.codes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
    padding: 1.5rem;
}

.code-card {
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 1.25rem;
    transition: all 0.2s ease;
}

    .code-card:hover {
        border-color: var(--accent);
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
    }

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.code-id {
    background: linear-gradient(135deg, var(--accent), #3b82f6);
    color: #fff;
    padding: 0.35rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
}

.code-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.code-card:hover .code-actions {
    opacity: 1;
}

.code-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.code-label {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.code-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* =============================================================================
   LAYOUT HELPERS
   ============================================================================= */
.two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.three-column {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* =============================================================================
   INFO CARDS
   ============================================================================= */
.info-card {
    background: var(--surface);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.info-icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .info-icon.blue {
        background: rgba(59, 130, 246, 0.1);
        color: #3b82f6;
    }

    .info-icon.green {
        background: rgba(16, 185, 129, 0.1);
        color: #10b981;
    }

    .info-icon.purple {
        background: rgba(139, 92, 246, 0.1);
        color: #8b5cf6;
    }

    .info-icon .material-symbols-outlined {
        font-size: 1.75rem;
    }

.info-content {
    display: flex;
    flex-direction: column;
}

.info-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.info-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-top: 0.25rem;
}

/* =============================================================================
   ACTION GRID
   ============================================================================= */
.action-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 1.5rem;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

    .action-card:hover {
        border-color: var(--accent);
        background: rgba(37, 99, 235, 0.03);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }

    .action-card.danger:hover {
        border-color: #ef4444;
        background: rgba(239, 68, 68, 0.03);
    }

    .action-card .material-symbols-outlined {
        font-size: 2.5rem;
        color: var(--accent);
    }

    .action-card.danger .material-symbols-outlined {
        color: #ef4444;
    }

.action-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-dark);
}

.action-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* =============================================================================
   UPLOAD ZONE
   ============================================================================= */
.upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 1rem;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f8fafc;
}

    .upload-zone:hover,
    .upload-zone.dragover {
        border-color: var(--accent);
        background: rgba(37, 99, 235, 0.03);
    }

    .upload-zone .material-symbols-outlined {
        font-size: 3rem;
        color: #94a3b8;
        margin-bottom: 0.75rem;
        display: block;
    }

    .upload-zone p {
        margin: 0;
        font-weight: 600;
        color: var(--text-dark);
        font-size: 1rem;
    }

.upload-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    display: block;
}

/* =============================================================================
   BLUEPRINT BROWSER
   ============================================================================= */
.blueprint-browser {
    min-height: 200px;
}

/* =============================================================================
   EMPTY STATE
   ============================================================================= */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

    .empty-state .material-symbols-outlined {
        font-size: 4rem;
        color: #cbd5e1;
        margin-bottom: 1.25rem;
    }

    .empty-state h3 {
        margin: 0 0 0.5rem;
        font-size: 1.25rem;
        color: var(--text-dark);
    }

    .empty-state p {
        margin: 0 0 1.25rem;
        color: var(--text-muted);
        font-size: 0.95rem;
    }

    .empty-state.full-width {
        grid-column: 1 / -1;
    }

/* =============================================================================
   ACTION BUTTONS
   ============================================================================= */
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .action-btn .material-symbols-outlined {
        font-size: 1.2rem;
    }

    .action-btn.primary {
        background: linear-gradient(135deg, var(--accent), #3b82f6);
        color: #fff;
        box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
    }

        .action-btn.primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
        }

    .action-btn.outline {
        background: transparent;
        color: var(--text-muted);
        border: 1.5px solid #e2e8f0;
    }

        .action-btn.outline:hover {
            background: #f8fafc;
            border-color: #cbd5e1;
            color: var(--text-dark);
        }

    .action-btn.danger {
        background: linear-gradient(135deg, #ef4444, #dc2626);
        color: #fff;
    }

/* =============================================================================
   FORM ELEMENTS
   ============================================================================= */
.form-group {
    margin-bottom: 1.25rem;
}

    .form-group label {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        font-size: 0.9rem;
        font-weight: 600;
        color: var(--text-muted);
        margin-bottom: 0.5rem;
    }

        .form-group label .material-symbols-outlined {
            font-size: 1.15rem;
        }

.text-input, .select-input {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.75rem;
    font-size: 0.95rem;
    background: #fff;
    transition: all 0.2s ease;
}

    .text-input:focus, .select-input:focus {
        outline: none;
        border-color: var(--accent);
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    }

.form-hint {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

/* =============================================================================
   MODALS
   ============================================================================= */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .modal[hidden] {
        display: none;
    }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
}

.modal-dialog {
    position: relative;
    background: var(--surface);
    border-radius: 1rem;
    width: 90%;
    max-width: 520px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
    animation: modalIn 0.25s ease;
}

    .modal-dialog.modal-sm {
        max-width: 420px;
    }

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

    .modal-header h3 {
        margin: 0;
        font-size: 1.2rem;
        font-weight: 700;
    }

    .modal-header.danger {
        background: rgba(239, 68, 68, 0.05);
    }

        .modal-header.danger h3 {
            color: #dc2626;
        }

.modal-close {
    border: none;
    background: transparent;
    font-size: 1.75rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem;
}

    .modal-close:hover {
        color: var(--text-dark);
    }

.modal-body {
    padding: 1.5rem;
}

    .modal-body p {
        margin: 0;
        color: var(--text-muted);
        line-height: 1.5;
    }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 0 0 1rem 1rem;
}

/* =============================================================================
   TOAST
   ============================================================================= */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1rem 1.75rem;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.3);
    z-index: 1100;
    animation: toastIn 0.3s ease;
}

    .toast.error {
        background: linear-gradient(135deg, #ef4444, #dc2626);
        box-shadow: 0 8px 24px rgba(239, 68, 68, 0.3);
    }

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* =============================================================================
   RESPONSIVE - Tablet
   ============================================================================= */
@media (max-width: 1200px) {
    .admin-container > .admin-layout {
        grid-template-columns: 240px 1fr;
    }

    .admin-main {
        padding: 1.5rem 2rem;
    }

    .action-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .two-column {
        grid-template-columns: 1fr;
    }

    .three-column {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* =============================================================================
   RESPONSIVE - Mobile
   ============================================================================= */
@media (max-width: 768px) {
    .admin-container > .admin-layout {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        display: none;
    }

    .admin-main {
        padding: 1rem;
    }

    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .stats-row {
        flex-wrap: wrap;
    }

    .stat-item {
        flex: 1 1 45%;
        min-width: 140px;
    }

    .toolbar {
        flex-direction: column;
    }

    .search-box {
        max-width: none;
        width: 100%;
    }

    .three-column {
        grid-template-columns: 1fr;
    }

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

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

    .form-row {
        grid-template-columns: 1fr;
    }
}
/* =============================================================================
   BLUEPRINT TAGGING SECTION
   ============================================================================= */
#tab-tagging {
    display: none;
}

    #tab-tagging.active {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    #tab-tagging .content-header {
        flex-shrink: 0;
        margin-bottom: 1rem;
    }

.tagging-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.tagging-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    min-height: 0;
    padding-right: 0.5rem;
}

    .tagging-sidebar > .data-card {
        flex-shrink: 0;
    }

        .tagging-sidebar > .data-card .card-body {
            padding: 1rem;
        }

    .tagging-sidebar .form-group {
        margin-bottom: 1rem;
    }

        .tagging-sidebar .form-group:last-child {
            margin-bottom: 0;
        }

.tagging-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.tagging-interface {
    display: none;
    flex-direction: column;
    flex: 1;
    background: var(--surface);
    border-radius: 1rem;
    border: 1px solid rgba(226, 232, 240, 0.8);
    overflow: hidden;
    min-height: 0;
}

    .tagging-interface[style*="flex"] {
        display: flex;
    }

.tagging-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: 1rem;
    border: 1px solid rgba(226, 232, 240, 0.8);
    color: #94a3b8;
    text-align: center;
    padding: 3rem;
}

    .tagging-empty-state .material-symbols-outlined {
        font-size: 4rem;
        margin-bottom: 1rem;
        opacity: 0.5;
    }

    .tagging-empty-state h3 {
        margin: 0 0 0.5rem;
        font-size: 1.25rem;
        color: var(--text-dark);
    }

    .tagging-empty-state p {
        margin: 0;
        font-size: 0.95rem;
    }

/* Blueprint Grid for Tagging */
.tag-blueprint-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    max-height: 180px;
    overflow-y: auto;
}

.tag-blueprint-item {
    position: relative;
    aspect-ratio: 4/3;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .tag-blueprint-item:hover {
        border-color: var(--accent);
    }

    .tag-blueprint-item.selected {
        border-color: #10b981;
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    }

    .tag-blueprint-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .tag-blueprint-item .tag-indicator {
        position: absolute;
        top: 0.25rem;
        right: 0.25rem;
        display: flex;
        align-items: center;
        gap: 0.2rem;
        padding: 0.15rem 0.4rem;
        background: #10b981;
        color: #fff;
        font-size: 0.65rem;
        font-weight: 700;
        border-radius: 999px;
    }

    .tag-blueprint-item .blueprint-name {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 0.35rem 0.5rem;
        background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
        color: #fff;
        font-size: 0.65rem;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

/* Tagged Units List */
.tagged-units-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    max-height: 120px;
    overflow-y: auto;
}

.tagged-unit-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.6rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

    .tagged-unit-chip:hover {
        border-color: var(--accent);
        background: rgba(37, 99, 235, 0.05);
    }

    .tagged-unit-chip.selected {
        background: var(--accent);
        color: #fff;
        border-color: var(--accent);
    }

    .tagged-unit-chip .delete-chip {
        width: 14px;
        height: 14px;
        border: none;
        background: transparent;
        color: inherit;
        cursor: pointer;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        opacity: 0.6;
    }

        .tagged-unit-chip .delete-chip:hover {
            opacity: 1;
            background: rgba(239, 68, 68, 0.2);
            color: #dc2626;
        }

    .tagged-unit-chip.selected .delete-chip:hover {
        background: rgba(255, 255, 255, 0.2);
        color: #fff;
    }

    .tagged-unit-chip .delete-chip .material-symbols-outlined {
        font-size: 11px;
    }

.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 0.3rem;
    background: var(--accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 999px;
    margin-left: 0.4rem;
}

.empty-hint {
    color: #94a3b8;
    font-size: 0.8rem;
    font-style: italic;
}

/* Tagging Toolbar */
.tagging-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    gap: 1rem;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.tool-group {
    display: flex;
    gap: 0.25rem;
}

.toolbar-separator {
    width: 1px;
    height: 1.75rem;
    background: #e2e8f0;
}

.tagging-toolbar .tool-btn {
    width: 2.25rem;
    height: 2.25rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.5rem;
    background: #fff;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

    .tagging-toolbar .tool-btn .material-symbols-outlined {
        font-size: 1.2rem;
    }

    .tagging-toolbar .tool-btn:hover {
        border-color: var(--accent);
        color: var(--accent);
    }

    .tagging-toolbar .tool-btn.active {
        background: var(--accent);
        border-color: var(--accent);
        color: #fff;
    }

    .tagging-toolbar .tool-btn.danger:hover {
        border-color: #ef4444;
        color: #ef4444;
    }

    .tagging-toolbar .tool-btn.danger.active {
        background: #ef4444;
        border-color: #ef4444;
    }

.ocr-group {
    display: flex;
    gap: 0.4rem;
}

.ocr-input {
    width: 90px;
    padding: 0.4rem 0.6rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.8rem;
}

    .ocr-input:focus {
        outline: none;
        border-color: var(--accent);
    }

.action-btn.small {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
}

.action-btn.secondary {
    background: rgba(37, 99, 235, 0.1);
    color: var(--accent);
    border: 1px solid rgba(37, 99, 235, 0.2);
}

    .action-btn.secondary:hover {
        background: rgba(37, 99, 235, 0.15);
    }

/* Canvas Container */
.tagging-canvas-container {
    position: relative;
    flex: 1;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    overflow: hidden;
    min-height: 0;
}

.tagging-canvas-wrapper {
    position: absolute;
    inset: 0;
    overflow: auto;
    cursor: crosshair;
}


    .tagging-canvas-wrapper.tool-select {
        cursor: grab;
    }

        .tagging-canvas-wrapper.tool-select:active {
            cursor: grabbing;
        }

    .tagging-canvas-wrapper.tool-delete {
        cursor: not-allowed;
    }

/* Inner container that sizes to the image */
.tagging-canvas-inner {
    position: relative;
    display: inline-block;
    /* Width and height set via JavaScript to match scaled image */
}

#tagging-image {
    display: block;
    transform-origin: top left;
    /* No max-width so it can scale freely */
}

.tag-markers-layer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    overflow: visible;
}

#tagging-image {
    display: block;
    max-width: none;
    transform-origin: top left;
}

.tag-markers-layer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    /* Width and height set dynamically via JS */
}

/* Tag Markers */
.tag-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    cursor: pointer;
    z-index: 10;
    /* Prevent markers from being cut off */
    overflow: visible;
}

.tag-marker-dot {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), 0 0 0 2px rgba(239, 68, 68, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.tag-marker:hover .tag-marker-dot {
    transform: scale(1.25);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6), 0 0 0 4px rgba(239, 68, 68, 0.4);
}

.tag-marker.selected .tag-marker-dot {
    background: linear-gradient(135deg, #10b981, #047857);
    transform: scale(1.3);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(16, 185, 129, 0.4);
}

.tag-marker-label {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    padding: 4px 12px;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 999px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 20;
}

.zoom-btn {
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    border-radius: 0.375rem;
    background: #f1f5f9;
    color: var(--text-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

    .zoom-btn:hover {
        background: #e2e8f0;
        color: var(--accent);
    }

    .zoom-btn .material-symbols-outlined {
        font-size: 1rem;
    }

.zoom-slider {
    width: 80px;
    height: 4px;
    appearance: none;
    background: #e2e8f0;
    border-radius: 2px;
    cursor: pointer;
}

    .zoom-slider::-webkit-slider-thumb {
        appearance: none;
        width: 12px;
        height: 12px;
        background: var(--accent);
        border-radius: 50%;
        cursor: pointer;
    }

.zoom-value {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 35px;
    text-align: center;
}

/* Responsive for Tagging */
@media (max-width: 1200px) {
    .tagging-layout {
        grid-template-columns: 260px 1fr;
    }

    .tagging-toolbar {
        flex-wrap: wrap;
    }
}

@media (max-width: 900px) {
    .tagging-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .tagging-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        overflow-y: visible;
        max-height: none;
    }

        .tagging-sidebar > .data-card {
            flex: 1 1 250px;
        }

    .tagging-main {
        min-height: 400px;
    }
}

/* =============================================================================
   BLUEPRINT MANAGEMENT
   ============================================================================= */

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Blueprint Tree */
.blueprint-tree {
    min-height: 200px;
}

.blueprint-job {
    margin-bottom: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    overflow: hidden;
}

.blueprint-job-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: #f8fafc;
    cursor: pointer;
    transition: background 0.15s ease;
}

    .blueprint-job-header:hover {
        background: #f1f5f9;
    }

    .blueprint-job-header .material-symbols-outlined {
        color: var(--accent);
    }

    .blueprint-job-header .job-name {
        flex: 1;
        font-weight: 600;
        color: var(--text-dark);
    }

    .blueprint-job-header .job-count {
        font-size: 0.8rem;
        color: var(--text-muted);
    }

.blueprint-job-content {
    display: none;
    padding: 0.5rem 1rem 1rem;
}

.blueprint-job.expanded .blueprint-job-content {
    display: block;
}

.blueprint-job.expanded .blueprint-job-header .expand-icon {
    transform: rotate(180deg);
}

.blueprint-building {
    margin-left: 1rem;
    margin-bottom: 0.5rem;
}

.blueprint-building-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: 0.5rem;
}

    .blueprint-building-header:hover {
        background: rgba(37, 99, 235, 0.05);
    }

    .blueprint-building-header .material-symbols-outlined {
        font-size: 1.2rem;
        color: #f97316;
    }

    .blueprint-building-header .building-name {
        flex: 1;
        font-weight: 500;
        font-size: 0.9rem;
    }

.blueprint-floor {
    margin-left: 2rem;
}

.blueprint-floor-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 0.375rem;
}

    .blueprint-floor-header:hover {
        background: rgba(37, 99, 235, 0.05);
        color: var(--text-dark);
    }

    .blueprint-floor-header .material-symbols-outlined {
        font-size: 1.1rem;
        color: #8b5cf6;
    }

.blueprint-files {
    margin-left: 3.5rem;
    display: none;
}

.blueprint-floor.expanded .blueprint-files {
    display: block;
}

.blueprint-file {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 0.375rem;
    transition: background 0.15s ease;
}

    .blueprint-file:hover {
        background: rgba(37, 99, 235, 0.05);
    }

    .blueprint-file .material-symbols-outlined {
        font-size: 1rem;
        color: #10b981;
    }

    .blueprint-file .file-name {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .blueprint-file .tag-badge {
        background: #10b981;
        color: #fff;
        font-size: 0.65rem;
        padding: 0.1rem 0.4rem;
        border-radius: 999px;
        font-weight: 700;
    }

    .blueprint-file .delete-file-btn {
        opacity: 0;
        padding: 0.25rem;
        border: none;
        background: transparent;
        color: #94a3b8;
        cursor: pointer;
        border-radius: 0.25rem;
        transition: all 0.15s ease;
    }

    .blueprint-file:hover .delete-file-btn {
        opacity: 1;
    }

    .blueprint-file .delete-file-btn:hover {
        color: #ef4444;
        background: rgba(239, 68, 68, 0.1);
    }

/* File List for Upload */
.file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.6rem;
    background: #f1f5f9;
    border-radius: 999px;
    font-size: 0.8rem;
}

    .file-item .remove-file {
        border: none;
        background: transparent;
        color: #94a3b8;
        cursor: pointer;
        padding: 0;
        display: flex;
        align-items: center;
    }

        .file-item .remove-file:hover {
            color: #ef4444;
        }

        .file-item .remove-file .material-symbols-outlined {
            font-size: 1rem;
        }

/* Sync Progress */
.sync-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.sync-progress p {
    margin: 0;
    color: var(--text-muted);
}

/* Detected Units Panel */
.detected-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.detected-units-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    max-height: 200px;
    overflow-y: auto;
}

.detected-unit-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    background: var(--surface-alt, #f1f5f9);
    border: 2px solid transparent;
    border-radius: 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

    .detected-unit-chip:hover {
        background: var(--primary-light, #dbeafe);
        color: var(--primary, #2563eb);
    }

    .detected-unit-chip.selected {
        background: var(--primary, #2563eb);
        color: white;
        border-color: var(--primary-dark, #1d4ed8);
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
    }

#detected-units-panel .card-header-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* =============================================================================
   DANGER ZONE / RESET SECTION
   ============================================================================= */
.danger-zone {
    border: 2px solid rgba(239, 68, 68, 0.3);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.03), rgba(239, 68, 68, 0.01));
}

    .danger-zone .card-header-inline h3 {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        color: #dc2626;
    }

    .danger-zone .card-header-inline .material-symbols-outlined {
        font-size: 1.25rem;
    }

.danger-warning {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    color: #b91c1c;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.reset-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.reset-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    transition: all 0.2s ease;
}

    .reset-option:hover {
        border-color: rgba(239, 68, 68, 0.3);
        background: rgba(239, 68, 68, 0.02);
    }

    .reset-option.full-reset {
        border: 2px solid rgba(239, 68, 68, 0.4);
        background: rgba(239, 68, 68, 0.05);
    }

.reset-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.reset-title {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.reset-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.reset-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, #e2e8f0, transparent);
    margin: 0.5rem 0;
}

.action-btn.danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

    .action-btn.danger:hover:not(:disabled) {
        background: linear-gradient(135deg, #dc2626, #b91c1c);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
    }

    .action-btn.danger.small {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

/* Reset Modal Styles */
.reset-confirm-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

    .reset-confirm-warning .material-symbols-outlined {
        font-size: 1.5rem;
        color: #dc2626;
        flex-shrink: 0;
    }

    .reset-confirm-warning p {
        margin: 0;
        color: #b91c1c;
        font-size: 0.9rem;
        line-height: 1.4;
    }