/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
    font-family: system-ui, -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Container ── */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px;
}

/* ── Header ── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-bottom: 16px;
}
.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a2e;
}

/* ── Sections ── */
section {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 20px;
    margin-bottom: 16px;
}
section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: #1a1a2e;
}

/* ── Config Row ── */
.config-row {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}
.config-item { display: flex; flex-direction: column; gap: 4px; }
.config-item label { font-size: 0.85rem; color: #666; font-weight: 500; }

/* ── Form Elements ── */
.select, input[type="text"], input[type="number"], input[type="date"] {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    background: #fff;
    transition: border-color 0.2s;
    outline: none;
}
.select:focus, input:focus { border-color: #DB0011; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    padding-top: 20px;
}
.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #DB0011;
}

/* ── Button Group (Radio-like) ── */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.btn-option {
    padding: 6px 14px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    background: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    color: #555;
}
.btn-option:hover { border-color: #DB0011; color: #DB0011; }
.btn-option.active {
    background: #DB0011;
    border-color: #DB0011;
    color: #fff;
}

/* ── Buttons ── */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-primary {
    background: #DB0011;
    color: #fff;
}
.btn-primary:hover { background: #b5000e; }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }
.btn-outline {
    background: transparent;
    border: 1px solid #d1d5db;
    color: #555;
}
.btn-outline:hover { border-color: #DB0011; color: #DB0011; }
.btn-danger {
    background: transparent;
    border: 1px solid #fca5a5;
    color: #ef4444;
}
.btn-danger:hover { background: #fef2f2; }
.btn-text {
    background: none;
    border: none;
    color: #DB0011;
    padding: 4px 8px;
    font-size: 0.8rem;
    cursor: pointer;
}
.btn-text:hover { text-decoration: underline; }

/* ── Form Layout ── */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.form-group label {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
}
.form-group input { width: 100%; }
.form-actions { text-align: right; margin-top: 4px; }

/* ── Progress Panel ── */
.progress-list { display: flex; flex-direction: column; gap: 10px; }
.progress-item {
    display: flex;
    align-items: center;
    gap: 12px;
}
.progress-name {
    width: 160px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #444;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.progress-bar-wrap {
    flex: 1;
    height: 20px;
    background: #f3f4f6;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}
.progress-bar {
    height: 100%;
    border-radius: 10px;
    transition: width 0.4s ease;
    min-width: 2px;
}
.progress-text {
    font-size: 0.8rem;
    color: #666;
    width: 130px;
    text-align: right;
    flex-shrink: 0;
    white-space: nowrap;
}

.progress-summary {
    display: flex;
    justify-content: center;
    gap: 40px;
    padding-top: 16px;
    margin-top: 16px;
    border-top: 1px solid #f0f0f0;
}
.summary-item { text-align: center; }
.summary-label { display: block; font-size: 0.8rem; color: #888; margin-bottom: 4px; }
.summary-value { font-size: 1.2rem; font-weight: 700; color: #DB0011; }

/* ── Transaction Table ── */
.txn-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.txn-list-header h2 { margin-bottom: 0; }
.txn-list-actions { display: flex; gap: 8px; }

.txn-table table {
    width: 100%;
    border-collapse: collapse;
}
.txn-table th, .txn-table td {
    padding: 10px 12px;
    text-align: left;
    font-size: 0.85rem;
    border-bottom: 1px solid #f0f0f0;
}
.txn-table th {
    color: #888;
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.txn-table tr:hover td { background: #fafafa; }
.txn-table .rc-value {
    font-weight: 600;
    color: #DB0011;
}
.txn-table .amount-value {
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.txn-table .actions-cell {
    white-space: nowrap;
}

.txn-summary-row {
    padding: 12px 0;
    margin-top: 8px;
    border-top: 2px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #666;
}

/* ── Modal ── */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    padding: 0 4px;
}
.modal-close:hover { color: #333; }
.modal-body { padding: 20px; }

/* ── Ledger Table in Modal ── */
.ledger-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.ledger-table th, .ledger-table td {
    padding: 8px 10px;
    text-align: left;
    font-size: 0.85rem;
    border-bottom: 1px solid #f0f0f0;
}
.ledger-table th { color: #888; font-weight: 500; font-size: 0.8rem; }
.ledger-table .total-row td { font-weight: 700; border-top: 2px solid #e5e7eb; }
.ledger-table .cap-warn { color: #ef4444; font-size: 0.75rem; }

/* ── Toast ── */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #1a1a2e;
    color: #fff;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 2000;
    animation: slideIn 0.3s ease;
    max-width: 360px;
}
.toast .toast-rc { color: #fbbf24; font-weight: 700; font-size: 1.1rem; }
.toast .toast-detail { font-size: 0.8rem; color: #d1d5db; margin-top: 6px; }

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

/* ── Empty State ── */
.empty-state {
    text-align: center;
    color: #999;
    padding: 30px;
    font-size: 0.9rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    html { font-size: 13px; }
    .container { padding: 10px; }
    .form-row { grid-template-columns: 1fr; }
    .config-row { flex-direction: column; gap: 10px; align-items: flex-start; }
    .progress-name { width: 100px; font-size: 0.75rem; }
    .progress-text { width: 90px; font-size: 0.75rem; }
    .progress-summary { gap: 20px; }
    .txn-list-header { flex-direction: column; gap: 10px; align-items: flex-start; }
    .txn-table { overflow-x: auto; }
}
