/* Flyr.os Agent Analytics & Concierge Hub — mobile-first, no frameworks */
:root {
  --brand: #0B6E2E;
  --brand-strong: #095826;
  --brand-tint: rgba(11, 110, 46, 0.10);
  --brand-tint-2: rgba(11, 110, 46, 0.18);
  --bg: #F5F7F6;
  --surface: #FFFFFF;
  --ink: #1B2520;
  --ink-soft: #3D4A43;
  --muted: #6B7A71;
  --line: #E4EAE6;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 40, 28, 0.05), 0 4px 14px rgba(20, 40, 28, 0.06);
  --shadow-sm: 0 1px 2px rgba(20, 40, 28, 0.06);
  --amber: #B45309;
  --amber-bg: #FEF3E2;
  --blue: #1D4ED8;
  --blue-bg: #E8EEFC;
  --slate: #475569;
  --slate-bg: #EDF1F5;
  --green: #0B6E2E;
  --green-bg: #E4F3E9;
  --red: #B91C1C;
  --red-bg: #FBE9E9;
  --star: #E8A93C;
  --sat-top: env(safe-area-inset-top, 0px);
  --sat-bottom: env(safe-area-inset-bottom, 0px);
  --sat-left: env(safe-area-inset-left, 0px);
  --sat-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }

.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(12px + var(--sat-top)) calc(14px + var(--sat-right)) calc(40px + var(--sat-bottom)) calc(14px + var(--sat-left));
}

/* ---------- Header ---------- */
.dash-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 2px 14px;
}
.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
  box-shadow: var(--shadow-sm);
}
.agent-meta { min-width: 0; flex: 1 1 auto; }
.agent-name {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-agency {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.refresh-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.5s ease, background 0.15s ease;
}
.refresh-btn:active { background: var(--brand-tint); }
.refresh-btn.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.refresh-btn svg { width: 18px; height: 18px; stroke: var(--ink-soft); }
.refreshed-note {
  font-size: 11.5px;
  color: var(--muted);
  text-align: right;
  margin: -8px 2px 10px;
}

.demo-banner {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid #F2DFC0;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  padding: 7px 12px;
  margin: 0 0 12px;
}

/* ---------- Chips ---------- */
.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.chip:active { transform: scale(0.97); }
.period-row { margin: 2px 0 16px; justify-content: space-between; }
.period-row .chips { display: flex; gap: 8px; }

/* ---------- KPI grid ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 14px 12px;
}
.kpi .k-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0 0 4px;
}
.kpi .k-value {
  font-size: 30px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  margin: 0;
  color: var(--ink);
}
.kpi .k-delta {
  font-size: 11.5px;
  margin: 5px 0 0;
  color: var(--muted);
}
.kpi .k-delta.up { color: var(--brand); }
.kpi .k-delta.down { color: var(--red); }

/* ---------- Sparkline card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 14px 10px;
  margin-bottom: 18px;
}
.card h2, .section-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 2px;
}
.card .card-sub {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 10px;
}
.spark-wrap { position: relative; }
.spark-wrap canvas {
  display: block;
  width: 100%;
  height: 160px;
  touch-action: pan-y;
}
.spark-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity 0.12s ease;
  z-index: 5;
  box-shadow: var(--shadow);
}
.spark-tooltip.visible { opacity: 1; }
.spark-tooltip .tt-date { color: #B9C6BE; font-size: 11px; }
.spark-tooltip b { font-variant-numeric: tabular-nums; }

/* ---------- Concierge section ---------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 4px 2px 10px;
}
.section-head h2 { font-size: 17px; margin: 0; }
.summary-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.summary-chip {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.summary-chip .star { color: var(--star); }
.filter-row { margin-bottom: 12px; }

/* ---------- Request cards ---------- */
.req-list { display: flex; flex-direction: column; gap: 10px; }
.req-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 13px 14px;
  transition: box-shadow 0.15s ease;
}
.req-card:focus-within, .req-card:hover { box-shadow: var(--shadow); }
.req-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.type-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--brand-tint);
  display: flex;
  align-items: center;
  justify-content: center;
}
.type-icon svg { width: 18px; height: 18px; stroke: var(--brand); fill: none; }
.type-icon.handyman { background: #EEF1F6; }
.type-icon.handyman svg { stroke: var(--slate); }
.req-main { flex: 1 1 auto; min-width: 0; }
.req-name-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.req-name { font-weight: 700; font-size: 14.5px; margin: 0; }
.req-time { font-size: 11.5px; color: var(--muted); flex: 0 0 auto; }
.req-phone { font-size: 12.5px; color: var(--muted); margin: 1px 0 0; }
.req-summary {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 7px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.req-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.status-pill {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 999px;
  padding: 4px 10px;
  text-transform: capitalize;
}
.status-pill.submitted  { background: var(--slate-bg); color: var(--slate); }
.status-pill.in_progress { background: var(--amber-bg); color: var(--amber); }
.status-pill.scheduled { background: var(--blue-bg); color: var(--blue); }
.status-pill.activated, .status-pill.completed { background: var(--green-bg); color: var(--green); }
.status-pill.cancelled { background: var(--red-bg); color: var(--red); }
.attention-flag {
  font-size: 11px;
  font-weight: 700;
  color: var(--amber);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.stars { display: inline-flex; gap: 1px; align-items: center; }
.stars svg { width: 15px; height: 15px; }
.stars .filled svg { fill: var(--star); stroke: var(--star); }
.stars .empty svg { fill: none; stroke: #CBD5CE; }
.rating-comment {
  font-size: 12.5px;
  color: var(--ink-soft);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin: 8px 0 0;
  font-style: italic;
}
.expand-hint {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.expand-hint svg { width: 12px; height: 12px; stroke: currentColor; transition: transform 0.2s ease; }
.req-card.open .expand-hint svg { transform: rotate(180deg); }

/* timeline */
.timeline {
  list-style: none;
  margin: 12px 0 2px;
  padding: 0 0 0 4px;
  display: none;
}
.req-card.open .timeline { display: block; }
.timeline li {
  position: relative;
  padding: 0 0 14px 22px;
  font-size: 13px;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
.timeline li::after {
  content: "";
  position: absolute;
  left: 7.5px;
  top: 15px;
  bottom: -1px;
  width: 1.5px;
  background: var(--line);
}
.timeline li:last-child::after { display: none; }
.timeline .tl-status { font-weight: 600; text-transform: capitalize; }
.timeline .tl-at { color: var(--muted); font-size: 12px; margin-left: 6px; }

/* rating collector row */
.rate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px dashed var(--brand-tint-2);
  background: var(--brand-tint);
  border-radius: var(--radius-sm);
}
.rate-row span { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.rate-btn {
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  border-radius: 999px;
  padding: 7px 13px;
  transition: background 0.15s ease;
  white-space: nowrap;
}
.rate-btn:hover { background: var(--brand-strong); }
.rate-btn.copied { background: var(--ink-soft); }

/* ---------- Empty / error states ---------- */
.empty-state, .error-state {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 36px 20px;
  margin: 8px 0 18px;
}
.empty-state .glyph, .error-state .glyph {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--brand-tint);
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-state .glyph svg, .error-state .glyph svg { width: 26px; height: 26px; stroke: var(--brand); fill: none; }
.empty-state h3, .error-state h3 { margin: 0 0 6px; font-size: 16px; }
.empty-state p, .error-state p { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; }
.error-state .glyph { background: var(--red-bg); }
.error-state .glyph svg { stroke: var(--red); }
.btn-primary {
  border: none;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: 11px 22px;
  font-size: 14px;
  transition: background 0.15s ease;
}
.btn-primary:hover { background: var(--brand-strong); }

/* ---------- Rating page ---------- */
.rate-page {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(24px + var(--sat-top)) calc(20px + var(--sat-right)) calc(40px + var(--sat-bottom)) calc(20px + var(--sat-left));
}
.rate-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 20px;
  text-align: center;
}
.rate-card .brandmark {
  font-weight: 800;
  color: var(--brand);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 18px;
}
.rate-card h1 { font-size: 20px; margin: 0 0 6px; }
.rate-card .rate-context { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.big-stars { display: flex; justify-content: center; gap: 10px; margin-bottom: 8px; }
.big-stars button {
  background: none;
  border: none;
  padding: 6px;
  line-height: 0;
  transition: transform 0.12s ease;
}
.big-stars button:active { transform: scale(1.2); }
.big-stars svg { width: 42px; height: 42px; fill: none; stroke: #CBD5CE; stroke-width: 1.6; transition: fill 0.12s ease, stroke 0.12s ease; }
.big-stars button.lit svg { fill: var(--star); stroke: var(--star); }
.rate-hint { font-size: 13px; color: var(--muted); min-height: 18px; margin: 0 0 18px; }
.rate-comment {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 14px;
  min-height: 84px;
  resize: vertical;
  margin-bottom: 16px;
  background: var(--bg);
}
.rate-comment:focus { outline: 2px solid var(--brand-tint-2); border-color: var(--brand); }
.rate-submit { width: 100%; }
.rate-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.rate-back {
  display: inline-block;
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}
.rate-thanks .glyph {
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--green-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.rate-thanks .glyph svg { width: 30px; height: 30px; stroke: var(--brand); fill: none; }
.rate-error-msg { color: var(--red); font-size: 13px; margin: 10px 0 0; min-height: 18px; }

/* ---------- Skeleton / boot ---------- */
.boot-splash {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: 13.5px;
}
.boot-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.94); opacity: 0.82; } }

/* ---------- Desktop ---------- */
@media (min-width: 680px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .agent-name { font-size: 20px; }
  .spark-wrap canvas { height: 190px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
