/* ==========================================================================
   ざいのーと [最安値管理] PC専用スタイル
   ========================================================================== */

:root {
    --primary-bg: #fbf9f4;
    --header-bg: #8a5d0c;
    --header-color: #ffffff;
    --text-color: #2a1d00;
    --heading-color: #382302;
    --muted-color: #634b22;
    --card-bg: #ffffff;
    --border-color: #decfae;
    --border-dark: #b89f6d;
    --table-header-bg: #eddcb8;
    --table-header-color: #3d2600;
    --table-header-border: #cbbba0;
    --row-hover-bg: #fcf5e5;
    --button-bg: #a66f0e;
    --button-hover-bg: #8a5a06;
    --button-color: #ffffff;
    --save-button-bg: #1e7e34;
    --unsaved-color: #b32400;
    --badge-best-bg: #fff1b8;
    --badge-best-border: #d49500;
    --badge-best-text: #4a2c00;
    --tab-border: #a87818;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'メイリオ', Meiryo, sans-serif;
    background-color: var(--primary-bg);
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.5;
    min-width: 1000px;
}

a {
    color: #8f5c00;
    text-decoration: none;
    font-weight: 600;
}
a:hover {
    text-decoration: underline;
    color: #613e00;
}

/* ヘッダー・タイトルバー */
.app-header {
    background-color: var(--header-bg);
    color: var(--header-color);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    gap: 10px;
    min-width: 1000px;
    box-sizing: border-box;
}

.app-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap !important;
    flex-shrink: 0;
}

.app-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.app-subtitle {
    font-size: 13px;
    opacity: 0.9;
}

.app-title a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: inherit;
    text-decoration: none;
}
.app-title-main,
.app-title-tag {
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    display: inline;
}
.subtitle-line1,
.subtitle-line2 {
    display: inline;
}
.subtitle-line1::after {
    content: " ";
}

.header-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
}

.header-links a,
.header-links .current-app {
    color: #ffffff !important;
    font-size: 13px !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", sans-serif !important;
    line-height: 1 !important;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 9px !important;
    border-radius: 4px !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    text-decoration: none !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
    box-sizing: border-box !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    height: 30px !important;
    transition: background 0.2s, border-color 0.2s;
}

.header-links a:hover {
    background: rgba(255, 255, 255, 0.28) !important;
    border-color: rgba(255, 255, 255, 0.45) !important;
    text-decoration: none !important;
    color: #ffffff !important;
}

.header-links a.home-btn {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.4);
}

.header-links .current-app {
    background: rgba(0, 0, 0, 0.28) !important;
    color: rgba(255, 255, 255, 0.45) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    cursor: default !important;
    pointer-events: none !important;
    box-shadow: none !important;
}

/* 5アプリのイメージカラー枠線＋総合TOPボタン（PC・スマホ共通） */
.header-links a.nav-zaiko {
    border: 1.5px solid #38bdf8 !important;
    background: rgba(56, 189, 248, 0.14) !important;
}
.header-links a.nav-recipe {
    border: 1.5px solid #34d399 !important;
    background: rgba(52, 211, 153, 0.14) !important;
}
.header-links a.nav-price {
    border: 1.5px solid #fbbf24 !important;
    background: rgba(251, 191, 36, 0.14) !important;
}
.header-links a.nav-money {
    border: 1.5px solid #fb7185 !important;
    background: rgba(251, 113, 133, 0.14) !important;
}
.header-links a.nav-wallet {
    border: 1.5px solid #c084fc !important;
    background: rgba(192, 132, 252, 0.16) !important;
}
.header-links a.home-btn {
    border: 1.5px solid rgba(255, 255, 255, 0.7) !important;
    background: rgba(255, 255, 255, 0.22) !important;
}

.header-links a.nav-zaiko:hover { background: rgba(56, 189, 248, 0.28) !important; border-color: #7dd3fc !important; }
.header-links a.nav-recipe:hover { background: rgba(52, 211, 153, 0.28) !important; border-color: #6ee7b7 !important; }
.header-links a.nav-price:hover { background: rgba(251, 191, 36, 0.28) !important; border-color: #fde68a !important; }
.header-links a.nav-money:hover { background: rgba(251, 113, 133, 0.28) !important; border-color: #fda4af !important; }
.header-links a.nav-wallet:hover { background: rgba(192, 132, 252, 0.3) !important; border-color: #d8b4fe !important; }
.header-links a.home-btn:hover { background: rgba(255, 255, 255, 0.34) !important; border-color: #ffffff !important; }

.header-links .current-app.nav-zaiko {
    border: 1.5px solid rgba(56, 189, 248, 0.45) !important;
}
.header-links .current-app.nav-recipe {
    border: 1.5px solid rgba(52, 211, 153, 0.45) !important;
}
.header-links .current-app.nav-price {
    border: 1.5px solid rgba(251, 191, 36, 0.45) !important;
}
.header-links .current-app.nav-money {
    border: 1.5px solid rgba(251, 113, 133, 0.45) !important;
}
.header-links .current-app.nav-wallet {
    border: 1.5px solid rgba(192, 132, 252, 0.45) !important;
}

/* メインコンテナ */
.main-container {
    padding: 8px 12px 30px;
    width: 100%;
    min-width: 1000px;
    box-sizing: border-box;
}

/* タブナビゲーション */
.tab-navigation {
    display: flex !important;
    width: 100% !important;
    min-width: 1000px !important;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    gap: 4px;
    border-bottom: 2px solid var(--tab-border);
    padding-left: 4px;
    padding-right: 4px;
    box-sizing: border-box;
    align-items: flex-end;
}

.tab-button,
.tab-manual-btn {
    background: #eeddbb;
    border: 1px solid var(--border-color);
    border-bottom: none;
    padding: 5px 12px;
    font-size: 13.5px;
    font-weight: 700;
    color: #4a3308;
    cursor: pointer;
    border-radius: 5px 5px 0 0;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    text-decoration: none !important;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.tab-button:hover,
.tab-manual-btn:hover {
    background: #faeecf;
    color: #2b1b00;
}

.tab-manual-btn {
    margin-left: auto !important;
}

.tab-button.active {
    background: #ffffff;
    border-color: var(--tab-border);
    border-top: 2px solid var(--tab-border);
    color: var(--tab-border);
    padding-bottom: 6px;
    margin-bottom: -2px;
}

.tab-content-panel {
    display: none;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-top: none;
    border-left: 2px solid var(--tab-border);
    border-right: 2px solid var(--tab-border);
    border-bottom: 2px solid var(--tab-border);
    border-radius: 0 0 6px 6px;
    padding: 8px 12px;
    margin-bottom: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
    min-height: 0;
}

.tab-content-panel.active {
    display: block;
}

/* 検索・絞り込みタブ内の整列 (zaiko準拠 2行構成) */
.search-tab-content {
    display: flex;
    flex-direction: column;
    width: max-content;
    max-width: 100%;
    gap: 6px;
    position: relative;
    top: 2px;
}

.search-tab-content .form-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
}

.search-tab-content .form-item label {
    font-size: 12px;
    font-weight: 700;
    color: var(--heading-color);
    white-space: nowrap;
}

.search-tab-content select,
.search-tab-content input[type="text"] {
    padding: 3px 6px;
    height: 26px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-color);
    background-color: #fff;
    box-sizing: border-box;
    outline: none;
}

.search-tab-content select:focus,
.search-tab-content input[type="text"]:focus {
    border-color: var(--header-bg);
    box-shadow: 0 0 0 2px rgba(168, 120, 24, 0.2);
}

.search-tab-content button,
.search-tab-content .custom-button {
    box-sizing: border-box;
    height: 26px;
    padding: 2px 10px;
    border: 1px solid #aebdca !important;
    border-radius: 3px;
    background: #f5f8fa !important;
    color: #263746 !important;
    font-size: 13px;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap !important;
    cursor: pointer;
    box-shadow: none;
}

.search-tab-content button:hover:not(:disabled),
.search-tab-content .custom-button:hover:not(:disabled) {
    background: #e4f1f8 !important;
    border-color: #6f9db8 !important;
    color: #263746 !important;
}

.search-tab-content button:disabled,
.search-tab-content .custom-button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    background: #f5f8fa !important;
    color: #8c98a3 !important;
    border: 1px solid #aebdca !important;
}

.filter-status-text {
    font-size: 12px;
    font-weight: 600;
    color: var(--heading-color);
    margin-left: 6px;
    white-space: nowrap;
}

/* 新価格追加フォームのグリッド整列 (zaiko準拠) */
.add-form-container {
    display: flex;
    flex-direction: column;
    width: max-content;
    max-width: 100%;
    gap: 6px;
    position: relative;
    top: 2px;
}

.form-row {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
    gap: 5px 8px;
}

.form-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
}

.form-item label {
    font-size: 12px;
    font-weight: 700;
    color: var(--heading-color);
    white-space: nowrap;
}

.form-item input,
.form-item select {
    padding: 3px 6px;
    height: 26px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-color);
    background-color: #fff;
    outline: none;
    box-sizing: border-box;
}

.form-item input:focus,
.form-item select:focus {
    border-color: var(--header-bg);
    box-shadow: 0 0 0 2px rgba(168, 120, 24, 0.2);
}

.tax-preset-btn {
    background: #eeddbb;
    border: 1px solid #d5c49b;
    color: #3b2502;
    padding: 1px 5px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 3px;
    cursor: pointer;
}
.tax-preset-btn:hover {
    background: #faeecf;
    border-color: #b89f6d;
}

.calc-note {
    font-size: 11px;
    color: var(--muted-color);
    margin-top: 2px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}

/* ボタン共通 */
button,
input[type="button"],
input[type="submit"],
input[type="reset"],
.custom-button,
.tab-button {
    white-space: nowrap !important;
}

.custom-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap !important;
    flex-shrink: 0;
    text-decoration: none;
    background-color: var(--button-bg);
    color: var(--button-color);
    border: 1px solid #7d5206;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 700;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s;
}

.custom-button:hover {
    background-color: var(--button-hover-bg);
}

.custom-button.secondary {
    background-color: #e8dcc4;
    color: #382402;
    border-color: #baa47d;
}
.custom-button.secondary:hover {
    background-color: #d8c7a6;
}

.custom-button.success {
    background-color: var(--save-button-bg);
    border-color: #145523;
}
.custom-button.success:hover {
    background-color: #17652a;
}

/* アクションバー（常時表示エリア: zaiko / recipe踏襲・上ラベル化・不要ボタン非表示） */
.action-bar-container,
.global-action-bar {
    background: #f7eed8;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 12px;
    margin-bottom: 12px;
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-end !important;
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    gap: 16px !important;
    box-sizing: border-box;
    width: 100%;
}

.action-bar-left {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-end !important;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    gap: 12px !important;
    flex: 0 0 auto !important;
}

.action-bar-right {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-end !important;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    gap: 16px !important;
    flex: 1 1 auto !important;
    margin-left: 0 !important;
}

.action-bar-right .meta-info-control {
    margin-left: auto !important;
}

/* 保存ブロック */
.save-action-group {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
}

#saveAllButton {
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    line-height: 28px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    padding: 0 12px !important;
    border-radius: 5px !important;
    border: 1px solid #aebdca !important;
    background: #f5f8fa !important;
    color: #263746 !important;
    box-sizing: border-box !important;
    cursor: pointer !important;
    margin: 0 !important;
    transition: background-color 0.15s, border-color 0.15s;
}

#saveAllButton:hover {
    background: #e4f1f8 !important;
    border-color: #6f9db8 !important;
}

#saveAllButton.has-unsaved-changes {
    background-color: #d9381e !important;
    border-color: #b32400 !important;
    color: #ffffff !important;
    animation: pulseSave 1.5s infinite;
}

.sort-control-wrap {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
}

/* PCモード: ソート実行ボタンをドロップダウンの右隣りに配置 */
.sort-control-wrap {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
}

@media screen and (min-width: 1025px) {
    body:not(.force-mobile-mode) #sortExecuteButton,
    body:not(.force-mobile-mode) .sort-execute-button {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-sizing: border-box !important;
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        line-height: 28px !important;
        padding: 0 10px !important;
        border-radius: 5px !important;
        border: 1px solid #c8ab7e !important;
        background: #fdf8ee !important;
        color: #5c3a00 !important;
        font-size: 13px !important;
        font-weight: 600 !important;
        cursor: pointer !important;
        margin: 0 !important;
        white-space: nowrap !important;
        flex: 0 0 auto !important;
        transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
    }

    body:not(.force-mobile-mode) #sortExecuteButton:hover,
    body:not(.force-mobile-mode) .sort-execute-button:hover {
        background: #f7ebd0 !important;
        border-color: #8e7136 !important;
    }

    body:not(.force-mobile-mode) #sortExecuteButton:active,
    body:not(.force-mobile-mode) .sort-execute-button:active {
        background: #ebd8b2 !important;
        transform: scale(0.98);
    }
}

body.force-pc-mode #sortExecuteButton,
body.force-pc-mode .sort-execute-button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    line-height: 28px !important;
    padding: 0 10px !important;
    border-radius: 5px !important;
    border: 1px solid #c8ab7e !important;
    background: #fdf8ee !important;
    color: #5c3a00 !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    margin: 0 !important;
    white-space: nowrap !important;
    flex: 0 0 auto !important;
    transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}

body.force-pc-mode #sortExecuteButton:hover,
body.force-pc-mode .sort-execute-button:hover {
    background: #f7ebd0 !important;
    border-color: #8e7136 !important;
}

body.force-pc-mode #sortExecuteButton:active,
body.force-pc-mode .sort-execute-button:active {
    background: #ebd8b2 !important;
    transform: scale(0.98);
}

/* 共通ラベル（上ラベル化: zaiko / recipe準拠） */
.action-bar-item-label,
.sort-group-label,
.color-priority-label {
    display: block !important;
    height: 16px !important;
    min-height: 16px !important;
    max-height: 16px !important;
    line-height: 16px !important;
    font-size: 11.5px !important;
    color: #475569 !important;
    font-weight: 500 !important;
    margin: 0 0 2px 0 !important;
    padding: 0 !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
}

.filter-input-group {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0 !important;
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-input-group select,
.filter-input-group input {
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    line-height: 28px !important;
    font-size: 13px !important;
    padding: 0 8px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 5px !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
    color: var(--text-color);
}

#periodFilter {
    width: auto !important;
    min-width: 95px !important;
}

#displayModeSelect {
    width: auto !important;
    min-width: 135px !important;
}

#sortSelect {
    width: auto !important;
    min-width: 175px !important;
}

/* 検索タブと重複するジャンル・店舗・品名検索をアクションバーでは非表示（検索タブ側に集約） */
.action-bar-left .filter-input-group:has(#genreFilter),
.action-bar-left .filter-input-group:has(#shopFilter),
.action-bar-left .filter-input-group:has(#searchInput) {
    display: none !important;
}

#searchInput {
    width: 140px;
}

/* 文字色コントロール */
.color-priority-control {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    flex: 0 0 auto !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
}

.color-priority-buttons {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    height: 30px !important;
    box-sizing: border-box !important;
}

.color-priority-buttons button,
.color-priority-control button {
    box-sizing: border-box;
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    line-height: 28px !important;
    padding: 0 10px !important;
    border: 1px solid #aebdca;
    border-radius: 4px;
    background: #f5f8fa;
    color: #263746;
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap !important;
}

.color-priority-buttons button:hover,
.color-priority-control button:hover {
    background: #e4f1f8;
    border-color: #6f9db8;
}

.color-priority-buttons button.active,
.color-priority-control button.active {
    background-color: #8c5d06;
    color: #ffffff;
    border-color: #6e4905;
}

/* メタ情報コントロール: 最新保存時刻 */
.meta-info-control {
    display: flex !important;
    align-items: center !important;
    height: 30px !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

#lastSavedTime,
.save-time-display {
    font-size: 12px !important;
    color: #5c3c04 !important;
    white-space: nowrap !important;
    line-height: 30px !important;
}


/* テーブルスタイル */
.table-container {
    overflow-x: visible !important;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.price-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 1000px;
    table-layout: fixed;
}

.price-table thead th,
.price-table th {
    background-color: var(--table-header-bg);
    color: var(--table-header-color);
    border: 1px solid var(--table-header-border);
    font-weight: 700;
    text-align: center;
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    padding: 2px 4px !important;
    height: 22px !important;
    max-height: 22px !important;
    font-size: 13px !important;
    line-height: 1.25 !important;
    box-sizing: border-box !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
}

.price-table td {
    border: 1px solid var(--border-color);
    padding: 3px 4px;
    color: var(--text-color);
    vertical-align: middle;
}

.price-table tr:hover {
    background-color: var(--row-hover-bg);
}

/* 表内直接編集用コントロール */
.table-input,
.table-select {
    width: 100%;
    height: 24px; /* ドロップ・テキストの値と内枠の上下パディングを上下1pxずつ詰める (26px -> 24px) */
    padding: 0 5px;
    border: 1px solid #d5c49b;
    border-radius: 3px;
    font-size: 13px;
    line-height: 24px;
    color: var(--text-color);
    background-color: #fff;
    box-sizing: border-box;
    outline: none;
    font-family: inherit;
    vertical-align: middle;
}

.table-input:focus,
.table-select:focus {
    border-color: var(--header-bg);
    box-shadow: 0 0 0 2px rgba(168, 120, 24, 0.25);
    background-color: #fffdf8;
}

.table-input-number {
    text-align: right;
    font-family: 'Consolas', monospace;
    font-weight: 600;
}

/* 日付入力：表側を広げて左右均等の隙間に収める */
.price-table th:nth-child(2),
.price-table td:nth-child(2) {
    min-width: 108px;
    width: 108px;
}
.price-table input[type=date] {
    width: 100%;
    max-width: 100%;
    height: 24px;
    line-height: 24px;
    padding: 0 4px;
    box-sizing: border-box;
}
input[type=date]::-webkit-calendar-picker-indicator {
    padding: 0;
    margin: 0;
    cursor: pointer;
}

/* 数値入力スピナー非表示 */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}
input[type=number] {
    -moz-appearance: textfield;
}

/* selectのデフォルト余白を正規化して高さを合わせる */
.table-select {
    -webkit-appearance: auto;
    padding: 0 2px;
}

.table-unit-group {
    display: flex;
    gap: 2px;
    align-items: center;
    justify-content: center;
}
.table-unit-group input {
    flex: 1;
    min-width: 40px;
}
.table-unit-group select {
    width: 46px;
}

.table-tax-group {
    display: flex !important;
    gap: 2px;
    align-items: center;
    justify-content: center;
}
.mobile-tax-display,
.mobile-unit-display {
    display: none !important;
}
.table-tax-group input:not([data-field="taxRate"]) {
    flex: 1;
    min-width: 44px;
}

/* 変更ハイライト（zaiko踏襲） */
td.changed-cell {
    background-color: #ffe6aa !important;
}
td.changed-cell input,
td.changed-cell select {
    background-color: #fff8e6;
    border-color: #c79100;
}

td.changed-row-number {
    background-color: #f7a831 !important;
    color: #402300 !important;
    font-weight: 700;
}

#saveAllButton {
    padding: 2px 9px;
    height: 26px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    border: 1px solid #aebdca;
    border-radius: 3px;
    background: #f5f8fa;
    color: #263746;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    line-height: 1.2;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s;
}

#saveAllButton:hover {
    background: #e4f1f8;
    border-color: #6f9db8;
}

#saveAllButton.has-unsaved-changes {
    background-color: orange !important;
    border-color: #d97706 !important;
    color: #000 !important;
}

#saveAllButton.has-unsaved-changes:hover {
    background-color: #ff9800 !important;
}

.price-table .num-cell {
    text-align: right;
    font-family: 'Consolas', monospace;
    font-weight: 600;
}

.price-table .center-cell {
    text-align: center;
}

.price-table .unit-price-cell {
    font-family: 'Consolas', monospace;
    font-weight: 700;
    color: #633c00;
    white-space: nowrap;
    padding: 3px 4px;
    font-size: 12.5px;
}

.unit-price-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
}

.unit-price-crown {
    font-size: 12px;
    line-height: 1;
    flex-shrink: 0;
    width: 16px;
    text-align: left;
}

.unit-price-val {
    width: 50px;
    text-align: right;
    white-space: nowrap;
    flex-shrink: 0;
}

.unit-price-unit {
    width: 48px;
    text-align: left;
    white-space: nowrap;
    flex-shrink: 0;
    padding-left: 2px;
}

/* 最安値バッジ */
.badge-best-price {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: var(--badge-best-bg);
    border: 1px solid var(--badge-best-border);
    color: var(--badge-best-text);
    padding: 1px 5px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2px;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(184, 130, 20, 0.2);
}

/* 操作列 ＆ ポップオーバー操作メニュー（zaiko最新仕様完全一致） */
.price-table td.row-action-cell {
    position: relative;
    min-width: 36px;
    text-align: center;
    padding: 2px 2px;
}

.price-table td .row-action-trigger {
    min-width: 30px;
    height: 20px;
    padding: 0 4px;
    font-size: 11px;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1;
    background-color: #f0f0f0;
    border: 1px solid #767676;
    border-radius: 2px;
    box-sizing: border-box;
    cursor: pointer;
    color: black;
    margin: 0;
}

.price-table td .row-action-trigger:hover {
    background-color: #e5e5e5;
    border-color: #4f4f4f;
}

.price-table td .row-action-menu,
.row-action-menu {
    position: fixed;
    z-index: 100000;
    display: none;
    min-width: 72px;
    padding: 3px;
    border: 1px solid #8aaec4;
    border-radius: 3px;
    background: #e6f5ff;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
    box-sizing: border-box;
}

.price-table td .row-action-menu.open,
.row-action-menu.open {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.price-table td .row-action-menu button,
.price-table td .row-action-menu a,
.row-action-menu button,
.row-action-menu a {
    width: 100%;
    height: 20px;
    padding: 0 6px;
    margin: 0;
    font-size: 11px;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1;
    text-decoration: none !important;
    background-color: #f0f0f0;
    border: 1px solid #767676;
    border-radius: 2px;
    box-sizing: border-box;
    cursor: pointer;
    color: black !important;
}

.price-table td .row-action-menu button:hover,
.price-table td .row-action-menu a:hover,
.row-action-menu button:hover,
.row-action-menu a:hover {
    background-color: #e5e5e5;
    border-color: #4f4f4f;
    color: black !important;
}

.price-table td .row-action-menu button.delete-button,
.row-action-menu button.delete-button {
    color: red !important;
}

/* グループ展開ボタン ＆ 子行スタイル（1行インライン配置で縦幅拡大を完全に防止） */
.row-no-cell {
    padding: 2px 2px !important;
    vertical-align: middle !important;
    text-align: center !important;
    white-space: nowrap !important;
}

.no-cell-content {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    white-space: nowrap;
    line-height: 1;
}

.no-cell-content .no-text {
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    letter-spacing: -0.2px;
}

.group-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 !important;
    padding: 0 3px !important;
    height: 18px !important;
    min-height: 18px !important;
    max-height: 18px !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    border: 1px solid #c7b28a !important;
    background: #fdf6e7 !important;
    color: #593d0a !important;
    border-radius: 3px !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    vertical-align: middle !important;
    box-sizing: border-box !important;
}
.group-toggle-btn:hover {
    background: #faeecf !important;
    border-color: #a88a54 !important;
}
.group-toggle-btn.open {
    background: #eddcb8 !important;
    color: #3b2502 !important;
    border-color: #b89f6d !important;
    padding: 0 2px !important;
}

.group-child-row {
    background-color: #fdfbf5;
}
.group-child-row:hover {
    background-color: #f7eed8 !important;
}
.group-child-row td {
    border-top: 1px dashed #e6d7b8;
}
.child-indent-icon {
    color: #8c7247;
    font-weight: bold;
    font-size: 10px;
    margin-right: 1px;
    line-height: 1;
}

/* サマリーカード（最安値サマリータブ用） */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.summary-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--header-bg);
    border-radius: 4px;
    padding: 10px 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.summary-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    border-bottom: 1px dashed #ebd9b0;
    padding-bottom: 4px;
}

.summary-card-title {
    font-size: 15px;
    font-weight: 700;
    color: #3a2300;
}

.summary-card-genre {
    font-size: 11px;
    background: #f5edd8;
    color: #573a03;
    padding: 2px 6px;
    border-radius: 3px;
}

.summary-best-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 4px;
}

.summary-best-price {
    font-size: 18px;
    font-weight: 700;
    color: #7a4a00;
    font-family: 'Consolas', monospace;
}

.summary-best-unit-price {
    font-size: 12px;
    color: #5c3c04;
    font-weight: 600;
}

.summary-best-shop {
    font-size: 12px;
    color: #47320a;
}

/* 通知メッセージ */
.app-notice {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #382402;
    color: #fff;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    z-index: 1000;
    display: none;
}

/* ファイル・データ管理タブ内の整列 */
.management-tab-content {
    display: flex;
    flex-direction: column;
    width: max-content;
    gap: 6px;
    position: relative;
    top: 2px;
}

.management-group {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    width: max-content;
    min-width: 100%;
    flex-shrink: 0;
    min-height: 26px;
    gap: 6px 8px;
}

.management-group-title {
    font-size: 0.88em;
    font-weight: 500;
    color: #333;
    width: 130px;
    min-width: 130px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    padding-right: 8px;
    border-right: 2px solid #d9e2ec;
    box-sizing: border-box;
}

/* ファイル・データ管理タブ内のボタン幅を統一 */
.management-tab-content .custom-button {
    width: 165px;
    height: 26px;
    font-size: 13px;
    text-align: center;
    justify-content: center;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    cursor: pointer;
    line-height: 1;
    padding: 0 8px;
}

.management-tab-content .danger-button {
    background-color: #d32f2f !important;
    color: #ffffff !important;
    border-color: #b71c1c !important;
}
.management-tab-content .danger-button:hover {
    background-color: #b71c1c !important;
}

/* Tooltip Help Anchor (zaiko準拠) */
.tab-button.management-help-anchor {
    position: relative;
}

.tab-button.management-help-anchor.help-visible::after {
    display: block !important;
    position: absolute;
    top: 50%;
    left: calc(100% + 8px);
    z-index: 1000;
    width: max-content;
    max-width: min(600px, calc(100vw - 420px));
    padding: 5px 9px;
    border: 1px solid #8aaec4;
    border-radius: 6px;
    background: #ffffff;
    color: #263746;
    content: attr(data-tooltip);
    font-size: 12px;
    font-weight: normal;
    line-height: 1.35;
    opacity: 1;
    pointer-events: none;
    white-space: normal;
    word-break: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transform: translateY(-50%);
    box-sizing: border-box;

    text-align: left !important;
}

/* 文字色優先コントロール (zaiko / money準拠) */
.color-priority-control {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    padding-left: 8px;
    border-left: 1px solid #d5bc8c;
    white-space: nowrap;
}

.color-priority-control span {
    font-size: 12px;
    font-weight: 700;
    color: #4a3308;
}

.color-priority-control button {
    box-sizing: border-box;
    height: 26px;
    padding: 2px 10px;
    border: 1px solid #aebdca;
    border-radius: 3px;
    background: #f5f8fa;
    color: #263746;
    font-size: 13px;
    cursor: pointer;
    line-height: 1.2;
    transition: all 0.15s ease;
    white-space: nowrap !important;
}

.color-priority-control button:hover {
    background: #e4f1f8;
    border-color: #6f9db8;
}

.color-priority-control button.active {
    background-color: #8c5d06;
    color: #ffffff;
    border-color: #6e4905;
}


/* ==========================================================================
   強制PCモード（ウィンドウを縮めてもPCスタイル・横スクロールを死守する保護レイアウト）
   ========================================================================== */
html.force-pc-mode,
body.force-pc-mode {
    min-width: 1000px !important;
    max-width: none !important;
    width: auto !important;
    overflow-x: visible !important;
}

html.force-pc-mode body,
body.force-pc-mode .main-container,
body.force-pc-mode .app-header {
    min-width: 1000px !important;
    max-width: none !important;
    box-sizing: border-box !important;
}

body.force-pc-mode .app-header {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
    padding: 10px 20px !important;
}

body.force-pc-mode .app-title-group {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    width: auto !important;
    white-space: nowrap !important;
}

body.force-pc-mode .app-title {
    display: block !important;
    line-height: normal !important;
}

body.force-pc-mode .app-subtitle {
    display: block !important;
    line-height: normal !important;
}

body.force-pc-mode .header-links {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 8px !important;
    white-space: nowrap !important;
}

body.force-pc-mode .tab-navigation {
    display: flex !important;
    border-bottom: 2px solid var(--tab-border, #a87818) !important;
    width: auto !important;
    min-width: 1000px !important;
}

body.force-pc-mode .tab-content-panel {
    min-width: 1000px !important;
    width: auto !important;
}

body.force-pc-mode .action-bar-container {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    min-width: 1000px !important;
    white-space: nowrap !important;
}

body.force-pc-mode .mobile-detail-overlay,
body.force-pc-mode .mobile-detail-sheet {
    display: none !important;
}

/* ==========================================================================
   【PCモード統一】タブエリア（タブナビゲーション＋タブパネル内）ボタン統一スタイル
   ※タブの外（アクションバー・ヘッダー・テーブル等）には干渉しないようタブ内に完全限定
   ========================================================================== */

/* 1. タブナビゲーションボタン（フォント13.5px・太さ600・システムフォント統一） */
body:not(.force-mobile-mode) .tab-navigation .tab-button,
body:not(.force-mobile-mode) .tab-navigation .tab-manual-btn,
body:not(.force-mobile-mode) .tab-button,
body:not(.force-mobile-mode) .tab-manual-btn {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", sans-serif !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
}

/* 2. タブパネル内の全ボタン（データ管理・追加・検索パネル内：高さ26px・フォント13px・太さ600統一） */
body:not(.force-mobile-mode) .tab-content-panel button,
body:not(.force-mobile-mode) .tab-content-panel .custom-button,
body:not(.force-mobile-mode) .tab-content-panel a.custom-button,
body:not(.force-mobile-mode) .tab-content-panel input[type="button"],
body:not(.force-mobile-mode) .tab-content-panel input[type="submit"],
body:not(.force-mobile-mode) .management-tab-content .custom-button,
body:not(.force-mobile-mode) .management-group .custom-button,
body:not(.force-mobile-mode) .management-group a,
body:not(.force-mobile-mode) .management-group button,
body:not(.force-mobile-mode) .management-group label,
body:not(.force-mobile-mode) .search-tab-content button,
body:not(.force-mobile-mode) .search-tab-content .custom-button,
body:not(.force-mobile-mode) #tab-panel-search button,
body:not(.force-mobile-mode) #tab-panel-search #searchButton,
body:not(.force-mobile-mode) #tab-panel-search #outOfStockButton,
body:not(.force-mobile-mode) #tab-panel-search #clearFilterButton,
body:not(.force-mobile-mode) #tab-panel-add button,
body:not(.force-mobile-mode) #tab-panel-manage button,
body:not(.force-mobile-mode) #tab-search button,
body:not(.force-mobile-mode) #tab-add button,
body:not(.force-mobile-mode) #tab-manage button,
body:not(.force-mobile-mode) .form-section button,
body:not(.force-mobile-mode) .add-form-row .custom-button,
body:not(.force-mobile-mode) #addButton,
body:not(.force-mobile-mode) #scanButton,
body:not(.force-mobile-mode) #addButton2,
body:not(.force-mobile-mode) #compressButton,
body:not(.force-mobile-mode) #addPriceSubmitBtn,
body:not(.force-mobile-mode) #addWalletSubmitBtn,
body:not(.force-mobile-mode) #submit-record-button,
body:not(.force-mobile-mode) #searchButton,
body:not(.force-mobile-mode) #searchButtonNew,
body:not(.force-mobile-mode) #tabSearchButton,
body:not(.force-mobile-mode) #search-button,
body:not(.force-mobile-mode) #clearFilterButton,
body:not(.force-mobile-mode) #clearFilterButtonNew,
body:not(.force-mobile-mode) #tabClearFilterButton,
body:not(.force-mobile-mode) #clear-filters-button,
body:not(.force-mobile-mode) #outOfStockButton,
body:not(.force-mobile-mode) #tabExpiringButton {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", sans-serif !important;
    height: 26px !important;
    min-height: 26px !important;
    line-height: 24px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    box-sizing: border-box !important;
}

/* 3. データ管理タブのグループタイトル（データ入出力、マスタ設定等：フォント12px・太さ600・高さ26px統一） */
body:not(.force-mobile-mode) .management-group-title {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", sans-serif !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    color: #333333 !important;
    width: 130px !important;
    min-width: 130px !important;
    height: 26px !important;
    display: inline-flex !important;
    align-items: center !important;
    padding-right: 8px !important;
    border-right: 2px solid #d9e2ec !important;
    box-sizing: border-box !important;
    white-space: nowrap !important;
    justify-content: flex-start !important;
    text-align: left !important;
    padding-left: 6px !important;
}

/* Excel風ヘッダー境界列幅リサイザー */
.col-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize !important;
    user-select: none;
    z-index: 120;
    background: transparent;
    transition: background-color 0.15s ease;
}

.col-resizer:hover,
.col-resizer.is-resizing {
    background-color: rgba(59, 130, 246, 0.7) !important;
}
