:root {
    --bg-dark: #0f1012;
    --bg-surface: #181a1f;
    --bg-surface-elevated: #22242b;

    --text-primary: #f2f2f3;
    --text-secondary: #9ea1aa;
    --text-muted: #646873;

    --accent-gold: #d4af37;
    --accent-gold-hover: #e5c357;
    --accent-gold-dim: rgba(212, 175, 55, 0.15);

    --border-color: #2e313b;

    --font-serif: 'Playfair Display', serif;
    --font-sans: 'Outfit', sans-serif;
    --font-unique: 'Cinzel', serif;
    --font-mono: 'Roboto Mono', monospace;
    --font-montserrat: 'Montserrat', sans-serif;

    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    font-variant-numeric: lining-nums;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-sans);
    font-weight: 600;
    letter-spacing: 0.5px;
    font-variant-numeric: lining-nums;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 2rem 0;
}

.brand {
    text-align: center;
    margin-bottom: 3rem;
}

.brand h1 {
    font-family: var(--font-unique);
    font-size: 2.2rem;
    color: var(--accent-gold);
    letter-spacing: 6px;
    font-weight: 700;
}

.brand p {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 4px;
    margin-top: 0.5rem;
    font-weight: 400;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0 1.5rem;
}

.nav-item {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
}

.nav-item:hover {
    color: var(--text-primary);
    background-color: var(--bg-surface-elevated);
}

.nav-item.active {
    color: var(--accent-gold);
    background-color: var(--accent-gold-dim);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-dark);
}

.topbar h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.user-profile {
    display: flex;
    align-items: center;
}

.user-profile .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--accent-gold);
    color: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-dark);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 440px;
    background-color: var(--bg-surface);
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper input {
    width: 100%;
    padding-right: 45px;
}

.password-toggle {
    position: absolute;
    right: 5px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    height: 35px;
    width: 35px;
}

.password-toggle:hover {
    color: var(--accent-gold);
    background: transparent;
    border-color: transparent;
}

/* Views */
#view-container {
    padding: 2.5rem;
    flex: 1;
}

.view.hidden {
    display: none;
}

.section-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

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

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

@keyframes auditTickerScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.audit-ticker-active {
    animation: auditTickerScroll 60s linear infinite;
}

.audit-ticker-active:hover {
    animation-play-state: paused;
}

/* Custom Scroll System for Audit Log */
#global-history-scroll-system::-webkit-scrollbar {
    width: 6px;
}

#global-history-scroll-system::-webkit-scrollbar-track {
    background: var(--bg-surface);
    border-radius: 10px;
}

#global-history-scroll-system::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.2);
    border-radius: 10px;
}

#global-history-scroll-system::-webkit-scrollbar-thumb:hover {
    background: var(--accent-gold);
}

.history-entry-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2) !important;
    border-color: var(--accent-gold) !important;
}

/* Forms & Cards */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.form-card {
    max-width: 800px;
    margin: 0 auto;
}

.form-card h3 {
    margin-bottom: 2rem;
    color: var(--accent-gold);
    font-size: 1.8rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.form-card h4 {
    margin: 2rem 0 1rem;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.divider {
    border: 0;
    height: 1px;
    background-color: var(--border-color);
    margin: 2rem 0;
}

.form-row {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input,
select {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.9rem 1rem;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: var(--transition);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 2px var(--accent-gold-dim);
}

input[readonly] {
    background-color: var(--bg-surface-elevated);
    color: var(--accent-gold);
    font-family: var(--font-mono);
    font-size: 1.1rem;
    letter-spacing: 1px;
    cursor: not-allowed;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ea1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

.dynamic-select-group {
    display: flex;
    gap: 0.5rem;
}

.dynamic-select-group select {
    flex: 1;
}

.btn-icon {
    width: 45px;
    height: auto;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

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

.hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2.5rem;
}

.btn {
    padding: 0.9rem 1.8rem;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background-color: var(--accent-gold);
    color: var(--bg-dark);
}

.btn-primary:hover {
    background-color: var(--accent-gold-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--accent-gold-dim);
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-surface-elevated);
}

/* Catalogue Grid */
.catalogue-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.search-bar input {
    width: 300px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 11cm);
    gap: 1.8rem;
    align-items: start;
    justify-content: start;
}

/* AI Vision Pulse Animation */
.search-bar.ai-scanning-active {
    border-color: var(--accent-gold) !important;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
    position: relative;
    overflow: hidden !important;
}

.search-bar.ai-scanning-active::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(212, 175, 55, 0.2) 50%,
            transparent 100%);
    animation: ai-scan-line 1.2s infinite ease-in-out;
}

@keyframes ai-scan-line {
    from {
        left: -100%;
    }

    to {
        left: 100%;
    }
}

.item-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: var(--transition), border-color 0.5s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    width: 9cm;
    height: 12cm;
    flex-shrink: 0;
}

/* Image gallery: fixed portion of the 14cm card height */
.gallery-wrapper {
    position: relative;
    width: 100%;
    height: 5.5cm;
    /* fixed image area */
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}

/* Details section fills remaining space */
.item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0.8rem 1rem 0.4rem !important;
}

/* Spec grid fills available detail space */
.item-specs-grid {
    flex: 1;
    overflow: hidden;
    font-size: 0.82rem !important;
}

/* Clamp remarks to 2 lines to keep card uniform */
.item-remarks-box {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8rem;
}

/* Barcode strip pinned to bottom of the fixed-height card */
.card-barcode-strip {
    flex-shrink: 0;
}

.item-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border-color: var(--accent-gold-dim);
}

.card-checkbox-container {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
}

.item-checkbox {
    width: 22px;
    height: 22px;
    cursor: pointer;
    accent-color: var(--accent-gold);
}

.admin-actions {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 10;
    display: flex;
    gap: 0.5rem;
}

.btn-action {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-action:hover {
    background: var(--accent-gold);
    color: var(--bg-dark);
}

.btn-download-pdf:hover {
    background: #10b981 !important;
    /* Green for download */
    color: white !important;
}

.btn-delete-item:hover {
    background: #ef4444;
    color: white;
}

.item-placeholder-img {
    height: 200px;
    background: linear-gradient(135deg, var(--bg-surface-elevated) 0%, var(--bg-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.item-placeholder-img::after {
    content: '';
    width: 60px;
    height: 60px;
    border: 2px solid var(--accent-gold-dim);
    border-radius: 50%;
    position: absolute;
}

.item-details {
    padding: 1.5rem;
}

.serials {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.designer-badge {
    color: var(--accent-gold);
    background-color: var(--accent-gold-dim);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

.cat-badge {
    color: var(--text-secondary);
    background-color: var(--bg-surface-elevated);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

.item-title {
    font-family: var(--font-unique);
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
}

.kt-label {
    display: inline-block;
    padding: 0 4px;
    border-radius: 4px;
    font-weight: 900;
}

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

.item-remarks {
    margin-top: 0.5rem;
    padding: 0.8rem;
    background: #fff4e6;
    /* Light Orange Highlight */
    border-radius: 6px;
    font-size: 0.85rem;
    color: #854d0e;
    /* Darker Orange/Brown for text readability */
    border-left: 4px solid #f97316;
    /* Vibrant Orange border */
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem;
    color: var(--text-muted);
    background: var(--bg-surface);
    border-radius: 12px;
    border: 1px dashed var(--border-color);
}

.item-date {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
    font-family: var(--font-mono);
}


/* Toasts */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 10000;
}

/* Drag and Drop */
.drop-zone {
    max-width: 100%;
    height: 150px;
    padding: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    color: var(--text-secondary);
    border: 2px dashed var(--accent-gold);
    border-radius: 10px;
    background-color: var(--bg-dark);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.drop-zone--over {
    border-style: solid;
    background-color: var(--accent-gold-dim);
}

.drop-zone__input {
    display: none;
}

.drop-zone__thumb {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    overflow: hidden;
    background-color: transparent;
    background-size: cover;
    background-position: center;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.drop-zone__thumb::after {
    content: attr(data-label);
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 5px 0;
    color: white;
    background: rgba(0, 0, 0, 0.75);
    font-size: 14px;
    text-align: center;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 1rem;
}

.preview-item {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

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

.preview-item .btn-remove-img {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.9);
    color: white;
    border: none;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-card .item-placeholder-img {
    height: 200px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-bottom: 1px solid var(--border-color);
}

.item-card .item-placeholder-img.has-image::after {
    display: none;
}

.gallery-wrapper {
    position: relative;
    width: 100%;
    height: 200px;
    border-bottom: 1px solid var(--border-color);
}

.item-img-gallery {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-surface-elevated);
    overflow: hidden;
}

.item-img-gallery::-webkit-scrollbar {
    display: none;
}

.item-img-gallery img {
    height: 100%;
    width: 100%;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.item-img-gallery img:hover {
    transform: scale(1.02);
}

.swiper-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    transition: var(--transition);
    opacity: 0;
}

.gallery-wrapper:hover .swiper-btn {
    opacity: 1;
}

.swiper-btn:hover {
    background: var(--accent-gold);
}

.swiper-prev {
    left: 5px;
}

.swiper-next {
    right: 5px;
}

/* Card Thumbnail Strip */
.card-thumbnail-strip {
    display: flex;
    gap: 8px;
    padding: 0 1.25rem 1.25rem;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-gold-dim) transparent;
}

.card-thumbnail-strip::-webkit-scrollbar {
    height: 4px;
}

.card-thumbnail-strip::-webkit-scrollbar-thumb {
    background: var(--accent-gold-dim);
    border-radius: 4px;
}

.thumb-cell {
    flex: 0 0 50px;
    height: 50px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.thumb-cell:hover {
    border-color: var(--accent-gold);
    transform: scale(1.05);
}

.thumb-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lightbox-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    z-index: 2001;
    transition: var(--transition);
}

.lightbox-btn:hover {
    background: var(--accent-gold);
    transform: translateY(-50%) scale(1.1);
}

#lightbox-prev {
    left: -50px;
}

#lightbox-next {
    right: -50px;
}

@media (max-width: 768px) {
    #lightbox-prev {
        left: 10px;
    }

    #lightbox-next {
        right: 10px;
    }
}

.toast {
    background-color: var(--bg-surface-elevated);
    border-left: 4px solid var(--accent-gold);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 4px;
    margin-top: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease forwards;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 16, 18, 0.85);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    transition: var(--transition);
}

.modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    transform: translateY(0);
    transition: var(--transition);
}

.lightbox-content {
    max-width: 90vw;
    background: transparent;
    box-shadow: none;
    display: flex;
    justify-content: center;
    position: relative;
}

.modal.hidden .modal-content {
    transform: translateY(20px);
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.4rem;
    border: none;
    padding: 0;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
}

.btn-close:hover {
    color: var(--accent-gold);
}

.flex-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.modal-list-container {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-dark);
}

.manage-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

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

.manage-list li:last-child {
    border-bottom: none;
}

.manage-list span.code {
    color: var(--accent-gold);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    background: var(--bg-surface-elevated);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 10px;
}

.btn-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
    padding: 0 5px;
}

.btn-delete:hover {
    color: #ef4444;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* File Inputs */
input[type="file"] {
    color: var(--text-primary);
    background: var(--bg-dark);
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* Company Future Feed */
.feed-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
    padding-bottom: 3rem;
}

.feed-post {
    width: 100%;
    max-width: 470px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.feed-post-header {
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.feed-post-user {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-weight: 600;
}

.feed-post-user .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-gold);
    color: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.feed-post-media {
    width: 100%;
    aspect-ratio: 4 / 5;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
}

.feed-post-media img,
.feed-post-media video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Using contain instead of cover so full video is visible without cropping */
    background: #000;
}

.feed-post-footer {
    padding: 1rem;
}

.feed-post-caption {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.feed-post-caption strong {
    margin-right: 0.5rem;
    color: var(--text-primary);
}

.feed-post-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .feed-post {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}

/* Print Styles */
@media print {
    @page {
        size: A5;
        margin: 6mm;
    }

    * {
        text-transform: uppercase !important;
    }

    input[type="checkbox"],
    .item-checkbox {
        display: none !important;
    }

    body {
        background-color: white !important;
        color: black !important;
        height: auto;
        overflow: visible;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Print only selected if in selection mode */
    body.printing-selected-only .item-card:not(.is-selected-for-print) {
        display: none !important;
    }

    body.printing-selected-only .app-container::before {
        display: none !important;
        /* Only card details, no header */
    }

    /* Print Black/Bold for selection mode only */
    body.printing-selected-only .item-card.is-selected-for-print * {
        font-weight: 900 !important;
        color: #000 !important;
        letter-spacing: 1px !important;
    }

    body.printing-selected-only .app-container {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    /* One Page Per selected Design - Compact A5 Style */
    body.printing-selected-only .grid {
        display: block !important;
        padding: 0 !important;
        background: none !important;
    }

    body.printing-selected-only .item-card.is-selected-for-print {
        display: block !important;
        width: 100% !important;
        min-height: 198mm !important;
        /* Perfect A5 height coverage */
        margin: 0 !important;
        page-break-after: always !important;
        break-after: page !important;
        border: none !important;
        padding: 10mm !important;
        /* Balanced A5 margins */
        box-sizing: border-box;
        position: relative !important;
        overflow: hidden !important;
    }

    body.printing-selected-only .item-card.is-selected-for-print .item-title {
        font-family: var(--font-unique) !important;
        font-size: 2rem !important;
        /* Elegant focus for Cinzel */
        margin-bottom: 1.5rem !important;
        letter-spacing: 2px !important;
    }

    body.printing-selected-only .item-card.is-selected-for-print .item-details p,
    body.printing-selected-only .item-card.is-selected-for-print .item-details b {
        font-size: 1.1rem !important;
        /* Scaled down for A5 */
    }

    /* Target the new print-only elements */
    .print-only {
        display: none;
    }

    @media print {
        .print-only {
            display: block !important;
        }

        .certificate-print-header {
            text-align: center;
            margin-top: 15mm;
            margin-bottom: 10mm;
            border-bottom: 1px solid #eee;
            padding-bottom: 5mm;
        }

        .certificate-print-header h1 {
            margin: 0;
            font-size: 32pt;
            letter-spacing: 5px;
            color: #111 !important;
        }

        .certificate-print-header p {
            margin: 5px 0 0;
            color: #d4af37 !important;
            letter-spacing: 3px;
            font-weight: bold;
            font-size: 14pt;
        }

        .certificate-inner-border {
            position: absolute;
            top: 4mm;
            left: 4mm;
            right: 4mm;
            bottom: 4mm;
            border: 2pt double #d4af37;
            pointer-events: none;
        }

        body.printing-selected-only .item-card.is-selected-for-print .item-details {
            width: 100% !important;
            padding: 20px 40px !important;
            display: grid !important;
            grid-template-columns: 1fr 1fr !important;
            gap: 20px;
        }

        body.printing-selected-only .item-card.is-selected-for-print .item-image {
            width: 100% !important;
            max-height: 120mm !important;
            object-fit: contain;
            margin-bottom: 20px;
        }

        body.printing-selected-only .card-barcode-strip {
            position: absolute !important;
            bottom: 15mm !important;
            left: 10mm !important;
            right: 10mm !important;
            width: calc(100% - 20mm) !important;
            background: white !important;
            border: none !important;
        }
    }

    /* Professional Catalogue Header for Grid Page Prints */
    .app-container::before {
        content: 'JEWELLERY CATALOGUE - DESIGN INVENTORY';
        display: block;
        text-align: center;
        font-family: 'Playfair Display', serif;
        font-size: 24pt;
        color: #d4af37;
        margin-bottom: 20mm;
        border-bottom: 2px solid #d4af37;
        padding-bottom: 5mm;
    }

    .card-barcode-strip {
        background: #ffffff !important;
        border: 1px solid #000 !important;
        display: flex !important;
        visibility: visible !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .card-barcode-strip img,
    .card-barcode-strip svg {
        filter: contrast(200%) brightness(80%);
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        display: block !important;
        visibility: visible !important;
        width: 100% !important;
        height: 40px !important;
    }

    .print-hidden,
    .card-checkbox-container,
    .selection-cart-bar {
        display: none !important;
    }

    .sidebar,
    .topbar,
    .catalogue-header,
    .form-actions,
    #toast-container,
    .modal {
        display: none !important;
    }

    .app-container,
    .main-content {
        display: block;
        height: auto;
        overflow: visible;
    }

    #view-container {
        padding: 0;
    }

    .grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6mm !important;
        /* Equal spacing */
        padding: 5mm !important;
    }

    .item-card {
        break-inside: avoid;
        page-break-inside: avoid;
        border: 1.2pt solid #111 !important;
        /* Strong consistent border */
        box-shadow: none !important;
        transform: none !important;
        background-color: white !important;
        height: auto !important;
        overflow: visible !important;
        display: flex !important;
        flex-direction: column !important;
        margin-bottom: 2mm !important;
        box-sizing: border-box;
    }

    .item-details {
        padding: 0.6rem !important;
    }

    .item-specs-grid {
        gap: 0.4rem !important;
        font-size: 0.85rem !important;
    }

    .item-title {
        font-family: 'Montserrat', sans-serif !important;
        font-weight: 800 !important;
        font-size: 0.95rem !important;
        margin-bottom: 0.4rem !important;
        letter-spacing: -0.2px;
    }

    .kt-label {
        color: #d4af37 !important;
        font-weight: 900 !important;
    }

    .item-placeholder-img {
        background-color: #f5f5f5 !important;
        border-bottom: 1px solid #ccc;
    }

    .item-title {
        color: black !important;
    }

    .cat-badge,
    .designer-badge {
        background-color: transparent !important;
        border: 1px solid black;
        color: black !important;
    }

    .item-specs,
    .item-date,
    .hint {
        color: #333 !important;
    }
}

/* A5 Stylish Print Mode */
body.print-a5-stylish {
    background-color: white !important;
}

@media print {
    body.print-a5-stylish {
        width: 148mm;
        height: 210mm;
        margin: 0;
        padding: 0;
    }

    body.print-a5-stylish .grid {
        display: block !important;
        width: 100% !important;
    }

    body.print-a5-stylish .item-card {
        width: 100% !important;
        height: 100vh !important;
        page-break-after: always;
        border: none !important;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 20mm;
        box-sizing: border-box;
    }

    body.print-a5-stylish .gallery-wrapper {
        width: 100% !important;
        height: 100mm !important;
        margin-bottom: 15mm;
        border: none !important;
    }

    body.print-a5-stylish .item-img-gallery {
        background: none !important;
    }

    body.print-a5-stylish .item-img-gallery img {
        object-fit: contain !important;
    }

    body.print-a5-stylish .item-details {
        text-align: center;
        width: 100%;
    }

    body.print-a5-stylish .item-title {
        font-size: 24pt !important;
        margin-bottom: 10mm !important;
        text-transform: uppercase;
        letter-spacing: 2px;
        color: #000 !important;
        font-family: var(--font-sans);
    }

    body.print-a5-stylish .serials {
        justify-content: center;
        gap: 20mm;
        margin-bottom: 8mm;
    }

    body.print-a5-stylish .designer-badge,
    body.print-a5-stylish .cat-badge {
        font-size: 14pt !important;
        padding: 2mm 5mm !important;
        border: 1.5pt solid #000 !important;
    }

    body.print-a5-stylish .item-specs {
        font-size: 12pt !important;
        line-height: 1.8;
        color: #333 !important;
    }

    body.print-a5-stylish .item-remarks {
        margin-top: 10mm !important;
        border-left: 5pt solid #f97316 !important;
        padding: 8mm !important;
        background: #fff4e6 !important;
        font-style: italic;
        color: #854d0e !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body.print-a5-stylish .card-barcode-strip {
        margin-top: 15mm;
        width: 100%;
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        background: #ffffff !important;
        padding: 10mm;
        border-top: 1px solid #eee;
    }

    body.print-a5-stylish .card-barcode-strip img {
        height: 18mm !important;
        width: auto !important;
    }

    @page {
        size: A5;
        margin: 0;
    }
}

/* User management styles */
.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
}

.admin-badge {
    background: #4f46e5;
    color: white;
}

.designer-badge {
    background: var(--accent-gold-dim);
    color: var(--accent-gold);
}

.supervisor-badge {
    background: #dcfce7;
    color: #166534;
}

.table-responsive {
    overflow-x: auto;
}

.user-table th {
    color: var(--text-muted);
    font-weight: 500;
}

/* Company Logo Styles */
.logo-container img {
    max-height: 80px;
    width: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.logo-container img:hover {
    transform: scale(1.05);
}

.logo-upload-zone:hover {
    background: rgba(212, 175, 55, 0.05);
}

.main-company-branding {
    padding: 1rem 0;
}

.sidebar .main-company-branding {
    margin-bottom: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 1.5rem;
}

#settings-view h3 {
    color: var(--accent-gold);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

/* Danger Zone Styling */
.danger-zone {
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
    transition: var(--transition);
}

.danger-zone:hover {
    border-color: #ef4444 !important;
    box-shadow: 0 8px 32px rgba(239, 68, 68, 0.1) !important;
}

#btn-restart-data-alt:hover {
    background-color: #ef4444 !important;
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

#btn-restart-data-login:hover {
    opacity: 1 !important;
    text-decoration: underline !important;
}

/* ================================================
   RESPONSIVE DESIGN — TABLET & MOBILE
   ================================================ */

/* --- Tablet (≤ 1024px) --- */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    .grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1.5rem;
    }

    #view-container {
        padding: 1.5rem;
    }

    .topbar {
        padding: 1rem 1.5rem;
    }

    .form-card {
        max-width: 100%;
    }

    .catalogue-header {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .filters {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .search-bar input {
        width: 200px;
    }
}

/* --- Mobile (≤ 768px) --- */
@media (max-width: 768px) {

    body {
        overflow: auto;
        height: auto;
    }

    /* === App Layout: Stack sidebar above content === */
    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    /* === Mobile Sidebar: collapsed by default, toggle via JS class === */
    .sidebar {
        width: 100%;
        padding: 1rem 1.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 0.5rem;
        position: relative;
        z-index: 100;
    }

    .sidebar .brand {
        margin-bottom: 0;
        text-align: left;
    }

    .sidebar .brand h1 {
        font-size: 1.4rem;
    }

    .sidebar .brand p {
        display: none;
    }

    /* Navigation: horizontal scroll on mobile */
    .nav-menu {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.3rem;
        padding: 0;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .nav-menu::-webkit-scrollbar {
        display: none;
    }

    .nav-item {
        font-size: 0.8rem;
        padding: 0.5rem 0.8rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Admin/Logout buttons in sidebar */
    .sidebar>button,
    .sidebar>a.btn {
        font-size: 0.8rem;
        padding: 0.5rem 0.8rem;
    }

    /* === Main Content === */
    .main-content {
        overflow-y: auto;
        flex: 1;
    }

    /* === Topbar === */
    .topbar {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .topbar h2 {
        font-size: 1.1rem;
    }

    /* === View Container === */
    #view-container {
        padding: 1rem;
    }

    /* === Forms === */
    .form-row {
        flex-direction: column;
        gap: 1rem;
    }

    .form-card {
        max-width: 100%;
    }

    .form-card h3 {
        font-size: 1.4rem;
    }

    .card {
        padding: 1.5rem;
    }

    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .form-actions .btn {
        width: 100%;
    }

    /* === Catalogue Header === */
    .catalogue-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .search-bar input {
        width: 100%;
    }

    .filters {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .filters input,
    .filters select,
    .filters button {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 120px;
        font-size: 0.82rem;
        padding: 0.6rem 0.8rem;
    }

    /* === Catalogue Grid: scale cards down for mobile === */
    .grid {
        grid-template-columns: repeat(auto-fill, 47vw);
        gap: 0.75rem;
        justify-content: center;
    }

    .item-card {
        width: 47vw;
        height: auto;
        min-height: 300px;
    }

    .gallery-wrapper {
        height: 130px;
    }

    /* === Item Card === */
    .item-details {
        padding: 0.9rem;
    }

    .item-title {
        font-size: 0.95rem;
    }

    .admin-actions {
        top: 8px;
        left: 8px;
        gap: 0.3rem;
    }

    .btn-action {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .card-checkbox-container {
        top: 8px;
        right: 8px;
    }

    /* === Login Card === */
    .login-overlay {
        padding: 1rem;
        align-items: flex-start;
        padding-top: 2rem;
    }

    .login-card {
        width: 100%;
        max-width: 100%;
    }

    /* === Modals === */
    .modal {
        align-items: flex-end;
        padding: 0;
    }

    .modal-content {
        max-width: 100%;
        width: 100%;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-list-container {
        max-height: 200px;
    }

    /* === Buttons === */
    .btn {
        padding: 0.75rem 1.2rem;
        font-size: 0.9rem;
    }

    /* === Selection Cart Bar === */
    .selection-cart-bar {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }

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

    .cart-actions .btn {
        flex: 1;
        font-size: 0.8rem;
        padding: 0.6rem 0.5rem;
    }

    /* === Dashboard Stats Grid === */
    #stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    /* === Tables === */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .user-table {
        min-width: 500px;
    }

    /* === Section headings === */
    h2 {
        font-size: 1.3rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    /* === Dynamic select groups === */
    .dynamic-select-group {
        flex-wrap: wrap;
    }

    /* === Preview grid === */
    .preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    }

    /* === Flex-form (add category etc.) === */
    .flex-form {
        flex-direction: column;
    }

    /* === Toast notifications === */
    #toast-container {
        bottom: 1rem;
        right: 0.5rem;
        left: 0.5rem;
    }

    .toast {
        word-break: break-word;
    }

    /* === Pagination === */
    .pagination-container {
        flex-wrap: wrap;
        gap: 0.3rem;
        justify-content: center;
    }

    .page-btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.85rem;
    }
}

/* --- Small Mobile (≤ 480px) --- */
@media (max-width: 480px) {

    /* --- Small Mobile: single column cards --- */
    .grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .item-card {
        width: 100%;
        height: auto;
        min-height: 280px;
    }

    .gallery-wrapper {
        height: 120px;
    }

    .topbar h2 {
        font-size: 1rem;
    }

    #stats-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    .filters input,
    .filters select,
    .filters button {
        flex: 1 1 100%;
    }

    .nav-item {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }

    .form-card h3 {
        font-size: 1.2rem;
    }

    .card {
        padding: 1rem;
    }
}

/* Advanced Intel Animations & Mobile Fixes */
@media (max-width: 992px) {
    #advanced-intel-view .card-grid, 
    #advanced-intel-view > div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

#advanced-intel-view .card {
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

#advanced-intel-view .card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-gold);
    box-shadow: 0 10px 30px rgba(212, 175, 55, 0.1);
}

.loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0,0,0,0.3);
    border-radius: 50%;
    border-top-color: #000;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

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

#intel-occupancy-count {
    font-family: 'Roboto Mono', monospace;
    font-weight: bold;
}

.occupancy-pulse {
    animation: slowPulse 2s ease-in-out infinite;
}

@keyframes slowPulse {
    0% { opacity: 0.6; box-shadow: 0 0 0px #10b981; }
    50% { opacity: 1; box-shadow: 0 0 10px #10b981; }
    100% { opacity: 0.6; box-shadow: 0 0 0px #10b981; }
}

@keyframes aiScan {
    0% { top: 0%; opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

.hidden {
    display: none !important;
}