/* 設計系統：舒適閱讀、高對比、穩定 hover、鍵盤 focus 可見 */
:root {
    font-family: 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
    color: #0F172A;
    line-height: 1.65;
    --color-text: #0F172A;
    --color-text-muted: #475569;
    --color-border: #E2E8F0;
    --color-bg-soft: #F8FAFC;
    --color-bg-card: #FFFFFF;
    --color-primary: #2563EB;
    --color-primary-hover: #1D4ED8;
    --transition-ui: 0.2s ease;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-color: #E0F2FE;
    background-image: url('./background.png'),
        linear-gradient(160deg, #F0F9FF 0%, #E0F2FE 50%, #BAE6FD 100%);
    background-size: cover, 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
}

.hero {
    width: min(1200px, 95%);
    padding: 2rem 1rem;
}

.clock-card {
    background: var(--color-bg-card);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--color-border);
    text-align: center;
    transition: box-shadow var(--transition-ui), border-color var(--transition-ui);
}

.clock-card:hover {
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 4px 10px -4px rgba(0, 0, 0, 0.04);
}

.clock-card h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 1rem;
}

.clock-card .label {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

#date-display {
    font-size: clamp(1.875rem, 4.5vw, 3.5rem);
    margin: 0.25rem 0;
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

#time-display {
    font-size: clamp(1.75rem, 4vw, 3rem);
    margin: 0.25rem 0 2rem;
    font-weight: 500;
    color: var(--color-text);
}

.code-label {
    font-size: 1.125rem;
    font-weight: 600;
    margin-right: 0.5rem;
    color: var(--color-text);
}

#code-input {
    width: 300px;
    max-width: 80%;
    font-size: 1.125rem;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: 12px;
    margin-top: 0.5rem;
    text-align: center;
    background: var(--color-bg-card);
    color: var(--color-text);
    transition: border-color var(--transition-ui), box-shadow var(--transition-ui);
}

#code-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

#code-status {
    margin-top: 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.9375rem;
    min-height: 1.2rem;
}

#code-status.error {
    color: #dc2626;
}

.actions {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin: 2rem 0 1rem;
    flex-wrap: wrap;
}

.actions button {
    position: relative;
    display: inline-block;
    width: 180px;
    margin: 0;
    padding: 15px 30px;
    text-align: center;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: white;
    cursor: pointer;
    transition: background-color var(--transition-ui), box-shadow var(--transition-ui), opacity var(--transition-ui);
    border: 2px solid transparent;
    border-radius: 999px;
}

.actions button:hover {
    color: white;
    opacity: 0.95;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.actions button:active {
    opacity: 0.9;
}

.actions button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.6), 0 0 0 5px rgba(37, 99, 235, 0.25);
}

@media (prefers-reduced-motion: reduce) {
    .actions button {
        transition: none;
    }

    .actions button:hover {
        transform: none;
    }

    .actions button:active {
        transform: none;
    }
}

.actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.actions button.primary:disabled:hover,
.actions button.secondary:disabled:hover,
.actions button.tertiary:disabled:hover,
.actions button.quaternary:disabled:hover {
    transform: none;
    box-shadow: none;
}

.actions button.primary:disabled:hover {
    color: white;
}

.actions button.secondary:disabled:hover {
    color: white;
}

.actions button.tertiary:disabled:hover {
    color: white;
}

.actions button.quaternary:disabled:hover {
    color: white;
}

.actions button.primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.actions button.primary:hover {
    box-shadow: inset 0 -100px 0 0 rgba(0, 0, 0, 0.15);
}

.actions button.secondary {
    background: #ff944d;
    border-color: #ff944d;
}

.actions button.secondary:hover {
    box-shadow: inset 0 -100px 0 0 rgba(0, 0, 0, 0.15);
}

.actions button.tertiary {
    background: #10b981;
    border-color: #10b981;
}

.actions button.tertiary:hover {
    box-shadow: inset 0 -100px 0 0 rgba(0, 0, 0, 0.15);
}

.actions button.quaternary {
    background: #8b5cf6;
    border-color: #8b5cf6;
}

.actions button.quaternary:hover {
    box-shadow: inset 0 -100px 0 0 rgba(0, 0, 0, 0.15);
}

.back-btn {
    background: #64748B;
    color: white;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: background-color var(--transition-ui), box-shadow var(--transition-ui);
}

.back-btn:hover {
    background: #475569;
}

.back-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.4);
}

@media (prefers-reduced-motion: reduce) {
    .back-btn {
        transition: none;
    }
}

.info-text {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    margin: 0.5rem 0;
}

.info-text.error {
    color: #dc2626;
}

form {
    text-align: left;
    max-width: 500px;
    margin: 0 auto;
}

form label {
    display: block;
    margin: 1rem 0 0.5rem;
    font-weight: 600;
    color: var(--color-text);
    font-size: 0.9375rem;
}

form input,
form select,
form textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-bg-card);
    transition: border-color var(--transition-ui), box-shadow var(--transition-ui);
}

form input:focus,
form select:focus,
form textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

@media (prefers-reduced-motion: reduce) {

    form input,
    form select,
    form textarea {
        transition: none;
    }
}

form textarea {
    resize: vertical;
    min-height: 80px;
}

/* 請假時間：起始～到期同一行 */
.leave-time-label {
    display: block;
    margin: 1rem 0 0.5rem;
    font-weight: 600;
}

.leave-time-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.leave-time-row input[type="time"],
.leave-time-row select {
    flex: 1;
    min-width: 0;
    width: 100%;
}

.leave-time-sep {
    color: var(--color-text-muted);
    font-weight: 600;
    flex-shrink: 0;
    padding: 0 0.25rem;
}

.leave-time-hint {
    margin-top: 0.35rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* 補班/補休選單（首頁兩個按鈕） */
.makeup-menu {
    margin-top: 1.5rem;
    text-align: center;
}

.makeup-menu-hint {
    margin: 0 0 1.25rem;
    color: var(--color-text);
    font-size: 1.1rem;
    font-weight: 600;
}

.makeup-menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 280px;
    margin: 0 auto;
}

.makeup-menu-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 999px;
    border: 2px solid var(--color-primary);
    background: transparent;
    color: var(--color-primary);
    cursor: pointer;
    transition: background var(--transition-ui), color var(--transition-ui), box-shadow var(--transition-ui);
}

.makeup-menu-btn:hover {
    background: #2b7df1;
    color: #fff;
    box-shadow: 0 4px 12px rgba(43, 125, 241, 0.25);
}

.makeup-menu-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(43, 125, 241, 0.35);
}

.makeup-menu-btn-work {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.makeup-menu-btn-work:hover {
    background: var(--color-primary);
    color: #fff;
}

.makeup-menu-btn-leave {
    border-color: #10b981;
    color: #10b981;
}

.makeup-menu-btn-leave:hover {
    background: #10b981;
    color: #fff;
}

/* 補班/補休子畫面（登記表單＋記錄） */
.makeup-view {
    margin-top: 1rem;
    text-align: left;
}

/* 補班/補休頁區塊 */
.makeup-section {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
    text-align: left;
}

.makeup-section:first-of-type {
    margin-top: 1.5rem;
    padding-top: 0;
    border-top: none;
}

.makeup-section-title {
    font-size: 1.25rem;
    margin: 0 0 1rem;
    color: var(--color-text);
    font-weight: 600;
    text-align: center;
}

.records-subtitle {
    font-size: 1.0625rem;
    margin: 1.5rem 0 0.75rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.records-wrap {
    overflow-x: auto;
    margin-bottom: 0.5rem;
}

.records-wrap table {
    min-width: 320px;
}

form button[type="submit"] {
    margin-top: 1.5rem;
    width: 100%;
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    font-size: 1.0625rem;
    font-weight: 600;
    cursor: pointer;
    transition: box-shadow var(--transition-ui), background-color var(--transition-ui);
    color: #fff;
    background: var(--color-primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

form button[type="submit"]:hover {
    box-shadow: 0 6px 20px rgba(43, 125, 241, 0.35);
    background: var(--color-primary-hover);
}

form button[type="submit"]:active {
    box-shadow: 0 2px 8px rgba(43, 125, 241, 0.3);
}

form button[type="submit"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5), 0 0 0 5px rgba(37, 99, 235, 0.3);
}

.status-pending {
    color: #f59e0b;
}

.status-approved {
    color: #10b981;
}

.status-rejected {
    color: #dc2626;
}

.message {
    min-height: 1.25rem;
    font-weight: 600;
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    /* 保留換行符號 */
}

.message.success-in {
    color: var(--color-primary);
}

.message.success-out {
    color: #ff7a1a;
}

.message.error {
    color: #dc2626;
}

.records {
    margin-top: 2rem;
    text-align: left;
}

.records h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
}

table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 15px;
    overflow: hidden;
}

thead {
    background: #F1F5F9;
    border-bottom: 2px solid var(--color-border);
}

th,
td {
    padding: 0.875rem 1rem;
    text-align: left;
    color: var(--color-text);
}

th {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--color-text-muted);
}

tbody tr:nth-child(odd) {
    background: #FAFBFC;
}

tbody tr:nth-child(even) {
    background: var(--color-bg-card);
}

tbody tr:hover {
    background: #F1F5F9;
}

.empty {
    text-align: center;
    color: var(--color-text-muted);
    font-style: italic;
    padding: 1.5rem;
}

/* 管理員介面樣式 */
.admin-page {
    background: linear-gradient(160deg, #F0F9FF 0%, #E0F2FE 50%, #BAE6FD 100%);
    background-attachment: fixed;
    min-height: 100vh;
}

/* 頂部選單：固定、極緊湊高度，與頁面同背景、與下方內容同寬 */
.admin-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 0.25rem 0 0.2rem;
    background: linear-gradient(160deg, #F0F9FF 0%, #E0F2FE 50%, #BAE6FD 100%);
}

.admin-nav-wrap {
    width: min(1200px, 95%);
    margin: 0 auto;
    padding: 0 1rem;
}

.admin-nav-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.2rem;
    padding: 0.35rem 0.5rem;
    background: rgba(224, 242, 254, 0.95);
    border: 1px solid rgba(186, 230, 253, 0.8);
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

/* 導出 Excel：與刷新列表等按鈕一致，圓角、藍底白字 */
.admin-nav-export,
button.admin-nav-export.primary {
    margin-left: auto;
    padding: 0.45rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    border: none !important;
    border-radius: 10px !important;
    cursor: pointer;
    background: var(--color-primary) !important;
    color: #fff !important;
    transition: opacity 0.2s ease, box-shadow 0.2s ease;
}

.admin-nav-export:hover {
    opacity: 0.95;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.admin-nav-export:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.4);
}

.admin-nav-export:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.admin-nav-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.admin-nav-tab:hover {
    color: var(--color-text);
    background: rgba(37, 99, 235, 0.06);
}

.admin-nav-tab:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-primary);
}

.admin-nav-tab.active {
    color: var(--color-primary);
    background: rgba(37, 99, 235, 0.12);
}

.admin-nav-tab.active::after {
    content: '';
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.15rem;
    height: 2px;
    background: var(--color-primary);
    border-radius: 1px;
}

.admin-nav-icon {
    width: 1.1rem;
    height: 1.1rem;
    flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
    .admin-nav-tab {
        transition: none;
    }
}

/* 內容面板：僅顯示當前選中 */
.admin-panel {
    display: none;
}

.admin-panel.active {
    display: block;
}

.container {
    width: min(1200px, 95%);
    padding: 2rem 1rem;
    margin: 0 auto;
}

/* 管理員頁：內容緊貼選單，留白最小（用 px 避免 rem 被放大） */
.admin-page .container.admin-page-content {
    margin-top: 46px !important;
    padding-top: 4px !important;
    padding-bottom: 1rem;
}

.admin-page .admin-panel {
    margin-top: 0;
    padding-top: 0;
}

.admin-page .card {
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.admin-page .card:first-child {
    margin-top: 0;
}

.admin-page .card h1,
.admin-page .card h2 {
    margin-top: 0;
    margin-bottom: 0.75rem;
}

.card {
    background: var(--color-bg-card);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--color-border);
    overflow: visible;
    min-width: 0;
    transition: box-shadow var(--transition-ui);
}

.card:hover {
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.06), 0 4px 10px -4px rgba(0, 0, 0, 0.04);
}

.card h1,
.card h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--color-text);
    font-weight: 600;
}

.card form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.card label {
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
}

.card input,
.card select,
.card textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: 10px;
    font-size: 1rem;
    color: var(--color-text);
    transition: border-color var(--transition-ui), box-shadow var(--transition-ui);
}

.card input:focus,
.card select:focus,
.card textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.card button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: box-shadow var(--transition-ui), opacity var(--transition-ui);
}

.card button.primary {
    background: var(--color-primary);
    color: #fff;
}

.card button.secondary {
    background: #64748B;
    color: #fff;
}

.card button:hover {
    opacity: 0.95;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.card button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.card button.hidden {
    display: none;
}

.message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 500;
}

.message.error {
    background: #fee2e2;
    color: #dc2626;
}

.calendar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: flex-end;
}

.calendar label {
    display: block;
    margin-bottom: 0.5rem;
}

.calendar input,
.calendar button {
    flex: 1;
    min-width: 150px;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

.table-actions button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.table-actions button[data-action="edit"] {
    background: var(--color-primary);
    color: #fff;
}

.table-actions button[data-action="delete"] {
    background: #dc2626;
    color: #fff;
}

.table-actions button:hover {
    opacity: 0.9;
}

.table-actions button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

/* 請假申請管理過濾器樣式 */
.leave-filter-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
    box-sizing: border-box;
}

.leave-filter-options {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    flex-direction: row;
    overflow: visible;
}

.filter-label {
    margin: 0;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: max-content;
    max-width: 100%;
    overflow: visible;
    text-overflow: clip;
}

.filter-label input[type="radio"] {
    vertical-align: middle;
    margin: 0;
    flex-shrink: 0;
    width: auto;
}

.filter-label span {
    display: inline-block;
    vertical-align: middle;
    white-space: nowrap;
    word-break: keep-all;
    overflow: visible;
    text-overflow: clip;
    max-width: none;
    width: auto;
}

.refresh-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* 響應式設計 */
@media (max-width: 768px) {

    /* 主頁面手機優化 */
    .hero {
        width: 100%;
        padding: 1rem 0.5rem;
    }

    .clock-card {
        border-radius: 30px;
        padding: 1.5rem;
    }

    .clock-card .label {
        font-size: 1rem;
    }

    #date-display {
        font-size: 1.8rem;
    }

    #time-display {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .code-label {
        font-size: 1.1rem;
    }

    #code-input {
        width: 100%;
        max-width: 100%;
        font-size: 16px;
        /* 防止 iOS 自動縮放 */
        padding: 0.75rem;
    }

    .actions {
        flex-direction: column;
        gap: 1rem;
        margin: 1.5rem 0;
    }

    .actions button {
        width: 100%;
        padding: 1rem;
        font-size: 1.1rem;
    }

    .records {
        margin-top: 1.5rem;
    }

    .records h3 {
        font-size: 1.2rem;
    }

    /* 表格改為可橫向滾動 */
    .records {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .records table {
        min-width: 500px;
        font-size: 0.9rem;
    }

    .records th,
    .records td {
        padding: 0.6rem 0.5rem;
        white-space: nowrap;
    }

    /* 管理員介面手機優化 */
    .container {
        padding: 1rem 0.5rem;
    }

    .card {
        padding: 1.5rem;
        border-radius: 15px;
        margin-bottom: 1.5rem;
        overflow-x: auto;
        overflow-y: visible;
        /* 確保垂直方向內容不被截斷 */
    }

    .card h1 {
        font-size: 1.5rem;
    }

    .card h2 {
        font-size: 1.25rem;
    }

    /* 請假申請管理過濾器優化 */
    .leave-filter-container {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .leave-filter-container {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        width: 100%;
        box-sizing: border-box;
    }

    .leave-filter-options {
        width: 100%;
        flex-wrap: wrap;
        gap: 1rem;
        justify-content: flex-start;
        overflow: visible;
        display: flex;
        align-items: center;
        box-sizing: border-box;
    }

    .filter-label {
        font-size: 1rem;
        flex: none;
        white-space: nowrap;
        word-break: keep-all;
        overflow: visible;
        text-overflow: clip;
        min-width: max-content;
        width: auto;
        max-width: 100%;
        box-sizing: border-box;
        padding: 0.25rem 0;
    }

    .filter-label input[type="radio"] {
        flex-shrink: 0;
        margin-right: 0.5rem;
    }

    .filter-label span {
        white-space: nowrap;
        word-break: keep-all;
        overflow: visible;
        text-overflow: clip;
        max-width: none;
        width: auto;
        display: inline;
        box-sizing: border-box;
    }

    .refresh-btn {
        width: 100%;
        margin-top: 0;
    }

    /* 所有表格改為可橫向滾動 */
    .card>div[style*="overflow-x: auto"] {
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 700px;
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 0.6rem 0.5rem;
        white-space: nowrap;
    }

    /* 表單優化 */
    .card form {
        gap: 0.75rem;
    }

    .card input,
    .card select,
    .card textarea {
        font-size: 16px;
        /* 防止 iOS 自動縮放 */
        width: 100%;
    }

    /* 查詢區域優化 */
    .calendar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .calendar label {
        margin-bottom: 0.25rem;
    }

    .calendar input,
    .calendar button {
        width: 100%;
        min-width: auto;
    }

    /* 按鈕優化 */
    .card button {
        width: 100%;
        padding: 0.875rem;
    }

    .table-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .table-actions button {
        width: 100%;
        padding: 0.6rem;
    }

    /* 請假時間列：小螢幕保持同一行，縮小間距 */
    .leave-time-row {
        gap: 0.5rem;
    }

    /* 請假申請頁面優化 */
    form {
        max-width: 100%;
    }

    .back-btn {
        width: 100%;
        padding: 0.75rem;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 0.5rem;
    }

    .clock-card {
        padding: 1.25rem;
        border-radius: 20px;
    }

    #date-display {
        font-size: 1.5rem;
    }

    #time-display {
        font-size: 1.3rem;
    }

    .container {
        padding: 0.5rem;
    }

    .card {
        padding: 1rem;
        border-radius: 12px;
    }

    .card h1 {
        font-size: 1.3rem;
    }

    .card h2 {
        font-size: 1.1rem;
    }

    table {
        min-width: 600px;
        font-size: 0.8rem;
    }

    th,
    td {
        padding: 0.5rem 0.4rem;
        font-size: 0.8rem;
    }

    .actions button {
        font-size: 1rem;
        padding: 0.875rem;
    }

    .message {
        font-size: 0.9rem;
        padding: 0.625rem;
        word-break: break-word;
    }

    /* 請假申請管理過濾器在更小螢幕上優化 */
    .filter-label {
        font-size: 0.9rem;
        gap: 0.5rem;
        white-space: nowrap;
        word-break: keep-all;
        overflow: visible;
        flex-shrink: 0;
    }

    .filter-label span {
        white-space: nowrap;
        word-break: keep-all;
        overflow: visible;
        text-overflow: clip;
    }

    .leave-filter-options {
        gap: 0.75rem;
        flex-wrap: wrap;
        overflow: visible;
    }
}

/* 確保所有表格在手機上可以橫向滾動 */
@media (max-width: 768px) {

    /* 所有包含表格的容器都應該可橫向滾動 */
    .records,
    .card>div[style*="overflow-x: auto"],
    section.card>div[style*="overflow-x: auto"] {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        margin: 0 -1.5rem;
        padding: 0 1.5rem;
    }

    /* 確保表格容器不會溢出 */
    .card {
        overflow: visible;
    }

    /* 防止文字溢出 */
    th,
    td {
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;
    }

    /* 操作列保持較小寬度 */
    .table-actions {
        min-width: 120px;
    }
}

/* 更小的手機螢幕優化 */
@media (max-width: 360px) {
    .clock-card {
        padding: 1rem;
    }

    #date-display {
        font-size: 1.3rem;
    }

    #time-display {
        font-size: 1.1rem;
    }

    .actions button {
        font-size: 0.95rem;
        padding: 0.75rem;
    }

    table {
        min-width: 550px;
        font-size: 0.75rem;
    }

    th,
    td {
        padding: 0.4rem 0.3rem;
    }
}