/*
  ============================================================
  THEME VARIABLES
  ============================================================
*/
:root {
    --color-bg: #f0f2f5;
    --color-bg-elevated: #ffffff;
    --color-bg-subtle: #f8f9fb;
    --color-border: #e0e3ea;
    --color-border-soft: #eceef2;
    --color-text: #111827;
    --color-text-muted: #6b7280;
    --color-text-faint: #9ca3af;
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-primary-soft: #dbeafe;
    --color-primary-xsoft: #eff6ff;
    --color-danger: #dc2626;
    --color-danger-soft: #fef2f2;
    --color-success: #059669;
    --color-success-soft: #ecfdf5;
    --color-warning: #d97706;
    --color-warning-soft: #fffbeb;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-soft: 0 1px 4px rgba(15, 23, 42, 0.08);
    --shadow-card: 0 2px 8px rgba(15, 23, 42, 0.07);
    --shadow-lift: 0 8px 24px rgba(15, 23, 42, 0.13);
    --shadow-modal: 0 20px 60px rgba(11, 15, 26, 0.4);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --font-body:
        "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        sans-serif;
    --transition: 0.15s ease-out;
    --transition-slow: 0.25s ease-out;
}

body[data-theme="dark"] {
    --color-bg: #0d1117;
    --color-bg-elevated: #161b22;
    --color-bg-subtle: #1c2128;
    --color-border: #30363d;
    --color-border-soft: #21262d;
    --color-text: #e6edf3;
    --color-text-muted: #8b949e;
    --color-text-faint: #484f58;
    --color-primary: #58a6ff;
    --color-primary-dark: #388bfd;
    --color-primary-soft: #1f3a5a;
    --color-primary-xsoft: #0d1f36;
    --color-danger: #f85149;
    --color-danger-soft: #2a0e0e;
    --color-success: #3fb950;
    --color-success-soft: #0d2818;
    --color-warning: #d29922;
    --color-warning-soft: #271d04;
    --shadow-soft: 0 1px 4px rgba(0, 0, 0, 0.4);
    --shadow-card: 0 2px 10px rgba(0, 0, 0, 0.5);
    --shadow-lift: 0 8px 28px rgba(0, 0, 0, 0.6);
    --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.7);
}

/*
  ============================================================
  RESET + BASE
  ============================================================
*/
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/*
  ============================================================
  TOP BAR
  ============================================================
*/
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 24px;
    background-color: var(--color-bg-elevated);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: var(--shadow-soft);
}

body[data-theme="dark"] .top-bar {
    background-color: rgba(13, 17, 23, 0.95);
    backdrop-filter: blur(12px);
    border-bottom-color: var(--color-border);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Color accent stripe on the left edge of top bar */
.top-bar::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #2563eb 0%, #60a5fa 100%);
    border-radius: 0 2px 2px 0;
}

.top-bar-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--color-primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.app-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: var(--color-text);
}

.app-subtitle {
    font-size: 0.76rem;
    color: var(--color-text-muted);
    margin-top: 1px;
}

/*
  ============================================================
  SUMMARY STATS BAR
  ============================================================
*/
.stats-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.stat-chip {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    font-size: 0.78rem;
    box-shadow: var(--shadow-xs);
    white-space: nowrap;
}

.stat-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.stat-chip-dot--blue {
    background: var(--color-primary);
}

.stat-chip-dot--green {
    background: var(--color-success);
}

.stat-chip-dot--red {
    background: var(--color-danger);
}

.stat-chip-dot--orange {
    background: var(--color-warning);
}

.stat-chip-num {
    font-weight: 700;
    color: var(--color-text);
}

.stat-chip-label {
    color: var(--color-text-muted);
}

/*
  ============================================================
  LAYOUT
  ============================================================
*/
.layout {
    max-width: 100%;
    margin: 0;
    padding: 16px 20px 60px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@media (min-width: 1400px) {
    .layout {
        padding: 16px 32px 60px;
    }
}

/*
  ============================================================
  CONTROL PANEL
  ============================================================
*/
.panel-controls {
    display: grid;
    grid-template-columns: minmax(0, 180px) minmax(0, 180px) 1fr auto;
    gap: 10px;
    padding: 12px 16px;
    background-color: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    align-items: end;
}

@media (max-width: 900px) {
    .panel-controls {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 520px) {
    .panel-controls {
        grid-template-columns: 1fr;
    }
}

/*
  ============================================================
  FORM FIELDS
  ============================================================
*/
.field-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.field-group-grow {
    flex: 1 1 0;
}

.field-group-full {
    grid-column: 1 / -1;
}

.field-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-input,
.field-textarea,
select.field-input {
    font-family: inherit;
    font-size: 0.875rem;
    padding: 8px 11px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background-color: var(--color-bg-elevated);
    color: var(--color-text);
    outline: none;
    transition:
        border-color var(--transition),
        box-shadow var(--transition);
    width: 100%;
    min-height: 40px;
}

.field-input:focus,
.field-textarea:focus,
select.field-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.field-input-readonly {
    opacity: 0.7;
    cursor: default;
    background-color: var(--color-bg-subtle);
}

.field-textarea {
    resize: vertical;
    min-height: 72px;
}

.field-help {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    margin-top: 2px;
    line-height: 1.5;
}

/*
  ============================================================
  STATUS BAR
  ============================================================
*/
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 4px;
    font-size: 0.76rem;
    color: var(--color-text-muted);
}

.text-danger {
    color: var(--color-danger);
}

/*
  ============================================================
  PRODUCT GRID — fully responsive
  ============================================================
  1 col  < 480px  (mobile portrait)
  2 col  480–719px (mobile landscape / small tablet)
  3 col  720–1023px (tablet)
  4 col  1024–1399px (laptop)
  5 col  1400–1799px (desktop)
  6 col  1800px+  (ultrawide)
*/
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

@media (max-width: 479px) {
    .product-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
}

@media (min-width: 1800px) {
    .product-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

/*
  ============================================================
  EMPTY STATE
  ============================================================
*/
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    gap: 12px;
}

.empty-state-icon {
    font-size: 48px;
    opacity: 0.3;
}

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

.empty-state-sub {
    font-size: 0.84rem;
    color: var(--color-text-muted);
    max-width: 280px;
    line-height: 1.6;
}

/*
  ============================================================
  PRODUCT CARD
  ============================================================
*/
.product-card {
    border-radius: var(--radius-lg);
    background-color: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    cursor: pointer;
    transition:
        transform var(--transition),
        box-shadow var(--transition),
        border-color var(--transition),
        opacity var(--transition);
    position: relative;
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lift);
    border-color: rgba(37, 99, 235, 0.35);
}

/* Category color stripe */
.product-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--card-accent, var(--color-primary));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.product-card--habis {
    opacity: 0.55;
    filter: grayscale(40%);
}

.product-card--habis:hover {
    opacity: 0.75;
}

/* Badge for out-of-stock */
.card-badge-habis {
    position: absolute;
    top: 12px;
    right: 10px;
    background-color: var(--color-danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.4);
}

/* Card image */
.product-card-image {
    background-color: var(--color-bg-subtle);
    overflow: hidden;
    position: relative;
}

.product-card-image img {
    width: 100%;
    height: 160px;
    object-fit: contain;
    display: block;
    transition: transform 0.3s ease;
    padding: 8px;
}

.product-card:hover .product-card-image img {
    transform: scale(1.05);
}

.product-card-image--fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 160px;
    color: var(--color-text-faint);
    font-size: 0.75rem;
    gap: 6px;
}

.product-card-image--fallback-icon {
    font-size: 28px;
    opacity: 0.35;
}

/* Photo count badge */
.card-photo-count {
    position: absolute;
    bottom: 7px;
    right: 7px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 999px;
    letter-spacing: 0.3px;
    backdrop-filter: blur(4px);
}

/* Card body */
.product-card-body {
    padding: 12px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.product-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card-id {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    font-family: monospace;
    margin-bottom: 4px;
    opacity: 0.85;
}

.product-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 0.72rem;
    color: var(--color-text-muted);
    align-items: center;
}

.product-card-badge {
    background-color: var(--color-primary-soft);
    color: var(--color-primary);
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 0.68rem;
    font-weight: 600;
}

/* Price table on card */
.card-price-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    margin-top: 2px;
}

.card-price-table td {
    padding: 2px 2px;
    vertical-align: middle;
}

.card-price-table td:first-child {
    color: var(--color-text-muted);
    width: 50px;
    font-weight: 500;
}

.card-price-table td:last-child {
    text-align: right;
    font-weight: 600;
    color: var(--color-text);
}

.card-price-table tr.price-row-het td:last-child {
    color: var(--color-primary);
    font-size: 0.85rem;
}

.card-price-divider {
    border: none;
    border-top: 1px dashed var(--color-border);
    margin: 3px 0;
}

/* Card footer (stock + SQ) */
.product-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 12px 10px;
    border-top: 1px solid var(--color-border-soft);
    font-size: 0.72rem;
    color: var(--color-text-muted);
    gap: 8px;
}

.card-stock {
    font-weight: 700;
    color: var(--color-success);
}

.card-stock--zero {
    color: var(--color-danger);
}

/*
  ============================================================
  PAGINATION
  ============================================================
*/
.pagination-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    padding: 10px 0 6px;
}

.page-btn {
    font-family: inherit;
    font-size: 0.82rem;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background-color: var(--color-bg-elevated);
    color: var(--color-text);
    cursor: pointer;
    transition:
        background-color var(--transition),
        border-color var(--transition);
}

.page-btn:hover:not(:disabled) {
    background-color: var(--color-primary-soft);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.page-btn-active {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    font-weight: 700;
}

.page-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.page-dots,
.page-sep {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    padding: 0 4px;
    user-select: none;
}

.page-input {
    font-family: inherit;
    font-size: 0.82rem;
    width: 54px;
    height: 36px;
    padding: 0 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background-color: var(--color-bg-elevated);
    color: var(--color-text);
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
}

.page-input::-webkit-outer-spin-button,
.page-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.page-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/*
  ============================================================
  BUTTONS
  ============================================================
*/
.btn {
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: 999px;
    border: 1px solid transparent;
    background-color: var(--color-primary);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    min-height: 40px;
    transition:
        background-color var(--transition),
        box-shadow var(--transition),
        transform var(--transition);
}

.btn:hover {
    background-color: var(--color-primary-dark);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-primary {
    background-color: var(--color-primary);
}

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

.btn-secondary:hover {
    background-color: var(--color-bg-subtle);
    box-shadow: none;
    transform: none;
}

.btn-ghost {
    background-color: transparent;
    color: var(--color-text-muted);
    border-color: var(--color-border);
}

.btn-ghost:hover {
    background-color: var(--color-bg-subtle);
    box-shadow: none;
    transform: none;
}

.btn-danger {
    background-color: var(--color-danger);
}

.btn-danger:hover {
    background-color: #b91c1c;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.3);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

@media (max-width: 480px) {
    .btn {
        min-height: 44px;
    }
}

/*
  ============================================================
  MODALS
  ============================================================
*/
.modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
    overflow-y: auto;
    padding: 20px 12px;
}

.modal.is-open {
    display: block;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(11, 15, 26, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    max-width: 840px;
    width: 100%;
    margin: 0 auto;
    background-color: var(--color-bg-elevated);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-modal);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-content-wide {
    max-width: 760px;
}

.modal-header {
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-subtle);
}

.modal-footer {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-subtle);
}

.modal-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.modal-close {
    border: none;
    background: transparent;
    font-size: 1.4rem;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    line-height: 1;
    min-height: 36px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-body {
    padding: 18px 20px;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

/* Form grid inside the product modal */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
}

@media (max-width: 560px) {

    .modal-content,
    .modal-content-wide {
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
    }

    .modal {
        padding: 0;
        align-items: flex-end;
    }

    .modal.is-open {
        display: flex;
    }

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

    .modal-body {
        max-height: 75vh;
    }
}

/*
  ============================================================
  LIVE MARGIN PREVIEW PANEL (in form modal)
  ============================================================
*/
.margin-preview {
    grid-column: 1 / -1;
    background: var(--color-bg-subtle);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-top: 4px;
}

.margin-preview-header {
    padding: 8px 14px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    background: var(--color-bg-elevated);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 6px;
}

.margin-preview-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-success);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.margin-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0;
}

.margin-tile {
    padding: 10px 14px;
    border-right: 1px solid var(--color-border-soft);
    border-bottom: 1px solid var(--color-border-soft);
}

.margin-tile:last-child {
    border-right: none;
}

.margin-tile-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--color-text-muted);
    margin-bottom: 3px;
}

.margin-tile-price {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap;
}

.margin-tile-pct {
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 2px;
}

.margin-tile-pct--pos {
    color: var(--color-success);
}

.margin-tile-pct--neg {
    color: var(--color-danger);
}

.margin-tile-pct--zero {
    color: var(--color-text-faint);
}

/*
  ============================================================
  DETAIL MODAL CONTENT
  ============================================================
*/
.detail-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 20px;
}

@media (max-width: 600px) {
    .detail-layout {
        grid-template-columns: 1fr;
    }
}

/* Carousel */
.carousel-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.carousel-main {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--color-border);
    background: var(--color-bg-subtle);
    cursor: zoom-in;
    aspect-ratio: 1 / 1;
}

.carousel-main img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: transform var(--transition-slow);
    padding: 8px;
}

.carousel-main:hover img {
    transform: scale(1.03);
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
    z-index: 2;
    backdrop-filter: blur(4px);
}

.carousel-main:hover .carousel-nav {
    opacity: 1;
}

.carousel-nav--prev {
    left: 8px;
}

.carousel-nav--next {
    right: 8px;
}

.carousel-nav:hover {
    background: rgba(0, 0, 0, 0.7);
}

.carousel-counter {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    backdrop-filter: blur(4px);
    pointer-events: none;
}

.carousel-thumbs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.carousel-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color var(--transition);
    background: var(--color-bg-subtle);
    flex-shrink: 0;
}

.carousel-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 2px;
    display: block;
}

.carousel-thumb--active {
    border-color: var(--color-primary);
}

.carousel-thumb:hover:not(.carousel-thumb--active) {
    border-color: var(--color-border);
}

/* No-image fallback for carousel */
.carousel-fallback {
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-subtle);
    color: var(--color-text-faint);
    font-size: 0.78rem;
}

.carousel-fallback-icon {
    font-size: 32px;
    opacity: 0.3;
}

/* Product info section */
.detail-info h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 5px;
    line-height: 1.3;
    letter-spacing: -0.2px;
}

.detail-meta {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.detail-meta-sep {
    color: var(--color-text-faint);
}

/* Quick Add Section */
.quick-add-section {
    margin-top: 8px;
    padding: 12px;
    background: var(--color-bg-subtle);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.quick-add-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.quick-add-field .detail-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text);
}

.detail-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.detail-status-badge--active {
    background: var(--color-success-soft);
    color: var(--color-success);
}

.detail-status-badge--inactive {
    background: var(--color-danger-soft);
    color: var(--color-danger);
}

/* Key-value pairs */
.detail-pairs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px 12px;
    font-size: 0.8rem;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: var(--color-bg-subtle);
    border: 1px solid var(--color-border-soft);
    border-radius: var(--radius-md);
}

.detail-label {
    color: var(--color-text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detail-value {
    font-weight: 600;
    color: var(--color-text);
    margin-top: 1px;
}

/* Discount toggles */
.discount-toggles {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
    padding: 8px 12px;
    background-color: var(--color-primary-xsoft);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-primary-soft);
    font-size: 0.8rem;
}

.discount-toggles label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    color: var(--color-primary);
}

.discount-toggles input[type="checkbox"] {
    cursor: pointer;
    width: 15px;
    height: 15px;
    accent-color: var(--color-primary);
}

.discount-label-text {
    color: var(--color-text-muted);
    font-size: 0.74rem;
    margin-right: 4px;
    font-weight: 500;
}

/* Price table in detail modal */
.detail-price-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.detail-price-table thead th {
    text-align: left;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    padding: 5px 8px;
    border-bottom: 2px solid var(--color-border);
    font-weight: 700;
}

.detail-price-table thead th:not(:first-child) {
    text-align: right;
}

.detail-price-table tbody tr:nth-child(odd) {
    background: var(--color-bg-subtle);
}

.detail-price-table tbody td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--color-border-soft);
    vertical-align: middle;
}

.detail-price-table tbody td:not(:first-child) {
    text-align: right;
}

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

.detail-price-table .tier-label {
    font-weight: 600;
}

.detail-price-table .tier-hpp {
    color: var(--color-text-muted);
    font-weight: 400;
}

.detail-price-table .price-final {
    font-weight: 700;
    color: var(--color-primary);
}

/* Margin badge */
.margin-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
}

.margin-badge--pos {
    background-color: var(--color-success-soft);
    color: var(--color-success);
}

.margin-badge--neg {
    background-color: var(--color-danger-soft);
    color: var(--color-danger);
}

/* Tags */
.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.detail-tag {
    font-size: 0.7rem;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--color-bg-subtle);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

.detail-desc {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    line-height: 1.6;
    padding: 8px 10px;
    background: var(--color-bg-subtle);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-border);
}

/*
  ============================================================
  LIGHTBOX
  ============================================================
*/
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.92);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox.is-open {
    display: flex;
}

.lightbox-img-wrap {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-img-wrap img {
    max-width: 90vw;
    max-height: 86vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.8);
    user-select: none;
    display: block;
}

.lightbox-close {
    position: fixed;
    top: 16px;
    right: 20px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1.4rem;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    backdrop-filter: blur(8px);
    line-height: 1;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.22);
}

.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    backdrop-filter: blur(8px);
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lightbox-nav--prev {
    left: 16px;
}

.lightbox-nav--next {
    right: 16px;
}

.lightbox-counter {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 5px 16px;
    border-radius: 999px;
    backdrop-filter: blur(8px);
    letter-spacing: 0.5px;
    pointer-events: none;
}

.lightbox-thumbs {
    position: fixed;
    bottom: 56px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    max-width: 90vw;
    overflow-x: auto;
    padding: 4px;
}

.lightbox-thumb {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color var(--transition);
    background: rgba(255, 255, 255, 0.08);
}

.lightbox-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 2px;
}

.lightbox-thumb--active {
    border-color: #fff;
}

.lightbox-thumb:hover:not(.lightbox-thumb--active) {
    border-color: rgba(255, 255, 255, 0.4);
}

/*
  ============================================================
  UTILITY
  ============================================================
*/
hr.detail-divider {
    border: none;
    border-top: 1px solid var(--color-border-soft);
    margin: 10px 0;
}

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

.text-success {
    color: var(--color-success);
}

.text-danger {
    color: var(--color-danger);
}

/* ============================================================
   CLIPBOARD COPY BUTTON & TOAST
   ============================================================ */

.card-copy-btn {
    font-size: 0.75rem;
    padding: 2px 6px;
    min-height: auto;
}

.detail-copy-btn {
    margin-top: 16px;
    width: 100%;
}

.copy-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: var(--color-bg-inverse, #1f2937);
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    z-index: 10000;
}

.copy-toast--visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

[data-theme="dark"] .copy-toast {
    background-color: var(--color-bg-inverse, #f3f4f6);
    color: #111827;
}
