/* ============ 全局样式 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    background: #f0f2f5;
    color: #333;
    font-size: 14px;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* ============ 登录页 ============ */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #1e3c72 100%);
    position: relative;
    overflow: hidden;
}
.login-wrap::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    top: -200px; right: -150px;
}
.login-wrap::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
    bottom: -150px; left: -100px;
}
.login-box {
    width: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 45px 45px 40px;
    z-index: 2;
    position: relative;
}
.login-box .logo {
    text-align: center;
    margin-bottom: 10px;
}
.login-box .logo .logo-icon {
    width: 60px; height: 60px;
    border-radius: 14px;
    background: linear-gradient(135deg, #2a5298, #1e88e5);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: bold;
    box-shadow: 0 6px 16px rgba(30,60,114,0.4);
}
.login-box h1 {
    text-align: center;
    font-size: 22px;
    color: #1e3c72;
    margin: 14px 0 6px;
    letter-spacing: 2px;
}
.login-box .sub {
    text-align: center;
    color: #999;
    font-size: 13px;
    margin-bottom: 30px;
}
.login-box .field { margin-bottom: 20px; }
.login-box .field label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 6px;
}
.login-box .field input {
    width: 100%;
    height: 44px;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0 14px;
    font-size: 14px;
    transition: border .2s, box-shadow .2s;
    outline: none;
}
.login-box .field input:focus {
    border-color: #1e88e5;
    box-shadow: 0 0 0 3px rgba(30,136,229,0.12);
}
.login-box .btn-login {
    width: 100%;
    height: 46px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #1e3c72, #1e88e5);
    color: #fff;
    font-size: 16px;
    letter-spacing: 4px;
    cursor: pointer;
    transition: opacity .2s, transform .1s;
    margin-top: 6px;
}
.login-box .btn-login:hover { opacity: 0.9; }
.login-box .btn-login:active { transform: scale(0.98); }
.login-tip {
    text-align: center;
    margin-top: 18px;
    color: #aaa;
    font-size: 12px;
}
.login-msg {
    text-align: center;
    color: #e53935;
    font-size: 13px;
    min-height: 20px;
    margin-bottom: 10px;
}

/* ============ 主布局 ============ */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px;
    background: #001529;
    color: #fff;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    overflow-y: auto;
    z-index: 100;
    transition: margin-left .3s;
}
.sidebar .brand {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    font-weight: bold;
    letter-spacing: 2px;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar .brand .b-icon {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, #1e88e5, #00acc1);
    display: inline-flex; align-items: center; justify-content: center;
    margin-right: 8px;
    font-size: 16px;
}
.menu-item { margin: 4px 0; }
.menu-item > a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    transition: all .2s;
    font-size: 14px;
}
.menu-item > a:hover { color: #fff; background: rgba(255,255,255,0.06); }
.menu-item > a .m-icon { width: 22px; margin-right: 8px; font-size: 15px; }
.menu-item > a .arrow { margin-left: auto; font-size: 10px; transition: transform .2s; }
.menu-item.open > a .arrow { transform: rotate(90deg); }
.menu-item > a.active { color: #fff; background: #1e88e5; }
.menu-item.active > a { color: #fff; background: #1e88e5; }
.submenu { display: none; background: rgba(0,0,0,0.25); }
.menu-item.open > .submenu { display: block; }
.submenu a {
    display: block;
    padding: 10px 20px 10px 50px;
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    transition: all .2s;
    cursor: pointer;
}
.submenu a:hover, .submenu a.active { color: #fff; background: rgba(30,136,229,0.2); }

.main {
    flex: 1;
    margin-left: 220px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.topbar {
    height: 60px;
    background: #fff;
    display: flex;
    align-items: center;
    padding: 0 24px;
    box-shadow: 0 1px 4px rgba(0,21,41,0.08);
    position: sticky;
    top: 0;
    z-index: 90;
}
.topbar .toggle-btn {
    font-size: 20px;
    color: #666;
    cursor: pointer;
    margin-right: 16px;
}
.topbar .page-title { font-size: 16px; font-weight: 600; color: #333; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.topbar .user-chip {
    display: flex; align-items: center; gap: 8px;
    cursor: pointer;
    color: #333;
    position: relative;
}
.topbar .avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e88e5, #00acc1);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px;
}
.topbar .user-name { font-size: 14px; }
.topbar .role-badge {
    font-size: 11px;
    background: #e3f2fd;
    color: #1565c0;
    padding: 2px 8px;
    border-radius: 10px;
}
.dropdown-menu {
    position: absolute;
    top: 46px; right: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    min-width: 140px;
    padding: 6px 0;
    display: none;
    z-index: 200;
}
.dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: #333;
    font-size: 13px;
}
.dropdown-menu a:hover { background: #f5f5f5; }

.content { padding: 20px 24px; flex: 1; }

/* ============ 卡片 ============ */
.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,21,41,0.06);
    padding: 20px;
    margin-bottom: 20px;
}
.card .card-title {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ============ 统计卡片 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 20px; }
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 22px;
    box-shadow: 0 2px 12px rgba(0,21,41,0.06);
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-card .s-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
}
.stat-card .s-label { color: #888; font-size: 13px; }
.stat-card .s-value { font-size: 24px; font-weight: 700; color: #333; margin-top: 2px; }
.s-blue { background: #e3f2fd; color: #1565c0; }
.s-green { background: #e8f5e9; color: #2e7d32; }
.s-orange { background: #fff3e0; color: #ef6c00; }
.s-purple { background: #f3e5f5; color: #6a1b9a; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table thead th {
    background: #f7f8fa;
    color: #555;
    font-weight: 600;
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid #e8e8e8;
    white-space: nowrap;
}
.data-table tbody td {
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
}
.data-table tbody tr:hover { background: #f5f8ff; }
.data-table .num { text-align: right; }

/* ============ 按钮 ============ */
.btn {
    display: inline-block;
    padding: 7px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all .2s;
    background: #f0f0f0;
    color: #333;
}
.btn:hover { opacity: 0.88; }
.btn-primary { background: #1e88e5; color: #fff; }
.btn-success { background: #43a047; color: #fff; }
.btn-danger { background: #e53935; color: #fff; }
.btn-warning { background: #fb8c00; color: #fff; }
.btn-outline { background: #fff; border: 1px solid #d0d0d0; color: #333; }
.btn-outline:hover { border-color: #1e88e5; color: #1e88e5; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ============ 表单 ============ */
.search-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}
.search-bar label { color: #666; font-size: 13px; }
.form-input, .form-select, input[type="text"], input[type="date"], input[type="number"], input[type="password"], select {
    height: 34px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    padding: 0 10px;
    font-size: 13px;
    outline: none;
    background: #fff;
    transition: border .2s;
}
.form-input:focus, select:focus, input:focus {
    border-color: #1e88e5;
    box-shadow: 0 0 0 3px rgba(30,136,229,0.1);
}
.form-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.form-group { display: flex; align-items: center; gap: 8px; }
.form-group label { color: #555; font-size: 13px; min-width: 60px; }

/* ============ 模态框 ============ */
.modal-mask {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}
.modal-mask.show { display: flex; }
.modal {
    background: #fff;
    border-radius: 12px;
    width: 520px;
    max-width: 94vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    animation: modalIn .25s;
}
@keyframes modalIn { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-lg { width: 900px; }
.modal .modal-head {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal .modal-close { cursor: pointer; color: #999; font-size: 20px; }
.modal .modal-body { padding: 20px; }
.modal .modal-foot { padding: 14px 20px; border-top: 1px solid #f0f0f0; text-align: right; }
.modal .modal-foot .btn { margin-left: 8px; }

/* ============ 徽标 ============ */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.badge-green { background: #e8f5e9; color: #2e7d32; }
.badge-red { background: #ffebee; color: #c62828; }
.badge-blue { background: #e3f2fd; color: #1565c0; }
.badge-orange { background: #fff3e0; color: #ef6c00; }
.badge-gray { background: #f0f0f0; color: #666; }

/* ============ 单据样式 ============ */
.doc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #1e88e5;
    padding-bottom: 12px;
    margin-bottom: 16px;
}
.doc-title { font-size: 20px; font-weight: 700; color: #1e3c72; letter-spacing: 3px; }
.doc-no { font-size: 13px; color: #666; }
.doc-no b { color: #1e88e5; font-size: 15px; }
.doc-info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.doc-info-grid .di { display: flex; align-items: center; }
.doc-info-grid .di label { color: #888; min-width: 70px; font-size: 13px; }
.doc-info-grid .di input { flex: 1; }

/* 单据明细表格编辑 */
.items-table { width: 100%; border-collapse: collapse; }
.items-table th { background: #f7f8fa; padding: 10px; font-size: 13px; color: #555; border: 1px solid #e8e8e8; text-align: center; }
.items-table td { padding: 6px; border: 1px solid #e8e8e8; }
.items-table input { width: 100%; border: none; outline: none; font-size: 13px; background: transparent; height: 30px; padding: 0 6px; }
.items-table input:focus { background: #f5f8ff; border-radius: 4px; }
.items-table .amount { text-align: right; color: #1e88e5; font-weight: 600; }
.total-row td { font-weight: 600; background: #f7f8fa; }

/* 提示 */
.msg-tip { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 3000; padding: 12px 24px; border-radius: 8px; color: #fff; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,0.2); display: none; }
.msg-success { background: #43a047; }
.msg-error { background: #e53935; }
.msg-info { background: #1e88e5; }

/* 空状态 */
.empty { text-align: center; color: #aaa; padding: 40px; font-size: 13px; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c0c4cc; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* 工作台 */
.welcome-banner {
    background: linear-gradient(135deg, #1e3c72, #1e88e5);
    border-radius: 12px;
    color: #fff;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 4px 16px rgba(30,60,114,0.25);
}
.welcome-banner h2 { font-size: 20px; margin-bottom: 8px; }
.welcome-banner p { color: rgba(255,255,255,0.85); font-size: 14px; }

@media (max-width: 900px) {
    .sidebar { margin-left: -220px; }
    .main { margin-left: 0; }
    .sidebar.open { margin-left: 0; }
}
