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

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 480px) {
    .modal-content {
        padding: 25px 20px;
        max-width: 95%;
        border-radius: 12px;
        max-height: 85vh;
    }
    
    .modal-content h2 {
        font-size: 22px;
        margin-bottom: 20px;
    }
    
    .form-group {
        margin-bottom: 18px;
    }
    
    .form-group label {
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 14px;
        font-size: 16px;
    }
    
    .button-group {
        flex-direction: column;
        gap: 12px;
    }
    
    .button-group button {
        width: 100%;
        padding: 14px 20px;
        font-size: 16px;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content h2 {
    margin-bottom: 30px;
    color: #667eea;
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.form-group {
    margin-bottom: 20px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s ease;
    background: #fafafa;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: #b0b0b0;
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

button:hover::before {
    left: 100%;
}

button:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.btn-secondary:hover {
    box-shadow: 0 8px 25px rgba(108, 117, 125, 0.4);
}

.btn-secondary:active {
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.error {
    color: #dc3545;
    text-align: center;
    margin-top: 10px;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.button-group button {
    flex: 1;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.sidebar-header {
    padding: 30px 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 15px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.current-role-info {
    background: rgba(255, 255, 255, 0.15);
    padding: 12px 16px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.current-role-info span {
    font-size: 14px;
    font-weight: 500;
    display: block;
    text-align: center;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-nav button {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 14px 18px;
    border-radius: 10px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: none;
    border: 2px solid transparent;
    width: 100%;
}

.sidebar-nav button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(5px);
    box-shadow: none;
}

.sidebar-nav button.active {
    background: white;
    color: #667eea;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.sidebar-nav button span:not(.nav-icon) {
    display: inline;
    opacity: 1;
}

.sidebar-nav button::before {
    display: none;
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 20px 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-btn {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    padding: 12px 18px;
    border-radius: 8px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    box-shadow: none;
}

.sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateX(5px);
    box-shadow: none;
}

.sidebar-btn::before {
    display: none;
}

.logout-btn:hover {
    background: rgba(220, 53, 69, 0.8);
}

.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 30px;
    background: #f5f7fa;
    min-height: 100vh;
}

header {
    background: white;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
    color: #667eea;
    margin-bottom: 10px;
}

.header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-info span {
    font-weight: bold;
    color: #555;
}

nav {
    background: white;
    padding: 15px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

nav button {
    background: #f8f9fa;
    color: #333;
    padding: 10px 20px;
    border: 2px solid transparent;
}

nav button:hover {
    background: #e9ecef;
}

nav button.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

main {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.view {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.view h2 {
    color: #667eea;
    margin-bottom: 25px;
    font-size: 26px;
    font-weight: 700;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.view-toggle {
    display: flex;
    gap: 10px;
}

.view-toggle button {
    background: #f8f9fa;
    color: #333;
    padding: 10px 20px;
    font-size: 14px;
}

.view-toggle button.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.view-navigation {
    display: flex;
    align-items: center;
    gap: 15px;
}

.view-navigation button {
    background: #f8f9fa;
    color: #667eea;
    padding: 10px 15px;
    font-size: 18px;
    min-width: 45px;
}

.view-navigation button:hover {
    background: #e9ecef;
}

.view-navigation span {
    font-weight: 600;
    font-size: 18px;
    color: #333;
    min-width: 120px;
    text-align: center;
}

.calendar-content {
    min-height: 400px;
    margin-top: 10px;
}

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

.calendar-day-header {
    text-align: center;
    font-weight: 600;
    color: #667eea;
    padding: 12px;
    font-size: 14px;
}

.calendar-day {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    min-height: 110px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.calendar-day:hover {
    background: #e9ecef;
    border-color: #667eea;
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.calendar-day.checked-in {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.calendar-day.today {
    border: 3px solid #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.calendar-day-number {
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 8px;
}

.calendar-day-status {
    font-size: 12px;
    margin-top: 5px;
    font-weight: 500;
}

.week-view {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 15px;
}

.week-day {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.week-day:hover {
    background: #e9ecef;
    border-color: #667eea;
}

.week-day.checked-in {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.week-day-header {
    font-weight: bold;
    margin-bottom: 10px;
    text-align: center;
}

.week-day-content {
    font-size: 12px;
}

.week-day-content p {
    margin: 5px 0;
}

.role-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.role-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s;
}

.role-card:hover {
    transform: translateY(-5px);
}

.role-card h3 {
    margin-bottom: 10px;
}

.role-card p {
    margin: 5px 0;
    font-size: 14px;
}

.filter-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.filter-group label {
    font-weight: bold;
    color: #555;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.history-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-item-date {
    font-weight: bold;
    color: #667eea;
}

.history-item-actions {
    display: flex;
    gap: 10px;
}

.history-item-actions button {
    padding: 5px 10px;
    font-size: 12px;
}

.history-item-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.history-item-content p {
    margin: 5px 0;
    font-size: 14px;
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 35px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.stat-card h3 {
    font-size: 14px;
    margin-bottom: 12px;
    opacity: 0.95;
    font-weight: 500;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 700;
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 25px;
}

.chart-box {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease;
}

.chart-box:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.chart-box h3 {
    color: #667eea;
    margin-bottom: 20px;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
}

.role-manage-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.role-manage-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.role-manage-card h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.role-manage-card p {
    margin: 5px 0;
    font-size: 14px;
}

.role-manage-card .actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.role-manage-card .actions button {
    padding: 8px 16px;
    font-size: 14px;
}

@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    
    .main-content {
        margin-left: 240px;
    }
    
    .sidebar-header h1 {
        font-size: 20px;
    }
    
    .sidebar-nav button {
        padding: 12px 15px;
        font-size: 14px;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: sticky;
        top: 0;
        z-index: 100;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
        max-height: none;
    }
    
    .sidebar-header {
        padding: 15px 20px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .sidebar-header h1 {
        font-size: 18px;
        margin-bottom: 0;
    }
    
    .current-role-info {
        display: none;
    }
    
    .sidebar-nav {
        padding: 10px 15px;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .sidebar-nav button {
        flex: 1 1 calc(33.333% - 8px);
        min-width: calc(33.333% - 8px);
        text-align: center;
        justify-content: center;
        padding: 10px 8px;
        font-size: 13px;
    }
    
    .sidebar-nav button:hover {
        transform: translateY(-2px);
    }
    
    .sidebar-footer {
        flex-direction: row;
        padding: 10px 15px;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .sidebar-btn {
        flex: 1;
        text-align: center;
        justify-content: center;
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .sidebar-btn:hover {
        transform: translateY(-2px);
    }
    
    .main-content {
        margin-left: 0;
        padding: 15px;
        background: #f5f7fa;
        min-height: auto;
    }
    
    .view {
        padding: 15px;
    }
    
    .view h2 {
        font-size: 20px;
        margin-bottom: 15px;
    }
    
    .calendar-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: 5px;
    }

    .calendar-day {
        padding: 10px 5px;
        min-height: 80px;
    }

    .calendar-day-number {
        font-size: 14px;
    }

    .calendar-day-status {
        font-size: 10px;
    }

    .week-view {
        grid-template-columns: 1fr;
    }

    .charts-container {
        grid-template-columns: 1fr;
    }

    .header-info {
        flex-direction: column;
        gap: 10px;
    }

    nav {
        flex-direction: column;
    }

    nav button {
        width: 100%;
    }
    
    .modal-content {
        padding: 25px 20px;
        max-width: 95%;
    }
    
    .modal-content h2 {
        font-size: 24px;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .filter-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group label {
        margin-bottom: 5px;
    }
    
    .filter-group input,
    .filter-group button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .sidebar-nav {
        flex-direction: column;
    }
    
    .sidebar-nav button {
        min-width: 100%;
    }
    
    .sidebar-footer {
        flex-direction: column;
    }
    
    .view {
        padding: 15px 10px;
    }
    
    .view h2 {
        font-size: 20px;
        margin-bottom: 20px;
    }
    
    .stats-cards {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-card .value {
        font-size: 24px;
    }
    
    .role-card {
        padding: 15px;
    }
    
    .role-manage-card {
        padding: 15px;
    }
    
    .history-item {
        padding: 12px;
    }
    
    .history-item-content {
        grid-template-columns: 1fr;
    }
    
    .calendar-day {
        min-height: 60px;
        padding: 8px 3px;
    }
    
    .calendar-day-number {
        font-size: 12px;
    }
    
    .calendar-day-status {
        font-size: 9px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
        padding: 14px;
    }
    
    .form-group label {
        font-size: 13px;
        margin-bottom: 6px;
    }
    
    button {
        padding: 12px 20px;
        font-size: 15px;
    }
    
    .button-group {
        gap: 8px;
    }
    
    .filter-group {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .filter-group label {
        margin-bottom: 4px;
        font-size: 13px;
    }
    
    .filter-group input,
    .filter-group button {
        width: 100%;
        padding: 12px;
    }
    
    .view-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .view-toggle {
        width: 100%;
        justify-content: center;
    }
    
    .view-toggle button {
        flex: 1;
        text-align: center;
    }
    
    .view-navigation {
        width: 100%;
        justify-content: space-between;
    }
    
    .view-navigation span {
        font-size: 16px;
    }
    
    .charts-container {
        grid-template-columns: 1fr;
    }
    
    .chart-box {
        padding: 15px;
    }
    
    .chart-box h3 {
        font-size: 16px;
        margin-bottom: 15px;
    }
    
    .week-view {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .week-day {
        padding: 12px;
    }
    
    .week-day-content {
        font-size: 11px;
    }
    
    .week-day-content p {
        margin: 4px 0;
    }
}
