/* 轩辕财务系统 - 全局样式表
 * 黑白商务风格 · 侧滑导航 · 响应式双端
 */

/* ========== CSS变量 ========== */
:root {
    --primary: #0A0A0A;
    --secondary: #737373;
    --accent: #C8A97E;
    --bg: #FAFAFA;
    --text: #1A1A1A;
    --dark: #0F0F0F;
    --light: #F5F5F5;
    --border: #E8E8E8;
    --white: #FFFFFF;
    --green: #16A34A;
    --red: #DC2626;
    --shadow: rgba(0,0,0,0.08);
    --radius: 0;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== 基础重置 ========== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
}

input, select, textarea {
    font-family: inherit;
    font-size: 1rem;
    outline: none;
}

table {
    border-collapse: collapse;
    width: 100%;
}

/* ========== 布局骨架 ========== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background: var(--dark);
    color: var(--white);
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--white);
}

.sidebar-brand span {
    color: var(--accent);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding: 0 4px;
}

.sidebar-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--dark);
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: var(--secondary);
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.sidebar-nav-title {
    padding: 8px 20px;
    font-size: 0.7rem;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    font-size: 0.88rem;
    transition: var(--transition);
    border-left: 3px solid transparent;
    position: relative;
}

.sidebar-nav-item:hover,
.sidebar-nav-item.active {
    color: var(--white);
    background: rgba(255,255,255,0.04);
    border-left-color: var(--accent);
}

.sidebar-nav-item .icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-nav-item:hover .icon,
.sidebar-nav-item.active .icon {
    opacity: 1;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.75rem;
    color: var(--secondary);
}

/* 主内容区 */
.main-content {
    flex: 1;
    margin-left: 0;
    transition: margin-left 0.35s;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* 顶部栏 */
.top-bar {
    height: 56px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: var(--transition);
}

.menu-btn:hover {
    background: var(--light);
}

.menu-btn svg {
    width: 22px;
    height: 22px;
    stroke: var(--primary);
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 1px;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 内容区域 */
.content-area {
    flex: 1;
    padding: 24px 20px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* ========== 组件 ========== */

/* 卡片 */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    padding: 24px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title .accent-line {
    width: 3px;
    height: 18px;
    background: var(--accent);
}

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 0.88rem;
    font-weight: 500;
    border: 1px solid transparent;
    transition: var(--transition);
    cursor: pointer;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: #1a1a1a;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: var(--white);
}

.btn-accent {
    background: var(--accent);
    color: var(--dark);
    border-color: var(--accent);
}

.btn-accent:hover {
    background: #b8996a;
}

.btn-danger {
    background: var(--red);
    color: var(--white);
    border-color: var(--red);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 表单 */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--primary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--text);
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
}

.form-input::placeholder {
    color: #bbb;
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--secondary);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* 表格 */
.data-table {
    width: 100%;
    font-size: 0.88rem;
}

.data-table thead th {
    background: var(--primary);
    color: var(--white);
    padding: 14px 16px;
    text-align: left;
    font-weight: 500;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.data-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: var(--light);
}

.data-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.data-table tbody tr:nth-child(even):hover {
    background: #f0f0f0;
}

/* 弹窗 */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.3s;
    border: 1px solid var(--border);
}

.modal-overlay.show .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* 状态标签 */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid;
}

.badge-success {
    color: var(--green);
    border-color: var(--green);
    background: rgba(22,163,74,0.06);
}

.badge-danger {
    color: var(--red);
    border-color: var(--red);
    background: rgba(220,38,38,0.06);
}

.badge-warning {
    color: #d97706;
    border-color: #d97706;
    background: rgba(217,119,6,0.06);
}

/* 数字展示 */
.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    padding: 24px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--accent);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: -1px;
}

.stat-value.accent {
    color: var(--accent);
}

/* 搜索栏 */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-bar .form-input,
.search-bar .form-select {
    width: auto;
    min-width: 160px;
}

/* 分页 */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 24px;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    color: var(--text);
    transition: var(--transition);
}

.pagination a:hover,
.pagination a.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.pagination span.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state-text {
    font-size: 0.95rem;
}

/* 步骤条 */
.steps {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 24px;
}

.step {
    flex: 1;
    text-align: center;
    position: relative;
}

.step-line {
    position: absolute;
    top: 14px;
    left: calc(-50% + 20px);
    right: calc(50% + 20px);
    height: 2px;
    background: var(--border);
}

.step:first-child .step-line {
    display: none;
}

.step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--border);
    color: var(--white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.step.active .step-dot,
.step.done .step-dot {
    background: var(--primary);
}

.step.active ~ .step .step-line,
.step.active ~ .step .step-dot {
    opacity: 0.3;
}

.step-label {
    font-size: 0.75rem;
    color: var(--secondary);
    margin-top: 6px;
}

/* 计算结果展示 */
.calc-result {
    background: var(--light);
    border-left: 3px solid var(--accent);
    padding: 20px;
    margin-top: 16px;
}

.calc-result-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.calc-result-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}

.calc-result-row:last-child {
    border-bottom: none;
}

.calc-result-row .label {
    color: var(--secondary);
}

.calc-result-row .value {
    font-weight: 500;
    color: var(--primary);
}

.calc-result-row.total {
    font-size: 1rem;
    font-weight: 600;
    border-top: 2px solid var(--primary);
    border-bottom: none;
    margin-top: 4px;
    padding-top: 12px;
}

.calc-result-row.total .value {
    color: var(--accent);
    font-size: 1.2rem;
}

/* 标签组 */
.tag-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.8rem;
    background: var(--light);
    border: 1px solid var(--border);
    color: var(--text);
    transition: var(--transition);
}

.tag:hover {
    border-color: var(--primary);
}

.tag.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* 提示消息 */
.toast-container {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--white);
    border: 1px solid var(--border);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.88rem;
    min-width: 280px;
    box-shadow: 0 4px 20px var(--shadow);
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    border-left: 3px solid var(--green);
}

.toast-error {
    border-left: 3px solid var(--red);
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* 加载 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 登录页专用 */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--dark);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(200,169,126,0.08) 0%, transparent 70%);
}

.login-box {
    background: var(--white);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    border: 1px solid var(--border);
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.login-brand h1 {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 3px;
}

.login-brand p {
    font-size: 0.8rem;
    color: var(--secondary);
    margin-top: 6px;
    letter-spacing: 1px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form .btn {
    width: 100%;
    margin-top: 8px;
}

/* ========== 响应式 ========== */
@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0);
        position: relative;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .menu-btn {
        display: none;
    }
    
    .content-area {
        padding: 32px 40px;
    }
}

@media (max-width: 768px) {
    .content-area {
        padding: 16px 12px;
    }
    
    .card {
        padding: 16px;
    }
    
    .data-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .search-bar {
        flex-direction: column;
    }
    
    .search-bar .form-input,
    .search-bar .form-select {
        width: 100%;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .login-box {
        padding: 32px 24px;
        margin: 16px;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .modal {
        max-width: calc(100vw - 24px);
    }
    
    .top-bar {
        padding: 0 12px;
    }
    
    .page-title {
        font-size: 0.95rem;
    }
}

/* 打印样式 */
@media print {
    .sidebar, .top-bar, .menu-btn, .btn, .pagination {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .card {
        border: 1px solid #ddd;
        break-inside: avoid;
    }
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}
