:root {
  --primary: #1d4ed8;
  --primary-light: #3b82f6;
  --primary-dark: #1e40af;
  --primary-bg: #eff6ff;
  --secondary: #64748b;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --purple: #7c3aed;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; }

/* Top Navigation */
.top-nav {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow); z-index: 100; position: relative;
}
.nav-left { display: flex; align-items: center; gap: 12px; }
.nav-logo { height: 36px; }
.nav-title { font-weight: 600; font-size: 16px; color: var(--primary-dark); }
.nav-center { flex: 1; max-width: 500px; margin: 0 32px; }
.nav-right { display: flex; align-items: center; }
.agent-badge {
  background: var(--primary-bg); color: var(--primary);
  padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 500;
}

/* Search */
.search-box {
  position: relative; width: 100%;
}
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--secondary); }
.search-box input {
  width: 100%; padding: 8px 12px 8px 36px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; outline: none; transition: border-color 0.2s;
}
.search-box input:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.search-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: 300px; overflow-y: auto; z-index: 200;
}
.search-dropdown.hidden { display: none; }
.search-result {
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.search-result:hover { background: var(--primary-bg); }
.search-result:last-child { border-bottom: none; }
.search-result .name { font-weight: 500; font-size: 14px; }
.search-result .meta { font-size: 12px; color: var(--text-muted); }

/* App Layout */
.app-layout { display: flex; height: calc(100vh - 60px); }

/* Sidebar */
.sidebar {
  width: 220px; background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 12px; flex-shrink: 0;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius);
  text-decoration: none; color: var(--text-muted); font-size: 14px; font-weight: 500;
  transition: all 0.15s;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-bg); color: var(--primary); }
.nav-item i { width: 18px; text-align: center; }

/* Main Content */
.main-content { flex: 1; overflow-y: auto; padding: 24px 32px; }

/* Views */
.view { display: none; }
.view.active { display: block; }
.view-header { margin-bottom: 24px; }
.view-header h1 { font-size: 24px; font-weight: 700; color: var(--text); }
.view-header .subtitle { font-size: 14px; color: var(--text-muted); margin-top: 4px; display: block; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; font-size: 20px;
}
.stat-icon.blue { background: #dbeafe; color: var(--primary); }
.stat-icon.orange { background: #fed7aa; color: var(--warning); }
.stat-icon.green { background: #d1fae5; color: var(--success); }
.stat-icon.purple { background: #ede9fe; color: var(--purple); }
.stat-value { font-size: 28px; font-weight: 700; display: block; }
.stat-label { font-size: 13px; color: var(--text-muted); }

/* Cards */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px 20px; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 10px 12px; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); border-bottom: 2px solid var(--border); font-weight: 600;
}
.data-table td {
  padding: 12px; font-size: 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:hover { background: var(--bg); }
.data-table tr { cursor: pointer; }

/* Badges */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 500; text-transform: capitalize;
}
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #d1fae5; color: #059669; }
.badge-orange { background: #fed7aa; color: #92400e; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-yellow { background: #fef3c7; color: #92400e; }

/* Customer Detail */
.customer-tabs {
  display: flex; gap: 0; margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
}
.tab {
  padding: 10px 20px; border: none; background: none; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Filters */
.filters-bar {
  display: flex; gap: 12px; margin-bottom: 16px;
}
.filters-bar select {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; background: var(--surface); cursor: pointer;
}

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 16px; padding: 12px;
}
.pagination button {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; font-size: 13px;
}
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Catalog Grid */
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.catalog-card {
  background: var(--surface); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); transition: transform 0.15s, box-shadow 0.15s;
}
.catalog-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.catalog-card h4 { font-size: 16px; margin-bottom: 8px; }
.catalog-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.catalog-card .price { font-size: 20px; font-weight: 700; color: var(--primary); }
.catalog-card .price-period { font-size: 13px; color: var(--text-muted); font-weight: 400; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-content {
  position: relative; background: var(--surface); border-radius: 12px;
  width: 90%; max-width: 700px; max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 18px; }
.modal-close { border: none; background: none; cursor: pointer; font-size: 18px; color: var(--text-muted); }
.modal-body { padding: 20px 24px; }
.modal-body .detail-row { display: flex; padding: 8px 0; border-bottom: 1px solid var(--border); }
.modal-body .detail-label { width: 140px; font-size: 13px; color: var(--text-muted); font-weight: 500; }
.modal-body .detail-value { flex: 1; font-size: 14px; }
.modal-body .notes-section { margin-top: 16px; }
.modal-body .note-item { padding: 10px; background: var(--bg); border-radius: var(--radius); margin-bottom: 8px; }
.modal-body .note-author { font-size: 12px; font-weight: 600; color: var(--primary); }
.modal-body .note-date { font-size: 11px; color: var(--text-muted); margin-left: 8px; }
.modal-body .note-text { font-size: 13px; margin-top: 4px; }

/* Buttons */
.btn-back {
  border: none; background: none; cursor: pointer;
  color: var(--primary); font-size: 14px; font-weight: 500;
  margin-bottom: 8px; display: inline-flex; align-items: center; gap: 6px;
}
.btn-back:hover { text-decoration: underline; }

/* Loading */
.loading-spinner { text-align: center; padding: 32px; color: var(--text-muted); font-size: 14px; }

/* Customer info grid */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.info-item .info-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.info-item .info-value { font-size: 15px; font-weight: 500; margin-top: 2px; }

/* Responsive */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .nav-center { display: none; }
}
