  body { font-family: -apple-system, BlinkMacSystemFont, "Microsoft JhengHei", sans-serif; background-color: #f4f6f9; padding: 15px; margin: 0; color: #333; }
        .container { max-width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 15px; }
        
        /* 頂部導覽卡片 */
        .top-nav-card { background: white; padding: 16px 20px; border-radius: 16px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); display: flex; justify-content: space-between; align-items: center; border: 1px solid #eaeef2; gap: 15px; flex-wrap: wrap; }
        .nav-left-group { display: flex; flex-direction: column; gap: 10px; }
        .nav-title-row { display: flex; align-items: center; gap: 12px; }
        .shield-icon { width: 40px; height: 40px; background: #e8f0fe; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #1a73e8; font-size: 20px; position: relative; flex-shrink: 0; }
        .shield-icon::after { content: '✨'; position: absolute; top: -4px; right: -4px; font-size: 11px; }
        h1 { color: #1a73e8; font-size: 20px; margin: 0; font-weight: 700; letter-spacing: 0.5px; }
        
        .lottery-select-group { display: inline-flex; align-items: center; gap: 8px; background: white; padding: 4px 0; border-radius: 8px; }
        .lottery-select-group label { font-weight: 700; color: #444; font-size: 14px; margin: 0; }
        .lottery-select-group select { padding: 6px 14px; font-size: 15px; font-weight: bold; border-radius: 10px; border: 1px solid #d0d7de; background: white; color: #1a73e8; cursor: pointer; outline: none; }

        /* 目前彩種顯示 + 選擇區塊（淺色發光閃爍提示） */
.lottery-current-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fffdf5;
    border: 2px solid #ffe0a3;
    border-radius: 12px;
    padding: 8px 14px;
    flex-shrink: 0;
    order: -1;
    animation: lotteryGlowPulse 1.8s ease-in-out infinite;
}

@keyframes lotteryGlowPulse {
    0% {
        box-shadow: 0 0 3px 0px rgba(255, 224, 163, 0.4);
        border-color: #ffe0a3;
    }
    50% {
        box-shadow: 0 0 12px 3px rgba(255, 210, 130, 0.7);
        border-color: #ffd27f;
    }
    100% {
        box-shadow: 0 0 3px 0px rgba(255, 224, 163, 0.4);
        border-color: #ffe0a3;
    }
}

.lottery-current-icon { font-size: 18px; }
.lottery-current-text { display: flex; flex-direction: column; line-height: 1.25; }
.lottery-current-label { font-size: 11px; color: #b8945a; font-weight: bold; }
.lottery-current-value { font-size: 15px; color: #e0902a; font-weight: 800; }

/* 彩種提示框 + 頁碼文字 群組（桌面：框在左，手機：框在右） */
.page-left-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 auto;
    min-width: 0;
}

@media (max-width: 600px) {
    /* 手機模式：改用兩欄 Grid，永遠左右固定對齊，不會跑歪 */
    .page-left-group {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        width: 100%;
        gap: 8px;
    }

    /* 頁碼文字固定在左欄 */
    .page-left-group .page-info {
        order: 1;
        justify-self: start;
        white-space: normal;
        line-height: 1.3;
    }

    /* 彩種提示框固定在右欄，並縮小尺寸 */
    .page-left-group .lottery-current-box {
        order: 2;
        justify-self: end;
        padding: 5px 8px;
        gap: 5px;
    }

        /* 手機模式：保留「目前彩種」文字標籤，只縮小字體節省空間 */
    .page-left-group .lottery-current-label {
        font-size: 14px;
    }

    .page-left-group .lottery-current-value {
        font-size: 15px;
    }

    .page-left-group .lottery-current-icon {
        font-size: 15px;
    }

    .page-left-group .lottery-current-box select {
        padding: 5px 5px;
        font-size: 13px;
    }

}


.legend-top-row {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}


        .nav-divider { width: 1px; height: 60px; background: #eaeef2; display: block; flex-shrink: 0; }
        .nav-right-group { display: flex; align-items: center; gap: 12px; }
        .user-avatar { width: 40px; height: 40px; background: #e8f0fe; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #1a73e8; font-size: 18px; flex-shrink: 0; }
        .user-info-col { display: flex; flex-direction: column; font-size: 13px; line-height: 1.3; }
        .user-email-line { font-weight: bold; color: #222; word-break: break-all; }
        
        .auth-btn { background: white; color: #1a73e8; border: 1px solid #d0d7de; padding: 6px 14px; border-radius: 10px; font-weight: bold; cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; transition: all 0.2s; white-space: nowrap; flex-shrink: 0; }
        .auth-btn:hover { background: #f1f3f4; border-color: #1a73e8; }

        /* 模式切換按鈕區 - 選取底色改為深藍色 #0b3a75 */
        .view-switch-bar { display: flex; gap: 10px; }
        .switch-tab-btn { flex: 1; padding: 12px; font-size: 15px; font-weight: bold; border-radius: 10px; border: 1px solid #d0d7de; background: white; color: #555; cursor: pointer; text-align: center; transition: all 0.2s; }
        .switch-tab-btn.active { background: #0b3a75; color: white; border-color: #0b3a75; box-shadow: 0 3px 10px rgba(11,58,117,0.35); }

        /* 輸入主卡片區塊 */
        .input-section-card { background: white; border: 1px solid #eaeef2; padding: 20px; border-radius: 16px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); display: flex; flex-direction: column; gap: 15px; }
        .input-card-row { display: flex; align-items: center; gap: 12px; background: #fcfcfd; border: 1px solid #eef0f2; padding: 12px 16px; border-radius: 12px; flex-wrap: wrap; }
        .field-icon { width: 38px; height: 38px; background: #e8f0fe; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #1a73e8; font-size: 18px; flex-shrink: 0; }
        .field-label { font-weight: bold; color: #444; font-size: 14px; min-width: 100px; }
        .field-content { flex: 1; min-width: 200px; }

        input[type="date"], input[type="text"] { width: 100%; padding: 10px 14px; box-sizing: border-box; border: 1px solid #d0d7de; border-radius: 8px; font-size: 15px; background: white; outline: none; transition: border-color 0.2s; }
        input[type="date"]:focus, input[type="text"]:focus, textarea:focus { border-color: #1a73e8; box-shadow: 0 0 0 3px rgba(26,115,232,0.1); }

        /* 三欄資料輸入列 */
        .triple-inputs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 15px; }
        .sub-input-box { background: #fcfcfd; border: 1px solid #eef0f2; padding: 15px; border-radius: 12px; display: flex; flex-direction: column; gap: 8px; }
        .sub-input-header { display: flex; justify-content: space-between; align-items: center; font-weight: bold; color: #444; font-size: 13px; }
        textarea { width: 100%; height: 60px; padding: 8px; box-sizing: border-box; border: 1px solid #d0d7de; border-radius: 8px; font-size: 14px; resize: none; font-family: inherit; outline: none; }
        
        .preview-btn { background-color: #f1f3f4; color: #555; border: 1px solid #d0d7de; padding: 4px; font-size: 12px; border-radius: 6px; cursor: pointer; font-weight: bold; width: 100%; transition: background 0.2s; }
        .preview-btn:hover { background-color: #e4e6e8; color: #1a73e8; }

        .batch-upload-box { background: #e8f4fd; border: 2px dashed #1a73e8; padding: 15px; border-radius: 12px; text-align: center; }
        .batch-btn { background-color: #28a745; color: white; border: none; padding: 10px 16px; font-size: 14px; border-radius: 8px; cursor: pointer; font-weight: bold; width: 100%; margin-top: 8px; transition: background 0.2s; }
        .batch-btn:hover { background-color: #218838; }

        .image-order-panel {
            margin-top: 14px;
            padding: 12px;
            border-radius: 14px;
            background: #ffffff;
            border: 1px solid #dbeafe;
            box-shadow: 0 3px 10px rgba(26,115,232,0.08);
            text-align: left;
        }

        .image-order-panel h3 {
            margin: 0 0 6px 0;
            color: #0b3a75;
            font-size: 15px;
            font-weight: 800;
        }

        .order-hint {
            margin: 0 0 12px 0;
            color: #555;
            font-size: 12px;
            line-height: 1.5;
        }

        .image-order-list {
            display: flex;
            flex-direction: column;
            gap: 10px;
            margin-bottom: 12px;
        }

        .image-order-item {
            display: grid;
            grid-template-columns: 30px 96px minmax(0, 1fr) auto;
            align-items: center;
            gap: 10px;
            padding: 10px;
            border-radius: 12px;
            background: #f8fbff;
            border: 1px solid #e1ecff;
        }

        .order-number {
            width: 28px;
            height: 28px;
            border-radius: 999px;
            background: #1a73e8;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 13px;
            font-weight: 800;
            flex-shrink: 0;
        }

        .order-thumb {
            width: 96px;
            height: 62px;
            object-fit: contain;
            background: white;
            border: 1px solid #d0d7de;
            border-radius: 8px;
        }

        .order-file-info {
            min-width: 0;
        }

        .order-role {
            font-size: 14px;
            font-weight: 800;
            color: #222;
            margin-bottom: 3px;
        }

        .order-file-name {
            font-size: 12px;
            color: #666;
            word-break: break-all;
        }

        .order-buttons {
            display: flex;
            gap: 6px;
            flex-wrap: nowrap;
        }

        .order-buttons button {
            background: white;
            color: #1a73e8;
            border: 1px solid #baddff;
            border-radius: 8px;
            padding: 6px 8px;
            font-size: 12px;
            font-weight: bold;
            cursor: pointer;
            white-space: nowrap;
        }

        .order-buttons button:hover:not(:disabled) {
            background: #e8f0fe;
        }

        .order-buttons button:disabled {
            opacity: 0.35;
            cursor: not-allowed;
        }

        @media (max-width: 600px) {
            .image-order-item {
                grid-template-columns: 28px 82px minmax(0, 1fr);
                gap: 8px;
            }

            .order-thumb {
                width: 82px;
                height: 56px;
            }

            .order-buttons {
                grid-column: 2 / 4;
                justify-content: flex-start;
            }

            .order-buttons button {
                padding: 6px 10px;
            }
        }


        .btn-group { display: flex; gap: 10px; margin-top: 5px; }
        button.primary-btn { background-color: #1a73e8; color: white; border: none; padding: 12px; font-size: 16px; border-radius: 8px; cursor: pointer; font-weight: bold; flex: 1; transition: background 0.2s; }
        button.primary-btn:hover { background-color: #1557b0; }
        button.primary-btn.edit-mode { background-color: #28a745; }
        button.primary-btn.edit-mode:hover { background-color: #218838; }
        button.cancel-btn { background-color: #6c757d; color: white; border: none; padding: 12px; font-size: 16px; border-radius: 8px; cursor: pointer; font-weight: bold; display: none; width: 120px; }
        
        /* 圖例與分頁工具列 */
        .legend-pagination-wrapper { background: white; border: 1px solid #eaeef2; border-radius: 16px; padding: 15px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); }
        .legend { display: flex; justify-content: space-around; flex-wrap: wrap; gap: 10px; font-size: 12px; margin-bottom: 12px; border-bottom: 1px solid #eaeef2; padding-bottom: 10px; color: #555; }
        .legend-col { display: flex; gap: 15px; align-items: center; }
        .legend-item { display: flex; align-items: center; gap: 6px; font-weight: 500; }
        
        .pagination-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
        .page-info { font-weight: bold; color: #1a73e8; font-size: 14px; }
        .page-btns { display: flex; gap: 8px; align-items: center; }
        .page-btn { background: white; border: 1px solid #d0d7de; padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: bold; cursor: pointer; color: #333; }
        .page-btn:hover:not(:disabled) { background: #e8f0fe; color: #1a73e8; border-color: #baddff; }
        .page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
        .jump-latest-btn { background: #28a745; color: white; border: none; padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: bold; cursor: pointer; }
        .jump-latest-btn:hover { background: #218838; }

        .history-container { display: flex; gap: 15px; align-items: flex-start; justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 10px; }
        
        .period-card { width: 250px; border: 1px solid #d0d7de; border-radius: 12px; padding: 12px; background: #fafbfc; flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
        .period-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; border-bottom: 1px solid #eaecef; padding-bottom: 6px;}
        .period-header h3 { margin: 0; color: #24292e; font-size: 14px; font-weight: 700; }
        
        .action-buttons { display: flex; gap: 6px; }
        .btn-edit { background-color: #17a2b8; color: white; border: none; padding: 3px 8px; font-size: 11px; border-radius: 4px; cursor: pointer; font-weight: bold; }
        .btn-delete { background-color: #dc3545; color: white; border: none; padding: 3px 8px; font-size: 11px; border-radius: 4px; cursor: pointer; font-weight: bold; }

        .section-title { font-weight: bold; color: #fff; background: #57606a; padding: 4px 0; text-align: center; border-radius: 6px; margin: 10px 0 6px 0; font-size: 12px; display: block; letter-spacing: 1px; }

        /* 帶有座標輔助 A~R, 1~3 的資料網格 */
        .data-grid-wrapper { display: flex; flex-direction: column; }
        .grid-header-row { display: grid; grid-template-columns: 20px repeat(3, 1fr); gap: 3px; font-size: 11px; font-weight: bold; color: #1a73e8; text-align: center; margin-bottom: 4px; }
        
        .grid-row-with-label { display: grid; grid-template-columns: 20px repeat(3, 1fr); gap: 3px; align-items: center; margin-bottom: 3px; }
        .row-label { font-size: 10px; font-weight: bold; color: #888; text-align: center; }

        .col-title { text-align: center; font-size: 11px; font-weight: bold; color: #57606a; border-bottom: 1px solid #d0d7de; padding-bottom: 2px; }

        .number-row { display: flex; align-items: center; justify-content: center; height: 22px; }
        

/* 統計庫 2x2 大格顯示 */
.stat-library-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    align-items: start;
}

.stat-col-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

/* 每一個統計庫大格 */
.stat-block {
    width: 78px;
    height: 52px;
    border: 1px solid #333;
    background: #fff;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    margin-bottom: 7px;
    box-sizing: border-box;
}

/* 統計庫每個號碼的小排版：左色點 / 號碼 / 右色點 */


/* 統計庫專用：不要沿用原本 .number 的小框 */
.stat-number-text {
    display: block;
    width: 18px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    font-size: 10px;
    font-weight: 800;
    color: #111;
    background: transparent;
    border: none;
    margin: 0;
    padding: 0;
}

/* 大格內四個位置 */
.stat-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
}

.stat-slot-1 {
    border-right: 1px solid #333;
    border-bottom: 1px solid #333;
}

.stat-slot-2 {
    border-bottom: 1px solid #333;
}

.stat-slot-3 {
    border-right: 1px solid #333;
}

/* 統計庫內的左右色點區，改成直排 */
 .stat-number-row {
    display: grid;
    grid-template-columns: 8px auto 8px;
    align-items: center;
    justify-content: center;
    column-gap: 1px;
    width: 100%;
    height: 20px;
    line-height: 1;
    box-sizing: border-box;
}

.stat-number-row .dots-left,
.stat-number-row .dots-right {
    width: 8px;
    height: 18px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.stat-number-row .dots-left {
    justify-self: end;
}

.stat-number-row .dots-right {
    justify-self: start;
}

.stat-number-row .number {
    width: 20px;
    height: 18px;
    line-height: 18px;
    font-size: 10px;
    margin: 0;
    border-radius: 3px;
}

.stat-number-row .dot {
    width: 4px;
    height: 4px;
    flex-shrink: 0;
}

/* ⬇️ 從這裡開始貼新的 CSS ⬇️ */

.num-box {
    display: inline-grid;
    grid-template-columns: 11px 14px 11px;
    grid-template-rows: 8px 8px 8px;
    border: 1.5px solid #000;
    background: #fff;
    width: 36px;
    height: 24px;
}
.num-box .cell {
    width: 100%;
    height: 100%;
}
.num-box .num-text {
    grid-row: 1 / span 3;
    grid-column: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    color: #000;
    background: #fff;
}

/* 左欄 (offset 0/2/4) */
.c-red    { background: #e8242c; }
.c-green  { background: #22a94a; }
.c-blue   { background: #2f37c9; }
/* 右欄 (offset 1/3/5) */
.c-yellow { background: #f4e50f; }
.c-pink   { background: #f6a6cc; }
.c-purple { background: #a24bab; }
/* 未中獎 = 留白 */
.c-blank  { background: #fff; }

        .number { width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 4px; background: #fff; font-weight: bold; border: 1px solid #d0d7de; font-size: 11px; margin: 0 1px; }
        /* =====================================================
   開獎號碼：玻璃立體彩球版本
   - 五顆固定順序：紅、藍、綠、黃、紫
   - 高光避開數字中心
   - 號碼獨立在最上層，不被特效干擾
   ===================================================== */

.win-number {
    position: relative;
    width: 28px;
    height: 28px;
    border-radius: 50%;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    margin: 0 2px;
    box-sizing: border-box;
    overflow: hidden;
    vertical-align: middle;

    color: #ffffff;
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0.2px;

    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.75),
        0 0 3px rgba(0, 0, 0, 0.5);

    box-shadow:
        inset -4px -5px 7px rgba(0, 0, 0, 0.38),
        inset 2px 2px 5px rgba(255, 255, 255, 0.36),
        0 2px 5px rgba(0, 0, 0, 0.28);
}

/* 號碼文字獨立拉到最上層 */
.win-number-text {
    position: relative;
    z-index: 5;
}

/* 左上玻璃高光：放在左上，不壓住數字中心 */
.win-number::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 3px;
    width: 16px;
    height: 9px;
    border-radius: 50%;

    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.92) 0%,
        rgba(255, 255, 255, 0.68) 42%,
        rgba(255, 255, 255, 0.14) 72%,
        rgba(255, 255, 255, 0) 100%
    );

    transform: rotate(-17deg);
    z-index: 2;
    pointer-events: none;
}

/* 下方暗部：增加球體深度 */
.win-number::after {
    content: "";
    position: absolute;
    left: 3px;
    right: 3px;
    bottom: 2px;
    height: 12px;
    border-radius: 50%;

    background: radial-gradient(
        ellipse at center,
        rgba(0, 0, 0, 0.34) 0%,
        rgba(0, 0, 0, 0.18) 45%,
        rgba(0, 0, 0, 0) 76%
    );

    z-index: 1;
    pointer-events: none;
}

/* 第 1 顆：紅球 */
.win-number.ball-red {
    background:
        radial-gradient(circle at 34% 27%,
            #ffd0ca 0%,
            #ff6a5f 28%,
            #d51f27 62%,
            #6d0c12 100%
        );
    border: 2px solid #ff6b63;
}

/* 第 2 顆：藍球 */
.win-number.ball-blue {
    background:
        radial-gradient(circle at 34% 27%,
            #d5f1ff 0%,
            #5ebdf3 28%,
            #0b79bf 62%,
            #063462 100%
        );
    border: 2px solid #61c4ff;
}

/* 第 3 顆：綠球 */
.win-number.ball-green {
    background:
        radial-gradient(circle at 34% 27%,
            #dcffd4 0%,
            #87f46b 28%,
            #37ad31 62%,
            #145a1d 100%
        );
    border: 2px solid #90ff78;
}

/* 第 4 顆：黃球 */
.win-number.ball-yellow {
    background:
        radial-gradient(circle at 34% 27%,
            #fff6c5 0%,
            #ffe066 28%,
            #c99816 62%,
            #684704 100%
        );
    border: 2px solid #ffe47a;
}

/* 第 5 顆：紫球 */
.win-number.ball-purple {
    background:
        radial-gradient(circle at 34% 27%,
            #f2c6ff 0%,
            #c25aea 28%,
            #8126b2 62%,
            #3d105f 100%
        );
    border: 2px solid #d66cff;
}


        .dot { width: 7px; height: 7px; border-radius: 2px; flex-shrink: 0; }
        .detail-color-dot {
            width: 9px;
            height: 9px;
            border-radius: 50%;
            display: inline-block;
        }

        .dot-0 { background-color: #d60000; } 
        .dot-1 { background-color: #eccc6c; } 
        .dot-2 { background-color: #34c759; } 
        .dot-3 { background-color: #ff6bb5; } 
        .dot-4 { background-color: #007aff; } 
        .dot-5 { background-color: #7b2cbf; } 

        .hidden-file-input { display: none; }

        /* 📊 格子中獎次數統計專區樣式 */
        .stats-section-card { background: white; border: 1px solid #eaeef2; padding: 20px; border-radius: 16px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); display: flex; flex-direction: column; gap: 15px; }
        
        .filter-controls-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; background: #fcfcfd; padding: 12px 16px; border-radius: 12px; border: 1px solid #eef0f2; }
        .filter-group { display: flex; align-items: center; gap: 8px; }
        .filter-group label { font-size: 13px; font-weight: bold; color: #444; }
        .filter-group select, .filter-group input[type="date"] { padding: 6px 10px; border-radius: 8px; border: 1px solid #d0d7de; font-size: 13px; font-weight: bold; color: #1a73e8; background: white; }

        .stat-rank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
        .stat-card { background: #f8f9fa; border: 1px solid #e1e4e8; border-radius: 12px; padding: 12px 15px; display: flex; flex-direction: column; gap: 8px; transition: all 0.2s; cursor: pointer; }
        .stat-card:hover { border-color: #1a73e8; background: #e8f0fe; }
        
        .stat-card-header { display: flex; justify-content: space-between; align-items: center; }
        .coord-badge { background: #1a73e8; color: white; padding: 3px 10px; border-radius: 6px; font-size: 14px; font-weight: bold; }
        
        /* 次數標籤樣式：綠底與高頻紅底 */
        .count-badge { background: #28a745; color: white; padding: 3px 10px; border-radius: 12px; font-size: 13px; font-weight: bold; }
        .count-badge.high-freq { background: #dc3545; } /* 4次以上標紅 */

        .col-name-hint { font-size: 12px; color: #666; font-weight: 500; }

        .details-expand-box { display: none; background: white; padding: 10px; border-radius: 8px; border: 1px dashed #baddff; margin-top: 6px; font-size: 12px; color: #333; }
        .detail-item-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; border-bottom: 1px solid #f0f0f0; }

        .show-more-btn-box { text-align: center; margin-top: 10px; }
        .show-more-btn { background: white; color: #1a73e8; border: 1px solid #1a73e8; padding: 8px 20px; border-radius: 8px; font-weight: bold; cursor: pointer; transition: all 0.2s; }
        .show-more-btn:hover { background: #e8f0fe; }
        
        /* Modal & Overlay */
        #previewModal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); display: none; justify-content: center; align-items: center; z-index: 10000; padding: 10px; box-sizing: border-box; }
        .modal-content { background: white; width: 100%; max-width: 480px; border-radius: 14px; padding: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); display: flex; flex-direction: column; max-height: 90vh; overflow-y: auto; }
        .modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eaeef2; padding-bottom: 10px; margin-bottom: 12px; font-weight: bold; color: #1a73e8; font-size: 16px; }
        .modal-img-preview { width: 100%; height: auto; object-fit: contain; border-radius: 8px; margin-bottom: 12px; border: 1px solid #ddd; display: none; background: #f9f9f9; max-height: 350px; }
        .modal-footer-btns { display: flex; gap: 10px; margin-top: 12px; }
        .modal-cancel-btn { background: #6c757d; color: white; border: none; padding: 10px 16px; border-radius: 8px; font-weight: bold; cursor: pointer; flex: 1; }
        .modal-confirm-btn { background: #28a745; color: white; border: none; padding: 10px 16px; border-radius: 8px; font-weight: bold; cursor: pointer; flex: 1; }

        #loadingOverlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: none; justify-content: center; align-items: center; z-index: 9999; color: white; font-size: 18px; font-weight: bold; flex-direction: column; gap: 10px; }
        .template-modal {
            position: fixed;
            z-index: 99999;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background: rgba(0, 0, 0, 0.55);
        }

        .template-modal-content {
            background: #fff;
            margin: 30px auto;
            padding: 16px;
            border-radius: 12px;
            width: min(960px, 94vw);
            box-shadow: 0 8px 30px rgba(0,0,0,0.25);
        }

        .template-modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 12px;
            border-bottom: 1px solid #ddd;
            padding-bottom: 8px;
            margin-bottom: 12px;
        }

        .template-modal-header h3 {
            margin: 0;
        }

        .template-close-btn {
            border: none;
            background: #333;
            color: #fff;
            font-size: 24px;
            line-height: 1;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            cursor: pointer;
        }

        .template-section {
            margin: 14px 0;
        }

        .template-label {
            display: block;
            font-weight: bold;
            margin-bottom: 6px;
        }

        .template-image-wrap {
            width: 100%;
            max-height: 460px;
            overflow: auto;
            border: 1px solid #ddd;
            border-radius: 8px;
            background: #f7f7f7;
            padding: 8px;
            box-sizing: border-box;
        }

        #templatePreviewCanvas {
            max-width: 100%;
            height: auto;
            display: block;
        }

        .template-status-box {
            padding: 10px;
            background: #f5f5f5;
            border-radius: 8px;
            border: 1px solid #ddd;
            white-space: pre-wrap;
            font-family: monospace;
        }

        .template-actions {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
            justify-content: flex-end;
            border-top: 1px solid #ddd;
            padding-top: 12px;
            margin-top: 12px;
        }
                /* 模板工具收合區 */
          .template-tools-collapsible {
              margin: 4px 0;
          }

          /* 模板工具列：左邊辨識模式，右邊模板工具 */
          .template-tools-toolbar {
              display: flex;
              align-items: center;
              gap: 8px;
              width: 100%;
          }

          /* 辨識模式外框 */
          .recognition-mode-box {
              display: flex;
              align-items: center;
              gap: 8px;
              flex: 0 0 auto;
          }

          /* 辨識模式文字 */
          .recognition-mode-label {
              font-size: 12px;
              font-weight: bold;
              color: #444;
              white-space: nowrap;
          }

          /* 白底/黑底切換外層 */
          .recognition-mode-switch {
              display: flex;
              align-items: center;
              border: 1px solid #d0d7de;
              border-radius: 999px;
              background: #ffffff;
              padding: 2px;
              overflow: hidden;
          }

          /* 未選取狀態 */
          .recognition-mode-btn {
              border: 1px solid transparent;
              background: #ffffff;
              color: #374151;
              padding: 6px 12px;
              font-size: 12px;
              font-weight: bold;
              border-radius: 999px;
              cursor: pointer;
              white-space: nowrap;
              transition: all 0.2s;
          }

          /* 未選取 hover */
          .recognition-mode-btn:hover {
              background: #f1f3f4;
          }

          /* 選取狀態：綠底白字綠框 */
          .recognition-mode-btn.active {
              background: #28a745;
              color: #ffffff;
              border-color: #28a745;
              box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
          }

          /* 模板工具按鈕 */
          .template-tools-toggle {
              flex: 1 1 auto;
              width: auto;
              background: #f8f9fa;
              color: #555;
              border: 1px solid #d0d7de;
              padding: 8px 12px;
              font-size: 12px;
              border-radius: 8px;
              cursor: pointer;
              font-weight: bold;
              text-align: center;
              transition: all 0.2s;
          }

          .template-tools-toggle:hover {
              background: #e8f0fe;
              color: #1a73e8;
              border-color: #baddff;
          }


        .template-tools-panel {
            margin-top: 8px;
            display: none;
            gap: 8px;
            flex-wrap: wrap;
            background: #fcfcfd;
            border: 1px dashed #d0d7de;
            border-radius: 10px;
            padding: 10px;
        }

        @media (max-width: 600px) {
    .top-nav-card {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: start;
        gap: 10px;
        padding: 14px 16px;
        flex-wrap: nowrap;
    }

    .nav-left-group {
        width: auto;
        min-width: 0;
        gap: 10px;
    }

    .nav-title-row {
        gap: 10px;
    }

    .shield-icon {
        width: 38px;
        height: 38px;
        font-size: 18px;
        border-radius: 11px;
    }

    h1 {
        font-size: 18px;
        white-space: nowrap;
    }

    .lottery-select-group {
        margin-left: 48px;
        gap: 6px;
        flex-wrap: nowrap;
    }

    .lottery-select-group label {
        font-size: 13px;
        white-space: nowrap;
    }

    .lottery-select-group select {
        padding: 6px 12px;
        font-size: 14px;
        min-width: 90px;
    }

    .nav-divider {
        display: none;
    }

    .nav-right-group {
        width: auto;
        display: grid;
        grid-template-columns: auto auto;
        grid-template-rows: auto auto;
        align-items: center;
        justify-content: end;
        column-gap: 8px;
        row-gap: 6px;
    }

    .user-avatar {
        grid-column: 1;
        grid-row: 1;
        width: 34px;
        height: 34px;
        font-size: 16px;
    }

    .user-info-col {
        grid-column: 2;
        grid-row: 1;
        font-size: 12px;
        line-height: 1.2;
        max-width: 95px;
    }

    .auth-btn {
        grid-column: 2;
        grid-row: 2;
        justify-self: start;
        padding: 5px 10px;
        font-size: 12px;
        border-radius: 9px;
    }

        .template-tools-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .recognition-mode-box {
        width: 100%;
        justify-content: space-between;
    }

    .recognition-mode-switch {
        flex: 1;
    }

    .recognition-mode-btn {
        flex: 1;
        padding: 7px 8px;
    }

    .template-tools-toggle {
        width: 100%;
    }

}
/* =====================================================
   數據庫表格色點樣式：固定中心版
   - 數字框永遠固定在欄位中央
   - 左邊色點貼著數字框左側
   - 右邊色點貼著數字框右側
   - 色點不推動數字
   - 不使用 !important
   ===================================================== */

.num-cell-box {
    position: relative;
    width: 72px;
    height: 24px;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
    overflow: visible;
}

/* 數字框固定在正中央 */
.num-cell-box .grid-num-text {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);

    display: block;
    width: 25px;
    height: 24px;
    line-height: 22px;

    border: 1px solid #d5dce3;
    border-radius: 4px;
    background: #ffffff;

    color: #1f2d3d;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    box-sizing: border-box;

    z-index: 2;
}

/* 左右色點容器不參與排版，只貼在數字框旁邊 */
.num-cell-box .led-side {
    position: absolute;
    top: 0;
    height: 24px;

    display: flex;
    align-items: center;
    gap: 2px;

    z-index: 1;
}

/* 左邊色點：貼在數字框左側，且由左到右排列 */
.num-cell-box .led-left {
    right: calc(50% + 15px);
    flex-direction: row;
    justify-content: flex-end;
}

/* 右邊色點：貼在數字框右側，且由左到右排列 */
.num-cell-box .led-right {
    left: calc(50% + 15px);
    flex-direction: row;
    justify-content: flex-start;
}

/* 單顆色點 */
.num-cell-box .led {
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 1px;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
}

/* 舊版 led-row 不再使用 */
.num-cell-box .led-row {
    display: none;
}

/* 保險：舊灰點不顯示 */
.num-cell-box .led-gray {
    display: none;
}
/* =====================================================
   數據庫號碼區 A / B / C 欄位垂直分隔線
   只套用資料列，不套用標題列
   ===================================================== */

/* 資料列欄位之間加細垂直線 */
.data-grid-wrapper .grid-row-with-label {
    column-gap: 0;
}

/* 只在資料列的 B 欄、C 欄左側加線 */
.data-grid-wrapper .grid-row-with-label > :nth-child(3),
.data-grid-wrapper .grid-row-with-label > :nth-child(4) {
    border-left: 1px solid rgba(0, 0, 0, 0.28);
}

/* 讓資料格內容不要貼到線 */
.data-grid-wrapper .grid-row-with-label > div {
    padding-left: 3px;
    padding-right: 3px;
    box-sizing: border-box;
}
/* 開獎號碼區塊排版 */
.winning-number-area {
    text-align: center;
    margin-bottom: 7px;
}

.winning-number-title {
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
}

.winning-number-list {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 30px;
}
