﻿:root {
    --bg: #edf2f8;
    --panel: #ffffff;
    --panel-soft: #f8fbff;
    --text: #1f2937;
    --text-soft: #6b7280;
    --line: #dbe3ef;
    --primary: #1677ff;
    --primary-hover: #0f66df;
    --danger: #e5484d;
    --danger-hover: #cf3f44;
    --success: #16a34a;
    --shadow: 0 6px 18px rgba(16, 24, 40, 0.06);
    --radius: 4px;
    --maxw: 730px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input,
select,
a {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

.hidden {
    display: none !important;
}

.page {
    width: 100%;
    max-width: var(--maxw);
    margin: 0 auto;
    min-height: 100vh;
    padding: calc(env(safe-area-inset-top) + 10px) 10px calc(env(safe-area-inset-bottom) + 16px);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: linear-gradient(180deg, #1d84ff 0%, #1677ff 100%);
    color: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.topbar-left {
    min-width: 0;
    flex: 1 1 auto;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.15;
}

.page-subtitle {
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.3;
    color: rgba(255, 255, 255, 0.76);
}

.topbar-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hero-actions {
    position: relative;
    z-index: 20;
}

.hero-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.14);
    color: #eff6ff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.hero-menu-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.hero-menu-icon {
    font-size: 13px;
    line-height: 1;
}

.hero-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 50;
    width: 154px;
    padding: 6px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(215, 224, 234, 0.96);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.hero-menu-item {
    display: flex;
    align-items: center;
    min-height: 38px;
    padding: 0 10px;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}

.hero-menu-item:hover {
    background: #eff6ff;
    color: var(--primary);
}

.summary-card {
    margin-top: 10px;
    padding: 12px 14px;
    background: linear-gradient(180deg, #f9fbff 0%, #f4f8fe 100%);
    border: 1px solid #d9e4f2;
    border-radius: var(--radius);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.75);
    display: flex;
    align-items: stretch;
    gap: 14px;
    flex-wrap: wrap;
}

.summary-item {
    min-width: 110px;
    flex: 1 1 140px;
    padding: 2px 0;
}

.summary-label {
    font-size: 12px;
    color: #627188;
    line-height: 1.2;
}

.summary-value {
    margin-top: 6px;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.1;
    word-break: break-word;
    color: #162338;
}

.list-wrap {
    margin-top: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #dde6f2;
    border-radius: var(--radius);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
}

.section-head-main {
    min-width: 0;
    flex: 1 1 auto;
}

.section-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.section-desc {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.45;
    color: #738297;
}

.section-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.cate-toolbar-actions #btnAdd {
    min-width: 96px;
}

.state-box {
    padding: 20px 10px;
    text-align: center;
    font-size: 13px;
    color: var(--text-soft);
    background: #fafcff;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
}

.cate-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cate-item {
    position: relative;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #d7e1ee;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
    transition: border-color .18s ease, box-shadow .18s ease;
}

.cate-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, #3082ff 0%, #8ab7ff 100%);
}

.cate-item:hover {
    border-color: #bfd2ed;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

.cate-main {
    padding: 12px 14px 14px;
}

.cate-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.cate-left {
    min-width: 0;
    flex: 1 1 auto;
}

.cate-link {
    display: block;
    max-width: 100%;
    padding-right: 6px;
}

.cate-title-row {
    display: block;
}

.cate-name {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.35;
    word-break: break-word;
    color: var(--text);
}

.cate-link:hover .cate-name {
    color: var(--primary);
}

.cate-link:hover {
    opacity: .95;
}

.cate-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.3;
    color: var(--text-soft);
}

.cate-meta-item {
    white-space: nowrap;
}

.cate-meta-divider {
    color: #9aa4b2;
}

.cate-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.action-icon-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: .18s ease;
}

.action-icon {
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
}

.action-enter-btn {
    border-color: #d5e4ff;
    background: #eef5ff;
    color: #245bba;
}

.action-rename-btn {
    border-color: #e7ddbc;
    background: #fff9eb;
    color: #9a6a12;
}

.action-rename-btn:hover {
    background: #fff2cf;
    border-color: #dcc78f;
}

.action-enter-btn:hover {
    background: #dbeafe;
    border-color: #b8d2ff;
}

.action-delete-btn {
    border-color: #f3c7c9;
    background: #fff1f2;
    color: var(--danger);
}

.action-delete-btn:hover {
    background: #ffe4e6;
    border-color: #efb4b7;
    color: var(--danger-hover);
}

.stats-row {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 12px 0 0;
    border-top: 1px solid #ecf1f7;
    background: transparent;
    border-radius: 4px;
}

.stat-inline {
    min-width: 0;
    padding: 0 2px;
}

.stat-label {
    font-size: 11px;
    color: var(--text-soft);
    line-height: 1.2;
}

.stat-value {
    margin-top: 4px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    word-break: break-word;
    color: #182539;
}

.stat-value.positive {
    color: var(--success);
}

.stat-value.negative {
    color: var(--danger);
}

.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    height: 32px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    transition: .18s ease;
    user-select: none;
    font-size: 13px;
    line-height: 1;
}

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-light {
    background: #fff;
    color: var(--text);
    border-color: var(--line);
}

.btn-light:hover {
    background: #f7faff;
}

.btn-danger {
    background: #fff5f5;
    color: var(--danger);
    border-color: #f3c7c9;
}

.btn-danger:hover {
    background: #ffeaea;
    color: var(--danger-hover);
    border-color: #efb4b7;
}

.dialog-mask {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.dialog {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 16px 36px rgba(2, 8, 23, 0.18);
    overflow: hidden;
}

.dialog-sm {
    max-width: 360px;
}

.add-dialog .dialog-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.add-dialog .dialog-title::before {
    content: "+";
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #e8f1ff;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
}

.rename-dialog .dialog-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rename-dialog .dialog-title::before {
    content: "✎";
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #fff4d8;
    color: #9a6a12;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.dialog-head {
    padding: 10px 12px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid var(--line);
}

.dialog-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}

.dialog-body {
    padding: 12px;
    background: #ffffff;
}

.dialog-foot {
    padding: 10px 12px 12px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.icon-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: #475467;
}

.form-row + .form-row {
    margin-top: 10px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    color: #475467;
    font-weight: 600;
    line-height: 1.2;
}

.input {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #cfd8e6;
    border-radius: 4px;
    background: #fff;
    color: var(--text);
    outline: none;
    font-size: 13px;
}

.input:focus {
    border-color: #7fb2ff;
    box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
}

.form-tip {
    margin-top: 8px;
    font-size: 11px;
    line-height: 1.55;
    color: var(--text-soft);
}

.confirm-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom) + 18px);
    transform: translateX(-50%) translateY(20px);
    min-width: 120px;
    max-width: calc(100vw - 24px);
    padding: 8px 12px;
    border-radius: 4px;
    background: rgba(17, 24, 39, 0.92);
    color: #fff;
    font-size: 12px;
    line-height: 1.4;
    opacity: 0;
    pointer-events: none;
    transition: all .22s ease;
    z-index: 1200;
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 620px) {
    .page {
        padding: calc(env(safe-area-inset-top) + 6px) 8px calc(env(safe-area-inset-bottom) + 10px);
    }

    .topbar {
        padding: 9px 10px;
        gap: 8px;
    }

    .page-title {
        font-size: 17px;
    }

    .page-subtitle {
        font-size: 11px;
    }

    .summary-card,
    .list-wrap {
        margin-top: 8px;
        padding: 8px;
    }

    .summary-card {
        gap: 10px 12px;
    }

    .summary-item {
        min-width: calc(50% - 6px);
        flex: 1 1 calc(50% - 6px);
    }

    .summary-value {
        font-size: 18px;
    }

    .cate-main {
        padding: 10px;
    }

    .cate-head {
        align-items: flex-start;
        gap: 8px;
    }

    .cate-name {
        font-size: 15px;
    }

    .cate-title-row {
        gap: 6px 8px;
    }

    .stats-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 12px;
        padding-top: 10px;
    }

    .stat-inline {
        min-width: 0;
    }

    .btn {
        height: 40px;
        padding: 0 14px;
        font-size: 13px;
    }

    .cate-actions {
        width: auto;
        display: flex;
        justify-content: flex-end;
        gap: 6px;
    }

    .cate-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        margin-bottom: 8px;
    }

    .cate-toolbar-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .cate-toolbar-actions .btn {
        width: 100%;
        min-width: 0;
    }

    .dialog-mask {
        align-items: flex-end;
        padding: 12px 0 0;
    }

    .dialog {
        max-width: none;
        max-height: min(84vh, 760px);
        border-radius: 16px 16px 0 0;
        overflow-y: auto;
        box-shadow: 0 -12px 36px rgba(15, 23, 42, 0.2);
    }

    .add-dialog,
    .rename-dialog,
    .dialog-sm {
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.18);
    }

    .dialog-head {
        padding: 12px 14px 10px;
        min-height: 52px;
        border-bottom-color: #e7edf6;
        background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
    }

    .add-dialog .dialog-head,
    .rename-dialog .dialog-head {
        padding: 14px 14px 10px;
    }

    .dialog-body {
        padding: 14px;
        background: #ffffff;
    }

    .add-dialog .dialog-body,
    .rename-dialog .dialog-body {
        padding: 14px;
        background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    }

    .dialog-sm .dialog-body {
        padding: 16px 14px 14px;
    }

    .add-dialog .form-row + .form-row,
    .rename-dialog .form-row + .form-row {
        margin-top: 14px;
    }

    .add-dialog .form-label,
    .rename-dialog .form-label {
        margin-bottom: 7px;
        font-size: 13px;
    }

    .add-dialog .input,
    .rename-dialog .input {
        height: 42px;
        padding: 0 12px;
        font-size: 14px;
        border-color: #c7d3e4;
        background: #fff;
    }

    .add-dialog .form-tip,
    .rename-dialog .form-tip {
        margin-top: 12px;
        padding: 10px 12px;
        border-radius: var(--radius);
        background: #f1f6ff;
        border: 1px solid #d9e7ff;
        font-size: 11px;
        line-height: 1.6;
    }

    .dialog-sm .form-tip {
        margin-top: 12px;
        padding: 10px 12px;
        border-radius: var(--radius);
        background: #f8fafc;
        border: 1px solid #e6edf5;
    }

    .confirm-text {
        font-size: 15px;
        line-height: 1.7;
    }

    .dialog-foot {
        padding: 10px 14px calc(env(safe-area-inset-bottom) + 14px);
        gap: 8px;
        flex-wrap: wrap;
        background: #fff;
        box-shadow: 0 -1px 0 #edf2f7;
    }

    .add-dialog .dialog-foot,
    .rename-dialog .dialog-foot {
        padding: 12px 14px calc(env(safe-area-inset-bottom) + 14px);
    }

    .add-dialog .dialog-foot .btn,
    .rename-dialog .dialog-foot .btn,
    .dialog-sm .dialog-foot .btn {
        height: 40px;
        font-size: 13px;
    }

    .dialog-foot .btn {
        flex: 1 1 calc(50% - 3px);
    }

    .input {
        height: 36px;
        padding: 0 10px;
        font-size: 13px;
    }
}

@media (max-width: 560px) {
    .topbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    .topbar-left {
        min-width: 0;
        flex: 1 1 auto;
    }

    .topbar-right {
        flex: 0 0 auto;
        gap: 6px;
    }

    .hero-menu-btn {
        width: auto;
        min-width: 96px;
        min-height: 40px;
        padding: 0 14px;
    }

    .cate-left {
        min-width: 0;
        flex: 1 1 auto;
    }

    .cate-meta {
        font-size: 11px;
    }

    .cate-actions {
        gap: 6px;
    }
}

@media (max-width: 420px) {
    .page {
        padding-left: 6px;
        padding-right: 6px;
    }

    .topbar {
        padding: 8px;
    }

    .summary-card,
    .list-wrap {
        padding: 6px;
    }

    .summary-card {
        gap: 8px 10px;
    }

    .summary-item {
        min-width: calc(50% - 5px);
        flex: 1 1 calc(50% - 5px);
    }

    .cate-main {
        padding: 8px;
    }

    .stats-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px 10px;
        padding-top: 8px;
    }

    .stat-inline {
        min-width: 0;
    }

    .cate-actions {
        gap: 6px;
    }

    .hero-menu {
        width: 146px;
    }

    .add-dialog .dialog-head,
    .rename-dialog .dialog-head {
        padding: 12px 12px 10px;
    }

    .add-dialog .dialog-body,
    .rename-dialog .dialog-body,
    .dialog-sm .dialog-body {
        padding: 12px;
    }

    .add-dialog .input,
    .rename-dialog .input {
        height: 40px;
        font-size: 13px;
    }

    .add-dialog .dialog-foot,
    .rename-dialog .dialog-foot,
    .dialog-sm .dialog-foot {
        padding: 10px 12px calc(env(safe-area-inset-bottom) + 12px);
    }

    .dialog-foot {
        flex-direction: column-reverse;
    }

    .dialog-foot .btn {
        flex: 1 1 auto;
        width: 100%;
    }

    .toast {
        bottom: calc(env(safe-area-inset-bottom) + 12px);
        padding: 7px 10px;
        font-size: 11px;
    }
}

@media (max-width: 720px) {
    .page {
        padding: 8px 6px 12px;
    }

    .list-wrap,
    .section-head,
    .sheet-header,
    .sheet-content,
    .sheet-footer {
        padding-left: 8px;
        padding-right: 8px;
    }

    .section-head,
    .cate-toolbar,
    .hero-actions,
    .cate-actions {
        gap: 6px;
    }

    .page-title {
        font-size: 18px;
        font-weight: 600;
    }

    .page-subtitle,
    .cate-desc,
    .cate-meta {
        font-size: 11px;
        line-height: 1.45;
    }
}

