* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft JhengHei", "PingFang TC", sans-serif;
}

body {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.hidden { display: none !important; }

/* ========== 顏色 ========== */
.text-qian { color: #3b82f6; }
.text-kun { color: #d97706; }
.text-tong { color: #0891b2; }
.text-nv { color: #db2777; }

/* ========== 首頁 ========== */
.page-home-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-card {
    background: white;
    border-radius: 20px;
    padding: 50px 60px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 420px;
    width: 100%;
}

.home-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.home-title {
    font-size: 28px;
    font-weight: bold;
    color: #1f2937;
    margin-bottom: 10px;
}

.home-subtitle {
    font-size: 14px;
    color: #9ca3af;
    margin-bottom: 36px;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    transition: 0.3s;
    margin-bottom: 12px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102,126,234,0.4);
}

.btn-secondary {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    color: white;
    background: #374151;
    cursor: pointer;
    margin-bottom: 8px;
}

.btn-public {
    width: 100%;
    padding: 10px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    color: #374151;
    background: white;
    cursor: pointer;
    margin-bottom: 8px;
}

.btn-public:hover {
    border-color: #667eea;
    color: #667eea;
}

/* ========== 通用卡片 & 表單 ========== */
.page-container {
    min-height: calc(100vh - 40px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 480px;
}

.card h2 {
    font-size: 24px;
    color: #1f2937;
    margin-bottom: 28px;
    text-align: center;
}

.form-title {
    text-align: center;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 8px;
}

.required {
    color: #ef4444;
}

.form-input, .form-select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 15px;
    color: #374151;
    background: white;
    transition: 0.2s;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102,126,234,0.1);
}

.checkbox-group {
    display: flex;
    gap: 24px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
}

.form-btn-group {
    display: flex;
    gap: 12px;
    margin-top: 28px;
}

.btn-submit {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: #10b981;
    cursor: pointer;
    transition: 0.3s;
}

.btn-submit:hover {
    background: #059669;
}

.btn-clear {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 500;
    color: white;
    background: #9ca3af;
    cursor: pointer;
    transition: 0.3s;
}

.btn-clear:hover {
    background: #6b7280;
}

.success-tip {
    margin-top: 16px;
    padding: 12px;
    background: #dcfce7;
    color: #166534;
    border-radius: 10px;
    text-align: center;
    font-weight: 500;
}

.success-tip span {
    font-size: 12px;
    font-weight: normal;
    color: #4b5563;
}

.btn-back {
    display: block;
    margin-top: 20px;
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 14px;
}

.btn-back:hover {
    color: #374151;
}

.error-text {
    color: #ef4444;
    font-size: 13px;
    margin-bottom: 12px;
    text-align: center;
}

.btn-large {
    margin-top: 8px;
}

/* ========== 管理員後台 ========== */
.admin-page {
    max-width: 1100px;
    margin: 0 auto;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-header h2 {
    color: white;
    font-size: 22px;
}

.admin-actions {
    display: flex;
    gap: 10px;
}

.btn-outline {
    padding: 10px 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: 0.2s;
}

.btn-outline:hover {
    background: rgba(255,255,255,0.2);
}

.btn-dark {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
    color: white;
    cursor: pointer;
    font-size: 14px;
}

.btn-dark:hover {
    background: rgba(0,0,0,0.4);
}

.btn-red {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: #ef4444;
    color: white;
    cursor: pointer;
    font-size: 13px;
}

.btn-red:hover {
    background: #dc2626;
}

.btn-green {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: #22c55e;
    color: white;
    cursor: pointer;
    font-size: 13px;
}

.btn-green:hover {
    background: #16a34a;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

/* ========== 篩選 & CSV ========== */
.filter-box, .csv-box {
    background: white;
    padding: 14px 20px;
    border-radius: 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.filter-label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.csv-input {
    flex: 1;
    font-size: 13px;
}

/* ========== 權限設定 ========== */
.permission-box {
    background: white;
    padding: 14px 20px;
    border-radius: 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border: 2px solid #e0e7ff;
}

.perm-title {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

/* ========== 統計卡片 - 白色框格樣式 ========== */
.stat-card-overview {
    background: white;
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.stat-card-title {
    font-size: 15px;
    color: #374151;
    margin-bottom: 14px;
    text-align: center;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.stat-grid-small {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.stat-box {
    background: white;
    border-radius: 10px;
    padding: 12px 8px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.stat-num {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 4px;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: #6b7280;
}

.stat-box-mini {
    background: rgba(255,255,255,0.7);
    border-radius: 8px;
    padding: 8px 4px;
    text-align: center;
}

.stat-num-sm {
    display: block;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 2px;
}

.stat-label-sm {
    display: block;
    font-size: 11px;
    color: #6b7280;
}

/* ========== 三場次卡片 ========== */
.session-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.session-card {
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.session-title {
    font-size: 16px;
    margin-bottom: 14px;
}

.card-cyan {
    background: #e0f7fa;
    color: #0891b2;
}

.card-cyan .stat-box {
    background: white;
}

.card-yellow {
    background: #fff9c4;
    color: #d97706;
}

.card-yellow .stat-box {
    background: white;
}

.card-red {
    background: #ffebee;
    color: #dc2626;
}

.card-red .stat-box {
    background: white;
}

.meal-section {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed rgba(0,0,0,0.1);
}

.meal-section h4 {
    font-size: 13px;
    margin-bottom: 10px;
    font-weight: 500;
}

.attend-rate {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(0,0,0,0.1);
    font-size: 13px;
    font-weight: 500;
}

/* ========== 清空按鈕 ========== */
.clear-box {
    background: white;
    padding: 14px 20px;
    border-radius: 12px;
    margin-bottom: 16px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.clear-box .btn-outline {
    background: white;
    border: 1.5px solid #e5e7eb;
    color: #374151;
    padding: 8px 16px;
}

.clear-box .btn-outline:hover {
    border-color: #667eea;
    color: #667eea;
}

/* ========== 名單列表 ========== */
.list-section {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.list-title {
    font-size: 17px;
    color: #1f2937;
    margin-bottom: 16px;
}

.list-box {
    min-height: 150px;
}

.empty-tip {
    text-align: center;
    color: #9ca3af;
    padding: 40px 0;
    font-size: 14px;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #f3f4f6;
    flex-wrap: wrap;
    gap: 10px;
}

.list-item:last-child {
    border-bottom: none;
}

.list-info h5 {
    font-size: 15px;
    color: #1f2937;
    margin-bottom: 6px;
}

.list-info p {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.6;
}

.list-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ========== 簽到狀態 ========== */
.attendance-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 6px;
}

.attend-status {
    background: #dcfce7;
    color: #166534;
}

.absent-status {
    background: #fee2e2;
    color: #991b1b;
}

.pending-status {
    background: #f3f4f6;
    color: #6b7280;
}

.checkin-btn {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
}

.btn-checkin-yes {
    background: #dcfce7;
    color: #166534;
}

.btn-checkin-no {
    background: #fee2e2;
    color: #991b1b;
}

/* ========== 公開頁 ========== */
.public-card {
    max-width: 600px;
}

.public-header {
    text-align: center;
    margin-bottom: 24px;
}

.public-header h2 {
    color: #1f2937;
    margin-bottom: 8px;
}

.public-subtitle {
    color: #6b7280;
    font-size: 14px;
}

.public-stat {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.public-stat .stat-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    font-size: 14px;
}

.public-list {
    max-height: 400px;
    overflow-y: auto;
}

.public-footer {
    text-align: center;
    margin-top: 24px;
}

.public-footer .btn-secondary {
    width: auto;
    padding: 10px 28px;
}

/* ========== 彈窗 ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s;
}

.modal-box {
    background: white;
    border-radius: 16px;
    padding: 32px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    animation: slideUp 0.3s;
}

.modal-box h3 {
    font-size: 20px;
    color: #1f2937;
    margin-bottom: 12px;
}

.modal-box p {
    color: #6b7280;
    margin-bottom: 24px;
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-buttons .btn-outline, .modal-buttons .btn-primary {
    width: auto;
    min-width: 100px;
    margin-bottom: 0;
}

.modal-buttons .btn-outline {
    background: #f3f4f6;
    color: #374151;
    border: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ========== 登出成功頁 ========== */
.success-card {
    text-align: center;
}

.success-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.btn-group {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-group .btn-primary, .btn-group .btn-outline {
    flex: 1;
    margin-bottom: 0;
}

/* ========== 響應式 ========== */
@media (max-width: 768px) {
    .stat-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .stat-grid-small {
        grid-template-columns: repeat(2, 1fr);
    }
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .session-cards {
        grid-template-columns: 1fr;
    }
    .list-item {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 28px 24px;
    }
    .home-card {
        padding: 40px 30px;
    }
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}