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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 0.95em;
    opacity: 0.85;
    margin-bottom: 10px;
    font-weight: 400;
    letter-spacing: 1px;
}

.date {
    font-size: 1.1em;
    opacity: 0.9;
}

main {
    padding: 30px;
}

section {
    margin-bottom: 40px;
}

h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
}

/* 区域标题 */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    margin-bottom: 0;
}

.toggle-add-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-size: 0.9em;
    min-width: auto;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.toggle-add-btn:hover {
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.4);
}

/* 添加项目表单 */
.add-project-form {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    animation: slideDown 0.3s ease;
}

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

.input-group {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

#projectName {
    flex: 1;
    min-width: 0;
    padding: 14px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1.05em;
    transition: all 0.3s ease;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

#projectName:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-1px);
}

#projectName::placeholder {
    color: #adb5bd;
}

button {
    padding: 14px 28px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    white-space: nowrap;
}

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

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

#addProjectBtn {
    min-width: 100px;
}

button.danger {
    background: #f44336;
}

button.danger:hover {
    background: #d32f2f;
}

/* 项目列表 */
.project-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.project-item {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: box-shadow 0.2s;
    border: 2px solid transparent;
    overflow: hidden;
    position: relative;
}

.project-item:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.project-item.active {
    background: #e8f5e9;
    border: 2px solid var(--project-color, #4caf50);
}

.project-color-bar {
    width: 100%;
    height: 4px;
    background: var(--project-color);
}

.project-info {
    flex: 1;
    padding: 12px 15px 0;
}

.project-name {
    font-size: 1em;
    font-weight: 600;
    color: #333;
    word-break: break-word;
}

.project-stats {
    font-size: 0.75em;
    color: #666;
    margin-top: 6px;
    line-height: 1.3;
}

.project-time {
    color: #333;
    font-size: 1.8em;
    font-weight: 700;
    margin-top: 8px;
}

.today-record-item .project-time {
    font-size: 1.5em;
    margin-top: 6px;
}

.project-controls {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 0 15px 12px;
}

.project-controls button {
    padding: 6px 12px;
    font-size: 0.85em;
    flex: 1;
    min-width: 60px;
}

.start-btn {
    background: #4caf50;
}

.start-btn:hover {
    background: #45a049;
}

.stop-btn {
    background: #ff9800;
}

.stop-btn:hover {
    background: #fb8c00;
}

.renew-btn {
    background: #2196f3;
}

.renew-btn:hover {
    background: #1976d2;
}

.delete-btn {
    background: #f44336;
}

.delete-btn:hover {
    background: #d32f2f;
}

/* 续期容器 - 框起来的版本 */
.renew-container {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    border: 2px solid;
    transition: all 0.3s ease;
}

.renew-container.renew-ok {
    background: #f1f8f4;
    border-color: #4caf50;
}

.renew-container.renew-warning {
    background: #fff8f0;
    border-color: #ff9800;
}

.renew-container.renew-urgent {
    background: #fff5f5;
    border-color: #f44336;
    animation: pulse 1.5s infinite;
}

.renew-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.renew-info-left {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex: 1;
}

.renew-countdown {
    font-size: 1.2em;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
}

.renew-ok .renew-countdown {
    color: #2e7d32;
}

.renew-warning .renew-countdown {
    color: #f57c00;
}

.renew-urgent .renew-countdown {
    color: #c62828;
}

.renew-hint {
    font-size: 0.7em;
    color: #666;
}

.renew-btn-inline {
    padding: 5px 12px;
    background: white;
    border: 2px solid;
    border-radius: 5px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.renew-ok .renew-btn-inline {
    border-color: #4caf50;
    color: #2e7d32;
}

.renew-ok .renew-btn-inline:hover {
    background: #4caf50;
    color: white;
}

.renew-warning .renew-btn-inline {
    border-color: #ff9800;
    color: #f57c00;
}

.renew-warning .renew-btn-inline:hover {
    background: #ff9800;
    color: white;
}

.renew-urgent .renew-btn-inline {
    border-color: #f44336;
    color: #c62828;
}

.renew-urgent .renew-btn-inline:hover {
    background: #f44336;
    color: white;
}

.renew-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.renew-progress-fill {
    height: 100%;
    transition: width 1s linear;
    border-radius: 3px;
}

.renew-ok .renew-progress-fill {
    background: #4caf50;
}

.renew-warning .renew-progress-fill {
    background: #ff9800;
}

.renew-urgent .renew-progress-fill {
    background: #f44336;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.01);
        opacity: 0.95;
    }
}

/* 今日记录 */
.today-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.today-record-item {
    background: #fff3e0;
    border-radius: 10px;
    padding: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.2s;
    border: 2px solid #ffb74d;
    overflow: hidden;
    position: relative;
}

.today-record-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.today-record-item.active {
    background: #e8f5e9;
    border: 2px solid var(--project-color, #4caf50);
}

.today-record-item .project-color-bar {
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
}

.today-record-item .project-info {
    flex: 1;
    padding: 14px 14px 14px 20px;
}

.today-record-item .project-controls {
    padding: 14px;
}

.today-record-item .project-controls.show-on-hover {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.today-record-item:hover .project-controls.show-on-hover {
    opacity: 1;
}

.continue-btn {
    background: #4caf50;
}

.continue-btn:hover {
    background: #45a049;
}

/* 统计 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
}

.stat-label {
    font-size: 0.9em;
    opacity: 0.9;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 1.8em;
    font-weight: 700;
}

/* 历史记录 */
.history-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
}

.history-item {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
}

.history-item:last-child {
    border-bottom: none;
}

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

.history-details {
    color: #666;
    font-size: 0.95em;
}

.history-project-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #999;
}

.empty-state p {
    font-size: 1.1em;
}

/* Toast提示 */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-size: 0.95em;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* 自定义弹框 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal-content {
    transform: scale(1);
}

.modal-title {
    font-size: 1.4em;
    color: #333;
    margin-bottom: 12px;
    font-weight: 600;
}

.modal-message {
    font-size: 1em;
    color: #666;
    line-height: 1.6;
    margin-bottom: 24px;
    white-space: pre-line;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

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

.modal-btn-primary.danger {
    background: #f44336;
}

.modal-btn-primary.danger:hover {
    background: #d32f2f;
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

.modal-btn-secondary {
    background: #e0e0e0;
    color: #666;
}

.modal-btn-secondary:hover {
    background: #d0d0d0;
    transform: translateY(-1px);
}

/* 响应式 */
@media (max-width: 768px) {
    .project-list {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .container {
        border-radius: 12px;
    }

    header h1 {
        font-size: 2em;
    }

    main {
        padding: 20px;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .toggle-add-btn {
        width: 100%;
    }

    .add-project-form {
        padding: 15px;
    }

    .input-group {
        flex-direction: column;
        gap: 10px;
    }

    #addProjectBtn {
        width: 100%;
    }

    .project-list {
        grid-template-columns: 1fr;
    }

    .today-record-item {
        flex-direction: column;
        align-items: stretch;
    }

    .today-record-item .project-info {
        padding: 15px 15px 15px 24px;
    }

    .today-record-item .project-controls {
        padding: 0 15px 15px;
    }

    .renew-top {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .renew-info-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .renew-btn-inline {
        width: 100%;
    }

    .history-controls {
        flex-direction: column;
    }

    .history-controls button {
        width: 100%;
    }
}
