:root {
    --bg: #e8edf7;
    --bg-alt: #f9fbff;
    --panel: #ffffff;
    --border: #e1e4ec;
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --danger: #dc2626;
    --text: #111827;
    --muted: #6b7280;
    --panel-shadow: 0 20px 40px rgba(37, 99, 235, 0.08);
    --gradient: linear-gradient(135deg, #7c3aed, #2563eb);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at top, #f9fbff, #e1e7f4 55%, #dee3ef);
    line-height: 1.5;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: radial-gradient(600px circle at 10% 20%, rgba(59, 130, 246, 0.15), transparent),
                radial-gradient(800px circle at 80% 0%, rgba(147, 51, 234, 0.1), transparent);
    z-index: -1;
}

header {
    padding: 2rem 1.5rem 1rem;
    text-align: center;
    background: var(--gradient);
    color: #fff;
    border-bottom-left-radius: 30% 12%;
    border-bottom-right-radius: 30% 12%;
    box-shadow: 0 25px 45px rgba(37, 99, 235, 0.35);
}

header h1 {
    margin: 0 0 0.3rem;
}

header p {
    margin: 0;
    opacity: 0.9;
}

main {
    width: 100%;
    max-width: none;
    padding: 1.5rem 3vw 2rem;
    margin: 0;
    animation: fadeIn 0.8s ease;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--panel-shadow);
    position: relative;
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.panel::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(120deg, rgba(59, 130, 246, 0.08), transparent);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.panel:hover {
    transform: translateY(-3px);
    box-shadow: 0 30px 50px rgba(17, 24, 39, 0.08);
}

.panel:hover::after {
    opacity: 1;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.panel-actions button {
    margin-left: 0.5rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.stat-card {
    border-radius: 16px;
    padding: 1rem 1.2rem;
    text-align: center;
    background: linear-gradient(150deg, rgba(37, 99, 235, 0.08), rgba(255, 255, 255, 0.9));
    border: 1px solid rgba(37, 99, 235, 0.2);
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card::before {
    content: "";
    position: absolute;
    width: 80px;
    height: 80px;
    background: rgba(59, 130, 246, 0.15);
    border-radius: 50%;
    top: -20px;
    right: -20px;
    filter: blur(10px);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 35px rgba(37, 99, 235, 0.18);
}

.stat-card strong {
    font-size: 1.8rem;
    display: block;
}

.stat-card .label {
    color: var(--muted);
    font-size: 0.9rem;
}

.filter-grid,
.export-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

label {
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
    color: var(--muted);
    gap: 0.3rem;
}

input, select, textarea, button {
    font: inherit;
}

input, select, textarea {
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}

textarea {
    width: 100%;
    resize: vertical;
}

button {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    background: linear-gradient(120deg, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 12px 20px rgba(37, 99, 235, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 25px rgba(37, 99, 235, 0.3);
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

#deleteFrozenBtn {
    background: var(--danger);
    box-shadow: 0 12px 20px rgba(220, 38, 38, 0.28);
}

#deleteFrozenBtn:hover {
    background: #b91c1c;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.list-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    color: var(--muted);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.list-summary .list-stats span + span {
    margin-left: 1rem;
}

.list-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.list-actions button {
    min-width: 150px;
}

.table-wrapper {
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

table {
    width: max(3200px, 100%);
    border-collapse: collapse;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(17, 24, 39, 0.08);
    table-layout: auto;
}

th, td {
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 0.85rem;
    white-space: nowrap;
    line-height: 1.25;
}

th:first-child,
td:first-child {
    width: 45px;
    text-align: center;
}

.select-account {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

#selectAllAccounts {
    cursor: pointer;
    accent-color: var(--primary);
}

th {
    background: #f3f4f6;
    font-weight: 600;
}

tbody tr:nth-child(even) {
    background: #fff;
}

tbody tr:hover {
    background: #eef2ff;
    transition: background 0.2s ease;
}

td[data-editable="1"] {
    cursor: pointer;
}

td.editing {
    background: #fffbe6;
}

.inline-editor {
    width: 100%;
    box-sizing: border-box;
    font: inherit;
    padding: 0.25rem 0.35rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: #fff;
}

td.empty {
    text-align: center;
    color: var(--muted);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.pagination button {
    min-width: 90px;
}

fieldset {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.8rem;
}

legend {
    padding: 0 0.5rem;
    font-weight: 600;
}

.field-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    font-size: 0.9rem;
}

.field-list label {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    color: var(--text);
}

.export-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: flex-start;
}

.export-actions button {
    flex: 0 0 auto;
    min-width: 200px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    white-space: nowrap;
}

.download-toggle {
    margin-top: 0.8rem;
    padding: 0.6rem 0.85rem;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    display: inline-block;
}

.download-toggle label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--text);
    margin: 0;
}

.download-toggle input {
    width: auto;
    margin: 0;
}

.import-result,
.export-summary {
    margin-top: 0.8rem;
    background: #f3f4f6;
    padding: 0.8rem;
    border-radius: 8px;
    color: var(--text);
}

.success {
    color: #16a34a;
}

.error {
    color: #dc2626;
}

footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--muted);
}

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

@media (max-width: 768px) {
    header {
        text-align: left;
    }
    .panel-actions {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    button {
        width: 100%;
    }
    .filter-actions {
        flex-direction: column;
    }
}
