:root {
  color-scheme: light;
  --navy: #071a2d;
  --blue: #0877f9;
  --blue-dark: #075fc5;
  --green: #0c9b69;
  --red: #c53636;
  --ink: #102033;
  --muted: #667487;
  --line: #dce3eb;
  --surface: #ffffff;
  --background: #f3f6f9;
  --shadow: 0 10px 30px rgba(8, 29, 54, 0.09);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--ink); min-height: 100vh; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.app-header {
  background: var(--navy); color: white; padding: calc(18px + env(safe-area-inset-top)) 20px 18px;
  display: flex; align-items: center; justify-content: space-between;
}
.app-header h1 { font-size: 22px; margin: 2px 0 0; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .14em; color: #72afff; }
.icon-button { border: 0; background: rgba(255,255,255,.1); color: inherit; width: 40px; height: 40px; border-radius: 12px; font-size: 20px; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.viewer-chip { display: flex; align-items: center; gap: 8px; padding: 6px 9px 6px 6px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.08); border-radius: 13px; }
.viewer-chip > span { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: #167ef1; color: white; font-weight: 900; }
.viewer-chip strong, .viewer-chip small { display: block; line-height: 1.15; }
.viewer-chip strong { font-size: 12px; }
.viewer-chip small { margin-top: 2px; color: #a9c9ef; font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }

.tabs { background: white; display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 4; }
.tab { border: 0; background: transparent; padding: 15px 8px 13px; color: var(--muted); font-weight: 700; border-bottom: 3px solid transparent; }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

main { width: min(760px, 100%); margin: 0 auto; padding: 18px 14px calc(36px + env(safe-area-inset-bottom)); }
.view { display: none; }
.view.active { display: block; }
.card { background: var(--surface); border: 1px solid #e5eaf0; border-radius: 20px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card h2 { margin: 0 0 7px; font-size: 21px; }
.card p { margin: 0; line-height: 1.5; color: var(--muted); }
.hero-card { display: grid; grid-template-columns: 52px 1fr; gap: 12px; }
.hero-card .stack { grid-column: 1 / -1; }
.maps-mark { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50% 50% 50% 8px; background: linear-gradient(135deg,#4285f4,#34a853); color:white; font-weight:900; font-size:22px; transform: rotate(-8deg); }
.maps-mark::first-letter { transform: rotate(8deg); }

.stack { display: grid; gap: 12px; }
label { font-size: 13px; font-weight: 800; color: #26384d; }
input, textarea { width: 100%; border: 1px solid #ccd6e2; border-radius: 12px; padding: 13px 14px; color: var(--ink); background: white; outline: none; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(8,119,249,.13); }
textarea { resize: vertical; line-height: 1.45; }
.input-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.primary, .secondary, .sent-button { border: 0; border-radius: 12px; min-height: 48px; padding: 12px 16px; font-weight: 800; }
.primary { background: var(--blue); color: white; }
.primary:hover { background: var(--blue-dark); }
.primary:disabled { opacity: .55; cursor: wait; }
.secondary { background: #e9f1fa; color: #17416d; }
.compact { min-height: 44px; padding: 10px 14px; }
.sent-button { background: #dff6ed; color: #08734f; border: 1px solid #a9e4cf; }
.text-button { border: 0; background: transparent; color: var(--blue); font-weight: 750; padding: 8px; }
.usage-heading{display:flex;justify-content:space-between;gap:14px;align-items:flex-start}.usage-heading h2{margin-top:4px}.usage-heading select{width:auto;border:1px solid #ccd6e2;border-radius:10px;padding:9px;background:white}.usage-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(145px,1fr));gap:10px;margin:18px 0}.usage-grid article{background:#f5f8fb;border:1px solid var(--line);border-radius:14px;padding:13px}.usage-grid span,.usage-grid small{display:block;color:var(--muted);font-size:11px}.usage-grid strong{display:block;font-size:24px;margin:3px 0}.usage-details{overflow-x:auto}.usage-details table{width:100%;border-collapse:collapse;font-size:12px}.usage-details th,.usage-details td{text-align:left;padding:9px;border-bottom:1px solid var(--line)}.usage-details th{color:#245078}.usage-details small{color:var(--muted)}.usage-note{margin-top:14px!important;font-size:12px}
.usage-bar{height:8px;background:#dce6f0;border-radius:999px;overflow:hidden;margin:10px 0}.usage-bar i{display:block;height:100%;border-radius:inherit;background:linear-gradient(90deg,#0c9b69,#0877f9)}

.loading { display: flex; gap: 14px; align-items: center; }
.loading span { display: block; color: var(--muted); margin-top: 3px; font-size: 14px; }
.spinner { width: 34px; height: 34px; border: 4px solid #dce8f6; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.status-line { display: flex; align-items: center; gap: 8px; color: var(--green); font-size: 13px; font-weight: 800; margin-bottom: 18px; }
.status-dot { width: 9px; height: 9px; background: var(--green); border-radius: 50%; box-shadow: 0 0 0 4px #dcf6ec; }
.lookup-notice { margin: -4px 0 18px; padding: 11px 12px; border-radius: 11px; background: #fff7df; border: 1px solid #efd998; color: #705514; font-size: 12px; line-height: 1.45; font-weight: 650; }
.business-heading { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.badge { display: inline-block; background: #eaf3ff; color: #1662b1; border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 800; margin-bottom: 8px; }
.map-link { color: var(--blue); font-size: 13px; font-weight: 800; white-space: nowrap; }
.details-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 20px 0 0; }
.details-grid div { background: #f5f8fb; border-radius: 12px; padding: 11px; min-width: 0; }
.details-grid dt { color: var(--muted); font-size: 11px; font-weight: 700; margin-bottom: 5px; }
.details-grid dd { margin: 0; font-size: 13px; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.details-grid.listing-details { grid-template-columns: 2fr 1fr; }
.required { color: #a93636; font-weight: 750; }
.top-rule { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 20px; }
.message-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; }

.success-card { text-align: center; }
.success-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 13px; background: #daf5e9; color: var(--green); font-size: 28px; font-weight: 900; }
.success-card p { margin-bottom: 20px; }
.error-banner { position: fixed; left: 14px; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); max-width: 700px; margin: auto; background: #fff0f0; color: #8c2525; border: 1px solid #f1b8b8; padding: 14px 16px; border-radius: 12px; box-shadow: var(--shadow); z-index: 8; }

.list-toolbar { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 14px; }
.scope-switcher { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 6px; margin-bottom: 12px; border: 1px solid var(--line); background: #eaf0f6; border-radius: 14px; }
.scope-button { border: 0; min-height: 42px; border-radius: 10px; padding: 8px 10px; background: transparent; color: #52677e; font-size: 12px; font-weight: 850; }
.scope-button span { display: inline-grid; place-items: center; min-width: 20px; min-height: 20px; margin-left: 3px; padding: 0 5px; border-radius: 999px; background: rgba(82,103,126,.12); font-size: 10px; }
.scope-button.active { background: white; color: var(--blue); box-shadow: 0 3px 10px rgba(8,29,54,.09); }
.scope-button.active span { color: white; background: var(--blue); }
.contact-filter { display: flex; gap: 8px; margin-bottom: 12px; }
.contact-filter-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; border: 1px solid var(--line); border-radius: 11px; padding: 8px 13px; background: white; color: #52677e; font-size: 12px; font-weight: 850; }
.contact-filter-button span { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: #e9eef4; font-size: 10px; }
.contact-filter-button.active { border-color: #7fb6f5; background: #eef6ff; color: var(--blue); }
.contact-filter-button[data-contact-filter="dnc"].active { border-color: #e29292; background: #fff0f0; color: var(--red); }
.contact-filter-button[data-contact-filter="dnc"].active span { background: #f7cccc; color: #8c2525; }
.list-help { background: #fff7df; border: 1px solid #efd998; color: #705514; border-radius: 12px; padding: 11px 12px; margin-bottom: 12px; font-size: 12px; font-weight: 700; line-height: 1.4; }
.prospect-list { display: grid; gap: 10px; }
.swipe-row { position: relative; min-width: 0; }
.swipe-row > .prospect-item { height: 100%; }
.swipe-dnc-action { display: none; }
.prospect-item { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 15px; box-shadow: 0 5px 16px rgba(8,29,54,.05); }
.prospect-item.clickable { cursor: pointer; position: relative; transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.prospect-item.clickable:hover { border-color: #8ebdf3; box-shadow: 0 8px 22px rgba(8,76,151,.11); transform: translateY(-1px); }
.prospect-item.clickable:focus-visible { outline: 3px solid rgba(8,119,249,.25); border-color: var(--blue); }
.prospect-item.dnc-card { border-color: #e7a3a3; background: #fff1f1; opacity: .68; box-shadow: 0 5px 16px rgba(145,35,35,.08); }
.prospect-item.dnc-card:hover, .prospect-item.dnc-card:focus-within { opacity: .9; border-color: #d87575; box-shadow: 0 8px 22px rgba(145,35,35,.14); }
.prospect-item.dnc-card .assignment-pill { background: #f8dada; color: #8f3434; }
.prospect-top { display: flex; justify-content: space-between; gap: 10px; }
.prospect-controls { display: grid; justify-items: end; gap: 8px; flex: 0 0 auto; }
.prospect-item h3 { margin: 0 0 4px; font-size: 16px; }
.prospect-item p { margin: 0; color: var(--muted); font-size: 13px; }
.assignment-pill { display: inline-flex; align-items: center; gap: 5px; margin-top: 7px; border-radius: 999px; padding: 4px 8px; background: #edf3ff; color: #315e98; font-size: 10px; font-weight: 850; }
.status-pill { border-radius: 999px; padding: 5px 8px; background: #eef3f8; color: #4a5d72; font-size: 10px; font-weight: 850; white-space: nowrap; height: fit-content; text-transform: uppercase; }
.status-pill.dnc { color: #972b2b; background: #ffe7e7; }
.prospect-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; color: #52677e; font-size: 12px; }
.delete-prospect { width: 100%; margin-top: 14px; border: 1px solid #e68f8f; background: #fff0f0; color: var(--red); border-radius: 11px; font-size: 13px; font-weight: 850; padding: 12px 14px; min-height: 44px; }
.delete-prospect:hover { background: #ffe1e1; border-color: #df8181; }
.delete-prospect:disabled { opacity: .55; cursor: wait; }
.empty-state { text-align: center; padding: 64px 20px; color: var(--muted); }
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { color: var(--ink); margin-bottom: 6px; }
.prospect-detail { margin-top: 0; }
.detail-back { border: 0; background: transparent; color: var(--blue); font-weight: 800; padding: 4px 0 14px; }
.detail-status-line { margin-top: 2px; }
.prospect-detail h2 { font-size: 24px; margin-bottom: 5px; }
.assignment-line { margin-top: 7px !important; color: #315e98 !important; font-size: 12px; font-weight: 800; }
.detail-grid { grid-template-columns: 1fr 1fr; margin-bottom: 18px; }
.detail-message-block { background: #f5f8fb; border: 1px solid var(--line); border-radius: 13px; padding: 14px; margin: 18px 0; }
.detail-message-block > span { display: block; color: var(--muted); font-size: 11px; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 7px; }
.detail-message-block p { color: var(--ink); white-space: pre-wrap; font-size: 14px; line-height: 1.5; }
.detail-delete { display: block; margin-top: 2px; }
.locked-message { background: #eef3f8; border-radius: 12px; padding: 13px; color: #52677e !important; font-size: 13px; }
.dnc-control { margin-top: 15px; }
.dnc-button { width: 100%; min-height: 46px; border: 1px solid #df8b8b; border-radius: 12px; padding: 11px 14px; background: #fff0f0; color: var(--red); font-size: 13px; font-weight: 900; }
.dnc-button:hover { background: #ffe2e2; }
.dnc-notice { display: grid; gap: 4px; border: 1px solid #e49a9a; border-radius: 12px; padding: 12px 13px; background: #fff0f0; color: #8c2525 !important; font-size: 12px; }
.dnc-notice strong { letter-spacing: .06em; }
.danger-zone { border-top: 1px solid #efcaca; margin-top: 22px; padding-top: 18px; }
.danger-zone > span { display: block; color: #9b3232; font-size: 11px; font-weight: 900; letter-spacing: .08em; margin-bottom: 6px; }
.danger-zone > p { margin-bottom: 13px; font-size: 12px; line-height: 1.45; }
.remove-contact-button { width: 100%; min-height: 44px; border: 1px solid #d3a24e; background: #fff7df; color: #765512; border-radius: 11px; font-size: 13px; font-weight: 850; padding: 11px 14px; }
.remove-contact-button:hover { background: #ffefc1; }

dialog { border: 0; border-radius: 20px; width: min(500px, calc(100% - 24px)); padding: 0; box-shadow: 0 25px 70px rgba(0,0,0,.28); }
dialog::backdrop { background: rgba(5,19,34,.62); }
dialog form { padding: 20px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; }
.dialog-heading h2 { margin: 2px 0 0; }
.dialog-heading .icon-button { background: #eff3f7; color: var(--ink); }
.helper { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.settings-identity { border: 1px solid #b9d7fb; background: #eef6ff; color: #285986; border-radius: 12px; padding: 11px 12px; font-size: 12px; font-weight: 750; }
.danger-text { color: var(--red); }

@media (min-width: 900px) {
  .app-header { padding-left: max(28px, calc((100vw - 1100px) / 2)); padding-right: max(28px, calc((100vw - 1100px) / 2)); }
  main { width: min(1100px, 100%); padding: 28px 24px 48px; }
  #addView > article, #addView > .error-banner { max-width: 780px; margin-left: auto; margin-right: auto; }
  .prospect-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prospect-detail { max-width: 780px; margin-left: auto; margin-right: auto; }
  .list-toolbar { grid-template-columns: minmax(320px, 1fr) auto; }
}

@media (max-width: 520px) {
  .app-header { padding-left: 14px; padding-right: 14px; }
  .app-header h1 { font-size: 19px; }
  .viewer-chip { padding-right: 6px; }
  .viewer-chip small { display: none; }
  .viewer-chip strong { max-width: 70px; overflow: hidden; text-overflow: ellipsis; }
  .scope-button { padding: 7px 5px; }
  .contact-filter { display: grid; grid-template-columns: 1fr 1fr; }
  .details-grid, .details-grid.listing-details { grid-template-columns: 1fr; }
  .details-grid div { display: grid; grid-template-columns: 92px 1fr; align-items: center; }
  .details-grid dt { margin: 0; }
  .message-meta { display: grid; }
  .swipe-row { overflow: hidden; border-radius: 16px; background: #b72f2f; }
  .swipe-row > .prospect-item { transition: transform .2s ease, border-color .15s ease, box-shadow .15s ease; touch-action: pan-y; }
  .swipe-row > .prospect-item.swiping { transition: none; }
  .swipe-dnc-action { position: absolute; z-index: 0; inset: 0 0 0 auto; display: flex; width: 104px; border: 0; align-items: center; justify-content: center; padding: 10px; background: #b72f2f; color: white; font-size: 11px; font-weight: 900; line-height: 1.15; letter-spacing: .03em; text-align: center; }
  .full-delete { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
}
