/* ==================== 基础重置 & 变量 ==================== */
:root {
    --bg: #0f1117;
    --bg-panel: #1a1d27;
    --bg-card: #222639;
    --bg-hover: #2a2e42;
    --border: #2e3348;
    --text: #e4e6ef;
    --text-dim: #8b8fa3;
    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #e17055;
    --blue: #74b9ff;
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
        'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==================== 顶部状态栏 ==================== */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-light);
}

.top-bar-center {
    display: flex;
    align-items: center;
    gap: 20px;
}

.cycle-info {
    font-size: 13px;
    color: var(--text-dim);
    background: var(--bg-card);
    padding: 4px 12px;
    border-radius: var(--radius);
}

.week-selector {
    display: flex;
    align-items: center;
    gap: 6px;
}

.week-selector label {
    font-size: 13px;
    color: var(--text-dim);
    margin-right: 4px;
}

.week-btn {
    padding: 4px 14px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-dim);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.week-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.week-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.top-bar-right {
    display: flex;
    gap: 8px;
}

/* ==================== 主布局 ==================== */
.main-layout {
    display: grid;
    grid-template-columns: 340px 1fr 400px;
    gap: 0;
    height: calc(100vh - 57px);
}

/* ==================== 面板通用 ==================== */
.panel {
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel:last-child {
    border-right: none;
}

.panel-header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
}

/* ==================== 左列：录入 ==================== */
.panel-input {
    background: var(--bg-panel);
}

.tab-group {
    display: flex;
    gap: 2px;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 2px;
}

.tab {
    flex: 1;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.tab.active {
    background: var(--accent);
    color: #fff;
}

.tab-content {
    display: none;
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

.input-textarea {
    width: 100%;
    min-height: 180px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    font-family: inherit;
    margin-bottom: 10px;
}

.input-textarea::placeholder {
    color: var(--text-dim);
    opacity: 0.6;
}

.input-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* ==================== 解析结果 ==================== */
.parse-result {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.parse-result h3 {
    font-size: 14px;
    margin-bottom: 10px;
}

.preview-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.preview-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 8px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

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

.preview-item .name { color: var(--blue); font-weight: 500; min-width: 40px; }
.preview-item .date { color: var(--text-dim); }
.preview-item .type { color: var(--warning); }
.preview-item .amount { color: var(--success); font-weight: 500; }

.warnings {
    background: rgba(253, 203, 110, 0.1);
    border: 1px solid var(--warning);
    border-radius: var(--radius);
    padding: 8px 10px;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--warning);
}

/* ==================== 中列：总览表 ==================== */
.panel-overview {
    background: var(--bg);
}

.overview-table-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.overview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.overview-table th {
    text-align: left;
    padding: 8px 10px;
    color: var(--text-dim);
    font-weight: 500;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg);
    font-size: 12px;
}

.overview-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.overview-table tr:hover td {
    background: var(--bg-hover);
}

.overview-table tr {
    cursor: pointer;
}

.cell-amount {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.cell-amount.empty {
    color: var(--text-dim);
    opacity: 0.4;
}

.cell-cumulative {
    color: var(--blue);
    font-weight: 600;
}

.cell-rate {
    font-weight: 600;
}

.rate-8 { color: var(--text-dim); }
.rate-13 { color: var(--warning); }
.rate-18 { color: var(--success); }
.rate-23 { color: var(--accent-light); }

/* ==================== 右列：结算 ==================== */
.panel-settle {
    background: var(--bg-panel);
}

.settle-actions {
    padding: 16px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}

.action-group {
    margin-bottom: 14px;
}

.action-group:last-child {
    margin-bottom: 0;
}

.action-group h3 {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.inline-form {
    display: flex;
    gap: 8px;
}

.report-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 16px 16px;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0 8px;
}

.report-header h3 {
    font-size: 14px;
}

.report-output {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    font-size: 12.5px;
    line-height: 1.7;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    color: var(--text);
}

/* ==================== 按钮系统 ==================== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    white-space: nowrap;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-light);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    opacity: 0.85;
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), #4834d4);
    color: #fff;
}

.btn-accent:hover {
    opacity: 0.9;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
}

.btn-outline:hover {
    border-color: var(--text-dim);
    color: var(--text);
}

.btn-full {
    width: 100%;
}

.btn-row {
    display: flex;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==================== 表单元素 ==================== */
.select {
    flex: 1;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
}

.select:focus {
    outline: none;
    border-color: var(--accent);
}

.input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
}

.input:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 4px;
}

/* ==================== 模态框 ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    min-width: 360px;
    max-width: 500px;
}

.modal-wide {
    min-width: 600px;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.modal p {
    color: var(--text-dim);
    font-size: 13px;
    margin-bottom: 16px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
}

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

/* ==================== 加载动画 ==================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 300;
    gap: 12px;
}

.loading-overlay p {
    color: var(--text-dim);
    font-size: 14px;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==================== Toast 通知 ==================== */
.toast-container {
    position: fixed;
    top: 70px;
    right: 24px;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 13px;
    animation: slideIn 0.3s ease;
    max-width: 320px;
}

.toast-success {
    background: rgba(0, 184, 148, 0.15);
    border: 1px solid var(--success);
    color: var(--success);
}

.toast-error {
    background: rgba(225, 112, 85, 0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.toast-info {
    background: rgba(116, 185, 255, 0.15);
    border: 1px solid var(--blue);
    color: var(--blue);
}

@keyframes slideIn {
    from { transform: translateX(100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ==================== 徽标 ==================== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background: var(--accent);
    color: #fff;
}

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* ==================== 文件上传区 ==================== */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    transition: all 0.2s;
    background: var(--bg-card);
}

.upload-zone.drag-over {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.08);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 12px;
    cursor: pointer;
    gap: 4px;
    color: var(--text-dim);
    transition: color 0.2s;
}

.upload-placeholder:hover {
    color: var(--text);
}

.upload-icon {
    font-size: 24px;
    margin-bottom: 2px;
}

.upload-hint {
    font-size: 11px;
    opacity: 0.6;
}

.upload-file-list {
    padding: 8px;
}

.file-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 4px 8px;
    font-size: 13px;
    color: var(--text-dim);
}

.file-list-header .badge {
    font-size: 10px;
    padding: 1px 6px;
}

.file-list-items {
    max-height: 140px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 6px;
    border-radius: 4px;
    font-size: 12px;
    transition: background 0.15s;
}

.file-item:hover {
    background: var(--bg-hover);
}

.file-icon {
    flex-shrink: 0;
    font-size: 14px;
}

.file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.file-size {
    flex-shrink: 0;
    color: var(--text-dim);
    font-size: 11px;
}

.file-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.file-item:hover .file-remove {
    opacity: 1;
}

.file-remove:hover {
    color: var(--danger);
}

/* ==================== 缩略图条 ==================== */
.thumb-strip {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 0;
}

.thumb-item {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-remove {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 18px;
    height: 18px;
    border: none;
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

.thumb-item:hover .thumb-remove {
    opacity: 1;
}

/* ==================== 结算复选框 ==================== */
.settle-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.settle-check {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-dim);
    transition: all 0.2s;
}

.settle-check:hover {
    border-color: var(--accent);
    color: var(--text);
}

.settle-check input:checked + span {
    color: var(--accent-light);
}

.settle-check input {
    accent-color: var(--accent);
}

/* ==================== 周按钮（动态） ==================== */
.week-btn small {
    display: block;
    font-size: 10px;
    opacity: 0.7;
    font-weight: 400;
}

.overview-table th small {
    font-weight: 400;
    opacity: 0.7;
}

/* ==================== 小标签 ==================== */
.currency-tag {
    font-size: 10px;
    color: var(--text-dim);
    margin-left: 2px;
}

/* ==================== 可编辑弹窗 ==================== */
.person-edit-body {
    max-height: 70vh;
    overflow-y: auto;
    padding: 4px 0;
}

.edit-section {
    margin-bottom: 16px;
}

.edit-section h4 {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.edit-bill-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.edit-bill-row label {
    font-size: 13px;
    color: var(--text);
    min-width: 110px;
}

.edit-bill-input {
    width: 140px !important;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.edit-tag {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent-light);
}

.edit-tag.tag-manual {
    background: rgba(253, 203, 110, 0.15);
    color: var(--warning);
}

.edit-info-row {
    display: flex;
    gap: 16px;
    padding: 8px 0;
    font-size: 13px;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.edit-week-group {
    margin-bottom: 14px;
    padding: 10px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.edit-week-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-light);
    margin-bottom: 8px;
}

.edit-tx-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.input-sm {
    padding: 5px 7px !important;
    font-size: 12px !important;
}

.select-sm {
    padding: 5px 4px !important;
    font-size: 12px !important;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}

.btn-icon.btn-del:hover {
    color: var(--danger);
}

.add-tx-btn {
    margin-top: 6px;
    font-size: 12px !important;
    padding: 4px 10px !important;
}

.edit-empty {
    color: var(--text-dim);
    font-size: 13px;
    padding: 12px 0;
}

.edit-actions {
    padding-top: 12px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}
