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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.6;
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ===== 侧边导航栏 ===== */
.sidebar {
    width: 240px;
    background: linear-gradient(180deg, #001529 0%, #003a8c 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 1px;
    line-height: 1.4;
}

.sidebar-header h1 small {
    display: block;
    font-size: 14px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 2px;
}

.nav-items {
    flex: 1;
    padding: 15px 10px;
    overflow-y: auto;
}

.nav-btn {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 14px 20px;
    margin-bottom: 6px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 15px;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.nav-btn.active {
    background: #1890ff;
    color: #fff;
    box-shadow: 0 2px 8px rgba(24, 144, 255, 0.4);
}

.nav-icon {
    font-size: 18px;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

.nav-text {
    font-weight: 500;
}

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

.user-info {
    text-align: center;
    margin-bottom: 12px;
}

.user-name {
    display: block;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
}

.user-role {
    display: block;
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    margin-top: 2px;
}

.logout-btn {
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
}

.logout-btn:hover {
    background: rgba(255, 77, 79, 0.8);
    border-color: rgba(255, 77, 79, 0.8);
    color: #fff;
}

/* ===== 主内容区域 ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    margin-right: 15px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #faad14;
    animation: pulse 1.5s infinite;
}

.status-dot.connected {
    background: #52c41a;
    animation: none;
}

.status-dot.error {
    background: #ff4d4f;
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.page-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 工具栏 ===== */
.page-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.search-input {
    min-width: 250px;
    padding: 9px 15px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s ease;
    flex: 1;
    max-width: 350px;
}

.search-input:focus {
    outline: none;
    border-color: #1890ff;
    box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.1);
}

.filter-select {
    padding: 9px 15px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
    min-width: 130px;
}

.filter-select:focus {
    outline: none;
    border-color: #1890ff;
    box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.1);
}

/* ===== 按钮样式 ===== */
.btn {
    padding: 9px 18px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.btn-primary {
    background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #40a9ff 0%, #1890ff 100%);
}

.btn-success {
    background: linear-gradient(135deg, #52c41a 0%, #389e0d 100%);
    color: #fff;
}

.btn-success:hover:not(:disabled) {
    background: linear-gradient(135deg, #73d13d 0%, #52c41a 100%);
}

.btn-danger {
    background: linear-gradient(135deg, #ff4d4f 0%, #cf1322 100%);
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, #ff7875 0%, #ff4d4f 100%);
}

.btn-warning {
    background: linear-gradient(135deg, #faad14 0%, #d48806 100%);
    color: #fff;
}

.btn-warning:hover:not(:disabled) {
    background: linear-gradient(135deg, #ffc53d 0%, #faad14 100%);
}

.btn-default {
    background: #fff;
    color: #333;
    border: 1px solid #d9d9d9;
}

.btn-default:hover:not(:disabled) {
    border-color: #1890ff;
    color: #1890ff;
}

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

/* ===== 表格样式 ===== */
.table-container {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead {
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
}

.data-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #e8e8e8;
    font-size: 14px;
    letter-spacing: 0.3px;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background-color 0.2s ease;
    cursor: pointer;
}

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

.data-table tbody tr.selected {
    background-color: #bae7ff;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* 状态标签 */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.status-pending {
    background: #fff7e6;
    color: #faad14;
    border: 1px solid #ffe58f;
}

.status-completed {
    background: #f6ffed;
    color: #52c41a;
    border: 1px solid #b7eb8f;
}

.status-cancelled {
    background: #fff2f0;
    color: #ff4d4f;
    border: 1px solid #ffccc7;
}

.status-active {
    background: #f6ffed;
    color: #52c41a;
    border: 1px solid #b7eb8f;
}

.status-inactive {
    background: #fff2f0;
    color: #ff4d4f;
    border: 1px solid #ffccc7;
}

/* 头像样式 */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e8e8e8;
    background: #f5f5f5;
}

.avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e8e8e8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #999;
}

/* ===== 模态框 ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-overlay.show {
    display: flex;
    animation: fadeInOverlay 0.25s ease;
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: #fff;
    border-radius: 12px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    padding: 24px 28px;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #f0f5ff 0%, #e6f7ff 100%);
}

.modal-header h2 {
    font-size: 22px;
    color: #1890ff;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
    transform: rotate(90deg);
}

.modal-body {
    padding: 28px;
}

.modal-footer {
    padding: 18px 28px;
    border-top: 1px solid #e8e8e8;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #fafafa;
    border-radius: 0 0 12px 12px;
}

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

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

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.form-label .required {
    color: #ff4d4f;
    margin-left: 3px;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: #1890ff;
    box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.1);
}

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

.form-input-number {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
}

/* 验光数据表格 */
.rx-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: #fafafa;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.rx-table th {
    background: #e8e8e8;
    padding: 10px;
    font-weight: 600;
    font-size: 13px;
    text-align: center;
    border: 1px solid #d9d9d9;
}

.rx-table td {
    padding: 8px;
    text-align: center;
    border: 1px solid #e8e8e8;
    background: #fff;
}

.rx-table .rx-label {
    background: #f5f5f5;
    font-weight: 600;
    color: #666;
}

.rx-input {
    width: 80px;
    padding: 6px 8px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    text-align: center;
    font-size: 14px;
}

.rx-input:focus {
    outline: none;
    border-color: #1890ff;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
}

/* 商品明细区域 */
.items-section {
    margin: 20px 0;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    overflow: hidden;
}

.items-header {
    background: linear-gradient(135deg, #f0f5ff 0%, #e6f7ff 100%);
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #d9d9d9;
}

.items-header h3 {
    font-size: 16px;
    color: #1890ff;
    font-weight: 600;
}

.items-toolbar {
    display: flex;
    gap: 8px;
}

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

.items-table th {
    background: #fafafa;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid #e8e8e8;
}

.items-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
}

/* 订单金额区域 */
.amount-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 20px 0;
    padding: 18px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
}

.amount-item {
    display: flex;
    flex-direction: column;
}

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

.amount-value {
    font-size: 22px;
    font-weight: 700;
    color: #ff4d4f;
}

.amount-value.total {
    color: #333;
    font-size: 18px;
}

/* ===== Toast提示 ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 22px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    animation: toastSlideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
}

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success {
    background: linear-gradient(135deg, #52c41a 0%, #389e0d 100%);
}

.toast.error {
    background: linear-gradient(135deg, #ff4d4f 0%, #cf1322 100%);
}

.toast.warning {
    background: linear-gradient(135deg, #faad14 0%, #d48806 100%);
}

.toast.info {
    background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
}

/* ===== 响应式设计 ===== */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 1001;
        transition: left 0.3s ease;
    }

    .sidebar.show {
        left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .page-toolbar {
        flex-wrap: wrap;
    }

    .search-input {
        max-width: 100%;
        flex: 1 1 100%;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal {
        max-width: 95%;
        margin: 10px;
    }
}

@media (max-width: 768px) {
    .page-container {
        padding: 12px;
    }

    .btn {
        padding: 8px 14px;
        font-size: 13px;
    }

    .data-table {
        font-size: 13px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 12px;
    }

    .modal-body {
        padding: 20px;
    }

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

    .rx-input {
        width: 65px;
        padding: 5px 6px;
    }
}

@media (max-width: 480px) {
    .top-bar {
        padding: 0 12px;
    }

    .page-toolbar {
        gap: 6px;
    }

    .btn {
        padding: 7px 11px;
        font-size: 12px;
    }

    .btn span {
        display: none;
    }

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

    .amount-section {
        grid-template-columns: 1fr;
    }
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

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

/* 图片预览 */
.image-preview {
    max-width: 120px;
    max-height: 120px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid #e8e8e8;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.image-preview:hover {
    transform: scale(1.05);
    border-color: #1890ff;
}

.images-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
    padding: 15px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px dashed #d9d9d9;
}

.no-data {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 16px;
}

.no-data-icon {
    font-size: 48px;
    margin-bottom: 15px;
}
