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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f7fa;
  color: #1a1a2e;
  line-height: 1.5;
}

header {
  background: #1a1a2e;
  color: #fff;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 { font-size: 1.4rem; font-weight: 600; }
header span { font-size: 0.85rem; opacity: 0.7; }

main { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }

/* --- List view --- */
#list-view {}

.controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
}

.controls input,
.controls select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  font-size: 0.9rem;
  min-width: 220px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

thead { background: #f0f2f5; }
th { text-align: left; padding: 0.75rem 1rem; font-size: 0.8rem; text-transform: uppercase; color: #555; letter-spacing: 0.03em; }
td { padding: 0.65rem 1rem; border-top: 1px solid #eee; font-size: 0.9rem; }

.company-btn {
  background: none;
  border: none;
  color: #2563eb;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
  padding: 0;
}
.company-btn:hover { text-decoration: underline; }

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-lead          { background: #e0e7ff; color: #3730a3; }
.badge-contacted     { background: #dbeafe; color: #1e40af; }
.badge-proposal_sent { background: #fef3c7; color: #92400e; }
.badge-negotiating   { background: #ffedd5; color: #9a3412; }
.badge-client        { background: #d1fae5; color: #065f46; }
.badge-lost          { background: #fee2e2; color: #991b1b; }

.badge-low       { background: #f3f4f6; color: #6b7280; }
.badge-medium    { background: #dbeafe; color: #1e40af; }
.badge-high      { background: #fef3c7; color: #92400e; }
.badge-very_high { background: #d1fae5; color: #065f46; }

/* --- Detail view --- */
#detail-view { display: none; }

.back-btn {
  background: none;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  margin-bottom: 1rem;
  color: #333;
}
.back-btn:hover { background: #f0f2f5; }

.detail-card {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 1rem;
}

.detail-card h2 { font-size: 1.3rem; margin-bottom: 1rem; }
.detail-card h3 { font-size: 1rem; margin-bottom: 0.75rem; color: #333; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.info-item label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}

.info-item span, .info-item select {
  font-size: 0.95rem;
}

.editable-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.editable-row label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
}

.editable-row select {
  padding: 0.45rem 0.6rem;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  font-size: 0.9rem;
}

.save-btn, .add-note-btn {
  padding: 0.5rem 1.2rem;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
}
.save-btn { background: #2563eb; }
.save-btn:hover { background: #1d4ed8; }
.add-note-btn { background: #059669; }
.add-note-btn:hover { background: #047857; }

.contacts-table { margin-bottom: 1.5rem; }
.contacts-table td, .contacts-table th { font-size: 0.85rem; }

.note-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.note-form label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
  flex: 1;
  min-width: 200px;
}

.note-form input {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  font-size: 0.9rem;
  width: 100%;
}

.notes-list { list-style: none; }

.notes-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid #eee;
}

.note-meta {
  font-size: 0.78rem;
  color: #888;
  margin-bottom: 0.2rem;
}

.note-text { font-size: 0.9rem; }

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #065f46;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 100;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}
