:root {
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --white: #ffffff;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', 'Sarabun', sans-serif; background: var(--gray-50); color: var(--gray-800); font-size: 14px; }

/* ─── Navbar ─── */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 56px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.nav-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--primary); white-space: nowrap; }
.nav-logo { font-size: 20px; }
.nav-links { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav-links a { padding: 6px 12px; border-radius: 6px; color: var(--gray-600); text-decoration: none; transition: all 0.15s; white-space: nowrap; }
.nav-links a:hover, .nav-links a.active { background: var(--gray-100); color: var(--primary); }
.btn-new { background: var(--primary) !important; color: var(--white) !important; padding: 6px 14px !important; border-radius: 6px; font-weight: 600; }
.btn-new:hover { background: var(--primary-dark) !important; }
.nav-user { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.nav-user a { color: var(--gray-400); text-decoration: none; font-size: 13px; }
.nav-user a:hover { color: var(--danger); }

/* ─── Dropdown ─── */
.dropdown { position: relative; }
.dropdown-toggle { padding: 6px 12px; border-radius: 6px; color: var(--gray-600); cursor: pointer; }
.dropdown-toggle:hover { background: var(--gray-100); }
.dropdown-menu { display: none; position: absolute; top: 100%; left: 0; background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); min-width: 160px; box-shadow: var(--shadow-md); z-index: 200; }
.dropdown:hover .dropdown-menu { display: block; }
.dropdown-menu a { display: block; padding: 8px 16px; color: var(--gray-600); text-decoration: none; }
.dropdown-menu a:hover { background: var(--gray-100); }

/* ─── Layout ─── */
.container { max-width: 1280px; margin: 0 auto; padding: 24px 16px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 20px; font-weight: 700; color: var(--gray-800); }

/* ─── Cards ─── */
.card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-200); font-weight: 600; font-size: 15px; }
.card-body { padding: 20px; }

/* ─── Stat Cards ─── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 16px 20px; }
.stat-card .stat-label { font-size: 12px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-card.red .stat-value { color: var(--danger); }
.stat-card.yellow .stat-value { color: var(--warning); }
.stat-card.green .stat-value { color: var(--success); }
.stat-card.blue .stat-value { color: var(--primary); }

/* ─── Table ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { background: var(--gray-50); padding: 10px 14px; text-align: left; font-size: 12px; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* ─── Badges ─── */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-sev-Critical { background: #fee2e2; color: #b91c1c; }
.badge-sev-Major { background: #fef3c7; color: #92400e; }
.badge-sev-Minor { background: #d1fae5; color: #065f46; }
.badge-status { background: var(--gray-100); color: var(--gray-600); }
.badge-status.SUBMITTED { background: #dbeafe; color: #1e40af; }
.badge-status.QA_INSPECTING { background: #ede9fe; color: #5b21b6; }
.badge-status.WAITING_SAMPLE { background: #fef3c7; color: #92400e; }
.badge-status.SUPPLIER_NEGOTIATING { background: #ffedd5; color: #c2410c; }
.badge-status.PENDING_DECISION { background: #fef9c3; color: #713f12; }
.badge-status.REFUND_PROCESSING { background: #dbeafe; color: #1e40af; }
.badge-status.INFORMING_CUSTOMER { background: #d1fae5; color: #065f46; }
.badge-status.CLOSED { background: var(--gray-100); color: var(--gray-600); }
.badge-status.REJECTED { background: #fee2e2; color: #b91c1c; }

/* ─── Role Badges ─── */
.badge-role { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.role-sales { background: #dbeafe; color: #1e40af; }
.role-qa { background: #ede9fe; color: #5b21b6; }
.role-purchase { background: #ffedd5; color: #c2410c; }
.role-manager { background: #d1fae5; color: #065f46; }
.role-accounting { background: #fef3c7; color: #92400e; }
.role-admin { background: #1f2937; color: #fff; }

/* ─── Forms ─── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-hint { font-size: 12px; color: var(--gray-400); margin-top: 4px; }
.form-control { width: 100%; padding: 9px 12px; border: 1px solid var(--gray-200); border-radius: 6px; font-size: 14px; color: var(--gray-800); background: var(--white); transition: border-color 0.15s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,78,216,0.1); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ─── Buttons ─── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; border: none; text-decoration: none; transition: all 0.15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-outline { background: transparent; color: var(--gray-600); border: 1px solid var(--gray-200); }
.btn-outline:hover { background: var(--gray-100); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* ─── Alert ─── */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }

/* ─── Timeline ─── */
.timeline { padding: 0; list-style: none; }
.timeline-item { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.timeline-item::before { content:''; position:absolute; left:15px; top:28px; bottom:0; width:2px; background: var(--gray-200); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 32px; height: 32px; border-radius: 50%; background: var(--gray-100); border: 2px solid var(--gray-200); display:flex; align-items:center; justify-content:center; font-size:14px; flex-shrink:0; }
.timeline-content { flex: 1; }
.timeline-header { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.timeline-action { font-weight: 600; font-size: 13px; }
.timeline-actor { font-size: 12px; color: var(--gray-400); }
.timeline-time { font-size: 12px; color: var(--gray-400); margin-left: auto; }
.timeline-note { margin-top: 4px; font-size: 13px; color: var(--gray-600); }

/* ─── Detail Grid ─── */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.detail-item .detail-label { font-size: 12px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.05em; }
.detail-item .detail-value { font-size: 15px; font-weight: 500; margin-top: 2px; }

/* ─── Filters ─── */
.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-bar .form-control { max-width: 200px; }
.search-input { flex: 1; min-width: 200px; max-width: 300px; }

/* ─── Login ─── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%); }
.login-card { background: #fff; border-radius: 12px; padding: 40px; width: 100%; max-width: 380px; box-shadow: 0 20px 40px rgba(0,0,0,0.15); }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--primary); margin-top: 8px; }
.login-logo p { font-size: 13px; color: var(--gray-400); }

/* ─── File Upload ─── */
.file-upload { border: 2px dashed var(--gray-200); border-radius: var(--radius); padding: 24px; text-align: center; cursor: pointer; transition: all 0.15s; }
.file-upload:hover { border-color: var(--primary); background: #eff6ff; }
.file-upload input { display: none; }
.file-list { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.file-item { background: var(--gray-100); border-radius: 4px; padding: 4px 10px; font-size: 12px; display: flex; align-items: center; gap: 6px; }

/* ─── Section Header ─── */
.section-title { font-size: 15px; font-weight: 700; color: var(--gray-800); margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid var(--primary); display: inline-block; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .navbar { flex-wrap: wrap; height: auto; padding: 12px; gap: 8px; }
  .nav-links { order: 3; width: 100%; flex-wrap: wrap; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; }
}
