@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Color Palette */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --secondary: #64748b;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;

    /* Backgrounds */
    --bg-main: #f8fafc;
    --bg-card: #ffffff;

    /* Text */
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-inverse: #ffffff;

    /* Borders & Shadows */
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Radii */
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    /* iPhone の Safari は、ボタンを続けて押すと「ダブルタップで拡大」になり画面がずれる（＋の連打）。
       続けて押した時の拡大だけを止める（スクロールと、指2本での拡大は今までどおり） */
    touch-action: manipulation;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f8fafc;
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 100px;
    /* Space for sticky cart */
}

.hidden {
    display: none !important;
}

/* --- Typography --- */
h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.025em;
}

/* --- Buttons --- */
button {
    cursor: pointer;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
}

button:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary);
    color: var(--text-inverse);
    padding: 12px 24px;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: transparent;
    color: var(--secondary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-secondary:hover {
    background-color: #f1f5f9;
    color: var(--text-main);
}

#refresh-items-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    line-height: 1;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid var(--border-color);
    box-shadow: none;
}

#refresh-items-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

#refresh-items-btn:active {
    transform: rotate(30deg) scale(0.9);
}

/* --- Login Form --- */
#login-container {
    margin-top: 10vh;
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: none;
    padding: 40px 30px;
    border: 1px solid var(--border-color);
}

#login-container h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.75rem;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--secondary);
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background-color: #ffffff;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* --- Order Screen Header --- */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-top: 10px;
}

/* --- Custom Item Styling --- */
.custom-item-card {
    background-color: #f8fafc;
    /* slight grey tint to distinguish it */
    transition: all 0.2s ease;
}

.custom-item-card:focus-within {
    border-color: var(--primary) !important;
    background-color: #ffffff;
}

.custom-item-card input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* --- Filter Tabs --- */
.filter-tabs {
    display: flex;
    margin-bottom: 20px;
    background: #e2e8f0;
    padding: 4px;
    border-radius: var(--radius-lg);
}

.tab-btn {
    flex: 1;
    background: transparent;
    color: var(--secondary);
    padding: 10px 0;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--radius-md);
}

.tab-btn.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* --- Search --- */
.search-container {
    margin-bottom: 24px;
    position: relative;
}

#search-input {
    width: 100%;
    padding: 14px 20px;
    padding-left: 44px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 1rem;
    background-color: #ffffff;
    box-shadow: none;
}

#search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-container::before {
    content: "🔍";
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary);
    font-size: 1.2rem;
    opacity: 0.5;
    transition: all 0.2s;
}

.search-container.searching::before {
    content: "⏳";
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.3; transform: translateY(-50%) scale(0.95); }
    to { opacity: 0.8; transform: translateY(-50%) scale(1.1); }
}

/* --- Announcement Banner --- */
.banner {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
}

/* --- Category Chips --- */
.category-scroll-wrapper {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding: 8px 4px 16px 4px;
    /* increased top padding slightly */
    margin-bottom: 0px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar for a cleaner look */
.category-scroll-wrapper::-webkit-scrollbar {
    display: none;
}

.category-scroll-wrapper {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* --- Scroll Arrows (Phase 15) --- */
.scroll-container-outer {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    overflow: visible;
}

/* Make the chip scroll area fill the space between arrows */
.scroll-container-outer .category-scroll-wrapper {
    flex: 1;
    min-width: 0;
}

.scroll-arrow {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.3rem;
    color: var(--secondary);
    user-select: none;
    padding: 0;
}

@media (max-width: 768px) {
    .scroll-arrow {
        display: none;
        /* タッチスワイプが使えるモバイルでは非表示 */
    }
}

.scroll-arrow:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.category-chip {
    padding: 8px 16px;
    border-radius: var(--radius-full);
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--secondary);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.category-chip:hover {
    background: var(--bg-body);
}

.category-chip.active {
    background: var(--primary);
    color: white;
    border: 1px solid var(--primary);
}

/* --- Manufacturer Chips --- */
.manufacturer-chip {
    flex: 0 0 auto;
    padding: 6px 14px;
    background-color: #f1f5f9;
    color: var(--secondary);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    border: 1px solid transparent;
    box-shadow: var(--shadow-sm);
}

.manufacturer-chip.active {
    background-color: #334155;
    /* Slate dark */
    color: white;
    border-color: #334155;
    box-shadow: 0 4px 8px rgba(51, 65, 85, 0.25);
}

/* --- List Container --- */
#item-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* --- Item Cards --- */
.item-card,
.history-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 0px;
    box-shadow: none;
}

.history-card {
    margin-bottom: 16px;
    /* Keep margin for history list */
}

/* --- Item Row Layout (v2.09 list style) --- */
.item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 4px;
}

.item-row:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.item-row-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    gap: 1px;
}

.item-code {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

.item-row-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.35;
    word-break: break-word;
}

/* --- Favorites Toggle --- */
.btn-fav {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    /* Slightly smaller star */
    color: #cbd5e1;
    cursor: pointer;
    margin-right: 8px;
    /* Less margin */
    margin-top: -2px;
    transition: color 0.2s, transform 0.2s;
    flex-shrink: 0;
    /* Prevent star from squishing */
}

.btn-fav:hover {
    transform: scale(1.2);
}

.btn-fav.active {
    color: var(--accent);
}

/* --- Order Controls --- */
.order-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f1f5f9;
    padding: 4px 6px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    /* Never expand to push name column away */
}

.btn-qty {
    background-color: #ffffff;
    color: var(--text-main);
    width: 32px;
    /* Slightly smaller buttons for grid */
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.125rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.btn-qty:hover {
    background-color: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary-light);
}

.qty-input {
    width: 48px;
    text-align: center;
    border: none;
    background: transparent;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-main);
}

.qty-input:focus {
    outline: none;
}

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* --- Cart Summary (Sticky Bottom) --- */
.cart-summary {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 600px;
    background: #0f172a;
    padding: 16px 24px;
    border-radius: var(--radius-full);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    color: white;
}

.cart-summary p {
    font-weight: 500;
    font-size: 1.125rem;
    margin: 0;
}

#total-qty {
    font-weight: 700;
    font-size: 1.25rem;
    color: #60a5fa;
    /* Light blue */
    margin: 0 4px;
}

.cart-summary button {
    padding: 10px 16px;
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    /* slightly smaller font to fit buttons */
    white-space: nowrap;
    /* Prevent text wrapping */
}

/* --- History List --- */
#history-list {
    margin-bottom: 20px;
}

.history-group-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.history-group-card:hover {
    box-shadow: var(--shadow-md);
}

.history-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.5);
    border-left: 5px solid var(--primary);
}

.history-header:hover {
    background: rgba(255, 255, 255, 0.8);
}

.history-date {
    font-size: 0.875rem;
    color: var(--secondary);
    font-weight: 600;
}

.history-summary {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-main);
}

.history-toggle {
    color: var(--secondary);
    font-size: 0.875rem;
    font-weight: bold;
}

.history-body {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: #ffffff;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-color);
    font-size: 0.95rem;
    color: var(--text-main);
}

.history-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.history-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px dashed var(--border-color);
}

.history-actions button {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: var(--radius-full);
}

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

.btn-danger:hover {
    background-color: #fef2f2;
}

/* --- Confirmation Screen --- */
#confirmation-container {
    padding-top: 10vh;
    /* align nicely like login */
}

.confirm-items-wrapper {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.confirm-item-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px dashed var(--border-color);
    font-size: 1rem;
    color: var(--text-main);
}

.confirm-item-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.confirm-item-name {
    font-weight: 500;
    flex: 1;
    padding-right: 16px;
    word-break: break-word;
}

.confirm-item-qty {
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

/* --- Loading Overlay --- */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #eee;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* --- Responsive Adjustments --- */
@media (max-width: 480px) {
    .qty-input {
        width: 60px;
    }

    .qty-input {
        width: 60px;
    }

    .cart-summary {
        bottom: 16px;
        padding: 12px 20px;
        width: calc(100% - 32px);
    }
}

/* ================================================================
   CART SIDEBAR (Phase 16 - v2.07)
   ================================================================ */

/* Cart toggle button in header */
#cart-toggle-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 6px 12px;
    position: relative;
}

#cart-badge {
    font-weight: 700;
    color: var(--primary);
}

/* Dark overlay when sidebar is open */
.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 99;
}

/* Sidebar panel */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: 320px;
    max-width: 90vw;
    background: #ffffff;
    border-left: 1px solid var(--border-color);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.cart-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--primary-light);
}

.cart-sidebar-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

.cart-close-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid var(--border-color);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--secondary);
}

.cart-close-btn:hover {
    background: var(--bg-main);
    color: var(--danger);
    border-color: var(--danger);
}

/* Scrollable item list */
.cart-sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* Empty cart message */
.cart-empty-msg {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 0.9rem;
}

/* Individual cart item row */
.cart-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-color);
}

.cart-item-row:last-child {
    border-bottom: none;
}

.cart-item-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    gap: 2px;
}

.cart-item-code {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

.cart-item-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-main);
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Controls: −  qty  +  ×  */
.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.cart-qty-btn {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-md);
    background: var(--primary-light);
    border: 1px solid #bfdbfe;
    color: var(--primary);
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.cart-qty-btn:hover {
    background: var(--primary);
    color: #ffffff;
}

.cart-qty-display {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 24px;
    text-align: center;
}

.cart-delete-btn {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-md);
    background: #fff0f0;
    border: 1px solid #fecaca;
    color: var(--danger);
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    margin-left: 2px;
}

.cart-delete-btn:hover {
    background: var(--danger);
    color: #ffffff;
}

/* Sidebar footer with total */
.cart-sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: #f8fafc;
}

.cart-sidebar-total {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    text-align: right;
    margin-bottom: 12px;
}

.cart-sidebar-actions {
    display: flex;
    gap: 8px;
}

.cart-sidebar-actions button {
    flex: 1;
    padding: 10px;
    font-size: 0.85rem;
}

.cart-sidebar-total strong {
    font-size: 1.3rem;
    color: var(--primary);
}

@media (max-width: 480px) {
    .cart-sidebar {
        width: 100%;
        max-width: 100vw;
        top: auto;
        bottom: 0;
        height: 65vh;
        border-left: none;
        border-top: 1px solid var(--border-color);
        border-radius: 16px 16px 0 0;
    }
}

/* --- Selective Accordion Grouping UI --- */
.brand-section {
    margin-bottom: 12px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #edf2f7;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.brand-header {
    background: #f8fafc;
    padding: 14px 16px;
    font-weight: 800;
    font-size: 1rem;
    color: #4a5568;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.brand-header:active {
    background: #edf2f7;
}

.brand-header .arrow {
    font-size: 0.8rem;
    color: #cbd5e1;
    transition: transform 0.3s;
}

.brand-section.expanded .arrow {
    transform: rotate(180deg);
}

.brand-content {
    display: none;
    padding: 4px 0;
    border-top: 1px solid #edf2f7;
}

.brand-section.expanded .brand-content {
    display: block;
}

.brand-count {
    background: #edf2f7;
    color: #718096;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-right: 8px;
}

/* ==============================
   Barcode Scanner Styles
   ============================== */

/* Scan button in search bar */
.search-container {
    position: relative;
}
.scan-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
    z-index: 2;
}
.scan-btn:active {
    transform: translateY(-50%) scale(0.92);
    background: var(--primary-hover);
}

/* Scanner overlay */
.scanner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    backdrop-filter: blur(4px);
}

/* Scanner modal */
.scanner-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    z-index: 1001;
    padding: 20px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.scanner-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.scanner-header h3 {
    margin: 0;
    font-size: 1.1rem;
}
.scanner-close-btn {
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
}
.scanner-footer {
    text-align: center;
    margin-top: 16px;
    color: #475569;
    font-size: 0.875rem;
}

.jan-tail-search {
    margin-top: 12px;
}

.jan-tail-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 72px;
    gap: 8px;
}

.jan-tail-input {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.95rem;
    background: #fff;
}

.jan-tail-search-btn {
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
}

.jan-tail-results {
    margin-top: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.jan-tail-result-btn {
    width: 100%;
    border: none;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    padding: 10px 12px;
    text-align: left;
}

.jan-tail-result-btn:last-child {
    border-bottom: none;
}

.jan-tail-result-name {
    display: block;
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.35;
}

.jan-tail-result-meta {
    display: block;
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 0.72rem;
}

.jan-tail-empty {
    padding: 10px 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.scan-result-panel {
    margin-top: 14px;
    padding: 14px;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    background: #eff6ff;
}

.scan-result-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 12px;
}

.scan-result-code {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.scan-result-name {
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.35;
    word-break: break-word;
}

.scan-result-controls {
    display: grid;
    grid-template-columns: 44px minmax(76px, 1fr) 44px;
    gap: 8px;
    align-items: center;
}

.scan-qty-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #bfdbfe;
    color: var(--primary);
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-qty-input {
    width: 100%;
    height: 44px;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    background: #ffffff;
    color: var(--text-main);
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
}

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

.scan-quick-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.scan-quick-qty {
    min-height: 36px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #bfdbfe;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 700;
}

.scan-clear-qty {
    min-width: 96px;
    color: var(--danger);
    border-color: #fecaca;
}

/* Scan Toast */
.scan-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #065f46;
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    animation: toastIn 0.3s ease-out;
    max-width: 90vw;
}
.scan-toast.toast-error {
    background: #991b1b;
}
@keyframes toastIn {
    from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* Cart restore banner */
.cart-restore-banner {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e3a5f;
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    z-index: 9999;
    animation: toastIn 0.3s ease-out;
    max-width: 90vw;
}
.cart-restore-close {
    background: none;
    border: none;
    color: #aac4e8;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
}
.cart-restore-close:hover { color: #fff; }

/* Scanner zoom slider (iPhone 13等のピント調整用) */
.scan-zoom-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 8px 12px;
    background: #f3f7fb;
    border: 1px solid #d6e4f0;
    border-radius: 10px;
}
.scan-zoom-label {
    font-size: 0.8rem;
    color: #1e3a5f;
    font-weight: 600;
    white-space: nowrap;
}
.scan-zoom-presets {
    display: flex;
    gap: 6px;
    flex: 1;
    justify-content: flex-end;
}
.scan-zoom-preset-btn {
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: #1e3a5f;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 0;
    flex: 1;
    max-width: 56px;
    cursor: pointer;
}
.scan-zoom-preset-btn.active {
    background: #1e3a5f;
    border-color: #1e3a5f;
    color: #fff;
}

/* ==========================================
   📥 取り込みモード（LINE文面 → カート）
   ========================================== */
.import-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    z-index: 1001;
    padding: 20px;
    max-height: 88vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

.import-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.import-header h3 { margin: 0; }

/* LINE注文テキスト取込: 既存B2B画面に合わせた実務用UI */
.line-import-modal {
    max-width: 780px;
    margin-inline: auto;
    border: 1px solid #cbd5e1;
    box-shadow: 0 -18px 50px rgba(15, 23, 42, 0.18);
}

.line-import-kicker {
    margin: 0 0 3px;
    color: #0f766e;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.line-import-scope {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0;
}

.line-import-scope span {
    padding: 4px 8px;
    border-radius: 999px;
    background: #ecfdf5;
    color: #047857;
    font-size: 0.68rem;
    font-weight: 700;
}

#line-import-text {
    width: 100%;
    min-height: 170px;
    padding: 13px;
    border: 2px solid #94a3b8;
    border-radius: 10px;
    background: #fff;
    color: #0f172a;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.7;
    resize: vertical;
}

#line-import-text:focus,
.line-candidate-search:focus {
    border-color: #0f766e;
    outline: 3px solid rgba(15, 118, 110, 0.14);
}

.line-import-main-btn {
    width: 100%;
    margin-top: 10px;
    background: #0f766e;
}

.line-import-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    overflow: hidden;
}

.line-import-metrics span {
    padding: 9px 6px;
    border-right: 1px solid #cbd5e1;
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 700;
    text-align: center;
}

.line-import-metrics span:last-child { border-right: 0; }
.line-import-metrics strong { display: block; color: #0f172a; font-size: 1.05rem; }
.line-import-list { display: grid; gap: 9px; }

.line-import-row {
    display: grid;
    grid-template-columns: minmax(150px, 0.85fr) minmax(240px, 1.4fr) 66px auto;
    gap: 10px;
    align-items: center;
    padding: 11px;
    border: 1px solid #dbe3ec;
    border-left: 5px solid #16a34a;
    border-radius: 10px;
    background: #fff;
}

.line-import-row.needs-attention {
    border-left-color: #f59e0b;
    background: #fffbeb;
}

.line-import-row.is-excluded {
    opacity: 0.48;
    border-left-color: #94a3b8;
    background: #f1f5f9;
}

.line-import-source small,
.line-import-match > small,
.line-import-quantity label {
    display: block;
    margin-bottom: 4px;
    color: #64748b;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.05em;
}

.line-import-source q {
    display: block;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.line-import-match strong { display: block; color: #0f172a; font-size: 0.86rem; line-height: 1.4; }
.line-import-match code { display: block; margin-top: 2px; color: #64748b; font-size: 0.66rem; }

.line-import-reason {
    display: inline-block;
    margin-top: 5px;
    padding: 3px 6px;
    border-radius: 5px;
    background: #dcfce7;
    color: #166534;
    font-size: 0.64rem;
    font-weight: 800;
}

.line-import-reason.is-all-product { background: #e0f2fe; color: #075985; }
.line-import-reason.is-attention { background: #fef3c7; color: #92400e; }

.line-candidate-picker {
    display: grid;
    gap: 6px;
    margin-top: 8px;
    padding: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
}

.line-candidate-search,
.line-candidate-select {
    width: 100%;
    min-height: 42px;
    padding: 8px;
    border: 1px solid #94a3b8;
    border-radius: 7px;
    background: #fff;
    color: #0f172a;
    font-size: 0.9rem;
}

.line-candidate-search { border-width: 2px; }
.line-candidate-status { color: #64748b; font-size: 0.62rem; line-height: 1.35; }
.line-candidate-select:disabled { background: #e2e8f0; color: #64748b; }

.line-import-quantity label { text-align: center; }
.line-import-qty {
    width: 58px;
    min-height: 48px;
    padding: 7px 3px;
    border: 2px solid #64748b;
    border-radius: 8px;
    background: #fff;
    color: #0f172a;
    font-size: 1.1rem;
    font-weight: 800;
    text-align: center;
}

.line-import-qty.is-invalid { border-color: #dc2626; background: #fef2f2; }
.line-import-exclude { border: 0; background: transparent; color: #64748b; font-size: 0.68rem; text-decoration: underline; cursor: pointer; }

.line-import-cart-bar {
    position: sticky;
    bottom: -20px;
    margin: 13px -20px -20px;
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid #cbd5e1;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
}

.line-import-cart-bar p { margin: 0; color: #334155; font-size: 0.78rem; font-weight: 700; }

@media (max-width: 680px) {
    .line-import-row { grid-template-columns: minmax(0, 1fr) 72px; }
    .line-import-source,
    .line-import-match { grid-column: 1 / -1; }
    .line-import-match { padding-top: 8px; border-top: 1px solid #e2e8f0; }
    .line-import-quantity { grid-column: 1; }
    .line-import-exclude { grid-column: 2; align-self: end; min-height: 44px; }
}

/* 発注書画像取込: 現場確認を最短にする、紙と数字の検品台 */
.sheet-ocr-modal {
    max-width: 860px;
    margin-inline: auto;
    border: 1px solid #b8c7c3;
    box-shadow: 0 -22px 60px rgba(15, 38, 34, 0.24);
}

.sheet-ocr-kicker {
    margin: 0 0 3px;
    color: #b45309;
    font-size: 0.64rem;
    font-weight: 900;
    letter-spacing: 0.09em;
}

.sheet-ocr-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin: 12px 0 16px;
}

.sheet-ocr-steps span {
    padding: 7px 4px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #f8fafc;
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 800;
    text-align: center;
}

.sheet-ocr-steps span.is-active {
    border-color: #0f766e;
    background: #ccfbf1;
    color: #115e59;
}

.sheet-ocr-main-btn {
    width: 100%;
    min-height: 52px;
    margin-top: 10px;
    background: #0f766e;
    font-size: 1rem;
}

.sheet-ocr-source-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.sheet-ocr-privacy {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 10px;
}

.sheet-ocr-privacy span {
    padding: 7px 5px;
    border: 1px solid #d1fae5;
    border-radius: 7px;
    background: #f0fdfa;
    color: #0f766e;
    font-size: 0.66rem;
    font-weight: 800;
    text-align: center;
}

.sheet-ocr-corner-guide {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
    margin: 0 0 9px;
    color: #0f172a;
}

.sheet-ocr-corner-guide strong { font-size: 0.9rem; }
.sheet-ocr-corner-guide span { color: #64748b; font-size: 0.7rem; white-space: nowrap; }

.sheet-ocr-canvas-wrap {
    overflow: hidden;
    border: 2px solid #0f766e;
    border-radius: 10px;
    background: #0f172a;
    line-height: 0;
}

#sheet-ocr-photo-canvas {
    display: block;
    width: 100%;
    max-height: 58vh;
    object-fit: contain;
    cursor: crosshair;
    touch-action: manipulation;
}

.sheet-ocr-corner-actions {
    display: grid;
    grid-template-columns: minmax(120px, 0.55fr) minmax(180px, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.sheet-ocr-corner-actions button { min-height: 48px; }

#sheet-ocr-processing-step {
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: #173b36;
    text-align: center;
}

#sheet-ocr-processing-step.hidden { display: none; }
#sheet-ocr-processing-step strong { margin-top: 14px; font-size: 1rem; }
#sheet-ocr-processing-step p { max-width: 420px; margin: 7px 0 0; color: #64748b; font-size: 0.78rem; line-height: 1.55; }

.sheet-ocr-processing-mark {
    width: 62px;
    height: 62px;
    padding: 7px;
    border: 1px solid #99f6e4;
    border-radius: 14px;
    background: #f0fdfa;
}

.sheet-ocr-processing-mark span {
    display: block;
    width: 100%;
    height: 100%;
    border: 4px solid #99f6e4;
    border-top-color: #0f766e;
    border-radius: 50%;
    animation: sheetOcrSpin 0.85s linear infinite;
}

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

.sheet-ocr-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 9px;
    border: 1px solid #b8c7c3;
    border-radius: 9px;
    overflow: hidden;
    background: #f8fafc;
}

.sheet-ocr-metrics span {
    padding: 8px 5px;
    border-right: 1px solid #cbd5e1;
    color: #64748b;
    font-size: 0.64rem;
    font-weight: 800;
    text-align: center;
}

.sheet-ocr-metrics span:last-child { border-right: 0; }
.sheet-ocr-metrics strong { display: block; color: #0f172a; font-size: 1.02rem; }
.sheet-ocr-review-note { margin: 0 0 10px; color: #475569; font-size: 0.74rem; line-height: 1.5; }
.sheet-ocr-review-list { display: grid; gap: 9px; }

.sheet-ocr-review-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 72px;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid #dbe3ec;
    border-left: 5px solid #16a34a;
    border-radius: 9px;
    background: #fff;
}

.sheet-ocr-review-row.needs-attention {
    border-left-color: #f59e0b;
    background: #fffbeb;
}

.sheet-ocr-review-row.is-excluded {
    border-left-color: #94a3b8;
    background: #f8fafc;
    opacity: 0.72;
}

.sheet-ocr-product strong {
    display: block;
    color: #0f172a;
    font-size: 0.86rem;
    line-height: 1.4;
}

.sheet-ocr-product code { display: block; margin-top: 2px; color: #64748b; font-size: 0.66rem; }

.sheet-ocr-strip {
    display: block;
    width: 100%;
    max-height: 96px;
    margin-top: 7px;
    border: 1px solid #94a3b8;
    border-radius: 5px;
    background: #fff;
    object-fit: contain;
}

.sheet-ocr-reading {
    display: inline-block;
    margin-top: 5px;
    padding: 3px 6px;
    border-radius: 5px;
    background: #dcfce7;
    color: #166534;
    font-size: 0.63rem;
    font-weight: 800;
}

.sheet-ocr-reading.is-attention { background: #fef3c7; color: #92400e; }
.sheet-ocr-quantity label { display: block; margin-bottom: 4px; color: #64748b; font-size: 0.62rem; font-weight: 800; text-align: center; }
.sheet-ocr-qty {
    width: 62px;
    min-height: 54px;
    padding: 7px 3px;
    border: 2px solid #64748b;
    border-radius: 8px;
    background: #fff;
    color: #0f172a;
    font-size: 1.22rem;
    font-weight: 900;
    text-align: center;
}
.sheet-ocr-qty.is-invalid { border-color: #dc2626; background: #fef2f2; }
.sheet-ocr-review-row.is-attention-target { outline: 3px solid #b45309; outline-offset: -3px; }
#sheet-ocr-next-attention:disabled { opacity: 0.6; cursor: default; }
.sheet-ocr-quantity-hint {
    display: block;
    margin-top: 3px;
    color: #64748b;
    font-size: 0.58rem;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
}

.sheet-ocr-cart-bar {
    position: sticky;
    bottom: -20px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 0.55fr);
    gap: 10px;
    align-items: center;
    margin: 13px -20px -20px;
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid #b8c7c3;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
}

.sheet-ocr-cart-bar p { margin: 0; color: #334155; font-size: 0.75rem; font-weight: 800; }
.sheet-ocr-cart-bar button { min-height: 48px; }
.sheet-ocr-cart-bar #sheet-ocr-status {
    grid-column: 1 / -1;
    min-width: 0;
    line-height: 1.6;
    overflow-wrap: anywhere;
    text-align: left;
}

.sheet-ocr-qr-reader {
    position: fixed;
    left: -10000px;
    top: -10000px;
    width: 320px;
    height: 240px;
    overflow: hidden;
    pointer-events: none;
}

@media (max-width: 680px) {
    .sheet-ocr-modal { padding: 16px; }
    .sheet-ocr-source-actions { grid-template-columns: 1fr; }
    .sheet-ocr-privacy { grid-template-columns: 1fr; }
    .sheet-ocr-privacy span { padding: 5px; }
    .sheet-ocr-corner-guide { display: block; }
    .sheet-ocr-corner-guide span { display: block; margin-top: 3px; }
    .sheet-ocr-corner-actions { grid-template-columns: 1fr; }
    .sheet-ocr-review-row { grid-template-columns: minmax(0, 1fr) 68px; padding: 9px; }
    .sheet-ocr-strip { max-height: 82px; }
    .sheet-ocr-cart-bar { grid-template-columns: 1fr; bottom: -16px; margin: 13px -16px -16px; padding-inline: 16px; }
    .sheet-ocr-cart-bar button { width: 100%; }
}

.print-layout-modal {
    max-height: none;
}

.print-layout-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    margin: 12px 0 6px;
}

.print-layout-label:first-of-type {
    margin-top: 0;
}

.print-column-segments {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.print-column-segments label {
    min-width: 0;
    cursor: pointer;
}

.print-column-segments input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.print-column-segments span {
    min-height: 58px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #334155;
}

.print-column-segments strong {
    font-size: 1rem;
}

.print-column-segments small {
    margin-top: 2px;
    font-size: 0.7rem;
    color: #64748b;
}

.print-column-segments input:checked + span {
    border-color: var(--primary);
    background: #eff6ff;
    color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary);
}

.print-column-segments input:focus-visible + span {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.print-layout-create-btn {
    width: 100%;
    margin-top: 14px;
}

.import-desc {
    font-size: 0.85rem;
    color: #475569;
    margin-bottom: 10px;
    line-height: 1.5;
}

.import-model-picker {
    min-width: 0;
    margin: 10px 0 0;
    padding: 0;
    border: 0;
}

.import-model-picker legend {
    margin-bottom: 5px;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 600;
}

.import-model-segments {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.import-model-segments label {
    min-width: 0;
    cursor: pointer;
}

.import-model-segments input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.import-model-segments span {
    min-height: 48px;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #334155;
}

.import-model-segments strong { font-size: 0.9rem; }
.import-model-segments small { color: #64748b; font-size: 0.7rem; }

.import-model-segments input:checked + span {
    border-color: var(--primary);
    background: #eff6ff;
    color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary);
}

.import-model-segments input:focus-visible + span {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.import-model-segments input:disabled + span {
    cursor: wait;
    opacity: 0.55;
}

.batch-model-picker { margin-top: 12px; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.code-entry-modal {
    padding: 0;
    overflow: hidden;
}

.code-entry-modal .import-header {
    margin: 0;
    padding: 14px 16px;
    border-bottom: 1px solid #b8c7d9;
    background: #eaf2fb;
}

#code-entry-form {
    padding: 14px;
}

.code-entry-table {
    overflow: hidden;
    border: 1px solid #93a9c3;
    background: #fff;
}

.code-entry-table-row {
    display: grid;
    grid-template-columns: 42px minmax(96px, 0.85fr) minmax(120px, 2fr) 72px 38px;
    min-height: 50px;
    border-bottom: 1px solid #aebdce;
}

.code-entry-table-row > * {
    min-width: 0;
    border-right: 1px solid #aebdce;
}

.code-entry-table-row > *:last-child {
    border-right: 0;
}

.code-entry-table-head {
    min-height: 38px;
    background: #4f80b8;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

#code-entry-rows {
    max-height: min(52vh, 460px);
    overflow-y: auto;
}

.code-entry-active-row {
    border-bottom: 0;
}

.code-entry-table-head > span,
.code-entry-no,
.code-entry-product,
.code-entry-saved-code,
.code-entry-row-action {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 7px 8px;
}

.code-entry-no {
    background: #edf4fb;
    color: #1f4773;
    font-size: 0.82rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.code-entry-cell {
    display: flex;
    align-items: stretch;
}

.code-entry-cell input,
.code-entry-row-qty {
    width: 100%;
    min-width: 0;
    border: 0;
    border-radius: 0;
    background: #fff;
    color: #0f172a;
    font: inherit;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.code-entry-cell input:focus,
.code-entry-row-qty:focus {
    position: relative;
    z-index: 1;
    outline: 3px solid #f4b942;
    outline-offset: -3px;
}

.code-entry-cell input:disabled {
    background: #f1f5f9;
    color: #94a3b8;
}

.code-entry-product {
    justify-content: flex-start;
    background: #f8fafc;
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.code-entry-product.is-resolved {
    background: #fff;
    color: #172033;
}

.code-entry-saved-code {
    color: #24364b;
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
}

.code-entry-saved-name {
    display: flex;
    align-items: center;
    padding: 7px 8px;
    color: #172033;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.code-entry-row-action {
    border-top: 0;
    border-bottom: 0;
    border-left: 0;
    background: #f8fafc;
    color: #52647a;
    font: inherit;
    font-size: 1.3rem;
    font-weight: 500;
    cursor: pointer;
}

.code-entry-row-action:hover {
    background: #e7eef6;
    color: #163d6b;
}

.code-entry-row-action:focus-visible {
    outline: 3px solid #f4b942;
    outline-offset: -3px;
}

.code-entry-row-action:disabled {
    cursor: default;
    opacity: 0.35;
}

.code-entry-delete-btn:hover {
    background: #fff1f2;
    color: #b42318;
}

.code-entry-add-btn {
    background: #e9f2fc;
    color: #1f5d99;
}

.code-entry-status {
    min-height: 20px;
    margin-top: 8px;
    color: #166534;
    font-size: 0.78rem;
}

.code-entry-status.is-error {
    color: #b91c1c;
    font-weight: 600;
}

@media (min-width: 700px) {
    .code-entry-modal,
    .print-layout-modal {
        left: 50%;
        right: auto;
        bottom: 24px;
        width: min(760px, calc(100% - 32px));
        border-radius: 8px;
        transform: translateX(-50%);
        animation: none;
    }

    .print-layout-modal {
        width: min(520px, calc(100% - 32px));
    }
}

@media (max-width: 540px) {
    .code-entry-table-row {
        grid-template-columns: 36px 94px minmax(94px, 1fr) 62px 34px;
    }

    .code-entry-table-head,
    .code-entry-product,
    .code-entry-saved-name {
        font-size: 0.7rem;
    }

    .code-entry-table-head > span,
    .code-entry-no,
    .code-entry-product,
    .code-entry-saved-code,
    .code-entry-row-action,
    .code-entry-saved-name {
        padding: 6px 4px;
    }

    .code-entry-cell input,
    .code-entry-row-qty,
    .code-entry-saved-code {
        font-size: 0.86rem;
    }
}

@media (max-width: 360px) {
    #code-entry-form {
        padding: 10px;
    }

    .code-entry-table-row {
        grid-template-columns: 32px 82px minmax(78px, 1fr) 58px 32px;
    }
}

.import-legend { font-size: 0.75rem; color: #64748b; }

.conf-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin: 0 4px 0 10px;
    vertical-align: middle;
}
.conf-dot.conf-high { background: #22c55e; }
.conf-dot.conf-medium { background: #eab308; }
.conf-dot.conf-low { background: #f97316; }

#import-text {
    width: 100%;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    padding: 12px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
}

.import-status {
    font-size: 0.8rem;
    color: #2563eb;
    margin-top: 8px;
    text-align: center;
}
.import-status.import-status-error { color: #dc2626; font-weight: 600; }

.import-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-left-width: 5px;
    border-radius: 10px;
    margin-bottom: 8px;
    background: #fff;
}
.import-row.conf-high { border-left-color: #22c55e; }
.import-row.conf-medium { border-left-color: #eab308; background: #fefce8; }
.import-row.conf-low { border-left-color: #f97316; background: #fff7ed; }

.import-row-check input {
    width: 20px;
    height: 20px;
}

.import-row-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.import-row-source {
    font-size: 0.72rem;
    color: #64748b;
    overflow-wrap: anywhere;
}

.import-row-name { font-size: 0.85rem; font-weight: 600; }

.import-row-code { font-size: 0.72rem; color: #94a3b8; font-weight: 400; }

.import-row-conf { font-size: 0.72rem; color: #92400e; }

.import-qty {
    width: 58px;
    padding: 8px 4px;
    text-align: center;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
}

.import-row-unmatched {
    border-left-color: #dc2626;
    background: #fef2f2;
}

.import-unmatched-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #dc2626;
    margin: 14px 0 8px;
}

.import-empty {
    text-align: center;
    color: #64748b;
    font-size: 0.85rem;
    padding: 16px 0;
}

.import-debug {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #f8fafc;
    color: #334155;
    font-size: 0.75rem;
}

.import-debug summary {
    padding: 10px;
    cursor: pointer;
    font-weight: 700;
}

.import-debug pre {
    max-height: 280px;
    overflow: auto;
    margin: 0;
    padding: 10px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    color: #111827;
    font-family: Menlo, Monaco, "Courier New", monospace;
    font-size: 0.68rem;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.import-usage-summary {
    margin: 10px 0 0;
    color: #475569;
    font-size: 0.72rem;
    text-align: right;
}

.import-retry-btn {
    width: 100%;
    margin-top: 10px;
}

.import-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}
.import-actions .btn-secondary { flex: 1; }
.import-actions .btn-primary { flex: 2; }

/* 取り込みモード: 写真アップ */
.import-photo-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border: 2px dashed var(--primary);
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
}
.import-photo-label.import-photo-label-full {
    opacity: 0.45;
    cursor: default;
}

.import-photo-thumbs {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.import-thumb {
    position: relative;
    width: 84px;
    height: 84px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #cbd5e1;
}
.import-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.import-thumb-del {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.75);
    color: #fff;
    border: none;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

/* 一括取り込み */
.batch-row-thumb {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    flex-shrink: 0;
}

.batch-salon-select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.82rem;
    background: #fff;
    margin: 2px 0;
}

/* ===== マスター：サロン検索リスト ===== */
.master-salon-item {
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    border: 1px solid transparent;
}
.master-salon-item:hover {
    background: #f1f5f9;
}
.master-salon-item.is-selected {
    background: #e0e7ff;
    border-color: var(--primary, #4338ca);
    font-weight: 600;
}
.master-salon-empty {
    padding: 12px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
}

/* ===== コードでまとめ発注 モーダル ===== */
.code-filter-prefix-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
}
.code-filter-prefix-label input {
    flex: 0 0 auto;
    width: 120px;
    padding: 10px 12px;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1.1rem;
    letter-spacing: 0.15em;
    text-align: center;
}
.code-filter-prefix-label input:focus {
    outline: none;
    border-color: var(--primary, #4338ca);
}
.code-filter-status {
    font-size: 0.82rem;
    color: #475569;
    margin: 6px 0 10px;
}
.code-filter-status.is-error {
    color: #b91c1c;
}
.code-filter-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
    /* 広い画面でも商品名と数量欄が離れすぎないよう幅を絞る */
    max-width: 440px;
}
.code-filter-row {
    display: grid;
    grid-template-columns: 78px 1fr 72px;
    align-items: center;
    gap: 10px;
    padding: 8px 6px;
    border-bottom: 1px solid #eef2f7;
}
.code-filter-code {
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.82rem;
    color: #64748b;
    white-space: nowrap;
}
.code-filter-name {
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}
.code-filter-qty {
    width: 72px;
    padding: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    text-align: center;
}
.code-filter-qty::placeholder {
    color: #cbd5e1;
}
.code-filter-qty:focus {
    outline: none;
    border-color: var(--primary, #4338ca);
}
.search-empty {
    padding: 24px 16px;
    text-align: center;
    color: #64748b;
    overflow-wrap: anywhere;
}
.search-empty p { margin-bottom: 16px; line-height: 1.7; }
.search-empty button, .search-more {
    min-height: 44px;
    white-space: normal;
    border: 1px solid #94a3b8;
    background: #fff;
    color: #1e3a5f;
    font-weight: 600;
}
.search-more { display: block; margin: 16px auto; padding: 12px 20px; }

/* --- 発注結果（受付画面・送れなかった画面）空発注対策 2026-09-20 --- */
.order-result-screen {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: var(--bg-main);
    overflow-y: auto;
    padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}
.order-result-screen.hidden { display: none; }
.order-result-card {
    max-width: 560px;
    margin: 0 auto;
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px 20px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}
.order-result-badge {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 16px;
}
.order-result-badge.is-ok { color: #047857; }
.order-result-badge.is-ng { color: #b91c1c; }
.order-result-lead { font-weight: 600; margin: 0 0 12px; }
.order-result-reason {
    background: #fef2f2;
    border-left: 4px solid var(--danger);
    padding: 10px 12px;
    border-radius: 6px;
    margin: 0 0 12px;
}
.order-result-meta {
    display: grid;
    gap: 6px;
    margin: 0 0 16px;
    padding: 12px;
    background: var(--primary-light);
    border-radius: 8px;
}
.order-result-meta div { display: flex; justify-content: space-between; gap: 12px; }
.order-result-meta dt { color: var(--text-muted); }
.order-result-meta dd { margin: 0; font-weight: 600; text-align: right; }
.order-result-group h3 { font-size: 1rem; margin: 12px 0 6px; }
.order-result-group ul { list-style: none; margin: 0; padding: 0; }
.order-result-group li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #e2e8f0;
    overflow-wrap: anywhere;
}
.order-result-group li strong { white-space: nowrap; }
.order-result-total { font-weight: 700; text-align: right; margin: 12px 0; }
.order-result-note { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 12px; }
.order-result-contact,
.order-result-close {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 12px;
    padding: 14px;
    font-size: 1rem;
    text-decoration: none;
}

/* 商品一覧の取得失敗のお知らせ */
.items-fetch-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 12px;
    padding: 12px;
    background: #fffbeb;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    font-size: 0.9rem;
}
.items-fetch-notice button { flex-shrink: 0; }
