/* ============================================================================
   Sales Assistant — design system
   Light theme inspired by Airbnb (calm, airy, premium), dark theme inspired by
   Robinhood (near-black, bold numerals, confident emerald accent). Theme
   follows the device's color scheme. Legacy variable names (--primary, --accent,
   --success, --danger, --bg, --surface, --border, --text, --muted) are preserved
   so inline styles across the views keep working.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Radii */
  --radius: 16px;
  --radius-sm: 12px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  /* Type */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  /* ---------- Light theme (default) ---------- */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f2f4f6;
  --surface-3: #e9edf1;
  --border: #ebedf0;
  --border-strong: #dde1e6;

  --text: #0f1720;
  --text-2: #38434f;
  --muted: #6b7580;
  --faint: #9aa4af;

  --brand: #0a8f5b;
  --brand-ink: #ffffff;
  --brand-strong: #087a4d;
  --brand-tint: #eafaf2;

  --primary: var(--brand);
  --primary-ink: var(--brand-ink);
  --accent: #2f6fed;
  --success: #0a8f5b;
  --warning: #c2740a;
  --danger: #e0413f;

  --shadow-sm: 0 1px 2px rgba(15, 23, 32, 0.04), 0 1px 3px rgba(15, 23, 32, 0.05);
  --shadow: 0 2px 6px rgba(15, 23, 32, 0.05), 0 6px 16px rgba(15, 23, 32, 0.06);
  --shadow-lg: 0 12px 34px rgba(15, 23, 32, 0.14);
  --ring: 0 0 0 3px rgba(10, 143, 91, 0.18);

  --nav-bg: rgba(255, 255, 255, 0.86);
  --bar-bg: rgba(246, 247, 249, 0.8);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* ---------- Dark theme (Robinhood-inspired) ---------- */
    --bg: #0a0b0d;
    --surface: #131518;
    --surface-2: #1b1e22;
    --surface-3: #23272c;
    --border: #24272c;
    --border-strong: #30353b;

    --text: #f4f7fa;
    --text-2: #c4ccd4;
    --muted: #8b95a1;
    --faint: #626b76;

    --brand: #10c96f;
    --brand-ink: #04150d;
    --brand-strong: #0fb866;
    --brand-tint: rgba(16, 201, 111, 0.12);

    --primary: var(--brand);
    --primary-ink: var(--brand-ink);
    --accent: #4c8dff;
    --success: #10c96f;
    --warning: #f5a623;
    --danger: #ff5a5f;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.45), 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
    --ring: 0 0 0 3px rgba(16, 201, 111, 0.28);

    --nav-bg: rgba(19, 21, 24, 0.86);
    --bar-bg: rgba(10, 11, 13, 0.8);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Inline line icons (match the nav icon style) */
.ico {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.18em;
}
.ico-lg { width: 22px; height: 22px; stroke-width: 1.8; }
.ico-xl { width: 46px; height: 46px; stroke-width: 1.5; }
.section-title .ico { vertical-align: -0.16em; margin-right: 2px; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
  letter-spacing: -0.006em;
}

#app { display: flex; flex-direction: column; min-height: 100dvh; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + var(--safe-top)) 20px 14px;
  background: var(--bar-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.topbar h1 {
  font-size: 1.4rem;
  margin: 0;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.icon-btn {
  border: none;
  background: var(--brand);
  color: var(--brand-ink);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  font-size: 1.5rem;
  font-weight: 300;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(10, 143, 91, 0.32);
  transition: transform 0.12s ease, box-shadow 0.2s;
}
.icon-btn:active { transform: scale(0.9); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.icon-btn-ghost svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Voice assistant overlay ---------- */
.voice-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade 0.18s ease;
}
.voice-close {
  position: absolute;
  top: calc(16px + var(--safe-top)); right: 20px;
  background: none; border: none; color: var(--muted);
  font-size: 2rem; line-height: 1; cursor: pointer;
}
.voice-inner { width: 100%; max-width: 460px; text-align: center; }
.voice-orb {
  width: 96px; height: 96px;
  margin: 0 auto 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand);
  color: var(--brand-ink);
  box-shadow: 0 8px 30px rgba(10, 143, 91, 0.4);
}
.voice-orb svg { width: 40px; height: 40px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.voice-orb.listening { animation: pulse 1.5s ease-in-out infinite; }
.voice-status { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; min-height: 1.5em; }
.voice-transcript { color: var(--muted); font-size: 1rem; margin-top: 8px; min-height: 1.4em; font-style: italic; }
.voice-form { display: flex; gap: 10px; margin: 22px 0 10px; }
.voice-form input {
  flex: 1;
  padding: 13px 16px; font-size: 16px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-pill);
  color: var(--text);
}
.voice-form input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.voice-form .btn { border-radius: var(--radius-pill); padding-left: 22px; padding-right: 22px; }
.voice-hint { color: var(--muted); font-size: 0.8rem; margin-bottom: 18px; }
.voice-examples { display: flex; flex-direction: column; gap: 8px; }
.voice-eg {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  color: var(--text-2);
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.voice-eg:active { transform: scale(0.99); background: var(--surface-3); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 8px 30px rgba(10, 143, 91, 0.4), 0 0 0 0 rgba(10, 143, 91, 0.4); }
  50% { box-shadow: 0 8px 30px rgba(10, 143, 91, 0.4), 0 0 0 18px rgba(10, 143, 91, 0); }
}

/* ---------- View area ---------- */
.view {
  flex: 1;
  padding: 18px 20px calc(104px + var(--safe-bottom));
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}

/* Raised voice button in the nav */
.tab-voice {
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  color: var(--muted);
}
.tab-voice .tab-label { color: var(--brand); font-weight: 700; }
.voice-fab {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  margin: -22px auto 3px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: var(--brand-ink);
  box-shadow: 0 6px 18px rgba(10, 143, 91, 0.42);
  border: 3px solid var(--nav-bg);
  transition: transform 0.12s ease;
}
.tab-voice:active .voice-fab { transform: scale(0.92); }
.voice-fab svg {
  width: 25px; height: 25px;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 11px 4px 12px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.15s;
  position: relative;
}
.tab-icon { display: grid; place-items: center; height: 24px; }
.tab-icon svg {
  width: 24px; height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s;
}
.tab.active { color: var(--brand); }
.tab.active .tab-icon svg { stroke-width: 2.1; transform: translateY(-1px); }
.tab.active::before {
  content: "";
  position: absolute;
  top: 0;
  width: 26px; height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--brand);
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.card-tap {
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.2s, border-color 0.2s;
}
.card-tap:active {
  transform: scale(0.988);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}

.section-title {
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 26px 2px 12px;
  font-weight: 700;
}
.section-title:first-child { margin-top: 6px; }
.section-title .muted { font-weight: 500; }

/* ---------- Rows / list items ---------- */
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.row-main { min-width: 0; }
.row-title { font-weight: 650; font-size: 1.02rem; letter-spacing: -0.015em; }
.row-sub { color: var(--muted); font-size: 0.86rem; margin-top: 3px; }
.row-meta { text-align: right; flex-shrink: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.83rem; }
.strong { font-weight: 700; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
  line-height: 1.5;
}
.badge-new { color: #0e7490; background: color-mix(in srgb, #06b6d4 14%, transparent); }
.badge-working { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.badge-appt { color: #7c3aed; background: color-mix(in srgb, #8b5cf6 16%, transparent); }
.badge-negotiating { color: var(--warning); background: color-mix(in srgb, var(--warning) 16%, transparent); }
.badge-sold, .badge-available { color: var(--success); background: var(--brand-tint); }
.badge-delivered { color: var(--muted); background: color-mix(in srgb, var(--muted) 15%, transparent); }
.badge-lost { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.badge-hold, .badge-soon { color: var(--warning); background: color-mix(in srgb, var(--warning) 16%, transparent); }
.badge-due { color: var(--danger); background: color-mix(in srgb, var(--danger) 15%, transparent); }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 650;
  font-family: inherit;
  letter-spacing: -0.01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s ease, box-shadow 0.2s, filter 0.15s, background 0.15s;
  text-decoration: none;
}
.btn:active { transform: scale(0.975); }
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
  box-shadow: 0 3px 12px rgba(10, 143, 91, 0.26);
}
.btn-primary:active { filter: brightness(0.96); }
.btn-success { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); box-shadow: 0 3px 12px rgba(10, 143, 91, 0.26); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }
.btn-ghost { background: var(--surface-2); border-color: transparent; }
.btn-ghost:active { background: var(--surface-3); }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 9px 13px; font-size: 0.85rem; border-radius: 10px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-2);
  margin-bottom: 7px;
  letter-spacing: -0.01em;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 13px 15px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px; /* prevents iOS zoom on focus */
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7580' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 18px;
  padding-right: 40px;
}
.field textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
.field-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 0.77rem; color: var(--muted); margin-top: 7px; line-height: 1.45; }
.switch { display: flex; align-items: center; gap: 9px; font-size: 0.84rem; color: var(--text-2); font-weight: 550; cursor: pointer; }
.switch input { width: 22px; height: 22px; flex: none; accent-color: var(--brand); }
.hint .mono { color: var(--text-2); font-weight: 600; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(9, 12, 16, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.18s ease;
}
.modal {
  background: var(--surface);
  width: 100%;
  max-width: 620px;
  max-height: 92dvh;
  overflow-y: auto;
  border-radius: 26px 26px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 10px 22px calc(28px + var(--safe-bottom));
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal-handle {
  width: 40px; height: 5px;
  border-radius: 3px;
  background: var(--border-strong);
  margin: 8px auto 16px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h2 { font-size: 1.25rem; margin: 0; font-weight: 730; letter-spacing: -0.025em; }
.modal-close {
  background: none; border: none; color: var(--muted);
  font-size: 1.7rem; line-height: 1; cursor: pointer; padding: 0 6px;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 26px; border-bottom: 1px solid var(--border); max-height: 88dvh; }
}

/* ---------- Toast ---------- */
#toast-root {
  position: fixed;
  bottom: calc(88px + var(--safe-bottom));
  left: 0; right: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--surface);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast-success { background: var(--brand); color: var(--brand-ink); }
.toast-danger { background: var(--danger); color: #fff; }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 7px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-icon { font-size: 2.8rem; margin-bottom: 10px; opacity: 0.9; }
.empty .strong { color: var(--text); font-size: 1.05rem; }
.empty .small { margin-top: 4px; }

/* ---------- Checklist ---------- */
.check-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--border);
}
.check-item:last-child { border-bottom: none; }
.check-item input[type="checkbox"] {
  width: 24px; height: 24px; flex-shrink: 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.check-item label { flex: 1; font-size: 0.96rem; }
.check-item.done label { text-decoration: line-through; color: var(--muted); }

/* ---------- Progress bar ---------- */
.progress {
  height: 8px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: 10px;
}
.progress > span {
  display: block; height: 100%;
  background: var(--brand);
  border-radius: var(--radius-pill);
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Search ---------- */
.searchbar { margin-bottom: 16px; position: relative; }
.searchbar input {
  width: 100%;
  padding: 13px 15px 13px 44px;
  font-size: 16px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-pill);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.searchbar input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.searchbar::before {
  content: "";
  position: absolute;
  left: 16px; top: 50%;
  width: 18px; height: 18px;
  transform: translateY(-50%);
  background: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--border); margin: 18px 0; border: none; }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 650; text-align: right; }
.kv-total { font-size: 1.2rem; padding: 6px 0 12px; }
.kv-total .v { color: var(--brand); font-weight: 800; }
.fab-note { text-align: center; color: var(--muted); font-size: 0.79rem; margin-top: 20px; line-height: 1.5; }
a.link { color: var(--brand); text-decoration: none; font-weight: 650; }

/* Prospecting call-list card (dashboard) */
.prospect-card {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(10, 143, 91, 0.32);
}
.prospect-card .ico { vertical-align: -0.2em; }

/* Greeting / hero on dashboard */
.hero { margin: 4px 2px 18px; }
.hero-greeting { color: var(--muted); font-size: 0.9rem; font-weight: 550; }
.hero-title { font-size: 1.55rem; font-weight: 780; letter-spacing: -0.035em; margin-top: 2px; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(40px); } to { transform: translateY(0); } }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
