* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
    background-color: #f5f5f5;
    padding-bottom: 70px;
}

/* ヘッダー */
.app-header {
    background-color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 18px;
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-actions button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    transition: background 0.3s;
}

.header-actions button:hover {
    background: rgba(0,0,0,0.05);
    border-radius: 50%;
}

/* 検索バー */
.search-container {
    display: none;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 61px;
    z-index: 99;
    animation: slideDown 0.3s;
}

.search-container.active {
    display: flex;
    align-items: center;
    gap: 8px;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.search-input:focus {
    border-color: #4a90e2;
}

.search-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #666;
    cursor: pointer;
    padding: 8px;
    transition: color 0.3s;
}

.search-close-btn:hover {
    color: #333;
}

/* 一覧テーブル */
.list-container {
    padding: 16px;
    padding-top: 0;
}

.list-header {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 12px;
    padding-top: 16px;
}

.delete-all-btn {
    background: #e74c3c;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
    box-shadow: 0 2px 4px rgba(231, 76, 60, 0.3);
}

.delete-all-btn:hover {
    background: #c0392b;
}

.import-btn {
    background: #27ae60;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
    box-shadow: 0 2px 4px rgba(39, 174, 96, 0.3);
}

.import-btn:hover {
    background: #229954;
}

/* 入出庫履歴画面 */
.history-view-container {
    padding: 16px;
    padding-bottom: 80px;
}

.history-view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.history-view-header h2 {
    font-size: 20px;
    font-weight: 500;
    margin: 0;
}

.history-view-header .refresh-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    transition: background 0.3s;
}

.history-view-header .refresh-btn:hover {
    background: rgba(0,0,0,0.05);
    border-radius: 50%;
}

.history-view-container .history-table-container {
    background: #fff;
    border-radius: 8px;
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.history-view-container .history-table {
    width: 100%;
    min-width: 900px;
}

/* 注文書画面 */
.order-view-container {
    padding: 16px;
    padding-bottom: 80px;
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.order-header h2 {
    font-size: 20px;
    font-weight: 500;
    margin: 0;
}

.order-actions {
    display: flex;
    gap: 8px;
}

.print-btn {
    background: #27ae60;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
}

.print-btn:hover {
    background: #229954;
}

.order-info {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.order-info-item {
    display: flex;
    gap: 8px;
}

.order-label {
    font-weight: 500;
    color: #666;
}

.order-value {
    color: #333;
}

.order-table-container {
    background: #fff;
    border-radius: 8px;
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.order-table {
    width: 100%;
    border-collapse: collapse;
}

.order-table thead {
    background: #f8f9fa;
}

.order-table th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 500;
    font-size: 13px;
    color: #333;
    border-bottom: 2px solid #e0e0e0;
    white-space: nowrap;
}

.order-table td {
    padding: 12px 8px;
    font-size: 13px;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
}

.order-table tbody tr:hover {
    background-color: #f8f9fa;
}

.no-order {
    text-align: center;
    color: #999;
    padding: 40px;
}

.order-shortage {
    color: #e74c3c;
    font-weight: 500;
}

.order-quantity-input {
    width: 80px;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
}

/* 出庫分析画面 */
.analysis-view-container {
    padding: 16px;
    padding-bottom: 80px;
}

/* 在庫状況画面 */
.stock-status-container {
    padding: 16px;
    padding-bottom: 80px;
}

.stock-status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.stock-status-header h2 {
    font-size: 20px;
    font-weight: 500;
    margin: 0;
}

.stock-status-header .refresh-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    transition: background 0.3s;
}

.stock-status-header .refresh-btn:hover {
    background: rgba(0,0,0,0.05);
    border-radius: 50%;
}

.chart-container {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-width: 600px;
    margin: 0 auto;
}

.chart-container canvas {
    max-height: 400px;
}

.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.analysis-header h2 {
    font-size: 20px;
    font-weight: 500;
    margin: 0;
}

.analysis-table-container {
    background: #fff;
    border-radius: 8px;
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.analysis-table {
    width: 100%;
    border-collapse: collapse;
}

.analysis-table thead {
    background: #f8f9fa;
}

.analysis-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 500;
    font-size: 14px;
    color: #333;
    border-bottom: 2px solid #e0e0e0;
    white-space: nowrap;
}

.analysis-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.analysis-table th.sortable:hover {
    background: #e8f4f8;
}

.analysis-table td {
    padding: 12px 16px;
    font-size: 14px;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
}

.analysis-table tbody tr:hover {
    background-color: #f8f9fa;
    cursor: pointer;
}

.no-data {
    text-align: center;
    color: #999;
    padding: 40px;
}

.shipment-high {
    color: #e74c3c;
    font-weight: 500;
}

/* 在庫状況画面 */
.stock-status-container {
    padding: 16px;
    padding-bottom: 80px;
}

.stock-status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.stock-status-header h2 {
    font-size: 20px;
    font-weight: 500;
    margin: 0;
}

.stock-status-header .refresh-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    transition: background 0.3s;
}

.stock-status-header .refresh-btn:hover {
    background: rgba(0,0,0,0.05);
    border-radius: 50%;
}

.chart-container {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-width: 600px;
    margin: 0 auto;
}

.chart-container canvas {
    max-height: 400px;
}

/* 印刷用スタイル */
@media print {
    .app-header,
    .bottom-nav,
    .fab,
    .order-actions {
        display: none !important;
    }
    
    .order-view-container {
        padding: 0;
    }
    
    .order-table {
        border: 1px solid #000;
    }
    
    .order-table th,
    .order-table td {
        border: 1px solid #000;
        padding: 8px;
    }
}

/* 在庫テーブル */
.inventory-table {
    width: 100%;
    background: #fff;
    border-collapse: collapse;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
}

.inventory-table thead {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.inventory-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 500;
    font-size: 14px;
    color: #333;
    white-space: nowrap;
}

.inventory-table td {
    padding: 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    color: #555;
}

.inventory-table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s;
}

.inventory-table tbody tr:hover {
    background-color: #f8f9fa;
}

.row-arrow {
    color: #999;
    font-size: 18px;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: #fff;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    position: relative;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.back-btn {
    position: sticky;
    top: 0;
    left: 16px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 16px;
    z-index: 10;
}

.form-container {
    padding: 0 24px 24px;
}

.form-container h2 {
    font-size: 20px;
    margin-bottom: 24px;
    font-weight: 500;
}

/* フォームグループ */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: #333;
}

.required {
    color: #e74c3c;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: #4a90e2;
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

/* コード選択 */
.code-select {
    display: flex;
    gap: 12px;
}

.code-btn {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.code-btn.active {
    background: #4a90e2;
    color: #fff;
    border-color: #4a90e2;
}

/* 操作タイプ選択 */
.operation-select {
    display: flex;
    gap: 12px;
}

.operation-btn {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.operation-btn.active {
    background: #4a90e2;
    color: #fff;
    border-color: #4a90e2;
}

.help-text {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #666;
}

/* 数量コントロール */
.quantity-control {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 300px;
}

.qty-btn {
    width: 50px;
    height: 50px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 8px;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s;
}

.qty-btn:hover {
    background: #f0f0f0;
}

.qty-btn:active {
    background: #e0e0e0;
}

.qty-input {
    flex: 1;
    text-align: center;
    font-size: 18px;
    font-weight: 500;
}

/* 写真アップロード */
.photo-upload {
    cursor: pointer;
}

.photo-placeholder {
    width: 100%;
    height: 150px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    background: #f8f9fa;
    transition: all 0.3s;
}

.photo-placeholder:hover {
    border-color: #4a90e2;
    background: #f0f7ff;
}

.photo-placeholder img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* フォームアクション */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
}

.cancel-btn,
.save-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.cancel-btn {
    background: #f0f0f0;
    color: #666;
}

.cancel-btn:hover {
    background: #e0e0e0;
}

.save-btn {
    background: #4a90e2;
    color: #fff;
}

.save-btn:hover {
    background: #3a7bc8;
}

/* 詳細表示画面 */
.detail-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
}

.detail-header .back-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    margin-right: auto;
}

.delete-btn,
.more-btn,
.refresh-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    margin-left: 8px;
}

.detail-container {
    padding: 0;
}

.detail-info-section {
    padding: 24px;
    background: #fff;
}

.info-label {
    font-size: 12px;
    color: #999;
    margin-top: 16px;
    margin-bottom: 4px;
}

.info-label:first-child {
    margin-top: 0;
}

.info-value {
    font-size: 16px;
    color: #333;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.history-section {
    background: #f5f5f5;
    padding: 16px;
    min-height: 300px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
    color: #333;
}

.history-count {
    background: #e0e0e0;
    padding: 2px 12px;
    border-radius: 12px;
    font-size: 12px;
}

.history-table-container {
    background: #fff;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 12px;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.history-table thead {
    background: #f8f9fa;
}

.history-table th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 500;
    font-size: 12px;
    color: #666;
    border-bottom: 1px solid #e0e0e0;
    white-space: nowrap;
}

.history-table td {
    padding: 12px 8px;
    font-size: 13px;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
}

.history-table .no-history {
    text-align: center;
    color: #999;
    padding: 32px;
}

.history-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.history-btn {
    background: none;
    border: none;
    color: #4a90e2;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 16px;
}

.history-btn:hover {
    text-decoration: underline;
}

/* 詳細表示のレスポンシブ対応を削除 */
.detail-section {
    margin-bottom: 32px;
}

.detail-section h3 {
    font-size: 18px;
    margin-bottom: 16px;
    font-weight: 500;
    color: #333;
    border-bottom: 2px solid #4a90e2;
    padding-bottom: 8px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 0;
    border-bottom: 1px solid #f0f0f0;
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 500;
    color: #666;
    min-width: 120px;
}

.detail-value {
    flex: 1;
    text-align: right;
    color: #333;
    font-size: 16px;
}

.detail-photo {
    width: 100%;
    max-width: 300px;
    margin-left: auto;
}

.detail-photo img {
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.history-list {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    min-height: 100px;
}

.no-history {
    text-align: center;
    color: #999;
    padding: 24px 0;
}

.history-item {
    background: #fff;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-date {
    font-size: 12px;
    color: #999;
    margin-bottom: 4px;
}

.history-content {
    font-size: 14px;
    color: #333;
}

/* 編集ボタン（鉛筆マーク） */
.edit-fab {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #4a90e2;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
    transition: all 0.3s;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-fab svg {
    width: 24px;
    height: 24px;
}

.edit-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(74, 144, 226, 0.5);
}

.edit-fab:active {
    transform: scale(0.95);
}

/* 全履歴表示画面 */
.all-history-container {
    padding: 16px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.all-history-container .history-table-container {
    background: #fff;
    border-radius: 8px;
    overflow-x: auto;
}

.all-history-container .history-table {
    width: 100%;
    min-width: 900px;
}

.all-history-container .history-table th:last-child,
.all-history-container .history-table td:last-child {
    min-width: 150px;
}

/* フローティングアクションボタン */
.fab {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #4a90e2;
    color: #fff;
    border: none;
    font-size: 32px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
    transition: all 0.3s;
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(74, 144, 226, 0.5);
}

.fab:active {
    transform: scale(0.95);
}

/* 下部ナビゲーション */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 16px;
    color: #999;
    transition: color 0.3s;
}

.nav-item.active {
    color: #4a90e2;
}

.nav-icon {
    font-size: 24px;
}

.nav-label {
    font-size: 11px;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .inventory-table {
        font-size: 12px;
    }
    
    .inventory-table th,
    .inventory-table td {
        padding: 8px;
    }
    
    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .chart-container {
        padding: 20px;
    }

    /* ↓↓↓ ここに追加 ↓↓↓ */
    .chart-container {
        padding: 20px;
    }
    /* ↑↑↑ ここまで追加 ↑↑↑ */
}