/**
 * 老张订单管理系统 - 主样式文件
 *
 * @copyright   Copyright (c) 2026 老张个人
 * @author      老张
 * @license     Proprietary License
 * @version     1.0.0
 *
 * 本文件是老张订单管理系统的主样式文件，未经授权不得修改、复制或分发。
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1e3a8a;
    --primary-light: #3b82f6;
    --secondary-color: #f59e0b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
}

.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 28px;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 12px;
}

.layout-container {
    display: flex;
    min-height: calc(100vh - 60px);
}

.sidebar {
    width: 240px;
    background: var(--primary-color);
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .sidebar-header h1,
.sidebar.collapsed .sidebar-header p,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-group-title {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    padding: 24px 20px;
    text-align: center;
}

.sidebar.collapsed .sidebar-nav a {
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .nav-icon {
    font-size: 20px;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.sidebar-header p {
    font-size: 11px;
    opacity: 0.8;
    font-weight: 400;
}

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

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: #ffffff !important;
    text-decoration: none;
    transition: all 0.25s ease;
    position: relative;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    transform: translateX(2px);
}

.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.18);
    color: white;
    border-left: 3px solid white;
    font-weight: 500;
}

.sidebar-nav .icon {
    font-size: 18px;
    opacity: 0.9;
    flex-shrink: 0;
}

.nav-icon {
    font-size: 18px;
    opacity: 0.9;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
}

.nav-text {
    font-size: 14px;
    font-weight: 400;
    opacity: 0.95;
}

.nav-group {
    margin-top: 8px;
}

.nav-group-title {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.9) !important;
    letter-spacing: 0.5px;
    margin-top: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.25s ease;
    user-select: none;
}

.nav-group-icon {
    font-size: 16px;
}

.nav-group-title:hover {
    background: rgba(255, 255, 255, 0.08);
}

.nav-group-title::after {
    content: '▼';
    font-size: 8px;
    transition: transform 0.3s ease;
    opacity: 0.7;
    margin-left: auto;
}

.nav-group.active .nav-group-title::after {
    transform: rotate(180deg);
}

.nav-group ul {
    list-style: none;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.nav-group.active ul {
    max-height: 500px;
    opacity: 1;
}

.nav-group ul li a {
    padding-left: 32px;
}

.nav-group.active .nav-group-title {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff !important;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* 移动端：侧边栏抽屉遮罩层 */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.user-info {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.user-role {
    font-size: 12px;
    opacity: 0.8;
}

.logout-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    border-radius: 6px;
    text-align: center;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 24px;
    transition: margin-left 0.3s;
}

.top-bar {
    background: var(--primary-color) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    width: 100%;
    box-sizing: border-box;
    height: 56px;
}

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

.menu-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
}

.menu-toggle span {
    width: 20px;
    height: 2px;
    background: white !important;
    transition: all 0.3s;
}

.menu-toggle:hover span {
    background: rgba(255, 255, 255, 0.8) !important;
}

.top-bar-left h2 {
    font-size: 16px;
    font-weight: 600;
    color: white !important;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.user-role {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.user-actions .btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    white-space: nowrap;
}

.content-wrapper {
    flex: 1;
    padding: 24px;
    overflow: visible;
}

@media (max-width: 900px) {
    .sidebar,
    .sidebar.collapsed {
        position: fixed !important;
        left: 0 !important;
        top: 56px !important;
        bottom: 0 !important;
        z-index: 999 !important;
        width: 240px !important;
        transform: none !important;
    }
    
    .sidebar.collapsed .sidebar-header h1,
    .sidebar.collapsed .sidebar-header p,
    .sidebar.collapsed .nav-text,
    .sidebar.collapsed .nav-group-title {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .sidebar.collapsed .sidebar-header {
        padding: 20px !important;
        text-align: left !important;
    }
    
    .sidebar.collapsed .sidebar-nav a {
        justify-content: flex-start !important;
        padding: 12px 20px !important;
    }
    
    .main-content {
        margin-left: 240px !important;
    }
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1000;
        width: 240px !important;
        height: 100vh;
        transform: translateX(-100%) !important;
        transition: transform 0.3s !important;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0) !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
}

@media (max-width: 600px) {
    .sidebar {
        width: 240px !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s !important;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0) !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
}

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

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 180px;
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
    font-family: inherit;
    min-height: 40px;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
}

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

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

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

.btn-success:hover {
    background: #059669;
}

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

.btn-danger:hover {
    background: #dc2626;
}

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

.btn-warning:hover {
    background: #d97706;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-info {
    background: #3b82f6;
    color: white;
}

.btn-info:hover {
    background: #2563eb;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
    display: block;
}

.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table thead {
    background: var(--bg-secondary);
}

.table th {
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background: #f9fafb;
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

table tbody tr:nth-child(even) {
    background: var(--bg-secondary);
}

table tbody tr:hover {
    background: #e5e7eb;
}

.text-success {
    color: var(--success-color);
}

.text-error {
    color: var(--error-color);
}

.text-warning {
    color: var(--warning-color);
}

.text-center {
    text-align: center;
}

.btn-group {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.serial-number {
    display: inline-block;
    cursor: help;
    border-bottom: 1px dotted #6b7280;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-error {
    background: #fee2e2;
    color: #991b1b;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-secondary {
    background: #f3e8ff;
    color: #6b21a8;
}

@media (max-width: 767px) {
    .layout-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        position: fixed;
        left: 0;
        top: 56px;
        bottom: 0;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s;
        max-width: 280px;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        width: 100%;
        transform: translateX(-100%);
    }
    
    .sidebar.collapsed.mobile-open {
        transform: translateX(0);
    }
    
    .main-content {
        order: 1;
        margin-left: 0 !important;
    }
    
    .content-wrapper {
        padding: 12px;
    }
    
    .top-bar-left h2 {
        font-size: 16px;
    }
    
    .user-info {
        display: none;
    }
    
    .search-box form,
    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box input,
    .search-box select,
    .filter-form input,
    .filter-form select {
        min-width: 100%;
    }
    
    .search-box button,
    .search-box a,
    .filter-form button,
    .filter-form a {
        width: 100%;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .page-header h1 {
        font-size: 20px;
    }
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .pagination-links {
        flex-wrap: wrap;
    }
    
    .modal-content {
        width: 95%;
        max-height: 85vh;
        margin: 10px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }
    
    .modal-header h3 {
        font-size: 16px;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
    
    .form-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .form-row .form-group {
        min-width: 100%;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    .order-item-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .detail-section h3 {
        font-size: 16px;
    }
    
    .detail-table th,
    .detail-table td {
        display: block;
        width: 100%;
        padding: 8px 0;
    }
    
    .detail-table th {
        background: transparent;
        color: var(--text-secondary);
        font-weight: 500;
        padding-bottom: 4px;
    }
    
    .detail-table td {
        padding-top: 4px;
    }
    
    .table {
        font-size: 12px;
    }
    
    .table th,
    .table td {
        padding: 8px 6px;
    }
    
    .badge {
        font-size: 11px;
        padding: 3px 6px;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .btn-sm {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    .alert {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .search-box,
    .search-container,
    .filter-container {
        padding: 16px;
    }
    
    .form-container {
        padding: 16px;
    }
    
    .form-section {
        padding: 16px;
    }
    
    .detail-container {
        padding: 16px;
    }
}

/* 移动端（<768px）：个人设置表单强制自适应，避免 max-width 导致横向滚动 */
@media (max-width: 767px) {
    body {
        overflow-x: hidden;
    }
    
    .content-wrapper {
        overflow-x: hidden;
    }
    
    #profileForm {
        overflow-x: hidden;
        width: 100%;
    }
    
    /* profile.php 内联样式里存在 max-width: 300px，需要用 !important 覆盖 */
    #profileForm input,
    #profileForm select,
    #profileForm textarea {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    #profileForm [style*="max-width"] {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* 强制移动端模式（force=mobile）：不依赖屏幕宽度 */
body.force-mobile #menuToggle {
    display: none !important;
}

body.force-mobile {
    overflow-x: hidden;
}

body.force-mobile .content-wrapper {
    overflow-x: hidden;
}

body.force-mobile .layout-container {
    flex-direction: column;
}

body.force-mobile .main-content {
    order: 1;
    margin-left: 0 !important;
}

/* 保持与移动端抽屉样式一致：侧边栏默认收起 */
body.force-mobile .sidebar {
    width: 100%;
    position: fixed;
    left: 0;
    top: 56px;
    bottom: 0;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s;
    max-width: 280px;
}

body.force-mobile .sidebar.mobile-open {
    transform: translateX(0);
}

body.force-mobile .sidebar.collapsed {
    width: 100%;
    transform: translateX(-100%);
}

body.force-mobile .sidebar.collapsed.mobile-open {
    transform: translateX(0);
}

/* profile.php 内联样式里存在 max-width: 300px，需要用 !important 覆盖 */
body.force-mobile #profileForm {
    overflow-x: hidden;
    width: 100%;
}

body.force-mobile #profileForm input,
body.force-mobile #profileForm select,
body.force-mobile #profileForm textarea {
    width: 100% !important;
    max-width: 100% !important;
}

body.force-mobile #profileForm [style*="max-width"] {
    width: 100% !important;
    max-width: 100% !important;
}

@media (max-width: 480px) {
    body {
        font-size: 13px;
    }
    
    .content-wrapper {
        padding: 8px;
    }
    
    .top-bar {
        padding: 0 12px;
        height: 52px;
    }
    
    .menu-toggle span {
        width: 18px;
    }
    
    .top-bar-left h2 {
        font-size: 14px;
    }
    
    .page-header h1 {
        font-size: 18px;
    }
    
    .search-box,
    .search-container,
    .filter-container {
        padding: 12px;
    }
    
    .search-box form,
    .filter-form {
        gap: 8px;
    }
    
    .form-group {
        margin-bottom: 16px;
    }
    
    .form-group label {
        font-size: 13px;
    }
    
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    input[type="date"],
    input[type="url"],
    select,
    textarea {
        font-size: 13px;
        padding: 8px 10px;
    }
    
    .btn {
        padding: 8px 14px;
        font-size: 12px;
    }
    
    .btn-sm {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .table {
        font-size: 11px;
    }
    
    .table th,
    .table td {
        padding: 6px 4px;
    }
    
    .modal-content {
        width: 98%;
        margin: 5px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 12px;
    }
    
    .modal-header h3 {
        font-size: 14px;
    }
    
    .pagination a,
    .pagination .current {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .badge {
        font-size: 10px;
        padding: 2px 5px;
    }
    
    .alert {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .detail-container {
        padding: 12px;
    }
    
    .detail-section {
        margin-bottom: 20px;
    }
    
    .detail-section h3 {
        font-size: 14px;
        margin-bottom: 12px;
    }
    
    .form-container {
        padding: 12px;
    }
    
    .form-section {
        padding: 12px;
        margin-bottom: 20px;
    }
    
    .form-section h3 {
        font-size: 14px;
    }
    
    .order-item-row {
        padding: 12px;
        gap: 10px;
    }
}

@media (max-width: 360px) {
    .top-bar-left h2 {
        font-size: 13px;
    }
    
    .page-header h1 {
        font-size: 16px;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 11px;
    }
    
    .pagination a,
    .pagination .current {
        padding: 5px 10px;
        font-size: 11px;
    }
}

/* ===== 平板/折叠屏展开模式适配（720px ~ 1400px） ===== */
@media (min-width: 720px) and (max-width: 1400px) {
    /* 内容区缩小间距 */
    .main-content {
        padding: 16px;
    }

    .content-wrapper {
        padding: 16px;
    }

    /* 表单响应式：紧凑布局 */
    .form-row .form-group {
        min-width: 30%;
        flex: 1 1 30%;
    }

    .form-group label {
        font-size: 13px;
    }

    .form-control,
    .form-select {
        font-size: 13px;
        padding: 8px 10px;
    }

    /* 搜索/过滤允许换行 */
    .search-box form,
    .filter-form {
        flex-wrap: wrap !important;
        gap: 8px;
        align-items: flex-start;
    }

    .search-box input,
    .search-box select,
    .filter-form input,
    .filter-form select {
        min-width: 120px;
        max-width: 200px;
        flex: 1 1 auto;
        font-size: 13px;
        padding: 8px 10px;
    }

    .search-box button,
    .filter-form button {
        min-width: 80px;
        padding: 8px 12px;
        font-size: 13px;
        white-space: nowrap;
    }

    /* 表格允许横向滚动 */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        border: 1px solid var(--border-color);
    }

    .table {
        font-size: 12px;
        min-width: 600px;
    }

    .table th,
    .table td {
        padding: 8px 6px;
        white-space: nowrap;
    }

    .table th {
        font-size: 11px;
    }

    /* 表格操作列缩小 */
    .table .action-column {
        width: 80px;
        text-align: center;
    }

    /* 模态框适应窄屏 */
    .modal-content {
        width: 95%;
        max-width: 700px;
    }

    /* 页面标题 */
    .page-header h1 {
        font-size: 18px;
    }

    .page-header .btn {
        font-size: 13px;
        padding: 8px 16px;
    }

    /* 订单商品行适应 */
    .order-item-row {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 8px;
        padding: 12px;
    }

    .order-item-row .form-group {
        min-width: 100px;
        flex: none;
        margin-bottom: 8px;
    }

    .order-item-row .form-control {
        font-size: 12px;
        padding: 6px 8px;
    }

    /* 详情网格适应 */
    .detail-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 12px;
    }

    /* 卡片紧凑布局 */
    .card {
        padding: 16px;
    }

    .card-header {
        padding: 12px 16px;
        margin-bottom: 12px;
    }

    /* 统计卡片 */
    .stat-card {
        padding: 16px;
    }

    .stat-card .stat-value {
        font-size: 24px;
    }

    .stat-card .stat-label {
        font-size: 13px;
    }

    /* 输入框自适应 */
    input[type="text"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 13px;
        padding: 8px 10px;
    }

    textarea {
        min-height: 80px;
    }

    /* 按钮紧凑 */
    .btn {
        font-size: 13px;
        padding: 8px 16px;
    }

    .btn-sm {
        font-size: 12px;
        padding: 6px 12px;
    }

    .btn-lg {
        font-size: 14px;
        padding: 10px 24px;
    }

    /* 搜索框紧凑 */
    .search-box,
    .search-container,
    .filter-container {
        padding: 14px;
        margin-bottom: 16px;
    }

    /* 分页适应：仅作用于分页链接容器，不影响页面级 .pagination */
    .pagination-links {
        flex-wrap: wrap;
        gap: 4px;
    }

    .pagination .page-item a,
    .pagination .page-item span {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* 标签紧凑 */
    .badge {
        font-size: 11px;
        padding: 2px 6px;
    }

    /* 提示文字缩小 */
    .help-text,
    .form-text,
    small {
        font-size: 12px;
    }

    /* 卡片内间距 */
    .card-body {
        padding: 14px;
    }

    /* 页脚紧凑 */
    .footer {
        padding: 10px 16px;
        font-size: 12px;
    }

    /* 详情页适配 */
    .detail-container {
        padding: 16px;
    }

    .detail-section {
        margin-bottom: 20px;
    }

    .detail-section h3 {
        font-size: 15px;
        margin-bottom: 12px;
        padding-bottom: 8px;
    }

    .detail-table th {
        width: 100px;
        font-size: 12px;
        padding: 8px 6px;
    }

    .detail-table td {
        font-size: 12px;
        padding: 8px 6px;
        word-break: break-all;
    }

    .detail-section > div[style*="display: flex"] {
        flex-wrap: wrap;
        gap: 10px;
    }

    .detail-section .total-amount-display {
        font-size: 14px;
        padding: 8px 12px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-actions {
        flex-wrap: wrap;
        gap: 8px;
    }
}

@media (max-width: 900px) {
    /* 详情页小屏适配 */
    .detail-section > div[style*="flex: 1"] {
        flex: 1 1 45% !important;
        min-width: 150px;
    }

    .detail-table {
        font-size: 12px;
    }

    .detail-table th,
    .detail-table td {
        padding: 6px 4px;
    }

    .detail-section > div[style*="display: flex"] > div {
        flex: 1 1 100% !important;
        border-right: none !important;
        border-bottom: 1px solid #ddd;
    }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.page-actions {
    display: flex;
    gap: 10px;
}

.content {
    width: 100%;
}

.search-box {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.search-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.filter-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.search-box form,
.filter-form {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    align-items: center;
}

.search-box input,
.search-box select,
.filter-form input,
.filter-form select {
    flex: 0 0 auto;
    min-width: 150px;
    max-width: 200px;
}

.search-box input[type="text"],
.search-box input[type="date"] {
    min-width: 150px;
    max-width: 180px;
}

.search-box select[name="supplier_id"] {
    min-width: 180px;
    max-width: 220px;
}

.table-container {
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.report-table {
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.report-table table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
}

.report-table th,
.report-table td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    vertical-align: middle;
    font-size: 13px;
}

.report-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    white-space: nowrap;
}

.report-table tbody tr:hover {
    background: #f9fafb;
}

.report-table .total-row {
    background: #f8fafc;
    font-weight: 600;
}

.data-table {
    margin-bottom: 0;
}

.data-table thead {
    background: var(--bg-secondary);
}

.data-table th {
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
    background: #f9fafb;
}

.pagination {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.pagination-info {
    font-size: 14px;
    color: var(--text-secondary);
}

.page-info {
    font-size: 14px;
    color: var(--text-secondary);
    padding: 8px 16px;
}

.pagination-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.pagination a {
    padding: 8px 16px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s;
}

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

.amount-summary {
    display: flex;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.amount-item {
    flex: 1;
    padding: 12px;
    border-right: 1px solid #ddd;
    text-align: center;
}

.amount-item:last-child {
    border-right: none;
}

.amount-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.amount-value {
    font-size: 14px;
    font-weight: bold;
}

.amount-sub {
    font-size: 10px;
    color: #999;
    margin-top: 2px;
}

.amount-link {
    color: #007bff;
    cursor: pointer;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

@media (max-width: 1200px) {
    .amount-summary {
        flex-wrap: wrap;
    }
    
    .amount-item {
        flex: 1 1 30%;
        min-width: 120px;
        border-right: none;
        border-bottom: 1px solid #ddd;
    }
    
    .amount-item:nth-child(3n) {
        border-right: 1px solid #ddd;
    }
    
    .amount-item:last-child,
    .amount-item:nth-last-child(2),
    .amount-item:nth-last-child(3) {
        border-bottom: none;
    }
}

@media (max-width: 768px) {
    .amount-item {
        flex: 1 1 50%;
        border-right: 1px solid #ddd;
    }
    
    .amount-item:nth-child(2n) {
        border-right: none;
    }
    
    .amount-item:nth-last-child(2),
    .amount-item:last-child {
        border-bottom: none;
    }
}

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

.pagination .current {
    padding: 8px 16px;
    color: var(--text-secondary);
}

.detail-container {
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.detail-section {
    margin-bottom: 32px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.detail-table {
    width: 100%;
}

.detail-table th {
    width: 150px;
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

.detail-table td {
    color: var(--text-primary);
}

.form-container {
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.form-section {
    margin-bottom: 32px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.form-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.order-item-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    padding: 16px;
    background: white;
    border-radius: 6px;
    margin-bottom: 12px;
    align-items: end;
}

.order-item-row .form-group {
    margin-bottom: 0;
}

.required {
    color: var(--error-color);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-inactive {
    background: #fee2e2;
    color: #991b1b;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.show {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.3s;
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-overlay {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
}

.modal-content.modal-warning {
    background-color: white;
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    padding: 40px 30px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-warning .modal-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.modal-warning h3 {
    margin: 0 0 16px 0;
    font-size: 22px;
    color: #dc2626;
    font-weight: 600;
}

.modal-warning p {
    margin: 0 0 10px 0;
    font-size: 15px;
    color: #6b7280;
    line-height: 1.6;
}

.modal-warning .btn {
    margin-top: 24px;
    padding: 12px 32px;
    font-size: 15px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-warning .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

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

.tracking-table th,
.tracking-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.tracking-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

.tracking-table tbody tr:hover {
    background: #f9fafb;
}

.tracking-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
}

.tracking-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.tracking-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

.tracking-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.tracking-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

.tracking-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.product-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 4px;
}

.product-suggestions::-webkit-scrollbar {
    width: 6px;
}

.product-suggestions::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.product-suggestions::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.product-suggestions::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.suggestion-item {
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: var(--bg-secondary);
}

.suggestion-item strong {
    color: var(--text-primary);
    font-weight: 500;
}

.offset-amount {
    color: #ef4444;
    font-weight: 600;
}

.new-amount {
    color: #10b981;
    font-weight: 600;
}

.payment-detail-section {
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.payment-detail-section h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

.detail-item {
    display: flex;
    align-items: center;
}

.detail-item label {
    font-weight: 500;
    color: var(--text-secondary);
    margin-right: 8px;
    min-width: 80px;
}

.detail-item .amount {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
}

.reversal-info {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.reversal-info h4 {
    margin: 0 0 8px 0;
    color: #92400e;
}

.reversal-info p {
    margin: 4px 0;
    color: #78350f;
}

.payment-detail-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.vouchers-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.voucher-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.voucher-info {
    display: flex;
    gap: 12px;
    align-items: center;
}

.voucher-name {
    font-weight: 500;
    color: var(--text-primary);
}

.voucher-time,
.voucher-uploader {
    color: var(--text-secondary);
    font-size: 12px;
}

.voucher-remark {
    color: var(--text-secondary);
    font-size: 13px;
}

.voucher-actions {
    display: flex;
    gap: 8px;
}
