/* ============================================================
   全局重置 & 变量
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4A7C59;
    --primary-light: #7EB08A;
    --primary-dark: #3A6647;
    --primary-bg: #f0f7f3;
    --text-primary: #1e2b26;
    --text-secondary: #4f6b5b;
    --text-muted: #8aa89a;
    --border-color: #dce8df;
    --shadow: 0 4px 20px rgba(74, 124, 89, 0.10);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: 0.25s ease;
    --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

html {
    font-size: 16px;
}

body {
    font-family: var(--font);
    background: #f2f6f3;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 20px;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ============================================================
   Toast 提示
   ============================================================ */
.toast {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    padding: 14px 32px;
    border-radius: 12px;
    font-size: 0.95rem;
    z-index: 9999;
    max-width: 90%;
    text-align: center;
    pointer-events: none;
    animation: toastIn 0.3s ease;
    backdrop-filter: blur(4px);
}

.toast.hide {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-16px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-16px);
    }
}

/* ============================================================
   容器
   ============================================================ */
.app-container {
    max-width: 1280px;
    width: 100%;
    background: #ffffff;
    border-radius: 32px;
    box-shadow: var(--shadow);
    padding: 28px 32px 40px;
    min-height: 90vh;
    transition: all 0.3s ease;
}

/* ============================================================
   顶部栏
   ============================================================ */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--primary-bg);
    margin-bottom: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.brand .logo {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    overflow: hidden;
    flex-shrink: 0;
    background: #fff;
}

.brand .logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.brand .name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.brand .name small {
    display: block;
    font-size: 0.6rem;
    font-weight: 400;
    color: var(--primary);
    letter-spacing: 0.5px;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    background: var(--primary-bg);
    padding: 8px 18px 8px 14px;
    border-radius: 60px;
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.user-avatar:hover {
    background: #dce8df;
}

.btn-logout {
    background: transparent;
    border: 1px solid #e74c3c;
    color: #e74c3c;
    padding: 6px 16px;
    border-radius: 60px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: #e74c3c;
    color: #fff;
}

/* ============================================================
   统计卡片
   ============================================================ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--primary-bg);
    border-radius: var(--radius);
    padding: 18px 20px;
    text-align: center;
    transition: var(--transition);
    border: 1px solid transparent;
}

.stat-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 124, 89, 0.08);
}

.stat-card .number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.stat-card .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ============================================================
   搜索 & 操作栏
   ============================================================ */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
}

.toolbar .search-group {
    display: flex;
    flex: 1;
    min-width: 200px;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar .search-group input,
.toolbar .search-group select {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    background: #fafcfa;
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
    min-height: 44px;
}

.toolbar .search-group input:focus,
.toolbar .search-group select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(126, 176, 138, 0.15);
    background: #fff;
}

.toolbar .search-group input {
    flex: 1;
    min-width: 120px;
}

.toolbar .search-group select {
    min-width: 100px;
}

.toolbar .actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    min-height: 44px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 124, 89, 0.25);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border-color);
}

.btn-outline:hover {
    background: var(--primary-bg);
    border-color: var(--primary-light);
}

.btn-danger {
    background: #e74c3c;
    color: #fff;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-success {
    background: #27ae60;
    color: #fff;
}

.btn-success:hover {
    background: #1e8449;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
    min-height: 34px;
}

/* ============================================================
   表格
   ============================================================ */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 700px;
}

table thead {
    background: var(--primary-bg);
}

table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f4f1;
    vertical-align: middle;
}

table tr:hover td {
    background: #f8fbf9;
}

table td .actions-cell {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

table td .actions-cell .btn {
    min-height: 30px;
    padding: 4px 12px;
    font-size: 0.75rem;
}

/* ============================================================
   分页
   ============================================================ */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.pagination .info {
    font-size: 0.85rem;
}

.pagination .pages {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.pagination .pages button {
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
    min-width: 36px;
}

.pagination .pages button:hover:not(:disabled) {
    background: var(--primary-bg);
    border-color: var(--primary-light);
}

.pagination .pages button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.pagination .pages button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================================
   空状态
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 4rem;
    margin-bottom: 12px;
}

.empty-state .title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.empty-state .desc {
    font-size: 0.9rem;
}

/* ============================================================
   Loading
   ============================================================ */
.loading-overlay {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 60px 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================
   模态框
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 20px;
    backdrop-filter: blur(4px);
    animation: modalOverlayIn 0.25s ease;
}

.modal-overlay.show {
    display: flex;
}

@keyframes modalOverlayIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-box {
    background: #fff;
    border-radius: 24px;
    padding: 32px 36px;
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

@keyframes modalIn {
    from {
        transform: scale(0.92) translateY(20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.modal-box .modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal-box .modal-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.modal-box .modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ============================================================
   响应式
   ============================================================ */

/* 平板 */
@media (max-width: 1024px) {
    .app-container {
        padding: 20px 24px 32px;
        border-radius: 24px;
    }
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 手机 */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }
    .app-container {
        padding: 16px 16px 24px;
        border-radius: 20px;
        min-height: 95vh;
    }
    .top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .top-bar-right {
        justify-content: space-between;
    }
    .brand .name {
        font-size: 1rem;
    }
    .brand .logo {
        width: 40px;
        height: 40px;
    }
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .stat-card {
        padding: 14px 12px;
    }
    .stat-card .number {
        font-size: 1.5rem;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .toolbar .search-group {
        flex-direction: column;
    }
    .toolbar .search-group input,
    .toolbar .search-group select {
        width: 100%;
        min-width: unset;
    }
    .toolbar .actions {
        justify-content: stretch;
    }
    .toolbar .actions .btn {
        flex: 1;
        justify-content: center;
    }
    table {
        font-size: 0.8rem;
        min-width: 500px;
    }
    table th,
    table td {
        padding: 10px 12px;
    }
    .pagination {
        flex-direction: column;
        align-items: center;
    }
    .modal-box {
        padding: 24px 20px;
        margin: 10px;
        border-radius: 20px;
    }
}

/* 小手机 */
@media (max-width: 480px) {
    .app-container {
        padding: 12px 12px 20px;
        border-radius: 16px;
    }
    .stat-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .stat-card {
        padding: 12px 10px;
    }
    .stat-card .number {
        font-size: 1.3rem;
    }
    table {
        font-size: 0.75rem;
        min-width: 400px;
    }
    table th,
    table td {
        padding: 8px 10px;
    }
}

/* ============================================================
   表单页面通用样式
   ============================================================ */
.form-section {
    max-width: 680px;
    margin: 0 auto;
}

.form-section .form-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.form-section .form-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-group label .required {
    color: #e74c3c;
    margin-left: 2px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    background: #fafcfa;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(126, 176, 138, 0.12);
    background: #fff;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
    max-height: 200px;
}

.form-group .help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.form-actions .btn {
    min-width: 120px;
    justify-content: center;
}

/* 返回链接 */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
    transition: var(--transition);
    cursor: pointer;
}

.back-link:hover {
    color: var(--primary);
}