/* ========================
   K-Man售后管理系统 - 主样式表
   ======================== */

/* CSS变量 */
:root {
    --primary: #1a5276;
    --primary-light: #2874a6;
    --primary-dark: #154360;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --bg-dark: #1e293b;
    --text-main: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --border: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
    --nav-height: 60px;
    /* Gray scale aliases */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --sidebar-width: 240px;
}

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

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary);
}

/* ========================
   导航栏
   ======================== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.nav-brand a {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    margin-left: 24px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.85);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}

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

.nav-link.active {
    background: rgba(255,255,255,0.18);
    color: #fff;
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    padding-left: 16px;
    border-left: 1px solid rgba(255,255,255,0.15);
}

.user-name {
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
}

.logout-link {
    padding: 6px 12px;
    border-radius: var(--radius);
}

.role-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.role-管理员 { background: rgba(231,76,60,0.2); color: #fff; }
.role-内勤人员 { background: rgba(243,156,18,0.2); color: #fff; }
.role-业务员 { background: rgba(52,152,219,0.2); color: #fff; }
.role-维修员 { background: rgba(39,174,96,0.2); color: #fff; }
.role-统计员 { background: rgba(155,89,182,0.2); color: #fff; }

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* ========================
   主内容区
   ======================== */
.main-content {
    padding: calc(var(--nav-height) + 24px) 24px 24px;
    max-width: 1440px;
    margin: 0 auto;
}

.main-content.full-width {
    padding: 0;
    max-width: none;
}

/* ========================
   页面标题
   ======================== */
.page-header {
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 4px;
}

/* ========================
   卡片
   ======================== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.clickable-card {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.clickable-card:hover {
    color: inherit;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-icon.quote-total { background: #e8f4fd; color: var(--primary-light); }
.stat-icon.quote-amount { background: #e6f9ee; color: var(--success); }
.stat-icon.quote-paid { background: #e6f9ee; color: var(--success); }
.stat-icon.quote-unpaid { background: #fdecea; color: var(--danger); }
.stat-icon.borrow-total { background: #fff3e0; color: var(--warning); }
.stat-icon.borrow-out { background: #e8f4fd; color: var(--primary-light); }
.stat-icon.borrow-partial { background: #fff3e0; color: var(--warning); }
.stat-icon.borrow-returned { background: #e6f9ee; color: var(--success); }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ========================
   区块
   ======================== */
.section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-icon {
    width: 20px;
    height: 20px;
    color: var(--primary-light);
}

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

.link-more {
    font-size: 0.875rem;
    font-weight: 500;
}

/* ========================
   两列布局
   ======================== */
.two-column {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.two-column .section {
    margin-bottom: 0;
}

/* ========================
   工单状态条
   ======================== */
.ticket-status-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: space-around;
    padding: 12px 0;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 80px;
}

.clickable-status {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: transform 0.15s;
}

.clickable-status:hover {
    transform: translateY(-2px);
}

.clickable-status:hover .status-badge {
    opacity: 0.85;
}

.status-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* ========================
   状态标签
   ======================== */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-pending { background: #fef3c7; color: #92400e; }
.status-processing { background: #dbeafe; color: #1e40af; }
.status-waiting { background: #fce7f3; color: #9d174d; }
.status-repairing { background: #e0e7ff; color: #3730a3; }
.status-completed { background: #d1fae5; color: #065f46; }
.status-cancelled { background: #f3f4f6; color: #4b5563; }
.status-paid { background: #d1fae5; color: #065f46; }
.status-unpaid { background: #fdecea; color: #991b1b; }
.status-partial { background: #fef3c7; color: #92400e; }
.status-returned { background: #d1fae5; color: #065f46; }
.status-out { background: #dbeafe; color: #1e40af; }

/* ========================
   表格
   ======================== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead {
    background: #f9fafb;
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.data-table th:hover {
    background: #f3f4f6;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

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

.data-table tbody tr.clickable-row {
    cursor: pointer;
}

.empty-cell {
    text-align: center;
    color: var(--text-light);
    padding: 32px 16px !important;
}

/* ========================
   图表
   ======================== */
.chart-container {
    position: relative;
    width: 100%;
    height: 280px;
}

.chart-container canvas {
    width: 100%;
    height: 100%;
}

/* ========================
   按钮
   ======================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: #fff;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.btn-success {
    background: linear-gradient(135deg, #2ecc71 0%, var(--success) 100%);
    color: #fff;
}

.btn-success:hover {
    filter: brightness(1.05);
}

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

.btn-danger:hover {
    filter: brightness(1.05);
}

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

.btn-warning:hover {
    filter: brightness(1.05);
}

.btn-info {
    background: linear-gradient(135deg, #5dade2 0%, #3498db 100%);
    color: #fff;
}

.btn-info:hover {
    filter: brightness(1.05);
}

.btn-secondary {
    background: #f3f4f6;
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.btn-block {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
}

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

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

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="tel"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    color: var(--text-main);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(40,116,166,0.1);
}

.form-group input::placeholder {
    color: var(--text-light);
}

.input-wrapper {
    position: relative;
}

.input-wrapper input {
    padding-left: 42px;
}

.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-light);
    pointer-events: none;
}

/* 复选框 */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.checkbox-label input:checked + .checkmark {
    background: var(--primary-light);
    border-color: var(--primary-light);
}

.checkbox-label input:checked + .checkmark::after {
    content: '';
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

/* ========================
   登录页
   ======================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    padding: 24px;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

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

.login-logo {
    width: 160px;
    max-width: 80%;
    height: auto;
    margin: 0 auto 16px;
    color: var(--primary-light);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-logo img {
    width: 100%;
    height: auto;
    display: block;
    max-width: 100%;
    object-fit: contain;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 4px;
}

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

.login-form .input-wrapper input {
    padding-left: 42px;
    width: 100%;
    padding-top: 10px;
    padding-right: 14px;
    padding-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    color: var(--text-main);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
    box-sizing: border-box;
}

.login-form .input-wrapper input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(40,116,166,0.1);
}

.login-form .input-wrapper input::placeholder {
    color: var(--text-light);
}

.login-alerts {
    margin-bottom: 16px;
}

.login-alert {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.login-alert.alert-danger {
    background: #fdecea;
    color: #991b1b;
    border: 1px solid #f5c6cb;
}

/* ========================
   设置页
   ======================== */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.settings-grid .section-wide {
    grid-column: 1 / -1;
}

.settings-form {
    max-width: 400px;
}

.quick-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quick-link-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.quick-link-card:hover {
    border-color: var(--primary-light);
    background: #f8fafc;
    transform: translateX(4px);
}

.quick-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: #e8f4fd;
    color: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.quick-icon svg {
    width: 22px;
    height: 22px;
}

.quick-info {
    display: flex;
    flex-direction: column;
}

.quick-title {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.9375rem;
}

.quick-desc {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.backup-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.backup-status {
    display: flex;
    gap: 8px;
    font-size: 0.9375rem;
}

.backup-label {
    color: var(--text-secondary);
    min-width: 120px;
}

.backup-value {
    font-weight: 600;
    color: var(--text-main);
}

.backup-actions {
    display: flex;
    gap: 12px;
    margin-top: 4px;
}

.backup-hint {
    font-size: 0.8125rem;
    color: var(--text-light);
    margin-top: 4px;
}

.backup-list-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.section-subtitle {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 12px;
}

.backup-list-section .data-table {
    font-size: 0.875rem;
}

.backup-list-section .data-table td {
    padding: 8px 12px;
}

/* ========================
   消息提示 (Toast)
   ======================== */
.toast-container {
    position: fixed;
    top: calc(var(--nav-height) + 16px);
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.3s ease;
    pointer-events: auto;
    min-width: 200px;
    max-width: 360px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--info); }

.toast.hiding {
    animation: toastSlideOut 0.3s ease forwards;
}

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

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

/* ========================
   确认对话框
   ======================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal-box {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.2s ease;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.modal-body {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

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

@keyframes scaleIn {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ========================
   搜索/筛选
   ======================== */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-bar input {
    flex: 1;
    min-width: 200px;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
}

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

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

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

.pagination .current {
    background: var(--primary-light);
    color: #fff;
    border-color: var(--primary-light);
}

.pagination .disabled {
    color: var(--text-light);
    cursor: not-allowed;
    pointer-events: none;
}

/* ========================
   响应式
   ======================== */
@media (max-width: 1024px) {
    .two-column {
        grid-template-columns: 1fr;
    }
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0 16px;
    }
    .nav-toggle {
        display: flex;
    }
    .nav-menu {
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
        flex-direction: column;
        align-items: stretch;
        padding: 8px 16px 16px;
        gap: 0;
        margin-left: 0;
        display: none;
        box-shadow: var(--shadow-lg);
    }
    .nav-menu.open {
        display: flex;
    }
    .nav-links {
        flex-direction: column;
        gap: 2px;
    }
    .nav-user {
        margin-left: 0;
        padding: 12px 0 0;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.15);
        margin-top: 8px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .main-content {
        padding: calc(var(--nav-height) + 16px) 16px 16px;
    }
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .ticket-status-bar {
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .card-grid {
        grid-template-columns: 1fr;
    }
    .stat-card {
        padding: 16px;
    }
    .login-card {
        padding: 28px 20px;
    }
    .chart-container {
        height: 220px;
    }
    .backup-actions {
        flex-direction: column;
    }
    .backup-actions .btn {
        width: 100%;
    }
}

/* ========================
   兼容样式 - 独立页面导航栏
   ======================== */
.navbar-inner {
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
    gap: 24px;
}

.navbar-brand {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    list-style: none;
    flex: 1;
    margin: 0;
    padding: 0;
}

.navbar-nav li {
    list-style: none;
}

.navbar-nav li a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.85);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.navbar-nav li a:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

.navbar-nav li a.active {
    background: rgba(255,255,255,0.18);
    color: #fff;
}

/* 独立页面容器 */
.container {
    max-width: 1440px;
    margin: 0 auto;
}

.page-wrapper {
    padding: calc(var(--nav-height) + 24px) 24px 24px;
}

/* ========================
   兼容样式 - 卡片
   ======================== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-body {
    padding: 20px;
}

/* ========================
   兼容样式 - 页面标题
   ======================== */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

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

/* ========================
   兼容样式 - 表单控件
   ======================== */
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    color: var(--text-main);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(40,116,166,0.1);
}

.form-control::placeholder {
    color: var(--text-light);
}

select.form-control {
    cursor: pointer;
    appearance: auto;
}

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

/* ========================
   兼容样式 - 表格容器
   ======================== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
}

/* ========================
   兼容样式 - 徽章/标签
   ======================== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-primary { background: #dbeafe; color: #1e40af; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fdecea; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-gray { background: #f3f4f6; color: #4b5563; }

/* ========================
   兼容样式 - 小按钮
   ======================== */
.btn-sm {
    padding: 5px 12px;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
}

/* ========================
   兼容样式 - 空状态
   ======================== */
.empty-state {
    text-align: center;
    color: var(--text-light);
    padding: 32px 16px !important;
}

/* ========================
   兼容样式 - 搜索栏表单组
   ======================== */
.search-bar .form-group {
    margin-bottom: 0;
    min-width: 160px;
}

.search-bar .form-group label {
    font-size: 0.8125rem;
    margin-bottom: 4px;
}

.search-bar .form-control {
    min-width: 140px;
}

.search-bar .btn {
    align-self: flex-end;
    height: 40px;
}

/* ========================
   兼容样式 - 详情页
   ======================== */
.detail-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

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

.detail-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.detail-body {
    padding: 24px;
}

.detail-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    gap: 16px;
}

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

.detail-label {
    min-width: 120px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
    flex-shrink: 0;
}

.detail-value {
    color: var(--text-main);
    font-size: 0.9375rem;
    flex: 1;
}

/* ========================
   兼容样式 - 表单行布局
   ======================== */
.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 200px;
}

/* ========================
   兼容样式 - 动态表格
   ======================== */
.dynamic-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    margin-bottom: 16px;
}

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

.dynamic-table th {
    background: #f9fafb;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.dynamic-table input,
.dynamic-table select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    box-sizing: border-box;
}

.dynamic-table input:focus,
.dynamic-table select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(40,116,166,0.1);
}

/* ========================
   兼容样式 - 卡片列表（维修员派单）
   ======================== */
.assignment-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
    border-left: 4px solid var(--primary-light);
}

.assignment-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-main);
}

.assignment-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.assignment-info-item {
    font-size: 0.875rem;
}

.assignment-info-item .label {
    color: var(--text-secondary);
    margin-right: 8px;
}

/* ========================
   兼容样式 - 模态框表单
   ======================== */
.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.2s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-main);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* ========================
   兼容样式 - 金额汇总
   ======================== */
.amount-summary {
    background: #f9fafb;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-top: 16px;
}

.amount-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.9375rem;
}

.amount-row.total {
    border-top: 2px solid var(--border);
    margin-top: 8px;
    padding-top: 12px;
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--primary);
}

.amount-label {
    color: var(--text-secondary);
}

.amount-value {
    font-weight: 600;
    color: var(--text-main);
}

/* ========================
   兼容样式 - 响应式补充
   ======================== */
@media (max-width: 768px) {
    .navbar-nav {
        flex-wrap: wrap;
        gap: 4px;
    }
    .navbar-nav li a {
        padding: 6px 10px;
        font-size: 0.8125rem;
    }
    .form-row {
        flex-direction: column;
    }
    .detail-row {
        flex-direction: column;
        gap: 4px;
    }
    .detail-label {
        min-width: auto;
    }
}

/* ========================
   侧边栏布局 (Pattern B)
   ======================== */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-dark);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px 24px;
    font-size: 1.125rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    white-space: nowrap;
}

.sidebar-menu {
    list-style: none;
    padding: 8px 0;
    margin: 0;
    flex: 1;
}

.sidebar-menu li {
    list-style: none;
}

.sidebar-menu li a {
    display: block;
    padding: 12px 24px;
    color: rgba(255,255,255,0.75);
    font-size: 0.9375rem;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.sidebar-menu li a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.sidebar-menu li a.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-left: 3px solid var(--primary-light);
    padding-left: 21px;
}

/* 侧边栏布局下的主内容区 */
.layout .main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 0;
    max-width: none;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.topbar-user {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* 侧边栏布局下的内容区域需要padding */
.layout .main-content > .card,
.layout .main-content > div > .card {
    margin: 24px;
}

/* ========================
   卡片头部 (Pattern B)
   ======================== */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
}

/* ========================
   表格 .table (Pattern B)
   ======================== */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table thead {
    background: #f9fafb;
}

.table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

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

/* ========================
   模态框 (Pattern B)
   ======================== */
.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.2s ease;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header .modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-light);
    cursor: pointer;
    padding: 4px 8px;
    transition: color var(--transition);
}

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

.modal .modal-body {
    padding: 20px;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-bottom: 0;
}

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

/* ========================
   表单标签 (Pattern B)
   ======================== */
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 6px;
}

.required::before {
    content: '* ';
    color: var(--danger);
}

.form-text {
    font-size: 0.8125rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* ========================
   按钮补充 (Pattern B)
   ======================== */
.btn-link {
    background: none;
    border: none;
    color: var(--primary-light);
    padding: 5px 10px;
    font-size: 0.8125rem;
    cursor: pointer;
    text-decoration: none;
}

.btn-link:hover {
    color: var(--primary);
    text-decoration: underline;
    transform: none;
    box-shadow: none;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 1.125rem;
    line-height: 1;
    border-radius: var(--radius-sm);
}

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

/* ========================
   标签 Tag (Pattern B)
   ======================== */
.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.tag-success { background: #d1fae5; color: #065f46; }
.tag-default { background: #f3f4f6; color: #4b5563; }
.tag-warning { background: #fef3c7; color: #92400e; }
.tag-danger { background: #fdecea; color: #991b1b; }
.tag-info { background: #dbeafe; color: #1e40af; }

/* ========================
   详情页组件 (Pattern A/B共用)
   ======================== */
.detail-section {
    margin-bottom: 28px;
}

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

.detail-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-item-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-item-value {
    font-size: 0.9375rem;
    color: var(--text-main);
}

/* 兼容 borrow_detail.html 中使用 .detail-label / .detail-value 在 .detail-item 内 */
.detail-item .detail-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-item .detail-value {
    font-size: 0.9375rem;
    color: var(--text-main);
}

/* ========================
   操作列 (Pattern B)
   ======================== */
td.actions {
    white-space: nowrap;
    display: flex;
    gap: 4px;
    align-items: center;
}

td.row-actions {
    white-space: nowrap;
}

.empty-state-text {
    text-align: center;
    color: var(--text-light);
    padding: 16px;
    font-size: 0.875rem;
}

/* ========================
   派单卡片组件
   ======================== */
.assignment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.assignment-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-main);
}

.assignment-meta {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* ========================
   侧边栏响应式
   ======================== */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    .sidebar-header {
        font-size: 0;
        padding: 20px 12px;
    }
    .sidebar-header::first-letter {
        font-size: 1.125rem;
    }
    .sidebar-menu li a {
        padding: 12px 16px;
        font-size: 0;
    }
    .sidebar-menu li a::first-letter {
        font-size: 0.9375rem;
    }
    .layout .main-content {
        margin-left: 60px;
    }
    .detail-grid {
        grid-template-columns: 1fr;
    }
}
