:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --ring: #60a5fa;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --radius: 12px;
  --tap: 44px;
  --transition: 150ms;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Ubuntu,
    Cantarell,
    "Noto Sans",
    sans-serif;
}
a {
  color: var(--text);
  text-decoration: none;
}
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--space-2);
}
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  transition: width var(--transition) ease;
  overflow: hidden;
}
.hamburger {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 36px;
  padding: 0 12px;
  cursor: pointer;
  font-size: 16px;
  transition:
    background var(--transition),
    border-color var(--transition);
}
.hamburger:hover {
  background: #f3f4f6;
  border-color: var(--ring);
}
.brand {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-3);
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--border);
  min-height: var(--tap);
}
.logo {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}
.brand-text {
  display: flex;
  flex-direction: column;
}
.brand-title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
}
.brand-sub {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}
.menu-section {
  margin-top: var(--space-2);
  margin-bottom: var(--space-1);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 4px;
}
.menu-section.collapsible {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 10px;
  transition:
    background var(--transition),
    color var(--transition);
}
.menu-section.collapsible:hover {
  background: #f3f4f6;
  color: var(--text);
}
.menu-section .chevron {
  transition: transform var(--transition);
}
.menu-section.open .chevron {
  transform: rotate(180deg);
}
.menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.menu::-webkit-scrollbar {
  width: 6px;
}
.menu::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.5);
  border-radius: 999px;
}
.menu::-webkit-scrollbar-track {
  background: transparent;
}
.menu-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}
.menu-container.collapsed {
  display: none;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--text);
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition);
  text-decoration: none;
}
.menu-item:hover {
  border-color: var(--border);
  background: #f3f4f6;
}
.menu-item:active {
  background: #e5e7eb;
}
.menu-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--muted);
  transition: color var(--transition);
}
.menu-item:hover .menu-icon {
  color: var(--primary);
}
.menu-item.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.menu-item.active .menu-icon {
  color: #fff;
}
.menu-text {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition);
}
.content {
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}
.titlebar {
  padding: 0 var(--space-2);
}
.page-title {
  margin: 0;
  font-size: 22px;
}
.page-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}
.content-inner {
  padding: var(--space-2);
}
.user-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.profile {
  position: relative;
}
.profile-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}
.profile-toggle.open {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}
.profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13px;
}
.profile-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}
.profile-name {
  font-size: 13px;
  font-weight: 600;
}
.profile-role {
  font-size: 11px;
  color: var(--muted);
}
.profile-chevron {
  transition: transform var(--transition);
  color: var(--muted);
}
.profile-toggle.open .profile-chevron {
  transform: rotate(180deg);
}
.profile-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
  display: none;
  z-index: 20;
}
.profile-menu.open {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.profile-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
}
.profile-item:hover {
  background: #f3f4f6;
}
.profile-item.danger {
  color: #ef4444;
}
.profile-item.danger:hover {
  background: #fef2f2;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}
.card {
  background: var(--surface);
  padding: var(--space-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  min-height: var(--tap);
  transition:
    border-color var(--transition),
    transform var(--transition);
}
.card:hover {
  border-color: var(--ring);
  transform: translateY(-1px);
}
.card h2 {
  margin: 0 0 4px;
  font-size: 18px;
}
.card p {
  margin: 0;
  color: var(--muted);
}
button {
  min-height: var(--tap);
  padding: 0 var(--space-2);
  border-radius: 10px;
}
.btn,
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 var(--space-2);
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  border: 1px solid var(--primary);
  font-weight: 500;
  text-decoration: none;
  transition:
    background var(--transition),
    border-color var(--transition),
    transform var(--transition);
}
.btn:hover,
a.btn:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}
.btn:active,
a.btn:active {
  transform: scale(0.98);
}
input,
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--space-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
th {
  font-weight: 600;
  color: var(--muted);
  background: #f9fafb;
}
.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.actions a {
  color: var(--muted);
  transition: color var(--transition);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
}
.actions a:hover {
  color: var(--primary);
  background: #f3f4f6;
}
.action-delete:hover {
  color: #ef4444;
  background: #fef2f2;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) 0;
  margin-bottom: var(--space-2);
}
.page-header .title {
  margin: 0;
}
.page-header .subtitle {
  margin: 4px 0 0;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.form-field textarea {
  min-height: 120px;
}

.filters-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2);
  margin-bottom: var(--space-2);
}
.filter-form {
  margin: 0;
}
.filter-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-group {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 180px;
}
.search-group {
  flex: 2;
  min-width: 280px;
  position: relative;
}
.search-icon {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
}
.filter-group input,
.filter-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition);
}
.search-group input {
  padding-left: 36px;
}
.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--ring);
}
.filter-group select {
  cursor: pointer;
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}
.btn-secondary {
  background: #64748b;
  border-color: #64748b;
}
.btn-secondary:hover {
  background: #475569;
  border-color: #475569;
}

.leads-table th {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
}
.leads-table td {
  padding: 14px 16px;
  vertical-align: top;
}
.leads-table tbody tr:hover {
  background: #f9fafb;
}
.lead-title {
  font-weight: 500;
  color: var(--primary);
}
.lead-title:hover {
  text-decoration: underline;
}
.subtext {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}
.stage-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  text-transform: capitalize;
}
.stage-new {
  background: #dbeafe;
  color: #1d4ed8;
}
.stage-contacted {
  background: #fef3c7;
  color: #d97706;
}
.stage-qualified {
  background: #e0e7ff;
  color: #4338ca;
}
.stage-quoted {
  background: #fce7f3;
  color: #be185d;
}
.stage-won {
  background: #dcfce7;
  color: #15803d;
}
.stage-lost {
  background: #fee2e2;
  color: #dc2626;
}

.empty-state {
  text-align: center;
  padding: var(--space-3) var(--space-2);
  color: var(--muted);
}
.empty-state p {
  margin: var(--space-1) 0 4px;
  font-size: 18px;
}
.empty-state .subtitle {
  margin: 0 0 var(--space-2);
}
.stage-form {
  margin: 0;
}
.stage-select {
  width: auto;
  min-width: 90px;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition);
}
.stage-select:focus {
  outline: none;
  border-color: var(--ring);
}

/* Collapsed sidebar */
body.sidebar-collapsed .layout {
  grid-template-columns: 80px 1fr;
}
body.sidebar-collapsed .sidebar {
  width: 80px;
  padding: var(--space-2) var(--space-1);
}
body.sidebar-collapsed .brand {
  justify-content: center;
  gap: 0;
  padding: var(--space-1) 0;
}
body.sidebar-collapsed .brand-text {
  display: none;
}
body.sidebar-collapsed .menu-section {
  display: none;
}
body.sidebar-collapsed .menu-item {
  justify-content: center;
  padding: 10px 8px;
  gap: 0;
}
body.sidebar-collapsed .menu-text {
  display: none;
}
body.sidebar-collapsed .menu-item:hover {
  background: var(--primary);
  border-color: var(--primary);
}
body.sidebar-collapsed .menu-item:hover .menu-icon {
  color: #fff;
}

/* No sidebar */
.layout.no-sidebar {
  grid-template-columns: 1fr;
}

/* Notes section */
.notes-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}
.note-card {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: border-color var(--transition);
}
.note-card:hover {
  border-color: var(--ring);
}
.note-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
}
.note-author {
  font-weight: 500;
  color: var(--text);
}
.note-time {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.note-content {
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 12px;
  white-space: pre-wrap;
}
.note-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.note-form-section {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.note-textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  margin-bottom: 12px;
  transition: border-color var(--transition);
}
.note-textarea:focus {
  outline: none;
  border-color: var(--ring);
}
.btn-sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}
.btn-danger {
  background: #ef4444;
  border-color: #ef4444;
}
.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

/* Modal */
.modal {
  display: flex;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  transition: opacity 150ms ease;
}
.modal-content {
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 500px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  animation: modalSlideIn 150ms ease;
}
@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.modal-content h3 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 600;
}
