:root {
  color-scheme: light;
  --bg: #f8f6ef;
  --panel: #ffffff;
  --text: #181a1f;
  --muted: #667085;
  --line: #d8d4c7;
  --accent: #136f63;
  --accent-strong: #0b4c43;
  --accent-soft: #dceee8;
  --warn: #8a5b00;
  --danger: #9f1d1d;
  --shadow: 0 10px 24px rgba(31, 35, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
}

button:active {
  transform: translateY(1px);
}

button.secondary {
  color: var(--danger);
  background: #f7e4e4;
}

button:disabled {
  opacity: 0.58;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  background: #fff;
}

textarea {
  resize: vertical;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

main {
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 12px 12px max(32px, env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid rgba(216, 212, 199, 0.9);
  background: rgba(248, 246, 239, 0.94);
  backdrop-filter: blur(14px);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 19px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.icon-button {
  display: grid;
  width: 44px;
  min-width: 44px;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  font-size: 24px;
}

.source-panel,
.contact-card,
.group-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.source-panel {
  margin: 12px 0;
  padding: 12px;
}

.source-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.sync-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.sync-help {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

details {
  margin-top: 10px;
}

summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 700;
}

details textarea {
  margin-top: 10px;
}

details button {
  width: 100%;
  margin-top: 8px;
}

.source-status {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.source-status.error {
  color: var(--danger);
}

.group-nav {
  position: sticky;
  top: calc(70px + env(safe-area-inset-top));
  z-index: 15;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 8px;
  margin: 12px 0;
}

.group-nav button {
  padding: 0;
  font-size: 28px;
}

.group-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  margin-bottom: 12px;
}

.group-summary button {
  min-width: 116px;
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.contacts {
  display: grid;
  gap: 12px;
}

.contact-card {
  padding: 12px;
}

.contact-card > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.contact-company {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-chip {
  display: none;
  flex: 0 0 auto;
  max-width: 44%;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.status-chip.visible {
  display: inline-block;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.call-link {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.contact-fields {
  display: grid;
  grid-template-columns: minmax(92px, 34%) 1fr;
  gap: 6px 10px;
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.contact-fields dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.contact-fields dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.note-preview {
  display: none;
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  white-space: pre-wrap;
}

.note-preview.visible {
  display: block;
}

.contact-card footer {
  margin-top: 10px;
}

.note-button {
  width: 100%;
  color: var(--accent-strong);
  background: var(--accent-soft);
}

dialog {
  width: min(560px, calc(100% - 22px));
  border: 0;
  border-radius: 10px;
  padding: 0;
  color: var(--text);
  background: #fff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.44);
}

.note-form {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.note-form header,
.note-form footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.note-form footer button {
  flex: 1;
}

@media (min-width: 760px) {
  main {
    padding-top: 20px;
  }

  .contacts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
