*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --sidebar-bg: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active: #3b82f6;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans', sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--sidebar-bg); color: #fff; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; }
.sidebar-header { padding: 20px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-header h2 { font-size: 16px; font-weight: 600; color: #fff; letter-spacing: .5px; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--sidebar-text); text-decoration: none; font-size: 14px; transition: all .15s; border-left: 3px solid transparent; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-item.active { color: #fff; background: rgba(59,130,246,.15); border-left-color: var(--sidebar-active); }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.1); }
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; color: #fff; }
.user-detail { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; color: #fff; }
.user-role { font-size: 11px; color: var(--sidebar-text); }
.btn-logout { width: 100%; padding: 8px; background: rgba(255,255,255,.1); border: none; border-radius: 6px; color: var(--sidebar-text); cursor: pointer; font-size: 12px; transition: all .15s; }
.btn-logout:hover { background: rgba(239,68,68,.2); color: var(--error); }

.main-content { margin-left: 240px; flex: 1; display: flex; flex-direction: column; }
.topbar { height: 56px; background: var(--card-bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-size: 18px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.lang-select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: var(--card-bg); cursor: pointer; }
.content-area { padding: 24px; flex: 1; }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%); margin: 0; position: relative; overflow: hidden; }
.login-page::before { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(circle at 30% 50%, rgba(59,130,246,.08) 0%, transparent 50%), radial-gradient(circle at 70% 30%, rgba(16,185,129,.06) 0%, transparent 50%); animation: loginBg 10s ease-in-out infinite; }
@keyframes loginBg { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-2%,-1%); } }
.login-card { background: rgba(255,255,255,.97); backdrop-filter: blur(20px); border-radius: 16px; padding: 44px 40px 36px; width: 420px; max-width: 92vw; box-shadow: 0 25px 60px rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.05) inset; position: relative; z-index: 1; }
.login-header { text-align: center; margin-bottom: 32px; }
.login-header .login-icon { width: 52px; height: 52px; background: linear-gradient(135deg, #3b82f6, #2563eb); border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 26px; color: #fff; margin-bottom: 16px; box-shadow: 0 8px 24px rgba(37,99,235,.3); }
.login-header h1 { font-size: 22px; font-weight: 700; color: #1e293b; margin-bottom: 6px; letter-spacing: -.3px; }
.login-header p { font-size: 13px; color: #94a3b8; margin: 0; }
.login-lang { position: absolute; top: 16px; right: 20px; }
.login-lang select { padding: 5px 10px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 13px; background: #fff; cursor: pointer; color: #64748b; transition: border-color .15s; }
.login-lang select:focus { border-color: #3b82f6; outline: none; }
.login-form .form-group { margin-bottom: 18px; position: relative; }
.login-form label { display: block; font-size: 13px; font-weight: 500; color: #475569; margin-bottom: 6px; }
.login-form .form-input { padding: 10px 14px 10px 40px; border: 1.5px solid #e2e8f0; border-radius: 10px; font-size: 14px; background: #f8fafc; transition: all .15s; }
.login-form .form-input:focus { background: #fff; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.login-form .input-icon { position: absolute; left: 14px; bottom: 11px; font-size: 16px; color: #94a3b8; pointer-events: none; }
.login-error { color: #ef4444; font-size: 13px; margin-bottom: 12px; min-height: 20px; text-align: center; }
.login-form .btn { width: 100%; padding: 11px; border-radius: 10px; font-size: 15px; font-weight: 600; letter-spacing: .3px; cursor: pointer; transition: all .2s; background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff; border: none; box-shadow: 0 4px 14px rgba(37,99,235,.35); }
.login-form .btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,.45); }
.login-form .btn:active { transform: translateY(0); }
.login-hint { margin-top: 20px; padding-top: 16px; border-top: 1px solid #f1f5f9; font-size: 11px; color: #cbd5e1; text-align: center; line-height: 1.8; }
.login-hint p { margin: 0; }

/* Form Elements */
.form-input, .form-select, .form-textarea { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; transition: border-color .15s; background: #fff; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,115,232,.1); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 500; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-section { margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.form-section h3 { font-size: 15px; margin-bottom: 16px; color: var(--text); }
.form-actions { display: flex; gap: 12px; margin-top: 20px; }
.form-message { margin-top: 12px; }
.form-card { background: var(--card-bg); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.form-card h3 { font-size: 15px; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.required { color: var(--error); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px; font-size: 14px; cursor: pointer; transition: all .15s; border: 1px solid transparent; font-weight: 500; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--text-secondary); color: #fff; }
.btn-secondary:hover { background: #475569; }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }
/* Import Tabs */
.import-tabs { display: flex; gap: 2px; margin-bottom: 16px; border-bottom: 2px solid var(--border); }
.import-tab { padding: 10px 20px; background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; font-size: 14px; cursor: pointer; color: var(--text-secondary); transition: all .15s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.import-tab:hover { color: var(--text); }
.import-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.import-tab-content { }
.import-list { margin-top: 20px; }
.import-list-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.import-list-header h3 { font-size: 15px; margin: 0; }
.import-list-header .filter-input { width: 200px; }

/* Pagination Row */
.pagination-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding: 0 4px; }
.pagination-row select { width: auto !important; }
.pagination-nav { display: flex; gap: 4px; align-items: center; font-size: 13px; color: var(--text-secondary); }
.pagination-nav button { padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; font-size: 12px; }
.pagination-nav button:hover { background: var(--bg); }
.pagination-nav button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-nav .page-info { padding: 0 8px; }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* Table */
.table-container { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { background: #f8fafc; padding: 10px 14px; text-align: left; font-weight: 600; color: var(--text-secondary); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; border-bottom: 2px solid var(--border); white-space: nowrap; }
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.data-table td code { white-space: nowrap; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }
.order-link { color: var(--primary); text-decoration: none; font-weight: 500; }
.order-link:hover { text-decoration: underline; }

/* Status & Priority Badges */
.status-badge, .priority-badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.status-fault_report { background: #dbeafe; color: #1d4ed8; }
.status-initial_review { background: #fef3c7; color: #92400e; }
.status-technical_eval { background: #e0e7ff; color: #3730a3; }
.status-solution_proposal { background: #d1fae5; color: #065f46; }
.status-customer_confirm { background: #fce7f3; color: #9d174d; }
.status-repair_execution { background: #fff7ed; color: #9a3412; }
.status-quality_check { background: #dbeafe; color: #1e40af; }
.status-draft { background: #f3f4f6; color: #6b7280; }
.status-archived { background: #f3f4f6; color: #4b5563; }
.priority-low { background: #f0fdf4; color: #166534; }
.priority-normal { background: #f8fafc; color: #475569; }
.priority-high { background: #fef2f2; color: #991b1b; }
.priority-urgent { background: #fef2f2; color: #7f1d1d; font-weight: 700; }

/* Filter Bar */
.filter-bar { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.filter-input { width: 200px; }
.filter-select { width: 150px; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; font-size: 13px; color: var(--text-secondary); }

/* Detail */
.detail-grid { display: grid; gap: 20px; }
.detail-status-bar { display: flex; align-items: center; gap: 0; padding: 16px 0; overflow-x: auto; }
.status-step { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 60px; }
.step-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.status-step.completed .step-dot { background: var(--success); }
.status-step.current .step-dot { background: var(--primary); box-shadow: 0 0 0 4px rgba(26,115,232,.2); }
.step-label { font-size: 10px; text-align: center; color: var(--text-secondary); white-space: nowrap; }
.status-step.completed .step-label { color: var(--success); }
.status-step.current .step-label { color: var(--primary); font-weight: 600; }
.step-line { flex: 1; height: 2px; min-width: 20px; background: var(--border); margin: 0 4px; margin-top: -20px; }
.step-line.completed { background: var(--success); }
.detail-fields { margin-top: 16px; }
.field-row { display: flex; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.field-row:last-child { border-bottom: none; }
.field-label { width: 140px; flex-shrink: 0; color: var(--text-secondary); font-weight: 500; }
.field-value { flex: 1; color: var(--text); }
.detail-actions { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* History Timeline */
.history-timeline { position: relative; padding-left: 24px; }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: -20px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--primary); }
.timeline-item:not(:last-child)::before { content: ''; position: absolute; left: -16px; top: 14px; bottom: 0; width: 2px; background: var(--border); }
.timeline-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.timeline-status { font-weight: 600; font-size: 13px; color: var(--text); }
.timeline-operator { font-size: 12px; color: var(--text-secondary); }
.timeline-remark { font-size: 13px; color: var(--text); margin-top: 4px; }
.timeline-time { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

/* Import */
.import-grid { display: grid; gap: 20px; max-width: 600px; }
.import-stats { display: flex; gap: 16px; margin: 12px 0; }
.stat { padding: 8px 16px; border-radius: 6px; font-size: 14px; font-weight: 500; }
.stat-success { background: #d1fae5; color: #065f46; }
.stat-failed { background: #fef2f2; color: #991b1b; }
.import-errors { margin-top: 12px; padding: 12px; background: #fef2f2; border-radius: 6px; font-size: 13px; color: #991b1b; }
.import-errors ul { margin: 8px 0 0 20px; }

/* Settings */
.settings-grid { display: grid; gap: 20px; max-width: 700px; }
.process-list { overflow-x: auto; }

/* Utilities */
.text-center { text-align: center; }
.loading { color: var(--text-secondary); padding: 20px 0; text-align: center; }
.success { color: var(--success); padding: 8px 0; }
.error { color: var(--error); padding: 8px 0; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h2 { font-size: 20px; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.5); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-card { background: var(--card-bg); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.3); width: 90%; max-height: 80vh; overflow: hidden; display: flex; flex-direction: column; }
.modal-lg { max-width: 700px; }
.modal-xl { max-width: 90vw; max-height: 90vh; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; margin: 0; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-secondary); padding: 0; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.parts-modal-body { display: flex; flex-direction: column; gap: 16px; }

/* Parts Section */
.detail-parts { margin-bottom: 20px; }
.parts-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.parts-header h3 { font-size: 15px; margin: 0; }
.parts-table { font-size: 13px; }
.parts-table th { font-size: 12px; }
.part-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

/* Parts Search */
.parts-search-bar { display: flex; gap: 10px; }
.parts-search-bar input { flex: 1; }
.parts-search-results { max-height: 350px; overflow-y: auto; }
.parts-result-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.parts-result-item:hover { background: #f1f5f9; }
.parts-result-info { display: flex; flex-direction: column; gap: 2px; }
.parts-result-number { font-weight: 600; font-size: 13px; color: var(--primary); }
.parts-result-name { font-size: 12px; color: var(--text-secondary); }

/* Upload Preview */
.upload-preview { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.upload-thumb { width: 80px; text-align: center; }
.upload-thumb img { width: 80px; height: 80px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.upload-video-icon { display: block; width: 80px; height: 80px; background: #f1f5f9; border-radius: 6px; line-height: 80px; font-size: 32px; text-align: center; border: 1px solid var(--border); }
.upload-name { display: block; font-size: 10px; color: var(--text-secondary); margin-top: 4px; word-break: break-all; }

/* Input with side button */
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; }

/* Autocomplete */
.autocomplete-wrapper { position: relative; }
.autocomplete-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.1); z-index: 500; max-height: 200px; overflow-y: auto; }
.autocomplete-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: #f1f5f9; }
.autocomplete-item code { font-weight: 600; color: var(--primary); font-size: 12px; }
.autocomplete-item span { color: var(--text-secondary); font-size: 12px; flex: 1; }

/* Media Gallery */
.detail-media { margin-bottom: 20px; }
.detail-media h3 { font-size: 15px; margin-bottom: 12px; }
.media-grid { display: flex; gap: 12px; flex-wrap: wrap; }
.media-item { width: 120px; }
.media-preview { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.media-name { display: block; font-size: 11px; color: var(--text-secondary); margin-top: 4px; word-break: break-all; text-align: center; }
.media-file { display: flex; align-items: center; gap: 4px; color: var(--primary); text-decoration: none; font-size: 12px; }
.video-thumb { display: flex; align-items: center; justify-content: center; width: 120px; height: 120px; background: #1e293b; border-radius: 8px; color: #fff; font-size: 28px; cursor: pointer; }

/* Lightbox */
.lightbox { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.9); z-index: 2000; display: flex; align-items: center; justify-content: center; }
.lightbox-close { position: absolute; top: 16px; right: 24px; color: #fff; font-size: 36px; cursor: pointer; z-index: 2001; line-height: 1; }
.lightbox-close:hover { color: #ccc; }
.lightbox-content { max-width: 90vw; max-height: 90vh; }
.lightbox-img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: 8px; }
.lightbox-video { max-width: 90vw; max-height: 90vh; border-radius: 8px; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .main-content { margin-left: 200px; }
  .form-row { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-input, .filter-select { width: 100%; }
  .detail-status-bar { flex-wrap: wrap; }
}
