/* ============================================================
   Supply Chain Portal — 门类配件供应链平台
   Fire Door / Civil Air Defense Door / Special Door Parts
   ============================================================ */

:root {
    --primary: #1a56db;
    --primary-light: #e8f0fe;
    --primary-dark: #0f3b9e;
    --accent: #f59e0b;
    --accent-light: #fef3c7;
    --danger: #dc2626;
    --success: #16a34a;
    --success-light: #dcfce7;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Microsoft YaHei", "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== Header ===== */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-dark);
    text-decoration: none;
}

.header-logo .icon {
    width: 32px; height: 32px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 16px;
}

/* ===== Product Grid (九宫格) ===== */
.product-grid {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
    overflow-x: auto;
    max-width: 50vw;
    padding: 2px 0;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.product-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px 5px 5px;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    background: var(--bg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.product-card:hover {
    border-color: #93c5fd;
    background: #f0f7ff;
}

/* Selected: enlarge + glow */
.product-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(26,86,219,0.18), 0 4px 14px rgba(26,86,219,0.15);
    transform: scale(1.06);
    z-index: 2;
}

.product-card:not(.selected) {
    opacity: 0.72;
}

.product-card:not(.selected):hover {
    opacity: 0.9;
}

.product-card-thumb {
    width: 40px; height: 40px;
    border-radius: 6px;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    border: 1px solid var(--border-light);
    flex-shrink: 0;
}

.product-card-thumb img,
.product-card-thumb svg {
    width: 100%; height: 100%;
    object-fit: contain;
    padding: 3px;
    pointer-events: none;
}

.product-card-info {
    display: flex; flex-direction: column;
    line-height: 1.3;
}

.product-card-category {
    font-size: 10px; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
}

.product-card-name {
    font-size: 13px; font-weight: 700; color: var(--text);
    white-space: nowrap;
}

/* On selection, pump the name */
.product-card.selected .product-card-name {
    color: var(--primary-dark);
}

/* Badge for part count */
.product-card-count {
    position: absolute;
    top: -6px; right: -6px;
    background: var(--accent);
    color: #fff;
    font-size: 10px; font-weight: 700;
    min-width: 20px; height: 18px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 5px;
}

/* ===== (deprecated) select fallback ===== */
.product-select { display: none; }

.header-nav { display: flex; gap: 4px; }
.header-nav a {
    padding: 8px 16px;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}
.header-nav a:hover, .header-nav a.active {
    background: var(--primary-light);
    color: var(--primary);
}

/* ===== Main Layout ===== */
.main-container {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 0;
    height: calc(100vh - 64px);
    overflow: hidden;
}

/* Right column: detail panel (flex-grow) + inquiry cart (fixed bottom) */
.right-column {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ===== SVG Viewer Panel ===== */
.viewer-panel {
    position: relative;
    background: #e8ecf1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--border);
}

.viewer-toolbar {
    position: absolute;
    top: 12px; left: 12px;
    display: flex; gap: 6px; z-index: 10;
}

.viewer-toolbar button {
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
    color: var(--text-secondary);
}
.viewer-toolbar button:hover { background: var(--primary-light); color: var(--primary); }

.viewer-toolbar .btn-reset { margin-left: 8px; font-size: 12px; width: auto; padding: 0 12px; }

.viewer-product-label {
    font-size: 13px; font-weight: 600; color: var(--text);
    padding: 0 8px;
    display: flex; align-items: center;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.svg-wrapper {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    cursor: grab;
    transition: transform 0.05s ease-out;
}
.svg-wrapper:active { cursor: grabbing; }
.svg-wrapper.panning { transition: none; }

.svg-wrapper svg {
    max-width: 95%; max-height: 95%;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.12));
}

/* SVG hotspot styling */
.svg-wrapper svg [id^="hotspot."] {
    cursor: pointer;
    transition: opacity 0.15s;
}
.svg-wrapper svg [id^="hotspot."]:hover {
    opacity: 0.4 !important;
    filter: brightness(1.3);
}

/* Highlighted part */
.svg-wrapper svg [id^="Actor_"].highlighted path,
.svg-wrapper svg [id^="Actor_"].highlighted ellipse,
.svg-wrapper svg [id^="Actor_"].highlighted rect,
.svg-wrapper svg [id^="Actor_"].highlighted polygon {
    stroke: #f59e0b !important;
    stroke-width: 2 !important;
    filter: drop-shadow(0 0 6px rgba(245,158,11,0.6));
}

/* Hover tooltip — follows cursor, auto-size to content */
.viewer-legend {
    position: absolute;
    top: 0; left: 0;
    width: max-content;
    max-width: 220px;
    background: var(--surface);
    border: 1.5px solid var(--primary);
    border-radius: 8px;
    padding: 8px 12px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 30;
    /* default hidden offscreen until JS positions */
    transform: translate(0, -100%) translateY(-10px);
}

.viewer-legend.visible { opacity: 1; }

.viewer-legend-name {
    font-size: 14px; font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    white-space: nowrap;
}

.viewer-legend-code {
    font-size: 11px; font-weight: 500;
    color: var(--text-muted);
    font-family: "SF Mono", "Consolas", "Menlo", monospace;
    margin-top: 2px;
    white-space: nowrap;
}

/* ===== Gallery Page (产品目录 九宫格) ===== */
.gallery-page {
    padding: 32px 40px;
    max-width: 1280px;
    margin: 0 auto;
    height: 100%;
    overflow-y: auto;
}

.gallery-hero {
    text-align: center;
    margin-bottom: 36px;
}

.gallery-hero h1 {
    font-size: 26px; font-weight: 800; color: var(--text);
    margin-bottom: 6px;
}

.gallery-hero p {
    font-size: 14px; color: var(--text-secondary);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.gallery-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.gallery-card:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 30px rgba(26,86,219,0.15);
    transform: translateY(-3px);
}

.gallery-card-thumb {
    height: 200px;
    background: #e8ecf1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    overflow: hidden;
    position: relative;
}

.gallery-card-thumb img,
.gallery-card-thumb svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.gallery-card-body {
    padding: 16px 18px;
    flex: 1;
    display: flex; flex-direction: column;
    gap: 6px;
}

.gallery-card-category {
    font-size: 11px; color: var(--primary); font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
}

.gallery-card-name {
    font-size: 16px; font-weight: 700; color: var(--text);
    line-height: 1.3;
}

.gallery-card-desc {
    font-size: 12px; color: var(--text-secondary);
    line-height: 1.5;
    flex: 1;
}

.gallery-card-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

.gallery-card-count {
    font-size: 12px; color: var(--text-muted);
    display: flex; align-items: center; gap: 4px;
}

.gallery-card-arrow {
    color: var(--primary); font-size: 18px; font-weight: 700;
}

/* Back to gallery button in viewer */
.btn-back-gallery {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 13px; font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}
.btn-back-gallery:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

/* ===== Detail Sidebar ===== */
.detail-panel {
    background: var(--surface);
    display: flex; flex-direction: column;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.panel-empty {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text-muted);
    padding: 40px;
    text-align: center;
}
.panel-empty .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.panel-empty h3 { font-size: 16px; margin-bottom: 6px; color: var(--text-secondary); }
.panel-empty p { font-size: 13px; line-height: 1.6; }

/* Part info header */
.part-info-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, #f8fafc 0%, #e8f0fe 100%);
}

.part-name {
    font-size: 20px; font-weight: 700; color: var(--text);
}
.part-code {
    font-size: 13px; color: var(--text-muted);
    font-family: "SF Mono", "Consolas", monospace;
}

/* Property grid */
.property-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border);
    margin: 16px 20px;
    border-radius: var(--radius);
}
.property-item {
    background: var(--surface);
    padding: 12px 14px;
    min-width: 0;
    line-height: 1.5;
}
.property-item:first-child { border-radius: var(--radius) 0 0 0; }
.property-item.full { grid-column: 1 / -1; }
.property-label {
    font-size: 11px; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 3px;
    line-height: 1.4;
}
.property-value {
    font-size: 14px; font-weight: 600; color: var(--text);
    line-height: 1.45;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Supplier section */
.supplier-section {
    padding: 0 20px 20px;
}

.section-title {
    font-size: 15px; font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}
.section-title .badge {
    background: var(--primary-light);
    color: var(--primary);
    font-size: 11px; padding: 2px 8px; border-radius: 10px;
}

.supplier-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 8px;
    transition: var(--transition);
    cursor: pointer;
}
.supplier-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}
.supplier-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(26,86,219,0.2);
}

.supplier-header {
    display: flex; justify-content: space-between; align-items: start;
    margin-bottom: 8px;
}
.supplier-name { font-weight: 600; font-size: 14px; }
.supplier-price { font-weight: 700; font-size: 18px; color: var(--danger); }
.supplier-price .unit { font-size: 12px; font-weight: 400; color: var(--text-muted); }

.supplier-meta {
    display: flex; gap: 16px;
    font-size: 12px; color: var(--text-secondary);
}
.supplier-meta span { display: flex; align-items: center; gap: 4px; }

.btn-add-inquiry {
    width: 100%;
    padding: 10px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}
.btn-add-inquiry:hover { background: var(--primary-dark); }
.btn-add-inquiry:disabled { background: #cbd5e1; cursor: not-allowed; }

/* ===== Inquiry Panel ===== */
.inquiry-section {
    border-top: 2px solid var(--border);
    background: var(--surface);
    max-height: 320px;
    overflow-y: auto;
    flex-shrink: 0;
}

.inquiry-header {
    padding: 14px 20px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--surface); z-index: 5;
}
.inquiry-header h3 {
    font-size: 15px; font-weight: 700;
    display: flex; align-items: center; gap: 8px;
}

.inquiry-list { padding: 8px 20px; }
.inquiry-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}
.inquiry-item:last-child { border-bottom: none; }

.inquiry-item-info { flex: 1; min-width: 0; }
.inquiry-item-name { font-size: 13px; font-weight: 600; }
.inquiry-item-code { font-size: 11px; color: var(--text-muted); }

.inquiry-item-qty {
    display: flex; align-items: center; gap: 6px;
}
.inquiry-item-qty input {
    width: 64px; padding: 6px 8px;
    border: 1px solid var(--border); border-radius: 4px;
    font-size: 13px; text-align: center;
}
.inquiry-item-qty button {
    width: 26px; height: 26px;
    border: 1px solid var(--border); border-radius: 4px;
    background: var(--surface); cursor: pointer;
    font-size: 14px; color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
}
.inquiry-item-qty button:hover { background: var(--bg); }

.inquiry-item-price { font-weight: 600; font-size: 14px; color: var(--text); min-width: 80px; text-align: right; }
.inquiry-item-remove {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 16px; padding: 4px;
}
.inquiry-item-remove:hover { color: var(--danger); }

.inquiry-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}
.inquiry-total {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px;
    font-size: 15px; font-weight: 700;
}
.inquiry-total .amount { color: var(--danger); font-size: 20px; }

.inquiry-form { display: flex; flex-direction: column; gap: 8px; }
.inquiry-form-row { display: flex; gap: 8px; }
.inquiry-form input, .inquiry-form textarea {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}
.inquiry-form textarea { resize: vertical; min-height: 60px; }
.inquiry-form input:focus, .inquiry-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26,86,219,0.15);
}

.btn-submit-inquiry {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px; font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}
.btn-submit-inquiry:hover { background: #d97706; }
.btn-submit-inquiry:disabled { background: #e2e8f0; color: var(--text-muted); cursor: not-allowed; }

/* ===== Bulk Inquiry Page ===== */
.bulk-page {
    padding: 24px 32px;
    max-width: 1200px;
    margin: 0 auto;
}

.bulk-header { margin-bottom: 24px; }
.bulk-header h1 { font-size: 24px; font-weight: 700; }
.bulk-header p { color: var(--text-secondary); margin-top: 4px; }

.bulk-toolbar {
    display: flex; gap: 12px; margin-bottom: 20px;
    flex-wrap: wrap; align-items: center;
}

.search-box {
    flex: 1; min-width: 280px;
    position: relative;
}
.search-box input {
    width: 100%; padding: 10px 16px 10px 40px;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 14px;
}
.search-box .search-icon {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted);
}

.filter-select {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--surface);
    min-width: 150px;
}

/* Product table */
.product-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.product-table {
    width: 100%;
    border-collapse: collapse;
}
.product-table th {
    text-align: left;
    padding: 12px 16px;
    background: #f8fafc;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.product-table td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-light);
}
.product-table tr:hover td { background: #fafbfc; }
.product-table tr:last-child td { border-bottom: none; }

.product-table .prod-name { font-weight: 600; }
.product-table .prod-code { font-size: 12px; color: var(--text-muted); font-family: monospace; }

.qty-input {
    width: 70px; padding: 6px 8px;
    border: 1px solid var(--border); border-radius: 4px;
    font-size: 13px; text-align: center;
}

.btn-sm {
    padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 600;
    border: 1px solid var(--border); background: var(--surface); cursor: pointer;
    transition: var(--transition);
}
.btn-sm:hover { background: var(--bg); }
.btn-sm.btn-primary {
    background: var(--primary); color: #fff; border-color: var(--primary);
}
.btn-sm.btn-primary:hover { background: var(--primary-dark); }

.bulk-summary {
    margin-top: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.bulk-summary h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }

.selected-items { margin-bottom: 16px; }
.selected-item {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 0; border-bottom: 1px solid var(--border-light);
}
.selected-item .remove-btn {
    color: var(--text-muted); cursor: pointer; background: none; border: none;
    font-size: 16px;
}
.selected-item .remove-btn:hover { color: var(--danger); }

/* ===== Toast ===== */
.toast-container {
    position: fixed; top: 72px; right: 24px; z-index: 1000;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 12px 20px; border-radius: var(--radius);
    font-size: 14px; font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}
.toast.success { background: var(--success-light); color: var(--success); border: 1px solid #bbf7d0; }
.toast.error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.toast.info { background: var(--primary-light); color: var(--primary); border: 1px solid #bfdbfe; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== Responsive ===== */

/* ── Tablet ≤ 1024px ── */
@media (max-width: 1024px) {
    .header { padding: 0 12px; height: 56px; gap: 8px; }
    .header-logo { font-size: 15px; gap: 6px; }
    .header-logo .icon { width: 28px; height: 28px; font-size: 13px; }
    .header-nav a { padding: 6px 10px; font-size: 12px; }

    .product-grid { max-width: 36vw; gap: 6px; }
    .product-card { padding: 4px 8px 4px 4px; gap: 5px; }
    .product-card-thumb { width: 32px; height: 32px; }
    .product-card-name { font-size: 11px; }
    .product-card-category { font-size: 9px; }
    .product-card-count { font-size: 9px; min-width: 16px; height: 15px; top: -5px; right: -5px; }

    .main-container {
        grid-template-columns: 1fr;
        grid-template-rows: 55vh 1fr;
    }
    .detail-panel { border-left: none; border-top: 1px solid var(--border); }
    .right-column { min-height: 0; }

    .gallery-grid { grid-template-columns: repeat(2, 1fr); }
    .gallery-page { padding: 24px 20px; }
    .gallery-hero h1 { font-size: 22px; }
    .gallery-card-thumb { height: 160px; }

    .bulk-page { padding: 16px 20px; }
    .product-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .product-table { min-width: 700px; }

    .toast-container { top: 60px; right: 12px; }
    .viewer-toolbar button { width: 30px; height: 30px; font-size: 13px; }
}

/* ── Phone ≤ 768px ── */
@media (max-width: 768px) {
    .header { height: 50px; padding: 0 10px; gap: 6px; }
    .header-logo { font-size: 13px; }
    .header-logo .icon { width: 24px; height: 24px; font-size: 11px; }
    .header-nav { gap: 2px; }
    .header-nav a { padding: 5px 8px; font-size: 11px; }

    .product-grid { max-width: 30vw; gap: 4px; }
    .product-card { border-width: 1.5px; }
    .product-card-count { display: none; }
    .product-card-name { white-space: normal; font-size: 10px; max-width: 60px; overflow: hidden; text-overflow: ellipsis; }

    .main-container {
        grid-template-rows: 45vh 1fr;
    }

    .gallery-grid { grid-template-columns: 1fr; gap: 14px; }
    .gallery-page { padding: 16px 12px; }
    .gallery-hero { margin-bottom: 20px; }
    .gallery-hero h1 { font-size: 18px; }
    .gallery-hero p { font-size: 12px; }
    .gallery-card-thumb { height: 180px; padding: 16px; }
    .gallery-card-body { padding: 12px 14px; gap: 4px; }
    .gallery-card-name { font-size: 14px; }

    .viewer-toolbar {
        top: 6px; left: 6px; flex-wrap: wrap; gap: 4px;
    }
    .viewer-toolbar button { width: 28px; height: 28px; font-size: 12px; }
    .viewer-toolbar .btn-reset { font-size: 10px; padding: 0 8px; }
    .btn-back-gallery { font-size: 11px; padding: 4px 10px; }
    .viewer-product-label { font-size: 11px; max-width: 100px; padding: 0 4px; }

    .part-name { font-size: 17px; }
    .part-code { font-size: 11px; }
    .part-info-header { padding: 14px; }
    .property-grid { margin: 12px 14px; }
    .property-item { padding: 10px 12px; }
    .supplier-section { padding: 0 14px 14px; }

    .inquiry-section { max-height: 260px; }
    .inquiry-header { padding: 10px 14px; }
    .inquiry-list { padding: 6px 14px; }
    .inquiry-footer { padding: 10px 14px; }
    .inquiry-item-qty input { width: 48px; font-size: 12px; }
    .inquiry-item-qty button { width: 24px; height: 24px; font-size: 12px; }

    .bulk-page { padding: 12px; }
    .bulk-header h1 { font-size: 18px; }
    .bulk-toolbar { gap: 8px; }
    .search-box { min-width: 0; flex: 1 1 100%; }
    .filter-select { min-width: 0; font-size: 12px; padding: 8px 10px; }
    .product-table th, .product-table td { padding: 8px 10px; font-size: 12px; }
    .bulk-summary { padding: 16px; }
    .inquiry-form-row { flex-direction: column; }

    .toast-container { top: 54px; right: 8px; left: 8px; }
    .toast { font-size: 12px; padding: 10px 14px; max-width: none; }

    .viewer-legend { max-width: 180px; }
    .viewer-legend-name { font-size: 12px; }
    .viewer-legend-code { font-size: 10px; }
}

/* ── Small phone ≤ 480px ── */
@media (max-width: 480px) {
    .header { height: 44px; padding: 0 6px; gap: 4px; }
    .header-logo { font-size: 12px; gap: 4px; }
    .header-logo .icon { width: 22px; height: 22px; font-size: 10px; }
    .header-nav { display: none; }

    .product-grid { max-width: 50vw; gap: 4px; }
    .product-card { padding: 3px 6px 3px 3px; }
    .product-card-thumb { width: 28px; height: 28px; }
    .product-card-name { font-size: 9px; max-width: 48px; }
    .product-card-info { gap: 0; }

    .main-container {
        grid-template-rows: 40vh 1fr;
    }

    .gallery-hero h1 { font-size: 16px; }
    .gallery-hero p { font-size: 11px; }
    .gallery-card-thumb { height: 140px; padding: 12px; }
    .gallery-card-body { padding: 10px 12px; }
    .gallery-card-name { font-size: 13px; }
    .gallery-card-desc { font-size: 11px; }
    .gallery-card-arrow { font-size: 16px; }

    .viewer-toolbar {
        top: 4px; left: 4px; gap: 3px;
    }
    .viewer-toolbar button { width: 26px; height: 26px; font-size: 11px; }
    .viewer-toolbar .btn-reset { font-size: 9px; padding: 0 6px; }

    .property-grid { grid-template-columns: 1fr; }

    .supplier-header { flex-direction: column; gap: 4px; }
    .supplier-meta { flex-direction: column; gap: 2px; }
    .supplier-price { font-size: 16px; }

    .inquiry-item { flex-wrap: wrap; gap: 6px; }
    .inquiry-item-price { min-width: 0; font-size: 13px; }

    .bulk-toolbar { flex-direction: column; }
    .bulk-header h1 { font-size: 16px; }

    .viewer-legend { max-width: 150px; padding: 6px 10px; }
    .viewer-legend-name { font-size: 11px; }
    .viewer-legend-code { font-size: 9px; }
}

/* ===== Print Styles ===== */
@media print {
    .header, .viewer-toolbar, .btn-add-inquiry, .btn-submit-inquiry,
    .inquiry-item-remove, .inquiry-item-qty button { display: none !important; }
    .main-container { display: block; height: auto; }
    .detail-panel { border: none; overflow: visible; }
}
