:root {
    --primary-color: #667eea;
    --primary-dark: #5a67d8;
    --secondary-color: #764ba2;
    --accent-color: #ff7e5f;
    --success-color: #48bb78;
    --danger-color: #f56565;
    --warning-color: #ed8936;
    --text-color: #2d3748;
    --text-light: #718096;
    --bg-color: #f7fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    min-height: 100vh;
    line-height: 1.6;
    color: var(--text-color);
}

/* Login Page */
.page {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.page.active {
    display: block;
}

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

.login-container {
    max-width: 420px;
    margin: 10vh auto;
    background: var(--card-bg);
    padding: 3rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.login-container h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
    font-size: 1.75rem;
    font-weight: 700;
}

/* Dashboard */
header {
    background: var(--card-bg);
    padding: 1rem 2rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.9);
}

header h1 {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.badge {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 0.35rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

/* Tabs */
.tabs {
    background: var(--card-bg);
    padding: 0 2rem;
    display: flex;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
}

.tabs::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.tab-btn {
    background: none;
    border: none;
    padding: 1rem 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-weight: 500;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Tab Content */
.tab-content {
    display: none;
    max-width: 1200px;
    margin: 2rem auto;
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    animation: slideUp 0.3s ease-out;
}

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

.tab-content.active {
    display: block;
}

.tab-content h2 {
    color: var(--text-color);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 1rem;
}

.tab-content h3 {
    color: var(--text-color);
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
}

/* Forms */
.command-form {
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    transition: all 0.2s;
    background-color: #f8fafc;
    color: var(--text-color);
}

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

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.25);
}

.btn-primary:hover {
    box-shadow: 0 6px 8px rgba(102, 126, 234, 0.35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: white;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-color);
    border-color: var(--text-light);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), #38a169);
    color: white;
    box-shadow: 0 4px 6px rgba(72, 187, 120, 0.25);
}

.btn-success:hover {
    box-shadow: 0 6px 8px rgba(72, 187, 120, 0.35);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #e53e3e);
    color: white;
    box-shadow: 0 4px 6px rgba(245, 101, 101, 0.25);
}

.btn-danger:hover {
    box-shadow: 0 6px 8px rgba(245, 101, 101, 0.35);
    transform: translateY(-1px);
}

/* Result Box */
.result-box {
    margin-top: 2rem;
    padding: 0;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.result-header {
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-color);
}

.result-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.result-box pre {
    background: #1a202c;
    color: #e2e8f0;
    padding: 1.5rem;
    overflow-x: auto;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    max-height: 500px;
    overflow-y: auto;
    margin: 0;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Messages */
.error-message {
    background: #fff5f5;
    color: #c53030;
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-top: 1rem;
    border: 1px solid #feb2b2;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.success-message {
    background: #f0fff4;
    color: #276749;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid #9ae6b4;
}

.success-message h4 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.success-message code {
    display: block;
    background: rgba(255, 255, 255, 0.8);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin: 1rem 0;
    border: 1px solid rgba(0, 0, 0, 0.05);
    font-family: monospace;
    color: var(--primary-dark);
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    border-top: 1px solid var(--border-color);
    max-height: 600px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0;
}

table th,
table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 10;
}

table tr:last-child td {
    border-bottom: none;
}

table tr:hover {
    background: #f7fafc;
}

.log-file-item {
    padding: 1rem 1.5rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-file-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    transform: translateX(4px);
}

.log-file-name {
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.log-file-name::before {
    content: '📄';
}

.log-file-meta {
    font-size: 0.85rem;
    color: var(--text-light);
    background: #edf2f7;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
}

/* Loading Spinner */
.loading {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Query Builder */
.query-builder {
    background: #f8fafc;
    padding: 2rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.tab-description {
    color: var(--text-light);
    margin-bottom: 2rem;
    font-size: 1rem;
}

.condition-item {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    display: grid;
    grid-template-columns: 2fr 1fr 2fr auto;
    gap: 1rem;
    align-items: end;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.condition-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.btn-remove {
    background: #fff5f5;
    color: var(--danger-color);
    border: 1px solid #feb2b2;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-remove:hover {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.result-count {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.sql-display {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #2d3748;
    border-radius: var(--radius-md);
    color: #e2e8f0;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
}

.sql-display strong {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

/* Admin Only */
.admin-only {
    padding: 2rem;
    background: #fffaf0;
    border-radius: var(--radius-lg);
    border: 1px solid #fbd38d;
    margin-bottom: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
    .login-container {
        margin: 2rem 1rem;
        padding: 2rem;
    }

    header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .tabs {
        padding: 0 1rem;
    }

    .tab-content {
        margin: 1rem;
        padding: 1.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .condition-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .condition-item .btn-remove {
        width: 100%;
        margin-top: 0.5rem;
    }
}

/* ============================================
   使用量查詢頁面樣式
   ============================================ */
.usage-filters {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.filter-section {
    margin-bottom: 1.5rem;
}

.filter-section:last-child {
    margin-bottom: 0;
}

.filter-section > label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.year-select, .time-unit-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    min-width: 120px;
}

.month-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.month-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.month-item:hover {
    border-color: var(--primary-color);
}

.month-item.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.month-item input {
    display: none;
}

.org-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.org-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.org-item:hover {
    border-color: var(--primary-color);
}

.org-item.selected {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-color: var(--primary-color);
}

.org-item input {
    display: none;
}

/* 排名區塊 */
.usage-rankings {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .usage-rankings {
        grid-template-columns: 1fr;
    }
}

.ranking-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.ranking-card h3 {
    padding: 1rem 1.5rem;
    background: #f8fafc;
    margin: 0;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border-color);
}

.ranking-list-header {
    padding: 0.5rem 1.5rem;
    background-color: var(--card-bg);
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
}

.ranking-list-header .checkbox-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

.ranking-list {
    max-height: 400px;
    overflow-y: auto;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

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

.ranking-item:hover {
    background: #f7fafc;
}

.ranking-position {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.85rem;
    margin-right: 1rem;
    flex-shrink: 0;
}

.ranking-info {
    flex: 1;
    min-width: 0;
}

.ranking-name {
    display: block;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-org {
    display: block;
    font-size: 0.8rem;
    color: var(--text-light);
}

.ranking-count {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.1rem;
}

/* 詳細資料區 */
.usage-detail {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    margin-top: 2rem;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

.detail-header h3 {
    margin: 0;
}

.detail-actions {
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

/* ============================================
   組態查詢頁面樣式
   ============================================ */
.config-org-selector {
    margin-bottom: 2rem;
}

.config-org-selector label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.config-org-select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    min-width: 250px;
}

.org-summary {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.summary-card {
    flex: 1;
    min-width: 150px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.25);
}

.summary-icon {
    display: block;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.summary-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
}

.summary-label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.9;
}

.config-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.config-tab-btn {
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.config-tab-btn:hover {
    border-color: var(--primary-color);
}

.config-tab-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.config-content {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.config-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

.config-search {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    width: 250px;
}

.config-count {
    color: var(--text-light);
    font-size: 0.9rem;
}

.config-list {
    max-height: 500px;
    overflow-y: auto;
}

.config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

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

.config-item:hover {
    background: #f7fafc;
}

.config-item-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.config-item-icon {
    font-size: 1.25rem;
}

.config-item-name {
    font-weight: 600;
    color: var(--text-color);
}

.config-item-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.config-item-desc {
    color: var(--text-light);
    font-size: 0.85rem;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.approved, .status-badge.active {
    background: #c6f6d5;
    color: #276749;
}

.status-badge.revoked, .status-badge.inactive {
    background: #fed7d7;
    color: #c53030;
}

.status-badge.pending {
    background: #feebc8;
    color: #c05621;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0;
    line-height: 1;
}

.btn-close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.detail-section {
    margin-bottom: 2rem;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section h4 {
    margin: 0 0 1rem 0;
    color: var(--text-color);
    font-size: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
}

.detail-table th, .detail-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.detail-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.85rem;
}

.detail-table td:first-child {
    font-weight: 500;
    color: var(--text-light);
    width: 150px;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    padding: 0.35rem 0.75rem;
    background: #edf2f7;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: var(--text-color);
}

.tag.env {
    background: #c6f6d5;
    color: #276749;
}

/* Loading and Error Text */
.loading-text {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
}

.error-text {
    text-align: center;
    padding: 2rem;
    color: var(--danger-color);
}

/* Token Item */
.token-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
}

.token-item div {
    margin-bottom: 0.5rem;
}

.token-item div:last-child {
    margin-bottom: 0;
}

/* ===================================================================
   新增樣式：支持 UI 功能加強
   ================================================================ */

/* 年度與月份同列顯示 */
.filter-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-section-year {
    flex: 0 0 150px;
}

.filter-section-month {
    flex: 1;
    min-width: 400px;
}

/* 日期選擇器樣式 */
.day-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-color);
    border-radius: var(--radius-md);
}

.day-item {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--card-bg);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.day-item:hover {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.day-item input[type="checkbox"] {
    margin-right: 0.4rem;
}

/* 彙總資料卡片 */
.summary-stats {
    display: none;
    flex-wrap: wrap;
    gap: 2rem;
    margin: 1.5rem 0;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-radius: var(--radius-lg);
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.summary-stat-card {
    flex: 1 1 300px;
    min-width: 250px;
    text-align: center;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.summary-stat-label {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.summary-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    word-break: break-all;
    overflow-wrap: break-word;
    line-height: 1.3;
}

/* 排名控制區域 */
.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.ranking-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.ranking-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.ranking-filter {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    width: 200px;
    transition: border-color 0.2s;
}

.ranking-filter:focus {
    outline: none;
    border-color: var(--primary-color);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

/* 排名項目中的 checkbox */
.ranking-checkbox {
    display: flex;
    align-items: center;
    margin-right: 0.5rem;
    cursor: pointer;
}

.ranking-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.ranking-item {
    display: flex !important;
    align-items: center;
    gap: 0.75rem;
}

/* 系統組態子選單 */
.system-subtabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: var(--radius-md);
    flex-wrap: wrap;
}

.system-subtab-btn {
    padding: 0.6rem 1.2rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
}

.system-subtab-btn:hover {
    background: rgba(102, 126, 234, 0.05);
    border-color: var(--primary-color);
}

.system-subtab-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-color: transparent;
}

.system-subtab-content {
    display: none;
}

.system-subtab-content.active {
    display: block;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .filter-row {
        flex-direction: column;
    }
    
    .filter-section-year,
    .filter-section-month {
        flex: 1;
        min-width: 100%;
    }
    
    .ranking-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .ranking-controls {
        flex-direction: column;
        width: 100%;
    }
    
    .ranking-filter {
        width: 100%;
    }
    
    .summary-stats {
        flex-direction: column;
        gap: 1rem;
    }
}


/* 修正：日期選擇器樣式與其他 checkbox 一致 */
.day-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-color);
    border-radius: var(--radius-md);
}

.day-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.9rem;
}

.day-item:hover {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.day-item input[type="checkbox"]:checked + span,
.day-item:has(input[type="checkbox"]:checked) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.day-item input[type="checkbox"] {
    display: none;
}

