* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 16px;
}

.container {
    max-width: 600px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

header h1 {
    color: white;
    font-size: 24px;
    margin-bottom: 16px;
}

.tabs {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.tab-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 20px;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn.active {
    background: white;
    color: #667eea;
}

.calc-type-switch {
    display: flex;
    gap: 10px;
}

.type-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.type-btn.active[data-type="profit"] {
    border-color: #11998e;
    background: linear-gradient(135deg, rgba(17,153,142,0.1) 0%, rgba(56,239,125,0.1) 100%);
    color: #11998e;
}

.type-btn.active[data-type="loss"] {
    border-color: #ff6b6b;
    background: linear-gradient(135deg, rgba(255,107,107,0.1) 0%, rgba(255,142,83,0.1) 100%);
    color: #ff6b6b;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.card h2 {
    font-size: 18px;
    color: #333;
    margin-bottom: 16px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s;
    -webkit-appearance: none;
    appearance: none;
    background: white;
}

/* 日期和月份选择器样式修复 */
input[type="date"],
input[type="month"] {
    position: relative;
    cursor: pointer;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.btn:active {
    transform: scale(0.98);
}

.btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn.success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    margin-top: 16px;
}

.result-card {
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-section {
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 12px;
}

.result-section.profit {
    background: linear-gradient(135deg, rgba(17,153,142,0.1) 0%, rgba(56,239,125,0.1) 100%);
}

.result-section.loss {
    background: linear-gradient(135deg, rgba(255,107,107,0.1) 0%, rgba(255,142,83,0.1) 100%);
}

.result-section h3 {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px dashed #e0e0e0;
}

.result-item:last-child {
    border-bottom: none;
}

.result-item span:last-child {
    font-weight: 600;
    color: #333;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.summary-item {
    padding: 14px;
    border-radius: 10px;
    text-align: center;
}

.summary-item.profit {
    background: linear-gradient(135deg, rgba(17,153,142,0.1) 0%, rgba(56,239,125,0.1) 100%);
}

.summary-item.loss {
    background: linear-gradient(135deg, rgba(255,107,107,0.1) 0%, rgba(255,142,83,0.1) 100%);
}

.summary-item .label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
}

.summary-item .value {
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th, td {
    padding: 10px 6px;
    text-align: center;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    color: #666;
    font-weight: 500;
}

.action-btn {
    padding: 6px 10px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    margin: 2px;
}

.edit-btn {
    background: #667eea;
    color: white;
}

.delete-btn {
    background: #ff6b6b;
    color: white;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 16px;
    color: #333;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.modal-actions .btn {
    flex: 1;
    background: #e0e0e0;
    color: #333;
}

#monthPicker {
    width: 100%;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    -webkit-appearance: none;
    appearance: none;
    background: white;
    cursor: pointer;
}

.empty-tip {
    text-align: center;
    color: #999;
    padding: 40px 0;
}

/* Toast提示样式 */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.toast-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(17, 153, 142, 0.4);
}

.toast-error {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.4);
}

/* 数据操作按钮 */
.data-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.btn-small {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-small.export {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-small.import {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.btn-small:active {
    transform: scale(0.95);
}

/* 登录页面 */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: white;
    padding: 40px 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-width: 350px;
    width: 100%;
}

.login-card h1 {
    margin-bottom: 10px;
    color: #333;
}

.login-card p {
    color: #666;
    margin-bottom: 20px;
}

.login-card input {
    text-align: center;
    font-size: 18px;
    letter-spacing: 4px;
}

.login-error {
    color: #ff6b6b;
    font-size: 13px;
    margin-top: 12px;
    min-height: 20px;
}

/* 头部操作区 */
.header-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.role-tag {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.role-tag.admin {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.role-tag.guest {
    background: #e0e0e0;
    color: #666;
}

.btn-logout {
    padding: 4px 12px;
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 12px;
    background: transparent;
    color: white;
    font-size: 12px;
    cursor: pointer;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.2);
}

/* 编码管理 */
.code-list {
    margin-top: 16px;
}

.code-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
}

.code-value {
    font-family: monospace;
    font-size: 16px;
    font-weight: 600;
    color: #667eea;
    letter-spacing: 2px;
}
