/* ===== CRM 公共样式 ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-darkest: #0b1120;
  --bg-dark: #111827;
  --bg-card: #1f2937;
  --bg-card-hover: #27354f;
  --bg-input: #1a2332;
  --primary: #3b82f6;
  --primary-light: #60a5fa;
  --primary-dark: #2563eb;
  --success: #22c55e;
  --success-light: #4ade80;
  --warning: #f59e0b;
  --warning-light: #fbbf24;
  --danger: #ef4444;
  --danger-light: #f87171;
  --info: #06b6d4;
  --teal: #14b8a6;
  --purple: #8b5cf6;
  --pink: #ec4899;
  --text-white: #f8fafc;
  --text-gray: #94a3b8;
  --text-light-gray: #cbd5e1;
  --text-muted: #64748b;
  --border-color: rgba(255,255,255,0.06);
  --border-light: rgba(255,255,255,0.1);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
}

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-darkest);
  color: var(--text-white);
  overflow-x: hidden;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4b5563; }

/* ===== TOP HEADER ===== */
.top-header {
  height: 56px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-brand .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
}

.header-brand .logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-white);
  letter-spacing: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-search {
  position: relative;
}

.header-search input {
  width: 280px;
  height: 36px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0 36px 0 12px;
  color: var(--text-white);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.header-search input::placeholder { color: var(--text-muted); }
.header-search input:focus { border-color: var(--primary); }

.header-search svg {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-gray);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}

.header-btn:hover {
  background: var(--bg-card);
  color: var(--text-white);
  border-color: var(--border-light);
}

.header-btn .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  background: var(--danger);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: 2px solid var(--bg-card);
}

/* ===== SECONDARY NAV (Top Sub-menu) ===== */
.sub-nav {
  height: 44px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 4px;
  position: fixed;
  top: 56px;
  left: 220px;
  right: 0;
  z-index: 150;
}

.sub-nav-item {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-gray);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.sub-nav-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-light-gray);
}

.sub-nav-item.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary-light);
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: var(--bg-dark);
  border-right: 1px solid var(--border-color);
  padding: 12px 0;
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 0;
  width: 220px;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-section {
  padding: 0 12px;
  margin-bottom: 8px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-gray);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-light-gray);
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary-light);
}

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

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  padding: 24px;
  margin-left: 220px;
  margin-top: 100px;
  background: var(--bg-darkest);
  min-height: calc(100vh - 100px);
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-white);
}

.page-actions {
  display: flex;
  gap: 10px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  outline: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-light);
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(59,130,246,0.15);
}

.btn-secondary:active {
  background: var(--bg-card);
  transform: scale(0.96);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #16a34a;
}

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

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-white);
}

.card-body {
  padding: 20px;
}

/* ===== KPI CARDS ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border-color);
  transition: all 0.3s;
}

.kpi-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-card-label {
  font-size: 12px;
  color: var(--text-gray);
  font-weight: 500;
}

.kpi-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-card-icon.blue { background: rgba(59,130,246,0.15); color: var(--primary-light); }
.kpi-card-icon.green { background: rgba(34,197,94,0.15); color: var(--success-light); }
.kpi-card-icon.orange { background: rgba(245,158,11,0.15); color: var(--warning-light); }
.kpi-card-icon.red { background: rgba(239,68,68,0.15); color: var(--danger-light); }
.kpi-card-icon.purple { background: rgba(139,92,246,0.15); color: #a78bfa; }
.kpi-card-icon.cyan { background: rgba(6,182,212,0.15); color: #67e8f9; }

.kpi-card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-white);
  margin-bottom: 6px;
}

.kpi-card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.kpi-card-trend {
  display: flex;
  align-items: center;
  gap: 2px;
  font-weight: 600;
}

.kpi-card-trend.up { color: var(--success); }
.kpi-card-trend.down { color: var(--danger); }

.kpi-card-compare {
  color: var(--text-muted);
}

/* ===== TABLE ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255,255,255,0.02);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-light-gray);
  font-size: 13px;
}

.data-table tr:hover td {
  background: rgba(255,255,255,0.02);
}

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

/* Table cell content */
.cell-main {
  font-weight: 600;
  color: var(--text-white);
}

.cell-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.cell-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  color: white;
}

.cell-with-avatar {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ===== STATUS BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-success .badge-dot { background: var(--success); }

.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-warning .badge-dot { background: var(--warning); }

.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-danger .badge-dot { background: var(--danger); }

.badge-info { background: rgba(6,182,212,0.15); color: var(--info); }
.badge-info .badge-dot { background: var(--info); }

.badge-default { background: rgba(148,163,184,0.15); color: var(--text-gray); }
.badge-default .badge-dot { background: var(--text-gray); }

/* ===== PROGRESS BAR ===== */
.progress-bar {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
  width: 100%;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.progress-bar-fill.blue { background: var(--primary); }
.progress-bar-fill.green { background: var(--success); }
.progress-bar-fill.orange { background: var(--warning); }
.progress-bar-fill.red { background: var(--danger); }

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-gray);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
}

.tab:hover { color: var(--text-light-gray); }
.tab.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary);
}

/* ===== FORM ELEMENTS ===== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-gray);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  height: 40px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text-white);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
}

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

.form-textarea {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
  min-height: 80px;
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-input {
  height: 36px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text-white);
  font-size: 13px;
  outline: none;
  min-width: 180px;
}

.filter-input:focus { border-color: var(--primary); }
.filter-input::placeholder { color: var(--text-muted); }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  margin-top: 16px;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-gray);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.page-btn:hover {
  background: var(--bg-card);
  color: var(--text-white);
}

.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== CHART CONTAINER ===== */
.chart-container {
  position: relative;
  width: 100%;
  height: 300px;
}

/* ===== GRID LAYOUTS ===== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* ===== TIMELINE ===== */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.timeline-dot {
  position: absolute;
  left: -22px;
  top: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-darkest);
}

.timeline-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.timeline-content {
  font-size: 13px;
  color: var(--text-light-gray);
}

.timeline-content strong {
  color: var(--text-white);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: var(--bg-card);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-white);
  margin-bottom: 8px;
}

.empty-state-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeInUp 0.4s ease forwards;
  opacity: 0;
}

.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.2s; }
.delay-5 { animation-delay: 0.25s; }
.delay-6 { animation-delay: 0.3s; }

/* ===== MOBILE MENU TOGGLE ===== */
.mobile-menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-gray);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 8px;
}

.mobile-menu-toggle:hover {
  background: var(--bg-card);
  color: var(--text-white);
}

.mobile-menu-toggle svg {
  width: 20px;
  height: 20px;
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
  opacity: 0;
  transition: opacity 0.3s;
}

.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

.sidebar.mobile-open {
  display: block !important;
  transform: translateX(0);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .card-view { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  /* Header */
  .mobile-menu-toggle { display: flex; }
  .header-search { display: none; }
  .header-brand .logo-text { font-size: 14px; }

  /* Sidebar - hidden by default, slide in on mobile */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 260px;
    z-index: 250;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }

  .main-content {
    margin-left: 0;
    padding: 16px;
    margin-top: 100px;
    min-height: calc(100vh - 100px);
  }

  .sub-nav {
    left: 0;
    padding: 0 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sub-nav-item {
    padding: 8px 12px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* Grid layouts */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; gap: 12px; }
  .kpi-grid { grid-template-columns: 1fr; gap: 12px; }

  /* Page header */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-title { font-size: 18px; }

  .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  /* Filter bar */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-input {
    width: 100%;
    min-width: auto;
  }

  /* Table - horizontal scroll */
  .data-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }

  .data-table {
    min-width: 600px;
  }

  /* Card view */
  .card-view { grid-template-columns: 1fr; gap: 12px; }

  /* View toggle hidden on mobile (auto-switch) */
  .view-toggle { display: none; }

  /* Detail layout */
  .detail-layout { grid-template-columns: 1fr; }

  /* Pagination */
  .pagination {
    justify-content: center;
    flex-wrap: wrap;
  }

  /* Form */
  .form-group { margin-bottom: 12px; }

  /* Tabs */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Chart */
  .chart-container { height: 220px; }

  /* Card body padding */
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; }

  /* Timeline */
  .timeline { padding-left: 20px; }
}

@media (max-width: 600px) {
  .top-header { padding: 0 12px; }
  .main-content { padding: 12px; margin-top: 90px; }
  .page-title { font-size: 16px; }

  .btn {
    padding: 6px 12px;
    font-size: 12px;
  }

  .btn-sm {
    padding: 4px 8px;
    font-size: 11px;
  }

  .kpi-card { padding: 14px; }
  .kpi-card-value { font-size: 22px; }

  .user-avatar {
    width: 30px;
    height: 30px;
    font-size: 11px;
  }

  .header-btn {
    width: 32px;
    height: 32px;
  }
}

/* ===== DETAIL VIEW ===== */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

.detail-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}

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

.info-label {
  color: var(--text-gray);
}

.info-value {
  color: var(--text-white);
  font-weight: 500;
}

/* ===== CUSTOM LABEL (Rainbow Tag) ===== */
.custom-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  user-select: none;
  white-space: nowrap;
}

.custom-label:hover {
  filter: brightness(1.15);
  transform: scale(1.02);
}

.custom-label .label-text {
  outline: none;
  min-width: 20px;
}

.custom-label .label-text:focus {
  border-bottom: 1px dashed currentColor;
}

/* ===== COLOR PICKER POPUP ===== */
.color-picker-popup {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  min-width: 220px;
  display: none;
}

.color-picker-popup.show {
  display: block;
}

.color-picker-popup .popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.color-picker-popup .popup-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-white);
}

.color-picker-popup .popup-close {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-gray);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.color-picker-popup .popup-close:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-white);
}

/* Preset colors grid */
.color-presets {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.color-preset {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
}

.color-preset:hover {
  transform: scale(1.15);
  border-color: white;
}

.color-preset.active {
  border-color: white;
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--primary);
}

/* Custom color input */
.color-custom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.color-custom-row input[type="color"] {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}

.color-custom-row .color-hex-input {
  flex: 1;
  height: 32px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text-white);
  font-size: 12px;
  font-family: monospace;
  outline: none;
}

.color-custom-row .color-hex-input:focus {
  border-color: var(--primary);
}

/* Label text input */
.label-text-input {
  width: 100%;
  height: 32px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text-white);
  font-size: 12px;
  outline: none;
  margin-bottom: 12px;
}

.label-text-input:focus {
  border-color: var(--primary);
}

/* Label position in table */
.td-label {
  min-width: 100px;
}

/* ===== VIEW TOGGLE ===== */
.view-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 3px;
  margin-left: auto;
}

.view-toggle-btn {
  width: 32px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-gray);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.view-toggle-btn:hover {
  color: var(--text-light-gray);
}

.view-toggle-btn.active {
  background: var(--primary);
  color: white;
}

/* ===== CARD VIEW ===== */
.card-view {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.card-view.show {
  display: grid;
}

.data-table-wrapper.hide {
  display: none;
}

.view-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s;
}

.view-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.view-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.view-card-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}

.view-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-white);
  line-height: 1.3;
}

.view-card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.view-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-bottom: 12px;
}

.view-card-field {
  font-size: 12px;
}

.view-card-field-label {
  color: var(--text-muted);
  margin-bottom: 2px;
}

.view-card-field-value {
  color: var(--text-light-gray);
  font-weight: 500;
}

.view-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.view-card-actions {
  display: flex;
  gap: 6px;
}

@media (max-width: 1200px) {
  .card-view { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .card-view { grid-template-columns: 1fr; }
  .view-toggle { display: none; }
}

@media (max-width: 1100px) {
  .detail-layout { grid-template-columns: 1fr; }
}

/* ===== AI ASSISTANT FLOATING PANEL ===== */
.ai-assistant-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
  z-index: 1000;
  transition: all 0.3s;
  font-size: 24px;
}

.ai-assistant-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(59, 130, 246, 0.5);
}

.ai-assistant-fab.active {
  transform: rotate(45deg);
}

.ai-assistant-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-height: 600px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.ai-assistant-panel.show {
  display: flex;
}

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(135deg, rgba(59,130,246,0.1) 0%, rgba(139,92,246,0.1) 100%);
}

.ai-panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-white);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-panel-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-gray);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.ai-panel-close:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-white);
}

.ai-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.ai-panel-body::-webkit-scrollbar { width: 4px; }
.ai-panel-body::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

.ai-feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.ai-feature-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-light-gray);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 12px;
  text-align: center;
}

.ai-feature-btn:hover {
  background: rgba(59,130,246,0.1);
  border-color: var(--primary);
  color: var(--text-white);
  transform: translateY(-2px);
}

.ai-feature-btn .ai-icon {
  font-size: 22px;
}

.ai-chat-area {
  min-height: 120px;
}

.ai-chat-message {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.ai-chat-message.user {
  background: var(--primary);
  color: white;
  margin-left: 20px;
}

.ai-chat-message.assistant {
  background: var(--bg-input);
  color: var(--text-light-gray);
  margin-right: 20px;
  border: 1px solid var(--border-color);
}

.ai-chat-message.assistant .ai-msg-title {
  font-weight: 600;
  color: var(--text-white);
  margin-bottom: 4px;
}

.ai-chat-message.assistant .ai-msg-content {
  white-space: pre-wrap;
}

.ai-chat-message.assistant .ai-risk-high {
  color: #ef4444;
  font-weight: 600;
}

.ai-chat-message.assistant .ai-risk-medium {
  color: #f59e0b;
  font-weight: 600;
}

.ai-chat-message.assistant .ai-risk-low {
  color: #10b981;
  font-weight: 600;
}

.ai-panel-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
}

.ai-panel-input {
  flex: 1;
  height: 36px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text-white);
  font-size: 13px;
  outline: none;
}

.ai-panel-input:focus {
  border-color: var(--primary);
}

.ai-panel-send {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.ai-panel-send:hover {
  background: var(--primary-hover);
}

.ai-loading {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
  padding: 8px 0;
}

.ai-loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: ai-bounce 1.4s infinite ease-in-out both;
}

.ai-loading-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-loading-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes ai-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* AI Action Button (inline in pages) */
.ai-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: linear-gradient(135deg, rgba(59,130,246,0.2) 0%, rgba(139,92,246,0.2) 100%);
  border: 1px solid rgba(59,130,246,0.4);
  border-radius: 8px;
  color: #93c5fd;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}

.ai-action-btn:hover {
  background: linear-gradient(135deg, rgba(59,130,246,0.35) 0%, rgba(139,92,246,0.35) 100%);
  border-color: rgba(59,130,246,0.7);
  color: #bfdbfe;
  transform: translateY(-1px);
  box-shadow: 0 2px 12px rgba(59,130,246,0.2);
}

.ai-action-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* AI Row Button */
.btn-ai {
  background: linear-gradient(135deg, rgba(59,130,246,0.15) 0%, rgba(139,92,246,0.15) 100%);
  border: 1px solid rgba(59,130,246,0.3);
  color: #93c5fd;
}

.btn-ai:hover {
  background: linear-gradient(135deg, rgba(59,130,246,0.3) 0%, rgba(139,92,246,0.3) 100%);
  border-color: rgba(59,130,246,0.6);
  color: #bfdbfe;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(59,130,246,0.15);
}

/* AI Result Modal */
.ai-result-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.ai-result-modal.show {
  display: flex;
}

.ai-result-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

.ai-result-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-white);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-result-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.ai-result-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 600px) {
  .ai-assistant-panel {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 80px;
  }
  .ai-assistant-fab {
    bottom: 16px;
    right: 16px;
  }
}
