/* ============================================
   客户数据管理系统 - 现代商务风格样式
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  --bg: #f0f4f9;
  --bg-deep: #e8eef5;
  --ink: #1a2332;
  --ink-2: #374151;
  --ink-3: #6b7785;
  --brand: #0f2b5c;
  --brand-light: #1a4080;
  --brand-2: #1d6bd6;
  --brand-soft: #e8f0fe;
  --accent: #0891b2;
  --accent-soft: #ecfeff;
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --line: #dde3eb;
  --card: #ffffff;
  --card-hover: #fafcff;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 3px rgba(15,43,92,0.06), 0 1px 2px rgba(15,43,92,0.04);
  --shadow: 0 4px 16px rgba(15,43,92,0.08), 0 2px 6px rgba(15,43,92,0.04);
  --shadow-md: 0 8px 30px rgba(15,43,92,0.10), 0 4px 12px rgba(15,43,92,0.05);
  --shadow-lg: 0 16px 48px rgba(15,43,92,0.14), 0 8px 24px rgba(15,43,92,0.06);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
}

/* Subtle animated background pattern */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%, rgba(29,107,214,0.07) 0%, transparent 50%),
    radial-gradient(ellipse 60% 50% at 90% 100%, rgba(8,145,178,0.05) 0%, transparent 50%),
    linear-gradient(180deg, #f0f4f9 0%, #e8eef5 100%);
  pointer-events: none;
  z-index: -1;
}

a { color: var(--brand-2); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--brand-light); }

img { max-width: 100%; height: auto; }

/* ---------- Top Navigation ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: 62px;
  background: linear-gradient(135deg, var(--brand) 0%, #0a1f42 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 6px;
  box-shadow: 0 4px 20px rgba(15,43,92,0.25), 0 1px 3px rgba(0,0,0,0.1);
  backdrop-filter: blur(12px);
}

.brand {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0.8px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 12px;
}

.brand::before {
  content: '';
  display: inline-block;
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(59,130,246,0.4);
}

.topbar a {
  color: rgba(255,255,255,0.82);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.topbar a:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
  opacity: 1;
  transform: translateY(-1px);
  text-decoration: none;
}

.topbar a::after {
  /* nav icons via pseudo elements for visual flair */
  content: attr(data-icon);
  font-size: 11px;
  opacity: 0.7;
}

.spacer { flex: 1; }

.topbar > span:last-of-type {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 16px;
  border-left: 1px solid rgba(255,255,255,0.15);
}

.topbar > span:last-of-type strong {
  color: #fff;
  font-weight: 600;
}

/* ---------- Main Container ---------- */
.container {
  max-width: 1320px;
  margin: 28px auto;
  padding: 0 24px;
}

h1 {
  font-size: 26px;
  font-weight: 750;
  color: var(--ink);
  margin: 4px 0 22px;
  letter-spacing: -0.3px;
  position: relative;
  padding-bottom: 14px;
}

h1::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 48px;
  height: 3.5px;
  background: linear-gradient(90deg, var(--brand-2), var(--accent));
  border-radius: 2px;
}

/* ---------- Card Component ---------- */
.card {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(221,227,235,0.6);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* ---------- Login Page - Enhanced ---------- */
.login-wrapper {
  min-height: calc(100vh - 180px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.login-card {
  max-width:420px;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--brand-2), var(--accent), #8b5cf6, var(--brand-2));
  background-size: 300% 100%;
  animation: gradientShift 4s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.login-card__header {
  text-align: center;
  padding: 28px 24px 22px;
  margin-bottom: 4px;
}

.login-card__logo {
  font-size: 48px;
  display: inline-block;
  margin-bottom: 12px;
  animation: floatLogo 3s ease-in-out infinite;
}

@keyframes floatLogo {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.login-card__title {
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  margin: 0 0 6px;
  letter-spacing: -0.3px;
}

.login-card__subtitle {
  color: var(--ink-3);
  font-size: 14px;
  margin: 0;
}

.login-card form {
  padding: 0 32px 12px;
}

.login-field {
  margin-bottom: 18px;
}

.login-field__label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 7px;
  display: block;
  letter-spacing: 0.3px;
}

.login-field input {
  padding: 14px 16px;
  font-size: 15px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  transition: all 0.25s ease;
  background: #fafbfd;
}

.login-field input:focus {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 4px rgba(29,107,214,0.10), 0 4px 16px rgba(29,107,214,0.08);
  background: #fff;
}

.btn--login {
  width: 100%;
  padding: 14px !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  border-radius: var(--radius) !important;
  letter-spacing: 3px;
  margin-top: 6px;
  text-transform: uppercase;
}

.login-card__footer {
  text-align: center;
  padding: 18px 24px 24px;
  border-top: 1px solid #f1f5f9;
  margin-top: 4px;
}

.login-card__footer p {
  color: var(--ink-3);
  font-size: 13px;
  margin: 0;
}
.login-card__footer strong {
  color: var(--brand-2);
}

/* ---------- Forms (Narrow & Grid) ---------- */
.form-narrow {
  max-width:600px;
  display: grid;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px 20px;
}

.form-grid .field-negotiation_content,
.form-grid .field-note2,
.form-grid .field-current_progress,
.form-grid .field-customer_problem,
.form-grid .field-region {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink-2);
  letter-spacing: 0.2px;
}

label > span:first-child {
  display: flex;
  align-items: center;
  gap: 6px;
}

input, select, textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(29,107,214,0.10);
  background: #fff;
}

textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; appearance: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: #aab4c0;
  text-decoration: none;
  color: var(--ink);
}

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

.btn.primary {
  background: linear-gradient(135deg, var(--brand-2), #1565c0);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 12px rgba(29,107,214,0.28);
}

.btn.primary:hover {
  background: linear-gradient(135deg, #1a75e6, #1976d2);
  box-shadow: 0 5px 18px rgba(29,107,214,0.38);
  color: #fff;
  transform: translateY(-2px);
}

.btn.danger {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.btn.danger:hover {
  background: #fee4e4;
  border-color: #f8caca;
  box-shadow: 0 3px 12px rgba(220,38,38,0.15);
  color: var(--danger);
}

/* ---------- Toolbar / Filter Bar ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: rgba(255,255,255,0.85);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.toolbar input {
  max-width:240px;
  padding: 9px 14px;
  font-size: 13.5px;
}
.search-input { min-width: 220px; }

/* Table info bar */
.table-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}
.count-badge {
  font-size: 13px;
  color: var(--ink-3);
}
.count-badge strong {
  color: var(--brand-2);
  font-weight: 800;
}

/* Data table enhanced cells */
.data-table .id-tag {
  display: inline-block;
  background: #f1f5f9;
  color: #64748b;
  font-weight: 700;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.3px;
}
.customer-name-cell {
  font-weight: 600;
  color: var(--brand-2);
}
.phone-cell {
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 12.5px;
  color: var(--ink-2);
}
.tag-inline {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.tag--level { background: #f0fdf4; color: #166534; }
.sales-name {
  font-size: 12px;
  color: #7c3aed;
  font-weight: 600;
}
.date-cell {
  font-size: 12px;
  color: var(--ink-3);
}

.toolbar select {
  max-width:180px;
  padding: 9px 12px;
  font-size: 13.5px;
}

.toolbar .btn {
  font-size: 13px;
  padding: 9px 16px;
}

/* ---------- Alerts / Flash Messages ---------- */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin: 12px 0;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: slideIn 0.35s ease-out;
  border-left: 4px solid;
}

.alert-ok {
  background: var(--success-bg);
  color: #166534;
  border-color: var(--success-border);
}

.alert-error {
  background: var(--danger-bg);
  color: #991b1b;
  border-color: var(--danger-border);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.muted {
  color: var(--ink-3);
  font-size: 13.5px;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  font-size: 13.5px;
}

th, td {
  padding: 12px 16px;
  border-bottom: 1px solid #eff2f7;
  text-align: left;
  vertical-align: middle;
}

th {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  font-weight: 700;
  font-size: 12.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

tr:last-child td { border-bottom: none; }

tbody tr {
  transition: var(--transition);
}

tbody tr:hover {
  background: var(--brand-soft);
}

tbody tr:hover td {
  color: var(--ink);
}

/* Detail view table */
.detail-card { padding: 0; overflow: hidden; }

.detail-card__header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 24px 28px;
  background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
  border-bottom: 1px solid var(--line);
}

.avatar {
  width: 58px; height: 58px;
  border-radius: 16px;
  color: #fff;
  font-size: 26px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(59,130,246,0.3);
  flex-shrink: 0;
}

.detail-card__info h2 {
  font-size: 20px; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.3px;
}
.detail-card__info p {
  font-size: 13px; color: var(--ink-3); margin: 0;
}
.detail-card__status { margin-left: auto; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
}

.detail-group {
  border: none;
  padding: 20px 24px;
  margin: 0;
  border-bottom: 1px solid #f1f5f9;
}
.detail-group:last-child { border-bottom: none; }

.detail-group__title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--brand-2);
  padding: 0 0 12px;
  letter-spacing: 0.5px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px dotted #eef2f7;
}
.detail-item--full {
  grid-column: span 2;
  flex-direction: column;
  gap: 4px;
  border-bottom: none;
  background: #fafbfd;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 4px;
}

.detail-item__label {
  font-size: 13px;
  color: var(--ink-3);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.detail-item--full .detail-item__label { font-weight: 700; }
.detail-item__value {
  font-size: 13.5px;
  color: var(--ink);
  text-align: right;
  word-break: break-all;
}
.detail-item--full .detail-item__value { text-align: left; line-height: 1.65; }

.detail-card__actions {
  display: flex; gap: 10px;
  padding: 18px 24px;
  border-top: 1px solid #f1f5f9;
  background: #fafbfc;
}

.changed {
  background: #fff7ed !important;
  color: #9a3412;
  font-weight: 600;
  border-radius: 4px;
  padding: 4px 8px !important;
}

/* ---------- Stats Cards (Dashboard) - Enhanced ---------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: 4px 0 0 4px;
}

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

.stat-card__icon {
  font-size: 36px;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  flex-shrink: 0;
}

.stat-card__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card__value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1.2px;
  line-height: 1.1;
}

.stat-card__label {
  font-size: 13px;
  color: var(--ink-3);
  font-weight: 500;
}

/* Stat card variants */
.stat-card--primary { }
.stat-card--primary::before { background: linear-gradient(180deg, #3b82f6, #2563eb); }
.stat-card--primary .stat-card__icon { background: linear-gradient(135deg, #dbeafe, #bfdbfe); }
.stat-card--primary .stat-card__value { color: #2563eb; }

.stat-card--warning { }
.stat-card--warning::before { background: linear-gradient(180deg, #f59e0b, #d97706); }
.stat-card--warning .stat-card__icon { background: linear-gradient(135deg, #fef3c7, #fde68a); }
.stat-card--warning .stat-card__value { color: #d97706; }

.stat-card--success { }
.stat-card--success::before { background: linear-gradient(180deg, #10b981, #059669); }
.stat-card--success .stat-card__icon { background: linear-gradient(135deg, #d1fae5, #a7f3d0); }
.stat-card--success .stat-card__value { color: #059669; }

.stat-card--info { }
.stat-card--info::before { background: linear-gradient(180deg, #8b5cf6, #7c3aed); }
.stat-card--info .stat-card__icon { background: linear-gradient(135deg, #ede9fe, #ddd6fe); }
.stat-card--info .stat-card__value { color: #7c3aed; }

/* Legacy stat for backward compat */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}
.stat {
  background: linear-gradient(135deg, var(--brand-2) 0%, #1565c0 50%, #0d47a1 100%);
  color: #fff;
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  box-shadow: 0 8px 28px rgba(29,107,214,0.30);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 120px;
}
.stat::before {
  content: '';
  position: absolute;
  top: -30%; right: -15%;
  width: 140px; height: 140px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}
.stat::after {
  content: '';
  position: absolute;
  bottom: -20%; right: 10%;
  width: 80px; height: 80px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}
.stat:hover { transform: translateY(-4px); box-shadow: 0 14px 36px rgba(29,107,214,0.36); }
.stat b { font-size: 42px; font-weight: 800; line-height: 1.1; position: relative; z-index: 1; letter-spacing: -1px; }
.stat span { opacity: 0.88; font-size: 14px; font-weight: 500; margin-top: 6px; position: relative; z-index: 1; }
.stat--pending { background: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%); box-shadow: 0 8px 28px rgba(217,119,6,0.30); }
.stat--pending:hover { box-shadow: 0 14px 36px rgba(217,119,6,0.36); }

/* ---------- Charts Section (Enhanced) ---------- */
.chart-section {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.chart-row {
  display: grid;
  gap: 20px;
}
.chart-row--2col { grid-template-columns: repeat(2, 1fr); }

.chart-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all 0.3s ease;
}
.chart-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.chart-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid #f1f5f9;
  background: linear-gradient(180deg, #fafbfc, #f8fafc);
}

.chart-card__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-card__badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-2);
  letter-spacing: 0.3px;
}

.chart-card__body {
  height: 340px;
  padding: 12px;
}

.chart-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink-3);
  background: repeating-linear-gradient(45deg,#fafbfc,#fafbfc 10px,#f5f7fa 10px,#f5f7fa 20px);
  border-radius: var(--radius);
}
.chart-empty span { font-size: 32px; opacity: 0.4; }
.chart-empty strong { font-size: 15px; color: var(--ink-2); }
.chart-empty p { font-size: 13px; margin: 0; }

/* Legacy chart grid for backward compat */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.chart {
  height: 380px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
}

.chart-fallback {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ink-3);
  background: repeating-linear-gradient(
    45deg,
    #fafbfc,
    #fafbfc 10px,
    #f5f7fa 10px,
    #f5f7fa 20px
  );
  border-radius: var(--radius);
}

.chart-fallback strong {
  font-size: 15px;
  color: var(--ink-2);
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  gap: 6px;
  margin: 20px 0;
  flex-wrap: wrap;
  justify-content: center;
}

.pagination a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1.5px solid var(--line);
  text-decoration: none;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
}

.pagination a:hover {
  border-color: var(--brand-2);
  color: var(--brand-2);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.pagination a.active {
  background: linear-gradient(135deg, var(--brand-2), #1565c0);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 3px 10px rgba(29,107,214,0.25);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge.pending {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  border: 1px solid #fcd34d;
}

.badge.approved {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: #166534;
  border: 1px solid #6ee7b7;
}

.badge.rejected {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.badge.admin {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: #1e40af;
  border: 1px solid #93c5fd;
}
.badge.manager {
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  color: #3730a3;
  border: 1px solid #a5b4fc;
}
.badge.sales {
  background: linear-gradient(135deg, #fce7f3, #fbcfe8);
  color: #9d174d;
  border: 1px solid #f472b6;
}

.status-enabled {
  color: var(--success);
  font-weight: 700;
}
.status-disabled {
  color: var(--danger);
  font-weight: 700;
}

/* ---------- Review Form ---------- */
.review-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
  padding: 20px;
  background: var(--bg-deep);
  border-radius: var(--radius);
  border: 1.5px dashed var(--line);
}

.review-form textarea {
  min-height: 70px;
  font-size: 14px;
}

.review-form .btn {
  justify-content: center;
  padding: 11px 24px;
  font-size: 14px;
}

/* ---------- Assignment Card (Enhanced) ---------- */
.assignment-card { padding: 0; overflow: hidden; }

.assignment-card__header {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 20px 24px; background: linear-gradient(135deg, #f8fafc, #eff6ff);
  border-bottom: 1px solid var(--line);
}
.assignment-card__mgr-icon { font-size: 28px; }
.assignment-card__header > div:first-of-type { font-size: 15px; color: var(--ink-2); }
.assignment-card__header > div:first-of-type strong { font-weight: 800; color: var(--brand-2); font-size: 17px; }
.assignment-card__count {
  margin-left: auto;
  padding: 4px 14px;
  background: var(--brand-soft);
  border-radius: 999px;
  font-size: 13px;
  color: var(--brand-2);
  font-weight: 600;
}
.assignment-card__count strong { font-weight: 800; }

/* ---------- Check Grid (Assignments) ---------- */
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.check-grid label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  font-size: 13.5px;
  color: var(--ink-2);
  transition: var(--transition);
}

.check-grid label:hover {
  border-color: var(--brand-2);
  background: var(--brand-soft);
  color: var(--brand-2);
}

.check-grid input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand-2);
  cursor: pointer;
  flex-shrink: 0;
}

.inline-form {
  display: inline-flex;
  margin: 0;
  vertical-align: middle;
}

.link-button {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--font);
  font-size: inherit;
  color: var(--danger);
  font-weight: 600;
  transition: var(--transition);
}

.link-button:hover {
  color: #b91c1c;
  text-decoration: underline;
}

/* ---------- Customer Detail Enhancements ---------- */
.customer-detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.customer-avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand-2), var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(29,107,214,0.25);
}

.customer-meta-info h3 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.customer-meta-info p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-3);
}

/* ---------- Diff Table Enhancement ---------- */
.diff-table thead th {
  background: #f1f5f9;
}
.diff-table td {
  font-size: 13.5px;
  vertical-align: top;
}
.diff-before {
  color: var(--ink-3);
  text-decoration: line-through;
  background: #fef2f2;
  border-radius: 4px;
  padding: 4px 8px !important;
}
.diff-after {
  font-weight: 600;
  color: var(--success);
  background: #ecfdf5;
  border-radius: 4px;
  padding: 4px 8px !important;
}

/* ---------- Request Detail Card ---------- */
.request-detail-card { padding: 0; overflow: hidden; }

.request-meta-bar {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  padding: 18px 24px;
  background: linear-gradient(135deg, #f8fafc, #eff6ff);
  border-bottom: 1px solid var(--line);
  font-size: 13.5px; color: var(--ink-2);
}
.request-meta-bar strong { color: var(--ink); font-weight: 700; }
.req-status { margin-left: auto; }

.diff-table thead th { background: #f1f5f9; }
.diff-field-name { font-weight: 600; color: var(--brand-2); font-size: 13px; }
.diff-before { color: var(--ink-3); text-decoration: line-through; background: #fef2f2; border-radius: 4px; padding: 4px 8px !important; display: inline-block; }
.diff-after { font-weight: 600; color: var(--success); background: #ecfdf5; border-radius: 4px; padding: 4px 8px !important; display: inline-block; }

.review-result {
  display: flex; flex-wrap: wrap; gap: 18px;
  margin: 20px 24px; padding: 16px 20px;
  background: #f8fafc; border-radius: var(--radius-sm);
  border: 1px solid #eef2f7;
}
.review-result__item { font-size: 13.5px; color: var(--ink-3); }
.review-result__item strong { color: var(--ink-2); }

.review-panel {
  margin: 20px 24px; padding: 20px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: #fafbff;
}
.review-panel .section-title { margin-bottom: 12px; }
.review-buttons .btn { padding: 11px 22px !important; font-size: 14px !important; }

/* Legacy request info block for backward compat */
.request-info-block {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 18px;
  padding: 16px 20px;
  background: var(--bg-deep);
  border-radius: var(--radius);
}

.request-info-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.request-info-item .label {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.request-info-item .value {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

/* ---------- Import Page - Enhanced ---------- */
.import-page { display: flex; flex-direction: column; gap: 18px; }

.import-card { max-width: 600px; text-align: center; }

.import-card__title {
  font-size: 18px; font-weight: 700;
  color: var(--ink); margin-bottom: 20px;
  padding-bottom: 14px; border-bottom: 1px solid #f1f5f9;
}

.file-upload-label {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; padding: 24px;
  background: linear-gradient(135deg, #f8fafc, #eff6ff);
  border: 2.5px dashed #cbd5e1; border-radius: var(--radius-lg);
  cursor: pointer; transition: all 0.3s ease;
}
.file-upload-label:hover {
  border-color: var(--brand-2); background: var(--brand-soft);
  transform: translateY(-2px); box-shadow: var(--shadow-sm);
}
.file-upload__icon { font-size: 32px; }
.file-upload__text { font-weight: 600; color: var(--ink-2); font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.checkbox-label {
  font-weight: 500 !important;
  color: var(--warning) !important;
  justify-content: center;
  font-size: 13px;
}
.checkbox-label input[type="checkbox"] {
  width: auto; height: auto; margin-right: 8px;
  accent-color: var(--warning);
}

.import-buttons { justify-content: center; margin-top: 4px; }
.btn--lg { padding: 13px 28px !important; font-size: 15px !important; }

.import-info {
  background: #f8fafc; border-radius: var(--radius);
  padding: 16px 22px; border: 1px solid #eef2f7;
}
.import-info p {
  font-size: 13.5px; color: var(--ink-3); line-height: 1.7; margin: 4px 0;
}
.success-text { color: var(--success) !important; font-weight: 600; }
.error-text { color: var(--danger) !important; font-weight: 600; }

/* Legacy import-area for backward compat */
.import-area {
  border: 2.5px dashed var(--line);
  border-radius: var(--radius-lg);
  padding: 40px; text-align: center;
  background: #fafbff; transition: var(--transition); cursor: pointer;
}
.import-area:hover { border-color: var(--brand-2); background: var(--brand-soft); }

.import-area input[type="file"] {
  max-width: none;
  margin: 12px auto;
  padding: 10px;
}

/* ---------- User Table Enhancements ---------- */
.user-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ---------- Form Field Groups ---------- */
.field-group {
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 8px;
  background: #fafbfd;
  grid-column: 1 / -1;
  transition: var(--transition);
}

.field-group:hover {
  border-color: #c4cdd8;
  box-shadow: 0 2px 8px rgba(15,43,92,0.05);
}

.field-group-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-2);
  padding: 0 10px;
  margin-bottom: 14px;
  display: inline-block;
  letter-spacing: 0.3px;
}

.field .field {
  /* nested field reset */
}

/* ---------- Action Links in Tables ---------- */
.action-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.action-links a {
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  transition: var(--transition);
}

.action-links a:hover {
  background: var(--brand-soft);
  text-decoration: none;
}

.action-link-edit { color: var(--brand-2); }
.action-link-view { color: var(--accent); }
.action-link-delete { color: var(--danger); }
.action-link-request { color: var(--warning); }

/* ---------- Section Divider ---------- */
.section-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  margin: 24px 0 14px;
  padding-left: 12px;
  border-left: 3.5px solid var(--brand-2);
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--ink-3);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 15px;
}

/* ---------- Scrollbar Styling ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4cdd8; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a8b5c6; }

/* ---------- Selection ---------- */
::selection {
  background: rgba(29,107,214,0.18);
  color: var(--ink);
}

/* ---------- Responsive Design ---------- */
@media (max-width: 1024px) {
  .chart-grid, .chart-row--2col { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  body::before { background: linear-gradient(180deg, #f0f4f9 0%, #e8eef5 100%); }

  .topbar {
    height: auto;
    min-height: 56px;
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .topbar a {
    font-size: 12.5px;
    padding: 6px 10px;
  }

  .brand { font-size: 16px; }
  .brand::before { width: 24px; height: 24px; }

  .container {
    margin: 16px auto;
    padding: 0 14px;
  }

  h1 { font-size: 21px; }

  .form-grid,
  .chart-grid,
  .chart-row--2col,
  .stats { grid-template-columns: 1fr; }

  .form-grid .field-negotiation_content,
  .form-grid .field-note2,
  .form-grid .field-current_progress,
  .form-grid .field-customer_problem,
  .form-grid .field-region,
  .form-actions { grid-column: span 1; }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar input,
  .toolbar select { max-width: 100%; }

  .check-grid { grid-template-columns: repeat(2, 1fr); }

  .login-card {
    margin: 30px auto;
    padding: 24px 20px;
  }

  .stat { padding: 20px; min-height: 100px; }
  .stat b { font-size: 32px; }

  .stat-card { padding: 16px 18px; gap: 12px; }
  .stat-card__icon { width: 48px; height: 48px; font-size: 26px; }
  .stat-card__value { font-size: 24px; }

  .chart, .chart-card__body { height: 300px; }

  .request-info-block { flex-direction: column; gap: 12px; }

  th, td { padding: 10px 12px; font-size: 12.5px; }

  .action-links { flex-direction: column; align-items: flex-start; gap: 4px; }
}

@media (max-width: 480px) {
  .stats, .stats-row { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: 1fr; }
  .pagination a { padding: 6px 10px; font-size: 12px; }

  .stat-card { padding: 14px 16px; }
  .stat-card__icon { width: 42px; height: 42px; font-size: 22px; }
  .stat-card__value { font-size: 22px; }
}

/* ---------- Print Styles ---------- */
@media print {
  .topbar, .toolbar, .pagination, .btn, .form-actions, .review-form { display: none !important; }
  body { background: #fff; }
  body::before { display: none; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  table { font-size: 11px; }
}
