/* ===== 共通スタイル ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Hiragino Sans', 'Meiryo', sans-serif;
    background: #ffffff;
    min-height: 100vh;
}

/* ===== ナビゲーション ===== */
.nav {
    background: #1a5a96;
    padding: 10px 20px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.nav button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
}

.nav button.active {
    background: #fff;
    color: #1a5a96;
}

.nav button:not(.active) {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.nav button:hover:not(.active) {
    background: rgba(255,255,255,0.3);
}

.nav-info {
    margin-left: auto;
    color: rgba(255,255,255,0.8);
    font-size: 14px;
}

/* ===== ページ切り替え ===== */
.page {
    display: none;
    padding: 20px;
}

.page.active {
    display: block;
}

/* ===== 入力画面 ===== */
.input-page h1 {
    color: #333;
    margin-bottom: 16px;
    font-size: 22px;
}

/* ツールバー */
.toolbar {
    margin-bottom: 12px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.toolbar-hint {
    margin-left: auto;
    color: #666;
    font-size: 13px;
}

/* ボタン類 */
.btn {
    padding: 7px 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    transition: all 0.3s;
}

.btn-primary {
    background: #1a5a96;
    color: #fff;
}

.btn-primary:hover {
    background: #134a7c;
}

.btn-success {
    background: #2e7d32;
    color: #fff;
}

.btn-success:hover {
    background: #1b5e20;
}

.btn-danger {
    background: #c62828;
    color: #fff;
}

.btn-danger:hover {
    background: #b71c1c;
}

.btn-sort {
    background: #5c6bc0;
    color: #fff;
}

.btn-sort:hover {
    background: #3f51b5;
}

/* ===== テーブル（エクセル風） ===== */
.table-container {
    overflow-x: auto;
    background: #ffffff;
    border: 1px solid #999;
}

table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed;
}

/* ヘッダー：エクセル風 薄グレー */
th {
    background: #e8e8e8;
    color: #333;
    font-weight: bold;
    font-size: 13px;
    border: 1px solid #999;
    padding: 4px 2px;
    text-align: center;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* セル：薄い罫線 */
td {
    border: 1px solid #999;
    padding: 1px 1px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 番号セル */
.no-cell {
    padding: 0 !important;
}

.no-cell .row-no-input {
    color: #333;
    font-weight: bold;
    font-size: 13px;
    text-align: center;
    width: 100%;
    padding: 2px 1px;
}

.no-cell .row-no-input:focus {
    background: #fff;
    outline: 2px solid #4472c4;
    outline-offset: -1px;
}

/* 行ホバー：色は変えない（状態クラスで制御） */
tr:hover td {
    /* 何もしない */
}

/* ===== ★★★ 基本は絶対白 ★★★ ===== */
td {
    background: #ffffff !important;
}

td input,
td select {
    background: #ffffff !important;
}

/* ===== 繰越行 ===== */
tr.carry-row td {
    background: #fff3e0 !important;
}
tr.carry-row td input,
tr.carry-row td select {
    background: #fff3e0 !important;
}

/* ===== 請求不可（セル色より前に定義してセル色を優先させる） ===== */
tr.no-charge-row td {
    background: #e0e0e0 !important;
    color: #999;
}
tr.no-charge-row td input,
tr.no-charge-row td select {
    background: #e0e0e0 !important;
    color: #999;
}

/* ===== セル個別カラー（後に定義して最優先） ===== */
td.cell-red { background: #ffcdd2 !important; }
td.cell-red input, td.cell-red select { background: #ffcdd2 !important; }

td.cell-blue { background: #bbdefb !important; }
td.cell-blue input, td.cell-blue select { background: #bbdefb !important; }

td.cell-green { background: #c8e6c9 !important; }
td.cell-green input, td.cell-green select { background: #c8e6c9 !important; }

td.cell-yellow { background: #fff9c4 !important; }
td.cell-yellow input, td.cell-yellow select { background: #fff9c4 !important; }

td.cell-purple { background: #e1bee7 !important; }
td.cell-purple input, td.cell-purple select { background: #e1bee7 !important; }

td.cell-orange { background: #ffe0b2 !important; }
td.cell-orange input, td.cell-orange select { background: #ffe0b2 !important; }

td.cell-gray { background: #e0e0e0 !important; }
td.cell-gray input, td.cell-gray select { background: #e0e0e0 !important; }

/* ===== ★★★ 選択行（最優先） ★★★ ===== */
tr.row-checked td {
    background: #bbdefb !important;
    border-bottom: 2px solid #1976d2 !important;
}
tr.row-checked td input,
tr.row-checked td select {
    background: #bbdefb !important;
}

tr.row-checked:hover td {
    background: #90caf9 !important;
}
tr.row-checked:hover td input,
tr.row-checked:hover td select {
    background: #90caf9 !important;
}

/* チェックボックスを見やすく */
td:first-child input[type="checkbox"].row-check {
    width: 18px;
    height: 18px;
    accent-color: #1976d2;
    cursor: pointer;
}

/* ===== 入力フィールド（エクセル風） ===== */
td input,
td select {
    width: 100%;
    padding: 2px 2px;
    border: none;
    border-radius: 0;
    font-size: 14px;
    background: #ffffff;
    outline: none;
}

/* フォーカス時：エクセル風の青枠 */
td input:focus,
td select:focus {
    background: #ffffff;
    outline: 2px solid #4472c4;
    outline-offset: -1px;
}

input[type="date"] {
    min-width: 110px;
}

input[type="checkbox"] {
    width: auto;
    cursor: pointer;
    transform: scale(1.2);
}

input[type="number"] {
    min-width: 80px;
}

/* 工番入力 */
.job-no-input {
    background: #fffff0 !important;
    font-weight: bold;
}

.job-no-input:focus {
    background: #fffde0 !important;
}

/* 自動取得フィールド */
.auto-filled {
    background: #e8f0fe !important;
}

/* ===== 請求不可グレーアウト ===== */
.no-charge-row td:nth-child(16) input,
.no-charge-row td:nth-child(17) input,
.no-charge-row td:nth-child(18) input {
    background: #e0e0e0 !important;
    color: #999;
    cursor: not-allowed;
}

/* ===== モニター画面 ===== */
.monitor-page {
    background: #1a1a2e;
    min-height: calc(100vh - 52px);
}

.monitor-page h1 {
    color: #fff;
    text-align: center;
    padding: 15px;
    font-size: 28px;
}

.clock {
    color: #ffd700;
    font-size: 18px;
    text-align: right;
    padding: 10px 20px;
}

.monitor-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 0 20px 20px;
}

.laser-section {
    background: #16213e;
    border-radius: 10px;
    padding: 15px;
}

.laser-section h2 {
    color: #fff;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 20px;
}

.laser-1 h2 {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.laser-2 h2 {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.monitor-card {
    background: #0f3460;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    color: #fff;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
}

.monitor-card .designer {
    background: #e94560;
    padding: 8px 12px;
    border-radius: 5px;
    font-weight: bold;
    font-size: 14px;
    min-width: 60px;
    text-align: center;
}

.monitor-card .info {
    font-size: 13px;
    line-height: 1.6;
}

.monitor-card .info .job-no {
    color: #ffd700;
    font-weight: bold;
}

.monitor-card .info .project {
    color: #a5d6a7;
}

.monitor-card .delivery {
    background: #533483;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 12px;
    text-align: center;
    min-width: 70px;
}

.monitor-card .delivery.changed {
    background: #c62828;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.monitor-bottom {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 0 20px 20px;
}

.status-section {
    background: #16213e;
    border-radius: 10px;
    padding: 15px;
}

.status-section h3 {
    color: #fff;
    text-align: center;
    padding: 8px;
    border-radius: 5px;
    margin-bottom: 10px;
    font-size: 16px;
}

.status-complete h3 {
    background: #27ae60;
}

.status-shipped h3 {
    background: #8e44ad;
}

.status-item {
    background: #0f3460;
    border-radius: 5px;
    padding: 8px 12px;
    margin-bottom: 8px;
    color: #fff;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.empty-message {
    color: #666;
    text-align: center;
    padding: 20px;
}

/* ===== レスポンシブ ===== */
@media (max-width: 1200px) {
    .monitor-grid,
    .monitor-bottom {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .toolbar-hint {
        margin-left: 0;
        margin-top: 10px;
    }
    .nav {
        flex-wrap: wrap;
    }
    .nav-info {
        width: 100%;
        margin-top: 10px;
        margin-left: 0;
    }
}

/* ===== ローディング ===== */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: #666;
}

.loading::after {
    content: '';
    width: 30px;
    height: 30px;
    border: 3px solid #ddd;
    border-top-color: #1a5a96;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

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

/* ===== 通知メッセージ ===== */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 8px;
    color: #fff;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 9999;
    animation: slideIn 0.3s ease;
}

.toast.success { background: #2e7d32; }
.toast.error { background: #c62828; }
.toast.info { background: #1a5a96; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== 請求不可セル（〇ダブルクリック式） ===== */
.no-charge-cell {
    cursor: pointer;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    color: #c62828;
    user-select: none;
    position: relative;
}

.no-charge-cell:hover {
    background: #fff3e0 !important;
}

/* ホバー時に「ダブルクリック」ヒントを表示 */
.no-charge-cell:hover::after {
    content: "W";
    position: absolute;
    bottom: 1px;
    right: 2px;
    font-size: 8px;
    color: #bbb;
    font-weight: normal;
    pointer-events: none;
}

.no-charge-mark {
    display: inline-block;
}

/* ===== グレーアウト（請求不可時） ===== */
.grayed-out {
    background: #d0d0d0 !important;
}

.grayed-out input {
    background: #d0d0d0 !important;
    color: #888 !important;
    cursor: not-allowed;
}

/* ===== 日付入力 ===== */
.date-input {
    text-align: center;
    min-width: 60px;
    cursor: pointer;
}

/* ===== Excelインポートボタン ===== */
.btn-import {
    background: linear-gradient(135deg, #217346, #1d5c38) !important;
    color: #fff !important;
}

/* ===== 更新ボタン ===== */
.btn-refresh {
    background: linear-gradient(135deg, #2196F3, #1976D2) !important;
    color: #fff !important;
}

/* ===== 月選択エリア ===== */
.month-selector-area {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 20px;
    padding-right: 20px;
    border-right: 2px solid #444;
}

.month-input {
    padding: 6px 12px;
    font-size: 16px;
    font-weight: bold;
    border: 2px solid #3498db;
    border-radius: 6px;
    background: #fff;
    color: #000;
    cursor: pointer;
}

.month-input::-webkit-calendar-picker-indicator {
    filter: none;
    cursor: pointer;
}

.btn-month {
    padding: 6px 12px !important;
    background: #2c3e50 !important;
    color: #fff !important;
    border: 1px solid #34495e !important;
    font-size: 12px !important;
}

.btn-month:hover {
    background: #34495e !important;
}