:root {
  --wa-green: #25D366;
  --wa-dark: #075E54;
  --bg: #f6f8fa;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --border: #e5e7eb;
  --warn: #f59e0b;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: #dc2626; min-height: 1em; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

#login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
#login form { background: var(--card); padding: 32px; border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 360px; }
#login h1 { margin: 0 0 4px; font-size: 24px; }
#login input { width: 100%; padding: 14px; margin: 16px 0 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 16px; }
#login button { width: 100%; padding: 14px; background: var(--wa-dark); color: white; border: 0; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer; }

#app { max-width: 1100px; margin: 0 auto; padding: 0 16px 100px; }
header { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
header h1 { font-size: 18px; margin: 0; }
.header-actions { display: flex; gap: 8px; }
.ghost { background: transparent; border: 1px solid var(--border); padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; }

#progress { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
#progress-bar { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
#progress-fill { height: 100%; width: 0%; background: var(--wa-green); transition: width 0.3s ease; }
#progress-label { font-size: 14px; font-variant-numeric: tabular-nums; color: var(--muted); }

#tabs { display: flex; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.tab { flex: 1; padding: 12px; background: transparent; border: 0; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--wa-dark); border-bottom-color: var(--wa-dark); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; background: var(--border); color: var(--text); font-size: 12px; margin-left: 4px; font-variant-numeric: tabular-nums; }

#search { width: 100%; padding: 12px; margin: 12px 0; font-size: 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }

#main { display: block; }
#list-pane, #detail-pane { background: var(--card); border-radius: var(--radius); }
#contact-list { list-style: none; padding: 0; margin: 0; }
#contact-list li { padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
#contact-list li:last-child { border-bottom: 0; }
#contact-list li:active { background: #f3f4f6; }
#contact-list li.selected { background: #ecfdf5; }
.row-main { display: flex; flex-direction: column; gap: 2px; }
.row-name { font-weight: 500; font-size: 15px; }
.row-meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row-chev { color: var(--muted); }

#detail-pane { padding: 20px; }
#detail-pane h2 { margin: 0 0 4px; font-size: 18px; }
.meta { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
#detail-message { background: #f9fafb; padding: 16px; border-radius: 8px; font-family: -apple-system, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; border: 1px solid var(--border); }
.cta-stack { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.cta-primary { display: block; text-align: center; padding: 16px; background: var(--wa-green); color: white; text-decoration: none; border-radius: 8px; font-size: 16px; font-weight: 600; box-shadow: 0 2px 6px rgba(37,211,102,0.3); }
.cta-primary:active { transform: translateY(1px); }
.cta-row { display: flex; gap: 8px; }
.cta-secondary { flex: 1; padding: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; font-size: 15px; cursor: pointer; font-weight: 500; }
.cta-secondary:active { background: #f3f4f6; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #1f2933; color: white; padding: 12px 20px; border-radius: 24px; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); z-index: 1000; display: flex; align-items: center; gap: 16px; }
.toast button { background: transparent; border: 0; color: var(--wa-green); font-weight: 600; cursor: pointer; font-size: 14px; }

@media (min-width: 768px) {
  #main { display: grid; grid-template-columns: 380px 1fr; gap: 16px; margin-top: 12px; }
  #detail-pane { display: block !important; }
  .mobile-only { display: none; }
  #list-pane { max-height: calc(100vh - 240px); overflow-y: auto; }
}

@media (max-width: 767px) {
  #app.detail-open #list-pane { display: none; }
  #app:not(.detail-open) #detail-pane { display: none; }
  #detail-pane { padding: 16px; }
}
