:root {
  --primary: #0A9B8E;
  --primary-light: #0DBFAF;
  --primary-dark: #078578;
  --dark: #0D1117;
  --dark-2: #161B22;
  --dark-3: #21262D;
  --dark-4: #30363D;
  --gold: #C8A96E;
  --gold-light: #E8D5A8;
  --text: #E6EDF3;
  --text-muted: #8B949E;
  --text-dim: #6E7681;
  --success: #2EA043;
  --warning: #D29922;
  --danger: #F85149;
  --info: #58A6FF;
  --sidebar-w: 260px;
  --header-h: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--dark);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* Sidebar */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w); background: var(--dark-2);
  border-right: 1px solid var(--dark-4);
  display: flex; flex-direction: column; z-index: 100;
}
.sidebar-logo {
  padding: 20px 24px; border-bottom: 1px solid var(--dark-4);
  font-size: 20px; font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.sidebar-logo small { display: block; font-size: 11px; font-weight: 400; -webkit-text-fill-color: var(--text-muted); margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-dim); padding: 16px 12px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500; color: var(--text-muted);
  cursor: pointer; transition: all 0.15s; margin-bottom: 2px;
}
.nav-item:hover { background: var(--dark-3); color: var(--text); }
.nav-item.active { background: rgba(10,155,142,0.15); color: var(--primary-light); }
.nav-item .icon { font-size: 18px; width: 24px; text-align: center; }
.nav-item .badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; }

.sidebar-user {
  padding: 16px; border-top: 1px solid var(--dark-4);
  display: flex; align-items: center; gap: 12px;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
}
.user-info { flex: 1; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* Header */
.header {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0;
  height: var(--header-h); background: var(--dark-2);
  border-bottom: 1px solid var(--dark-4);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; z-index: 50;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-title { font-size: 18px; font-weight: 700; }
.header-breadcrumb { font-size: 12px; color: var(--text-muted); }
.header-right { display: flex; align-items: center; gap: 20px; }
.header-search {
  background: var(--dark-3); border: 1px solid var(--dark-4);
  border-radius: 8px; padding: 8px 14px;
  color: var(--text); font-size: 13px; width: 280px;
  font-family: inherit; outline: none;
}
.header-search:focus { border-color: var(--primary); }
.header-icon { position: relative; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.header-icon .dot { position: absolute; top: -2px; right: -2px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; }

/* Main */
.main {
  margin-left: var(--sidebar-w); margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
  padding: 28px 32px;
}

/* Cards */
.card {
  background: var(--dark-2); border: 1px solid var(--dark-4);
  border-radius: 12px; overflow: hidden; margin-bottom: 20px;
}
.card-header {
  padding: 18px 24px; border-bottom: 1px solid var(--dark-4);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 700; }
.card-action { font-size: 12px; color: var(--primary); cursor: pointer; font-weight: 500; }
.card-body { padding: 20px 24px; }

/* Stats */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 28px; }
.stat-card {
  background: var(--dark-2); border: 1px solid var(--dark-4);
  border-radius: 12px; padding: 24px; transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 800; margin-bottom: 4px; }
.stat-value.teal { color: var(--primary-light); }
.stat-value.gold { color: var(--gold); }
.stat-value.green { color: var(--success); }
.stat-value.blue { color: var(--info); }
.stat-change { font-size: 12px; color: var(--success); }
.stat-change.down { color: var(--danger); }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 28px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 28px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 16px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); border-bottom: 1px solid var(--dark-4); }
td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid rgba(48,54,61,0.5); }
tr:hover td { background: rgba(10,155,142,0.03); }

/* Status badges */
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.status-badge.hot { background: rgba(248,81,73,0.15); color: var(--danger); }
.status-badge.warm { background: rgba(210,153,34,0.15); color: var(--warning); }
.status-badge.cold { background: rgba(88,166,255,0.15); color: var(--info); }
.status-badge.new { background: rgba(10,155,142,0.15); color: var(--primary-light); }
.status-badge.won, .status-badge.approved, .status-badge.closed_won { background: rgba(46,160,67,0.15); color: var(--success); }
.status-badge.lost, .status-badge.rejected, .status-badge.closed_lost { background: rgba(248,81,73,0.1); color: #f0706c; }
.status-badge.pending { background: rgba(210,153,34,0.15); color: var(--warning); }
.status-badge.paid { background: rgba(10,155,142,0.15); color: var(--primary-light); }
.status-badge.contacted, .status-badge.qualified { background: rgba(88,166,255,0.15); color: var(--info); }
.status-badge.converted { background: rgba(46,160,67,0.15); color: var(--success); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; font-family: inherit; transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-outline { background: transparent; border: 1px solid var(--dark-4); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--text-muted); color: var(--text); }
.btn-gold { background: var(--gold); color: var(--dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 11px; }

/* Pipeline kanban */
.pipeline { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; min-height: 500px; }
.pipeline-col { min-width: 280px; flex: 1; background: var(--dark-2); border: 1px solid var(--dark-4); border-radius: 12px; display: flex; flex-direction: column; }
.pipeline-col-header { padding: 16px; border-bottom: 1px solid var(--dark-4); display: flex; align-items: center; justify-content: space-between; }
.pipeline-col-title { font-size: 13px; font-weight: 700; }
.pipeline-col-count { background: var(--dark-4); border-radius: 10px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.pipeline-col-body { padding: 12px; flex: 1; overflow-y: auto; }

.deal-card {
  background: var(--dark-3); border: 1px solid var(--dark-4);
  border-radius: 8px; padding: 14px; margin-bottom: 10px;
  cursor: pointer; transition: border-color 0.15s;
}
.deal-card:hover { border-color: var(--primary); }
.deal-name { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.deal-client { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.deal-amount { font-size: 14px; font-weight: 700; color: var(--primary-light); }
.deal-agent { font-size: 11px; color: var(--text-dim); }
.deal-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; margin-top: 8px; }
.deal-tag.offplan { background: rgba(200,169,110,0.2); color: var(--gold); }
.deal-tag.sale { background: rgba(88,166,255,0.15); color: var(--info); }
.deal-tag.lease { background: rgba(10,155,142,0.15); color: var(--primary-light); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--dark-3); border: 1px solid var(--dark-4);
  border-radius: 8px; color: var(--text); font-size: 14px;
  font-family: inherit; outline: none; transition: border 0.2s;
}
.form-control:focus { border-color: var(--primary); }
select.form-control { cursor: pointer; }
textarea.form-control { min-height: 100px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-header-left { display: flex; align-items: center; gap: 16px; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--dark-4); }
.tab-link {
  padding: 10px 20px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  transition: all 0.15s; display: inline-block;
}
.tab-link:hover { color: var(--text); }
.tab-link.active { color: var(--primary-light); border-bottom-color: var(--primary); }

/* Progress bars */
.progress-bar { height: 6px; background: var(--dark-4); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; }
.progress-fill.teal { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.progress-fill.gold { background: linear-gradient(90deg, #B8943E, var(--gold)); }

/* Activity feed */
.activity-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(48,54,61,0.4); }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.activity-text { font-size: 13px; color: var(--text-muted); }
.activity-text strong { color: var(--text); font-weight: 600; }
.activity-time { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* Alerts */
.alert {
  padding: 12px 16px; border-radius: 8px; margin-bottom: 16px;
  font-size: 13px; font-weight: 500;
}
.alert-success { background: rgba(46,160,67,0.15); color: var(--success); border: 1px solid rgba(46,160,67,0.3); }
.alert-info { background: rgba(88,166,255,0.15); color: var(--info); border: 1px solid rgba(88,166,255,0.3); }
.alert-warning { background: rgba(210,153,34,0.15); color: var(--warning); border: 1px solid rgba(210,153,34,0.3); }
.alert-error { background: rgba(248,81,73,0.15); color: var(--danger); border: 1px solid rgba(248,81,73,0.3); }

/* Commission summary */
.commission-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.comm-card { background: var(--dark-3); border-radius: 10px; padding: 20px; text-align: center; }
.comm-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.comm-value { font-size: 28px; font-weight: 800; margin-top: 4px; }

/* Notes section */
.note-item { padding: 12px 0; border-bottom: 1px solid rgba(48,54,61,0.4); }
.note-item:last-child { border-bottom: none; }
.note-meta { font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }
.note-text { font-size: 13px; color: var(--text-muted); }

/* Detail page */
.detail-header { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.detail-avatar { width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--gold)); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; color: #fff; }
.detail-title { font-size: 22px; font-weight: 700; }
.detail-sub { font-size: 13px; color: var(--text-muted); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--dark-4); border-radius: 3px; }

/* Responsive */
@media (max-width: 1200px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .header { left: 0; }
  .main { margin-left: 0; }
}
