:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e3e5e9;
  --text: #1c1f26;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --green-bg: #e9f9ee;
  --danger: #dc2626;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 12px 60px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding: 16px 4px 8px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar h1 {
  font-size: 22px;
  margin: 0;
}

.stats {
  font-size: 13px;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 4px 8px;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.toolbar {
  position: sticky;
  top: 52px;
  z-index: 19;
  background: var(--bg);
  display: flex;
  gap: 8px;
  padding: 4px 4px 12px;
}

#search {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 15px;
  background: var(--card);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: #eef0f3; color: var(--text); }
.btn-secondary:hover { background: #e3e5e9; }

.btn-danger { background: #fdecec; color: var(--danger); }
.btn-danger:hover { background: #fbdada; }

.btn-small {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.demo-banner {
  background: #fff7e6;
  border: 1px solid #ffe1a8;
  color: #8a5a00;
  font-size: 13px;
  border-radius: 10px;
  padding: 10px 14px;
  margin: 0 4px 10px;
}
.demo-banner.hidden { display: none; }

.status {
  font-size: 13px;
  color: var(--muted);
  padding: 0 4px 8px;
  min-height: 16px;
}

.company-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.company-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.company-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}

.chevron {
  transition: transform 0.15s ease;
  color: var(--muted);
  flex-shrink: 0;
}
.company-card.open > .company-header .chevron { transform: rotate(90deg); }

.company-title {
  flex: 1;
  min-width: 0;
}

.company-name {
  font-weight: 700;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.company-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  background: #eef2ff;
  color: #4338ca;
  border-radius: 6px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
}

.progress-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef0f3;
  color: var(--muted);
}
.progress-pill.done { background: var(--green-bg); color: var(--green); }

.company-body {
  display: none;
  border-top: 1px solid var(--border);
  padding: 4px 10px 12px;
}
.company-card.open > .company-body { display: block; }

.people-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.person-card {
  background: #fafafb;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.people-flat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.person-card.standalone {
  background: var(--card);
  border-radius: var(--radius);
}

.person-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.person-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #dfe3ea;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #6b7280;
}

.person-title { flex: 1; min-width: 0; }

.person-name { font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; }
.person-position { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }

.talked-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.talked-btn.done {
  background: var(--green-bg);
  color: var(--green);
  border-color: #bfe7cc;
}

.person-body {
  display: none;
  padding: 4px 14px 14px;
  border-top: 1px solid var(--border);
}
.person-card.open > .person-body { display: block; }

.person-detail {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.photo-box {
  width: 110px;
  height: 110px;
  border-radius: 12px;
  background: #eef0f3 center/cover no-repeat;
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  flex-shrink: 0;
  overflow: hidden;
}

.detail-fields {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-top: 4px;
}

.dossier-textarea {
  width: 100%;
  min-height: 90px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  resize: vertical;
}

.contact-line { font-size: 13px; color: var(--text); }

.person-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.add-person-row {
  margin-top: 8px;
}

.empty-hint {
  color: var(--muted);
  font-size: 13.5px;
  padding: 20px 8px;
  text-align: center;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 30, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: #fff;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 480px;
  padding: 20px;
  max-height: 85vh;
  overflow-y: auto;
}

@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 16px; margin-bottom: 40px; }
}

.modal h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.form-field {
  margin-bottom: 12px;
}

.form-field label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 4px;
}

.form-field input, .form-field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14.5px;
  font-family: inherit;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

@media (max-width: 480px) {
  .topbar h1 { font-size: 19px; }
  .photo-box { width: 90px; height: 90px; }
}
