/* BuildSignal Owner Portal — additions (lead details, analytics, activity).
   Uses only the existing design tokens from portal.css. */

/* Odd last cell in a detail grid spans the row instead of leaving a gap */
.detail-grid > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
.dg-hint { display: block; font-size: 0.74rem; color: var(--text-faint); margin-top: 2px; }

/* Lead header summary chips */
.lead-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 0.8rem; color: var(--text-muted); }
.lead-facts span { display: inline-flex; align-items: center; gap: 5px; }
.lead-facts svg { width: 13px; height: 13px; color: var(--text-faint); }

/* Appointment highlight block in the drawer */
.appt-card { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: var(--radius-md);
  background: linear-gradient(120deg, rgba(110,86,248,0.12), rgba(34,211,238,0.08)); border: 1px solid rgba(110,86,248,0.3); margin-bottom: 10px; }
.appt-card .date-chip { width: 52px; }
.appt-card .ac-main { min-width: 0; flex: 1; }
.appt-card .ac-title { font-weight: 600; font-size: 0.95rem; }
.appt-card .ac-sub { font-size: 0.8rem; color: var(--text-muted); }
.appt-card .btn { flex-shrink: 0; }
.appt-card.is-empty { background: var(--panel-2); border: 1px dashed var(--border-strong); }
.appt-card.is-empty .date-chip .dc-d { color: var(--text-faint); }
@media (max-width: 420px) { .appt-card { flex-wrap: wrap; } .appt-card .btn { width: 100%; } }

/* Communication history */
.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.activity li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.activity li:last-child { border-bottom: none; }
.activity .a-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.activity .a-ico svg { width: 15px; height: 15px; }
.activity .a-main { min-width: 0; flex: 1; }
.activity .a-text { font-size: 0.86rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.activity .a-meta { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-faint); margin-top: 2px; }
.activity .a-lead { font-weight: 600; color: var(--text); }
button.a-row { display: flex; gap: 12px; width: 100%; background: none; border: 0; padding: 0; text-align: left; color: inherit; min-width: 0; }
button.a-row:hover .a-lead { color: var(--cyan); }
.log-form { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px; margin-bottom: 12px; }
.log-form .textarea { min-height: 44px; }
.log-form .btn { grid-column: 1 / -1; }
@media (max-width: 420px) { .log-form { grid-template-columns: 1fr; } }

/* KPI grid with 8 tiles: 4 across on desktop, 2 on phones */
.kpi-grid.k8 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 640px) { .kpi-grid.k8 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi-value.money { font-size: 1.6rem; }
@media (max-width: 640px) { .kpi-value.money { font-size: 1.35rem; } }
.kpi.kpi-accent { border-color: rgba(110,86,248,0.35); background: linear-gradient(160deg, rgba(110,86,248,0.10), rgba(34,211,238,0.04) 60%), var(--panel); }

/* Mobile lead card additions */
.m-card-desc { font-size: 0.82rem; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.m-card-appt { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); background: rgba(110,86,248,0.08); border: 1px solid rgba(110,86,248,0.22); font-size: 0.8rem; }
.m-card-appt svg { width: 14px; height: 14px; color: #b3a6ff; flex-shrink: 0; }
.m-card-appt .ma-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-card-badges { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex-shrink: 0; }

.badge-quote-sent { background: rgba(255,138,61,0.12); color: var(--amber); border-color: rgba(255,138,61,0.3); }
.badge-requested { background: transparent; color: var(--warm); border: 1px dashed rgba(255,194,75,0.4); }
.value-note { font-size: 0.76rem; color: var(--text-faint); margin-top: 10px; }

/* Appointment statuses */
.badge-not-scheduled { background: transparent; color: var(--warm); border: 1px dashed rgba(255,194,75,0.45); }
.badge-booked { background: rgba(110,86,248,0.14); color: #b3a6ff; border-color: rgba(110,86,248,0.3); }
.badge-new-lead { background: rgba(91,143,201,0.14); color: #9cc0ea; border-color: rgba(91,143,201,0.28); }

/* Appointment editor */
.form-section-title { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); font-weight: 500; margin: 6px 0 2px; }
.form-grid .form-section-title { grid-column: 1 / -1; }
.form-grid .form-section-title:not(:first-child) { margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--border); }
.status-picker { border: 0; padding: 0; margin: 0; min-width: 0; }
.status-picker legend { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); padding: 0; margin-bottom: 6px; }
.status-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.status-opt { position: relative; }
.status-opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.status-opt span { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 6px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text-muted); font-size: 0.84rem; font-weight: 600; text-align: center; line-height: 1.2; transition: border-color .2s, background .2s, color .2s; }
.status-opt span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; opacity: .8; }
.status-opt input:focus-visible + span { box-shadow: var(--focus); }
.status-opt.s-not-scheduled input:checked + span { color: var(--warm); border-color: rgba(255,194,75,0.55); background: rgba(255,194,75,0.08); }
.status-opt.s-booked input:checked + span { color: #c4b9ff; border-color: rgba(110,86,248,0.7); background: rgba(110,86,248,0.14); }
.status-opt.s-completed input:checked + span { color: var(--cyan); border-color: rgba(34,211,238,0.6); background: rgba(34,211,238,0.1); }
.status-opt.s-cancelled input:checked + span { color: var(--text); border-color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.06); }
@media (max-width: 560px) { .status-options { grid-template-columns: 1fr 1fr; } }
.appt-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }

/* iOS Safari: empty date/time inputs collapse or overflow their grid cell */
input.input[type="date"], input.input[type="time"] {
  -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%;
  min-height: 46px; line-height: 1.3; text-align: left;
}
input.input[type="date"]::-webkit-date-and-time-value, input.input[type="time"]::-webkit-date-and-time-value { text-align: left; min-height: 1.3em; }
input.input[type="date"]::-webkit-calendar-picker-indicator, input.input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(0.7); cursor: pointer; }

/* Drawer on phones: bigger tap targets, tabs fill the width */
@media (max-width: 560px) {
  .drawer-tabs { padding: 0 8px; }
  .drawer-tabs button { flex: 1; padding: 0 6px; min-height: 48px; }
  .drawer-foot .btn { min-height: 46px; }
  .detail-section .btn-sm { min-height: 40px; }
}
.appt-row-actions { display: flex; gap: 6px; justify-content: flex-end; }
