/* =========================================================
   记账后台系统 - 样式表
   ========================================================= */

:root {
    --bg:            #f5f6f8;
    --surface:       #ffffff;
    --border:        #e9ecf1;
    --border-strong: #d8dde5;

    --text:   #171a1f;
    --text-2: #59616e;
    --text-3: #8d95a3;

    --primary:      #4f46e5;
    --primary-dark: #4338ca;
    --primary-soft: #eef1ff;

    --green:      #059669;
    --green-soft: #ecfdf5;
    --red:        #dc2626;
    --red-soft:   #fef2f2;
    --orange:     #ea580c;
    --orange-soft:#fff7ed;

    --radius:    14px;
    --radius-sm: 9px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow:    0 8px 24px rgba(16, 24, 40, .09);

    --sidebar-w: 234px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Microsoft YaHei", "Hiragino Sans GB", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--text-3); }
.empty { text-align: center; color: var(--text-3); padding: 34px 0; }

/* =========================================================
   整体骨架：侧边栏 + 主区域
   ========================================================= */
.app { display: flex; min-height: 100vh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 18px 14px 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 20px;
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }

.brand-logo {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, #6366f1, #4338ca);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(79, 70, 229, .35);
}
.brand-logo svg { width: 18px; height: 18px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-item:hover {
    background: #f4f5f8;
    color: var(--text);
    text-decoration: none;
}
.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}
.nav-icon {
    display: flex;
    width: 18px;
    height: 18px;
    color: currentColor;
    opacity: .85;
}

.sidebar-foot {
    padding: 12px 10px 2px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-3);
}

/* ---------- 主区域 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    height: 62px;
    flex: 0 0 62px;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 26px;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -.01em;
    margin: 0;
}

.userbox {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    color: var(--text-2);
}
.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}
.userbox .logout {
    margin-left: 4px;
    padding: 5px 11px;
    border-radius: 7px;
    border: 1px solid var(--border-strong);
    color: var(--text-2);
    font-size: 13px;
}
.userbox .logout:hover {
    background: #f4f5f8;
    color: var(--text);
    text-decoration: none;
}

.content { padding: 24px 26px 56px; }

/* 独立页面（登录 / 安装）用 */
.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px 26px 60px;
}

/* =========================================================
   统计卡片
   ========================================================= */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 17px 20px 17px 22px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow .18s, transform .18s;
}
.stat:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.stat::after {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--primary);
}
.stat.green::after  { background: var(--green); }
.stat.red::after    { background: var(--red); }
.stat.orange::after { background: var(--orange); }

.stat .label {
    font-size: 13px;
    color: var(--text-3);
    display: flex;
    align-items: center;
    gap: 7px;
}
.stat .label::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--primary);
    flex: 0 0 6px;
}
.stat.green .label::before  { background: var(--green); }
.stat.red .label::before    { background: var(--red); }
.stat.orange .label::before { background: var(--orange); }

.stat .value {
    margin-top: 7px;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -.015em;
    font-variant-numeric: tabular-nums;
}

/* =========================================================
   卡片
   ========================================================= */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 15px;
    font-weight: 650;
    margin: 0 0 16px;
    letter-spacing: -.01em;
}
.card-title::before {
    content: "";
    width: 3px;
    height: 15px;
    border-radius: 2px;
    background: var(--primary);
    flex: 0 0 3px;
}

/* =========================================================
   表格
   ========================================================= */
table { width: 100%; border-collapse: collapse; }

th, td {
    padding: 12px 14px;
    text-align: left;
    vertical-align: middle;
}
th {
    background: #fafbfc;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
    letter-spacing: .02em;
    white-space: nowrap;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
th:first-child { border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
th:last-child  { border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }

td { border-bottom: 1px solid #f2f4f7; font-size: 14px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfd; }
tfoot th { background: #fafbfc; border-top: 1px solid var(--border); }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* =========================================================
   表单
   ========================================================= */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--text-2); font-weight: 500; }

input[type=text], input[type=password], input[type=number], input[type=datetime-local],
input[type=month], select, textarea {
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    min-width: 150px;
    transition: border-color .15s, box-shadow .15s;
}
input[type=datetime-local], input[type=month] { min-width: 176px; }
textarea { height: auto; padding: 9px 12px; }

input::placeholder { color: #aab1bd; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .14);
}

.field.wide input, .field.wide select { min-width: 250px; }

/* =========================================================
   按钮
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover {
    background: var(--primary-dark);
    text-decoration: none;
    color: #fff;
}
.btn:active { transform: translateY(1px); }

.btn-plain {
    background: var(--surface);
    color: var(--text-2);
    border-color: var(--border-strong);
}
.btn-plain:hover {
    background: #f6f7f9;
    color: var(--text);
    border-color: #c6ccd6;
}

.btn-danger {
    background: var(--surface);
    color: var(--red);
    border-color: #f7d4d4;
}
.btn-danger:hover {
    background: var(--red-soft);
    color: var(--red);
    border-color: #f0b8b8;
}

.btn-sm { height: 31px; padding: 0 11px; font-size: 13px; border-radius: 8px; }

.actions { display: flex; gap: 8px; white-space: nowrap; align-items: center; }
.actions form { display: inline; margin: 0; }

/* =========================================================
   提示条
   ========================================================= */
.alert {
    padding: 11px 15px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 14px;
    margin-bottom: 16px;
}
.alert a { font-weight: 600; }
.alert-success { background: var(--green-soft);  color: #047857; border-color: #a7f3d0; }
.alert-error   { background: var(--red-soft);    color: #b91c1c; border-color: #fecaca; }
.alert-info    { background: #eff6ff;            color: #1d4ed8; border-color: #bfdbfe; }

/* =========================================================
   标签
   ========================================================= */
.tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: var(--primary-soft);
    color: var(--primary);
    line-height: 1.6;
}
.tag-green  { background: var(--green-soft);  color: #047857; }
.tag-red    { background: var(--red-soft);    color: #b91c1c; }
.tag-orange { background: var(--orange-soft); color: #c2410c; }

/* =========================================================
   筛选工具条
   ========================================================= */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--border);
}

/* =========================================================
   分页
   ========================================================= */
.pagination {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    padding-top: 18px;
    font-size: 13px;
    color: var(--text-3);
}
.pagination a {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 13px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-2);
    font-weight: 500;
}
.pagination a:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
}

/* =========================================================
   登录页
   ========================================================= */
.login-page {
    background:
        radial-gradient(900px 500px at 12% -10%, #e0e7ff 0%, rgba(224, 231, 255, 0) 60%),
        radial-gradient(800px 500px at 100% 110%, #ffe4e6 0%, rgba(255, 228, 230, 0) 55%),
        #f6f7f9;
}
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-box {
    width: 372px;
    max-width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(16, 24, 40, .12);
    padding: 32px 30px 30px;
}
.login-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}
.login-head .brand-logo { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px; }
.login-head .brand-logo svg { width: 24px; height: 24px; }
.login-head h1 { font-size: 18px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.login-head p { margin: 0; font-size: 13px; color: var(--text-3); }
.login-box .field { margin-bottom: 14px; }
.login-box .field input { width: 100%; min-width: 0; }
.login-box .btn { width: 100%; margin-top: 8px; height: 40px; }

.footer {
    text-align: center;
    color: var(--text-3);
    font-size: 12px;
    padding: 24px 0 32px;
}

/* =========================================================
   响应式
   ========================================================= */
@media (max-width: 860px) {
    .app { flex-direction: column; }

    .sidebar {
        position: static;
        height: auto;
        width: 100%;
        flex: none;
        flex-direction: row;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow-x: auto;
    }
    .brand { padding: 0; flex: 0 0 auto; }
    .brand-name { display: none; }
    .nav { flex-direction: row; flex: 1; gap: 4px; }
    .nav-item { padding: 7px 11px; white-space: nowrap; }
    .sidebar-foot { display: none; }

    .topbar { padding: 0 16px; height: 56px; flex: 0 0 56px; }
    .page-title { font-size: 16px; }
    .userbox .username { display: none; }
    .content { padding: 16px 16px 44px; }

    .stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
    .stat { padding: 14px 16px 14px 18px; }
    .stat .value { font-size: 20px; }

    .card { padding: 16px; }
    th, td { padding: 10px 10px; }
}
