*, *::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, #1e293b 0%, #334155 100%); margin: 0; }
.login-card { background: #fff; border-radius: 12px; padding: 40px; width: 400px; max-width: 90vw; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 { font-size: 22px; margin-bottom: 16px; }
.login-lang select { padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; }
.login-form .form-group { margin-bottom: 16px; }
.login-form label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.login-error { color: var(--error); font-size: 13px; margin-bottom: 12px; min-height: 20px; }
.login-hint { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-secondary); }
.login-hint p { margin: 2px 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); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* 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); }
.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-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; }

/* 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; }
}
