* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft JhengHei', '微軟正黑體', Arial, sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
}

/* 導航列 */
.top-nav {
    background: #667eea;
    padding: 0 30px;
    display: flex;
    gap: 0;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.top-nav a {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.top-nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.top-nav a.active {
    color: #fff;
    border-bottom-color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* 登入畫面 */
.login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 49px);
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    text-align: center;
}

.login-card h1 {
    color: #333;
    font-size: 1.8em;
    margin-bottom: 8px;
    border-bottom: none;
    padding-bottom: 0;
}

.login-subtitle {
    color: #888;
    margin-bottom: 32px;
    font-size: 15px;
}

.login-form .form-group {
    text-align: left;
    margin-bottom: 16px;
}

.login-form .form-group label {
    display: block;
    margin-bottom: 6px;
    color: #555;
    font-weight: 600;
    font-size: 14px;
}

.login-form input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
    outline: none;
}

.login-form input[type="text"]:focus {
    border-color: #667eea;
}

.btn-login {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-top: 8px;
}

.user-list {
    margin-bottom: 16px;
}

.user-list-label {
    font-size: 13px;
    color: #888;
    margin-bottom: 8px;
    text-align: left;
}

.user-chip {
    display: inline-block;
    padding: 6px 16px;
    background: #f0f2ff;
    color: #667eea;
    border-radius: 20px;
    margin: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.user-chip:hover {
    background: #667eea;
    color: #fff;
}

/* 主畫面 */
.main-screen {
    padding: 20px;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
}

/* 頂部資訊列 */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border-radius: 12px;
    padding: 16px 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-icon {
    font-size: 28px;
}

.user-name {
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.top-bar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* 今日狀態 */
.today-status {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 20px 28px;
    margin-bottom: 20px;
    color: white;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

.today-date {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.today-records {
    font-size: 15px;
    opacity: 0.95;
    line-height: 1.8;
}

/* 通用元件 */
.section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.2em;
    border-left: 4px solid #667eea;
    padding-left: 12px;
    font-weight: 700;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    font-family: inherit;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

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

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-clock {
    background: #28a745;
    color: white;
    font-size: 15px;
    padding: 10px 24px;
}

.btn-clock:hover {
    background: #218838;
    transform: translateY(-1px);
}

.btn-clock-out {
    background: #fd7e14;
}

.btn-clock-out:hover {
    background: #e8690b;
}

.btn-clock:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* 日曆 */
.calendar-section h2 {
    border-left: none;
    padding-left: 0;
    text-align: center;
    margin-bottom: 0;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
}

.calendar-header h2 {
    min-width: 180px;
    text-align: center;
    font-size: 1.3em;
    margin-bottom: 0;
}

.btn-nav {
    background: none;
    border: 2px solid #667eea;
    color: #667eea;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    padding: 0;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.btn-nav:hover {
    background: #667eea;
    color: white;
}

.btn-today {
    background: #f0f2ff;
    color: #667eea;
    border: 1px solid #667eea;
    padding: 6px 14px;
    font-size: 13px;
}

.btn-today:hover {
    background: #667eea;
    color: white;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 4px;
}

.weekday {
    text-align: center;
    font-weight: 700;
    font-size: 13px;
    color: #666;
    padding: 8px 0;
}

.weekday.sun { color: #dc3545; }
.weekday.sat { color: #007bff; }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    position: relative;
    aspect-ratio: 1;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    border: 2px solid transparent;
    min-height: 64px;
    padding: 4px 2px;
}

.calendar-day:hover {
    border-color: #667eea;
    transform: scale(1.05);
    z-index: 2;
}

.calendar-day.empty {
    cursor: default;
    background: transparent;
}

.calendar-day.empty:hover {
    border-color: transparent;
    transform: none;
}

.day-number {
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 2px;
}

.day-label {
    font-size: 9px;
    line-height: 1.1;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.day-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: absolute;
    top: 5px;
    right: 5px;
}

/* 日曆日期狀態色 */
.calendar-day.today {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.calendar-day.weekend {
    background: #f8f9fa;
}

.calendar-day.weekend .day-number {
    color: #999;
}

.calendar-day.sunday .day-number { color: #dc3545; }
.calendar-day.saturday .day-number { color: #007bff; }

.calendar-day.holiday {
    background: #fff5f5;
}

.calendar-day.holiday .day-number {
    color: #dc3545;
}

.calendar-day.holiday .day-label {
    color: #dc3545;
    font-weight: 600;
}

.calendar-day.present {
    background: #e8f5e9;
}

.calendar-day.present .day-status {
    background: #28a745;
}

.calendar-day.makeup-day {
    background: #fff8e1;
}

.calendar-day.makeup-day .day-status {
    background: #ff9800;
}

.calendar-day.absent-day {
    background: #ffebee;
}

.calendar-day.absent-day .day-status {
    background: #dc3545;
}

.calendar-day.future {
    opacity: 0.5;
}

.calendar-day .day-time {
    font-size: 8px;
    color: #666;
    line-height: 1.1;
    margin-top: 1px;
}

/* 圖例 */
.legend {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #666;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.dot-present { background: #28a745; }
.dot-makeup { background: #ff9800; }
.dot-absent { background: #dc3545; }
.dot-holiday { background: #dc3545; opacity: 0.4; }
.dot-weekend { background: #ccc; }
.dot-future { background: #e0e0e0; }

/* 統計卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.stat-card {
    text-align: center;
    padding: 20px 12px;
    border-radius: 12px;
    background: #f8f9fa;
    border: 1px solid #e8e8e8;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card.present { background: #e8f5e9; border-color: #c8e6c9; }
.stat-card.absent { background: #ffebee; border-color: #ffcdd2; }
.stat-card.makeup { background: #fff8e1; border-color: #ffecb3; }
.stat-card.holiday { background: #fce4ec; border-color: #f8bbd0; }
.stat-card.rate { background: #e3f2fd; border-color: #bbdefb; }

.stat-number {
    font-size: 2em;
    font-weight: 800;
    color: #333;
    line-height: 1.2;
}

.stat-card.present .stat-number { color: #28a745; }
.stat-card.absent .stat-number { color: #dc3545; }
.stat-card.makeup .stat-number { color: #ff9800; }
.stat-card.holiday .stat-number { color: #e91e63; }
.stat-card.rate .stat-number { color: #1976d2; }

.stat-label {
    font-size: 13px;
    color: #666;
    margin-top: 4px;
    font-weight: 600;
}

/* 出勤明細表 */
.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.detail-table th,
.detail-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.detail-table th {
    background: #667eea;
    color: white;
    font-weight: 600;
    border-bottom: none;
    position: sticky;
    top: 0;
}

.detail-table th:first-child {
    border-radius: 8px 0 0 0;
}

.detail-table th:last-child {
    border-radius: 0 8px 0 0;
}

.detail-table tbody tr:hover {
    background: #f8f9ff;
}

.detail-table .status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.present { background: #e8f5e9; color: #28a745; }
.status-badge.absent { background: #ffebee; color: #dc3545; }
.status-badge.makeup { background: #fff8e1; color: #ff9800; }
.status-badge.holiday { background: #fce4ec; color: #e91e63; }
.status-badge.weekend { background: #f5f5f5; color: #999; }
.status-badge.future { background: #f5f5f5; color: #bbb; }

.btn-edit {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.btn-edit:hover {
    background: #5568d3;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 440px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    font-size: 18px;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 24px;
}

.modal-body .form-group {
    margin-bottom: 16px;
}

.modal-body .form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #555;
    font-size: 14px;
}

.modal-body input[type="time"],
.modal-body input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.modal-body input:focus {
    border-color: #667eea;
}

/* 狀態選擇器 */
.status-selector {
    display: flex;
    gap: 12px;
}

.status-option {
    flex: 1;
    cursor: pointer;
}

.status-option input[type="radio"] {
    display: none;
}

.status-option-label {
    display: block;
    text-align: center;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    border: 2px solid #e0e0e0;
    transition: all 0.2s;
}

.status-option-label.present {
    color: #28a745;
}

.status-option-label.makeup {
    color: #ff9800;
}

.status-option input[type="radio"]:checked + .status-option-label.present {
    background: #e8f5e9;
    border-color: #28a745;
}

.status-option input[type="radio"]:checked + .status-option-label.makeup {
    background: #fff8e1;
    border-color: #ff9800;
}

.modal-date {
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 16px;
    text-align: center;
    padding: 10px;
    background: #f0f2ff;
    border-radius: 8px;
}

.modal-existing {
    font-size: 14px;
    color: #666;
    margin-bottom: 16px;
    line-height: 1.8;
    text-align: center;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* 響應式 */
@media (max-width: 768px) {
    .top-bar {
        flex-direction: column;
        gap: 12px;
    }

    .top-bar-actions {
        width: 100%;
        justify-content: center;
    }

    .calendar-day {
        min-height: 48px;
    }

    .day-number {
        font-size: 13px;
    }

    .day-label {
        font-size: 7px;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .detail-table {
        font-size: 12px;
    }

    .detail-table th,
    .detail-table td {
        padding: 8px 6px;
    }

    .legend {
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .calendar-day {
        min-height: 40px;
        border-radius: 6px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .top-nav {
        padding: 0 10px;
    }

    .top-nav a {
        padding: 12px 14px;
        font-size: 13px;
    }
}
