:root {
    --bg:        #0d0f14;
    --surface:   #141720;
    --card:      #1a1e2a;
    --border:    #252a38;
    --amber:     #e8a430;
    --amber-dim: #b07820;
    --amber-glow:#e8a43022;
    --text:      #e8e6df;
    --muted:     #7a7d8a;
    --danger:    #e05252;
    --success:   #4caf7d;
    --info:      #5b8dee;
    --radius:    10px;
    --shadow:    0 4px 24px rgba(0,0,0,0.4);
  }
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { scroll-behavior: smooth; }
  body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
  }

  /* â”€â”€ SIDEBAR â”€â”€ */
  #sidebar {
    width: 220px;
    min-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: width .3s;
  }
  .logo {
    padding: 0 24px 28px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
  }
  .logo-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 28px;
    font-weight: 600;
    color: var(--amber);
    letter-spacing: 3px;
    line-height: 1;
  }
  .logo-sub {
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--muted);
    margin-top: 4px;
  }
  nav { flex: 1; }
  .nav-section {
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--muted);
    padding: 16px 24px 6px;
    text-transform: uppercase;
  }
  .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 24px;
    cursor: pointer;
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all .2s;
    user-select: none;
  }
  .nav-item:hover { color: var(--text); background: var(--card); }
  .nav-item.active { color: var(--amber); border-left-color: var(--amber); background: var(--amber-glow); }
  .nav-icon { font-size: 16px; width: 20px; text-align: center; }
  .sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
  }
  .user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .user-avatar {
    width: 32px; height: 32px;
    background: var(--amber);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #000;
    flex-shrink: 0;
  }

  /* â”€â”€ MAIN â”€â”€ */
  #main {
    margin-left: 220px;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }
  .topbar {
    height: 62px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: var(--surface);
    position: sticky; top: 0; z-index: 50;
  }
  .topbar-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 22px;
    font-weight: 400;
    color: var(--text);
  }
  .topbar-actions { display: flex; gap: 10px; }
  .btn {
    padding: 8px 16px;
    border-radius: var(--radius);
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all .2s;
  }
  .btn-primary { background: var(--amber); color: #000; }
  .btn-primary:hover { background: #f5b840; }
  .btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
  .btn-ghost:hover { color: var(--text); border-color: var(--muted); }
  .btn-danger { background: var(--danger); color: #fff; }
  .btn-sm { padding: 5px 11px; font-size: 12px; }

  .content { padding: 32px; flex: 1; }

  /* â”€â”€ VIEWS â”€â”€ */
  .view { display: none; animation: fadeIn .3s ease; }
  .view.active { display: block; }
  @keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

  /* â”€â”€ DASHBOARD â”€â”€ */
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
  }
  .stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    position: relative;
    overflow: hidden;
    transition: border-color .2s;
  }
  .stat-card:hover { border-color: var(--amber-dim); }
  .stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--amber);
    opacity: 0;
    transition: opacity .2s;
  }
  .stat-card:hover::before { opacity: 1; }
  .stat-label { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
  .stat-value { font-family: 'Cormorant Garamond', serif; font-size: 40px; font-weight: 300; color: var(--amber); line-height: 1; }
  .stat-change { font-size: 12px; color: var(--success); margin-top: 6px; }
  .stat-icon { position: absolute; top: 18px; right: 20px; font-size: 24px; opacity: .18; }

  .dash-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 20px;
  }
  .panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
  }
  .panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .5px;
  }
  .panel-header span { color: var(--muted); font-weight: 400; font-size: 12px; }

  /* Recent Activity */
  .activity-list { padding: 0; }
  .activity-item {
    display: flex;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
    font-size: 13px;
  }
  .activity-item:last-child { border-bottom: none; }
  .activity-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-top: 4px;
    flex-shrink: 0;
  }
  .activity-dot.amber { background: var(--amber); }
  .activity-dot.green { background: var(--success); }
  .activity-dot.blue  { background: var(--info); }
  .activity-text { flex: 1; line-height: 1.5; }
  .activity-time { color: var(--muted); font-size: 11px; white-space: nowrap; }

  /* Pipeline mini */
  .pipeline-mini { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
  .pipeline-stage-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
  }
  .stage-label { width: 90px; color: var(--muted); font-size: 12px; }
  .stage-bar-wrap { flex: 1; height: 6px; background: var(--border); border-radius: 99px; }
  .stage-bar { height: 100%; border-radius: 99px; background: var(--amber); }
  .stage-count { width: 30px; text-align: right; color: var(--muted); font-size: 12px; }

  /* â”€â”€ CONTACTS â”€â”€ */
  .search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
  }
  .search-input {
    flex: 1;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 13.5px;
    outline: none;
    transition: border-color .2s;
  }
  .search-input:focus { border-color: var(--amber); }
  .search-input::placeholder { color: var(--muted); }

  .contacts-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
  .contacts-table thead tr {
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
  }
  .contacts-table th { padding: 10px 16px; text-align: left; font-weight: 500; }
  .contacts-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
  .contacts-table tbody tr { transition: background .15s; }
  .contacts-table tbody tr:hover { background: var(--surface); }
  .contact-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
    color: #000;
    flex-shrink: 0;
  }
  .contact-cell { display: flex; align-items: center; gap: 10px; }
  .tag {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid;
  }
  .tag-lead    { color: #5b8dee; border-color: #5b8dee44; background: #5b8dee11; }
  .tag-client  { color: var(--success); border-color: #4caf7d44; background: #4caf7d11; }
  .tag-partner { color: var(--amber); border-color: var(--amber-dim); background: var(--amber-glow); }
  .tag-prospect{ color: #bb79d6; border-color: #bb79d644; background: #bb79d611; }
  .icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    padding: 4px 7px;
    border-radius: 6px;
    color: var(--muted);
    transition: all .2s;
  }
  .icon-btn:hover { color: var(--text); background: var(--border); }
  .icon-btn.del:hover { color: var(--danger); }

  /* â”€â”€ DEALS / PIPELINE â”€â”€ */
  .kanban {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    align-items: start;
  }
  .kanban-col {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
  }
  .kanban-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .5px;
  }
  .stage-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
  }
  .kanban-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 80px; }
  .deal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    cursor: pointer;
    transition: border-color .2s, transform .15s;
    font-size: 13px;
  }
  .deal-card:hover { border-color: var(--amber-dim); transform: translateY(-2px); }
  .deal-name { font-weight: 600; margin-bottom: 5px; }
  .deal-company { color: var(--muted); font-size: 12px; }
  .deal-value { margin-top: 10px; color: var(--amber); font-family: 'JetBrains Mono', monospace; font-size: 13px; }
  .deal-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
  .deal-date { font-size: 11px; color: var(--muted); }
  .add-deal-btn {
    width: 100%; padding: 8px; background: none; border: 1px dashed var(--border);
    border-radius: 8px; color: var(--muted); font-size: 13px; cursor: pointer;
    transition: all .2s; margin: 0 10px 10px; width: calc(100% - 20px);
  }
  .add-deal-btn:hover { border-color: var(--amber-dim); color: var(--amber); }

  /* â”€â”€ TASKS â”€â”€ */
  .tasks-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
  .task-list { display: flex; flex-direction: column; gap: 8px; }
  .task-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 13px 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    transition: border-color .2s;
    font-size: 13.5px;
  }
  .task-item.done { opacity: .5; }
  .task-item.done .task-title { text-decoration: line-through; }
  .task-check {
    width: 18px; height: 18px;
    border-radius: 5px;
    border: 2px solid var(--border);
    flex-shrink: 0;
    cursor: pointer;
    margin-top: 1px;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
    transition: all .2s;
  }
  .task-check.checked { background: var(--amber); border-color: var(--amber); color: #000; }
  .task-title { flex: 1; line-height: 1.5; }
  .task-meta { color: var(--muted); font-size: 11px; margin-top: 3px; }
  .priority-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    margin-top: 5px;
    flex-shrink: 0;
  }
  .p-high   { background: var(--danger); }
  .p-medium { background: var(--amber); }
  .p-low    { background: var(--success); }

  /* â”€â”€ NOTES â”€â”€ */
  .notes-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .note-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    transition: border-color .2s;
  }
  .note-card:hover { border-color: var(--amber-dim); }
  .note-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 3px; height: 100%;
    border-radius: 10px 0 0 10px;
  }
  .nc-amber::before { background: var(--amber); }
  .nc-blue::before  { background: var(--info); }
  .nc-green::before { background: var(--success); }
  .nc-red::before   { background: var(--danger); }
  .note-title { font-weight: 600; font-size: 14px; }
  .note-body { font-size: 13px; color: var(--muted); line-height: 1.6; flex: 1; }
  .note-footer { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

  /* â”€â”€ MODALS â”€â”€ */
  .modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.7);
    z-index: 500;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 480px;
    max-width: 95vw;
    box-shadow: var(--shadow);
    animation: modalIn .25s ease;
  }
  @keyframes modalIn { from { opacity: 0; transform: scale(.95) translateY(-10px); } to { opacity: 1; transform: none; } }
  .modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .modal-title { font-family: 'Cormorant Garamond', serif; font-size: 20px; font-weight: 600; }
  .modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
  .modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
  .form-group { display: flex; flex-direction: column; gap: 6px; }
  .form-label { font-size: 12px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); }
  .form-input, .form-select, .form-textarea {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 13.5px;
    outline: none;
    transition: border-color .2s;
  }
  .form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--amber); }
  .form-select option { background: var(--card); }
  .form-textarea { resize: vertical; min-height: 80px; }
  .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

  /* â”€â”€ TOAST â”€â”€ */
  #toast {
    position: fixed; bottom: 30px; right: 30px;
    background: var(--card);
    border: 1px solid var(--amber-dim);
    border-left: 4px solid var(--amber);
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text);
    z-index: 9999;
    transform: translateY(80px);
    opacity: 0;
    transition: all .3s ease;
    pointer-events: none;
  }
  #toast.show { transform: translateY(0); opacity: 1; }

  /* SCROLLBAR */
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: var(--surface); }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

  /* Empty state */
  .empty-state {
    padding: 48px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
  .empty-state .empty-icon { font-size: 36px; }

  @media(max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2,1fr); }
    .kanban { grid-template-columns: repeat(2,1fr); }
  }