:root {
    --primary: #8257e5;
    --primary-light: #996dff;
    --secondary: #27c872;
    --danger: #ef4444;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --text-main: #1a1a1b;
    --text-support: #6b7280;
    --border: #e5e7eb;
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', -apple-system, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    line-height: 1.5;
    padding-bottom: 140px;
}

.main-wrapper {
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    padding: 2rem 1.5rem;
}

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

.logo-text {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--primary);
}

.tagline {
    color: var(--text-support);
    font-size: 0.95rem;
}

/* Search Bar - Card Style */
.search-container {
    margin-bottom: 2.5rem;
    position: relative;
    display: flex;
    gap: 12px;
}

#global-search {
    flex: 1;
    padding: 1.25rem 1.5rem;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 1rem;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
}

#global-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(130, 87, 229, 0.1);
}

.btn-search {
    background: var(--primary);
    color: white;
    padding: 0 2rem;
    border-radius: 16px;
    border: none;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(130, 87, 229, 0.3);
    cursor: pointer;
    transition: var(--transition);
}

.btn-search:hover {
    transform: translateY(-2px);
    background: var(--primary-light);
}

.search-popup {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
    z-index: 5000;
    animation: popIn 0.3s ease-out;
}

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

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

/* Scanner Layout - Two Column */
.scanner-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 850px) {
    .scanner-grid {
        grid-template-columns: 1fr;
    }
}

.scanner-left {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.scanner-right {
    position: sticky;
    top: 2rem;
}

.upload-area {
    background: var(--bg-white);
    border: 2px dashed var(--border);
    border-radius: 24px;
    padding: 4rem 2rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    box-shadow: var(--card-shadow);
}

#auth-switch {
    cursor: pointer;
    text-decoration: underline;
}

#auth-switch:hover {
    opacity: 0.8;
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(130, 87, 229, 0.02);
}

.upload-icon {
    font-size: 3.5rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

/* Cards & Progress */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    display: block;
}

.progress-info {
    margin: 1rem 0;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-support);
}

.progress-bar-bg {
    width: 100%;
    height: 12px;
    background: #f1f5f9;
    border-radius: 100px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 100px;
    transition: width 0.8s ease;
}

/* Bottom Nav - LUXURY CHUNKY FEEL */
.bottom-nav {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 550px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 40px;
    display: flex;
    justify-content: space-around;
    padding: 20px 10px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15);
    z-index: 6000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-support);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    flex: 1;
    transition: var(--transition);
    position: relative;
}

.nav-item i {
    font-size: 2rem;
    transition: var(--transition);
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active i {
    transform: translateY(-8px);
    color: var(--primary);
}

.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -10px;
    width: 16px;
    height: 5px;
    background: var(--primary);
    border-radius: 10px;
}

.nav-item:active {
    transform: scale(0.8);
}

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

.data-table th {
    background: #f8fafc;
    padding: 1.25rem 1rem;
    color: var(--text-support);
    font-size: 0.85rem;
    font-weight: 700;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

.status-tag {
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
}

.status-tag.owned {
    background: #dcfce7;
    color: #166534;
}

.status-tag.missing {
    background: #fee2e2;
    color: #991b1b;
}

/* Buttons - Advanced Hierarchy */
.btn-primary {
    background: var(--primary);
    color: white;
    padding: 1.1rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1rem;
    border: none;
    width: 100%;
    box-shadow: 0 8px 20px rgba(130, 87, 229, 0.2);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-accent {
    background: linear-gradient(135deg, #ff6b6b, #ff8e8e);
    color: white;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 800;
    border: none;
    box-shadow: 0 10px 25px rgba(255, 107, 107, 0.3);
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.8rem 1.2rem;
    border-radius: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: var(--border);
}

/* Floating Action Button (FAB) */
.fab-container {
    position: fixed;
    bottom: 110px;
    right: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 5000;
}

.fab-main {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 15px 35px rgba(130, 87, 229, 0.4);
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.fab-main:active {
    transform: scale(0.9);
}

.fab-label {
    position: absolute;
    right: 80px;
    background: white;
    padding: 8px 15px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transform: translateX(10px);
    pointer-events: none;
    transition: var(--transition);
}

.fab-item:hover .fab-label {
    opacity: 1;
    transform: translateX(0);
}

@media (max-width: 600px) {
    .fab-container {
        bottom: 100px;
        right: 20px;
    }
}

/* Page Animations */
.page {
    display: none;
}

.page.active {
    display: block;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

/* Mobile Responsiveness Improvements */
@media (max-width: 600px) {
    body {
        padding-bottom: 120px;
        /* Space for bottom nav */
    }

    .main-wrapper {
        padding: 1rem 1rem;
    }

    .header-section {
        margin-bottom: 1.5rem;
    }

    .logo-text {
        font-size: 1.8rem;
    }

    .tagline {
        font-size: 0.85rem;
    }

    /* Modal Adjustments */
    .modal-content {
        padding: 1.5rem;
        border-radius: 24px;
        width: 95%;
    }

    /* Table Adjustments - Card view for mobile */
    .data-table thead {
        display: none;
        /* Hide headers on small mobile */
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tr {
        margin-bottom: 15px;
        border: 1px solid var(--border);
        border-radius: 16px;
        padding: 10px;
        background: white;
        position: relative;
    }

    .data-table td {
        border: none;
        padding: 8px 5px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .data-table td:first-child::before {
        content: "DMC 번호";
        font-weight: 600;
        color: var(--text-support);
        font-size: 0.8rem;
    }

    .data-table td:nth-child(2)::before {
        content: "수량";
        font-weight: 600;
        color: var(--text-support);
        font-size: 0.8rem;
    }

    .data-table td:nth-child(3)::before {
        content: "위치";
        font-weight: 600;
        color: var(--text-support);
        font-size: 0.8rem;
    }

    /* Scanner Grid Fix */
    .scanner-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* Bottom Nav adjustment */
    .bottom-nav {
        bottom: 15px;
        padding: 12px 5px;
        width: 95%;
    }

    .nav-item i {
        font-size: 1.5rem;
    }

    .nav-item span {
        font-size: 0.75rem;
    }

    /* Button adjustments */
    .btn-primary {
        padding: 1rem;
        font-size: 1rem;
    }
}

/* Toast Notification */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20000;
    pointer-events: none;
}

.toast {
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastPop 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28), toastFadeOut 0.5s ease-in 2.5s forwards;
}

@keyframes toastPop {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.8);
    }

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

@keyframes toastFadeOut {
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* Onboarding Style */
.onboarding-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 2.5rem;
    border-radius: 32px;
    text-align: center;
    margin-bottom: 2rem;
    box-shadow: 0 20px 40px rgba(130, 87, 229, 0.2);
}

.onboarding-card h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.onboarding-card p {
    opacity: 0.9;
    font-size: 0.95rem;
}

.onboarding-card .btn-guide {
    background: white;
    color: var(--primary);
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 800;
    margin-top: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.onboarding-card .btn-guide:hover {
    transform: scale(1.05);
}

.hidden {
    display: none;
}

/* Modal Content Styling */
.modal-content {
    background: var(--bg-white);
    padding: 2.5rem;
    border-radius: 32px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.modal.active {
    display: flex !important;
}

/* Scrollbar for modal content */
.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}