:root {
    --color-bg: #f5f5f3;
    --color-surface: #ffffff;
    --color-border: #e0ded8;
    --color-text: #222220;
    --color-text-muted: #6b6a66;
    --color-primary: #1d6e56;
    --color-primary-dark: #0f5040;
    --color-danger: #a32d2d;
    --color-success: #3b6d11;
    --radius: 8px;
    --radius-lg: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    
    /* 縦スクロールバーの有無による画面幅のガタつき（左右のズレ）を完全に防ぐ */
    scrollbar-gutter: stable;
}

.container {
    max-width: 950px;
    margin: 0 auto;
    padding: 24px 16px 80px;
}

h1 { font-size: 22px; font-weight: 500; margin: 0 0 8px; }
h2 { font-size: 16px; font-weight: 500; margin: 0 0 12px; }

/* ナビゲーション */
.topnav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 12px 24px;
}
.topnav-brand { font-weight: 500; }
.topnav-links a {
    margin-left: 16px;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 14px;
}
.topnav-links a:hover { color: var(--color-text); }
.topnav-links .logout { color: var(--color-danger); }

/* ログイン画面 */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.auth-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 320px;
}
.auth-box h1 { font-size: 18px; text-align: center; margin-bottom: 24px; }
.auth-box label {
    display: block;
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 14px;
}
.auth-box input {
    display: block;
    width: 100%;
    margin-top: 4px;
}

/* フォーム要素 */
input[type="text"], input[type="password"], select {
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--color-surface);
    color: var(--color-text);
}
input:focus, select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(29, 110, 86, 0.15);
}

button {
    cursor: pointer;
    font-size: 14px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    padding: 8px 16px;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary-dark);
    width: 100%;
    padding: 12px;
    font-size: 15px;
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); }

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

.btn-scan {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.back-link { color: var(--color-text-muted); text-decoration: none; font-size: 14px; }

/* フィルタタブ（選択状態を目立つように改善） */
.filter-tabs { 
    display: flex; 
    gap: 8px; 
    margin-bottom: 16px; 
    flex-wrap: wrap; 
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 12px;
}
.filter-tabs a {
    padding: 8px 14px;
    border-radius: 4px;
    border: none;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 13px;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}
.filter-tabs a:hover {
    background: var(--color-bg);
    color: var(--color-text);
}
.filter-tabs a.active { 
    background: var(--color-primary); 
    color: #fff; 
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(29, 110, 86, 0.2);
}

/* テーブルコンテナ（横スクロール対応） */
.table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
}

/* テーブル */
.order-table { 
    width: 100%; 
    table-layout: auto;
    border-collapse: collapse; 
    background: var(--color-surface); 
    border-radius: var(--radius-lg); 
    overflow: hidden; 
}
.order-table th, .order-table td {
    padding: 10px 10px; 
    border-bottom: 1px solid var(--color-border);
    font-size: 13px; 
    text-align: left;
    white-space: nowrap;
}
.order-table th { color: var(--color-text-muted); font-weight: 500; font-size: 12px; }
.btn-link { color: var(--color-primary); text-decoration: none; font-size: 13px; white-space: nowrap; }

/* 各列の幅調整 */
.order-table th:nth-child(1), .order-table td:nth-child(1) { width: 30%; }
.order-table th:nth-child(2), .order-table td:nth-child(2) { width: 110px; }
.order-table th:nth-child(3), .order-table td:nth-child(3) { width: 25%; }
.order-table th:nth-child(4), .order-table td:nth-child(4) { width: 80px; text-align: right; }
.order-table th:nth-child(5), .order-table td:nth-child(5) { width: 110px; text-align: center; }
.order-table th:nth-child(6), .order-table td:nth-child(6) { width: 110px; text-align: center; }
.order-table th:nth-child(7), .order-table td:nth-child(7) { width: 90px; text-align: center; }

.empty-state { color: var(--color-text-muted); padding: 40px 0; text-align: center; }

/* バッジ */
.badge { 
    display: inline-block; 
    padding: 2px 8px; 
    border-radius: 999px; 
    font-size: 11px; 
    white-space: nowrap; 
}
.badge-gray { background: #ece9e2; color: #5f5e5a; }
.badge-blue { background: #e6f1fb; color: #0c447c; }
.badge-amber { background: #faeeda; color: #633806; }
.badge-teal { background: #e1f5ee; color: #085041; }
.badge-purple { background: #f0e8ff; color: #4a1a6f; }
.badge-green { background: #eaf3de; color: #27500a; }

/* 注文ヘッダー */
.order-header { margin-bottom: 20px; }
.order-meta, .order-address { font-size: 13px; color: var(--color-text-muted); margin: 4px 0; }

/* ステップカード */
.step-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    transition: opacity 0.2s;
}
.step-card-muted { background: transparent; border: none; }
.step-disabled { opacity: 0.45; pointer-events: none; }
.step-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.step-hint { font-size: 12px; color: var(--color-text-muted); margin: 8px 0 0; }

/* 商品明細 */
.item-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.item-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
}
.item-row.checked { background: #eaf3de; border-color: #c0dd97; }
.item-row input[type="checkbox"] { width: 18px; height: 18px; flex-shrink: 0; }
.item-info { flex: 1; }
.item-name { margin: 0; font-size: 14px; }
.item-sub { margin: 0; font-size: 12px; color: var(--color-text-muted); }
.method-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.method-badge.method-scan { background: #e1f5ee; color: #085041; }
.method-badge.method-checkbox { background: #ece9e2; color: #5f5e5a; }

/* 最終確認 */
.final-check-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: var(--radius); }
.final-check-row input { width: 18px; height: 18px; }

/* 発送フォーム */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; color: var(--color-text-muted); margin-bottom: 6px; }
.form-row select { width: 100%; }
.input-with-scan { display: flex; gap: 8px; }
.input-with-scan input { flex: 1; }

/* 発送履歴 */
.shipment-row { padding: 12px 0; border-bottom: 1px solid var(--color-border); }
.shipment-row:last-child { border-bottom: none; }
.status-done { color: var(--color-success); font-size: 13px; }

/* ログ */
.log-list { list-style: none; padding: 0; margin: 0; font-size: 12px; color: var(--color-text-muted); }
.log-list li { padding: 4px 0; }
.log-time { font-family: monospace; margin-right: 8px; }

/* アラート */
#alert-area { margin-bottom: 12px; }
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 8px; }
.alert-error { background: #fcebeb; color: #791f1f; }
.alert-success { background: #eaf3de; color: #27500a; }
.alert-info { background: #e6f1fb; color: #0c447c; }

/* スキャンモーダル */
.scan-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.scan-modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 16px;
    width: 90%;
    max-width: 420px;
    text-align: center;
}
.scan-modal-title { font-size: 14px; margin: 0 0 12px; }
.scan-modal video { width: 100%; border-radius: var(--radius); margin-bottom: 12px; background: #000; }