* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft JhengHei', 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    flex: 1;
}

h1 {
    color: white;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    font-size: 2.5em;
}

h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
}

/* Navigation */
.nav-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.nav-links a {
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    transition: all 0.3s;
    font-weight: 500;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.nav-links a:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

.nav-links a.active {
    background: white;
    color: #667eea;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* Card */
.card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

/* Form */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 20px;
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 600;
}

input[type="number"],
input[type="text"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

small {
    display: block;
    margin-top: 5px;
    color: #888;
    font-size: 0.85em;
}

/* Buttons */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 100%;
    margin-top: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 10px 20px;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
}

/* Loading */
.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading-container {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 1.2em;
}

/* Result Card */
.result-card {
    background: linear-gradient(135deg, #e0f7e9 0%, #c8f0d6 100%);
    border-left: 5px solid #4caf50;
}

.result-summary {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.result-summary h3 {
    color: #4caf50;
    margin-bottom: 15px;
}

.result-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.info-label {
    font-weight: 600;
    color: #555;
}

.info-value {
    color: #333;
    font-weight: bold;
}

.yearly-data {
    background: white;
    padding: 20px;
    border-radius: 10px;
}

.yearly-data h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.year-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(72px, 11vw, 120px), 1fr));
    gap: clamp(6px, 1vw, 10px);
}

.year-item {
    padding: clamp(6px, 1vw, 10px);
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
    transition: transform 0.2s;
}

.year-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.year-label {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 5px;
    font-size: clamp(11px, 1.1vw, 14px);
}

.year-value {
    font-size: clamp(0.88rem, 1.4vw, 1.1rem);
    color: #333;
}

/* Error Card */
.error-card {
    background: #fee;
    border-left: 5px solid #f44336;
    padding: 20px;
}

.error-card h2,
.error-card h3 {
    color: #f44336;
}

/* Records Page */
.records-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-box input {
    flex: 1;
}

.records-stats {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.1em;
}

.record-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 15px;
    border-left: 4px solid #667eea;
    transition: all 0.3s;
}

.record-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.record-id {
    font-size: 1.2em;
    font-weight: bold;
    color: #667eea;
}

.record-time {
    color: #888;
    font-size: 0.9em;
}

.record-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.detail-item {
    padding: 8px;
    background: white;
    border-radius: 6px;
}

.detail-label {
    font-size: 0.85em;
    color: #888;
    margin-bottom: 3px;
}

.detail-value {
    font-weight: 600;
    color: #333;
}

.no-data {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.no-data p {
    margin: 10px 0;
}

.no-data a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.no-data a:hover {
    text-decoration: underline;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: white;
    margin-top: 40px;
}

footer p {
    margin: 5px 0;
    font-size: 0.9em;
}

#statusIndicator {
    font-weight: bold;
}

.status-healthy {
    color: #4caf50;
}

.status-error {
    color: #f44336;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    h1 {
        font-size: 1.8em;
    }

    .form-row {
        flex-direction: column;
    }

    .nav-links {
        flex-direction: column;
        align-items: stretch;
    }

    .nav-links a {
        text-align: center;
    }

    .records-header {
        flex-direction: column;
        align-items: stretch;
    }

    .year-grid {
        grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
        gap: 6px;
    }
}
