* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    height: 100vh;
    overflow: hidden;
}
.app-layout {
    display: flex;
    height: 100vh;
}
/* Sidebar */
.sidebar {
    width: 240px;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #2d2d44;
    text-align: center;
}
.sidebar-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #fff;
}
.sidebar-header p {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}
.nav-menu {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}
.nav-group {
    margin-bottom: 5px;
}
.nav-group-title {
    padding: 12px 20px 8px;
    font-size: 14px;
    font-weight: 600;
    color: #ced4da;
    letter-spacing: 1px;
}
.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    cursor: pointer;
    transition: background 0.2s;
    color: #ccc;
    font-size: 14px;
    border-left: 3px solid transparent;
}
.nav-item:hover {
    background: #252542;
    color: #fff;
}
.nav-item.active {
    background: #252542;
    color: #4dabf7;
    border-left-color: #4dabf7;
}
.nav-item .step-num {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3a3a5c;
    color: #ccc;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    flex-shrink: 0;
}
.nav-item.active .step-num {
    background: #4dabf7;
    color: #fff;
}
.nav-item.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}
/* Main Content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.topbar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}
.topbar-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}
.topbar .year-month-select {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #e8f4fd;
    border: 1px solid #b8daff;
    border-radius: 6px;
    padding: 6px 14px;
}
.topbar .year-month-select .ym-label {
    font-size: 14px;
    color: #333;
    white-space: nowrap;
    font-weight: 500;
}
.topbar .year-month-select select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}
.content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}
.page-section {
    display: none;
}
.page-section.active {
    display: block;
}
.card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.card h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: 600;
}
.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.form-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 200px;
}
.form-group label {
    font-size: 13px;
    color: #666;
    margin-bottom: 5px;
}
.form-group input, .form-group select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}
.btn-primary { background-color: #007bff; color: white; }
.btn-primary:hover { background-color: #0056b3; }
.btn-success { background-color: #28a745; color: white; }
.btn-success:hover { background-color: #218838; }
.btn-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}
.status {
    padding: 10px;
    border-radius: 4px;
    margin-top: 10px;
    display: none;
}
.status.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}
.status.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}
th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    white-space: pre-wrap;
}
th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #555;
    position: sticky;
    top: 0;
    z-index: 10;
}
tr:hover { background-color: #f8f9fa; }
.value-cell { font-weight: 600; color: #28a745; text-align: right; }
.empty-value { color: #999; font-style: italic; text-align: right; }
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}
.error-list {
    margin-top: 10px;
    padding: 10px;
    background-color: #f8d7da;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
}
.error-item {
    color: #721c24;
    font-size: 13px;
    margin-bottom: 5px;
}
.loading-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.45);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}
.loading-overlay.active { display: flex; }
.loading-box {
    background: white;
    padding: 35px 50px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}
.loading-box .spinner {
    width: 40px; height: 40px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loading-box p { font-size: 16px; color: #333; font-weight: 500; }
.placeholder-text {
    color: #999;
    padding: 40px;
    text-align: center;
}
.table-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    text-align: right;
    font-family: inherit;
}
.table-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.15);
}
.table-input.changed {
    border-color: #28a745;
    background-color: #f0fff4;
}
.input-table td {
    padding: 4px 8px;
}
.input-table th {
    padding: 5px 8px;
}
.num-cell {
    text-align: right;
}
.table-scroll {
    overflow: auto;
    max-height: calc(100vh - 280px);
}

/* ===== Login Page ===== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}
.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}
.login-box {
    background: white;
    border-radius: 12px;
    padding: 40px 35px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.login-header {
    text-align: center;
    margin-bottom: 30px;
}
.login-header h2 {
    font-size: 24px;
    color: #1a1a2e;
    font-weight: 600;
    margin-bottom: 8px;
}
.login-header p {
    font-size: 14px;
    color: #888;
}
.login-form-group {
    margin-bottom: 20px;
}
.login-form-group label {
    display: block;
    font-size: 14px;
    color: #555;
    margin-bottom: 6px;
    font-weight: 500;
}
.login-form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.login-form-group input:focus {
    outline: none;
    border-color: #4dabf7;
    box-shadow: 0 0 0 3px rgba(77, 171, 247, 0.15);
}
.login-btn {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #4dabf7 0%, #228be6 100%);
    color: white;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}
.login-btn:hover {
    opacity: 0.9;
}
.login-btn:active {
    transform: translateY(1px);
}
.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.login-status {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
    display: none;
}
.login-status.success {
    display: block;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.login-status.error {
    display: block;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
.login-yearmonth {
    display: flex;
    align-items: center;
    gap: 8px;
}
.login-yearmonth select {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.login-yearmonth select:focus {
    outline: none;
    border-color: #4dabf7;
    box-shadow: 0 0 0 3px rgba(77, 171, 247, 0.15);
}
.login-yearmonth span {
    font-size: 14px;
    color: #555;
}

/* ===== Sidebar Footer (User + Logout) ===== */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid #2d2d44;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
}
.sidebar-footer .user-name {
    font-size: 14px;
    color: #ccc;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.logout-btn {
    padding: 6px 12px;
    border: 1px solid #dc3545;
    border-radius: 4px;
    background: transparent;
    color: #ff6b7a;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}
.logout-btn:hover {
    background: #dc3545;
    color: white;
}

.query-filter-box {
    background: #d4edda;
    border: 2px solid #28a745;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
}
#queryDataContainer table {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    font-size: 13px;
}
#queryDataContainer th {
    background-color: #d4edda;
    color: #155724;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 600;
    border-bottom: 2px solid #28a745;
}
#queryDataContainer td {
    padding: 8px 10px;
    font-size: 13px;
}
#queryDataContainer tr:nth-child(even) {
    background-color: #f8f9fa;
}
#queryDataContainer tr:hover {
    background-color: #e8f4fd;
}
.query-form {
    margin-bottom: 0;
}
.query-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
}
.query-field:nth-child(2) {
    margin-left: 80px;
}
.query-field {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.query-field label {
    font-size: 15px;
    color: #444;
    font-weight: 600;
    white-space: nowrap;
    margin-bottom: 0;
}
.query-field select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    background: #f0f0f0;
    outline: none;
    min-width: auto;
}
.query-field select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.15);
}
#queryIndicator {
    min-width: 200px;
}
.query-month-range {
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}
.query-month-range select {
    min-width: 58px;
    padding: 6px 6px;
}
.query-month-range span {
    font-size: 15px;
    color: #444;
}
.query-month-range .range-sep {
    color: #888;
    font-size: 15px;
    margin: 0 4px;
    font-weight: 600;
}
.query-actions {
    margin-left: auto;
}
.query-actions button {
    padding: 8px 40px;
    font-size: 15px;
}

/* ===== Custom Confirm Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.45);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: white;
    padding: 28px 32px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    max-width: 380px;
    width: 90%;
}
.modal-message {
    font-size: 15px;
    color: #333;
    margin-bottom: 24px;
    line-height: 1.5;
}
.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
}
.modal-buttons .btn {
    padding: 8px 24px;
    font-size: 14px;
}
.modal-buttons .btn:first-child {
    background-color: #6c757d;
    color: white;
}
.modal-buttons .btn:first-child:hover {
    background-color: #5a6268;
}
