/* Automte platform UI — design tokens aligned with marketing/styles.css :root */
:root {
  /* Waitlist aliases (reference: --black, --white, --cream, --muted, --border, --card-bg, --accent, --accent-dark) */
  --wl-black: #090909;
  --wl-white: #f7f5f0;
  --wl-cream: #ede9e0;
  --wl-muted: #888880;

  --bg: var(--wl-black);
  --bg2: #121212;
  --bg3: #161616;
  --surface: #151515;
  --surface2: #1a1a1a;
  --border: rgba(255, 255, 255, 0.08);
  --border2: rgba(255, 255, 255, 0.14);
  --text: var(--wl-white);
  --text2: var(--wl-muted);
  --text3: rgba(136, 136, 128, 0.72);
  --accent: #a78bfa;
  --accent-hover: #7c3aed;
  --accent-hover-text: var(--wl-white);
  --text-on-accent: var(--wl-black);
  --accent-dim: rgba(167, 139, 250, 0.15);
  --accent-border: rgba(167, 139, 250, 0.3);
  --blue: #4a9eff;
  --blue-dim: rgba(74, 158, 255, 0.12);
  --amber: #ffaa33;
  --amber-dim: rgba(255, 170, 51, 0.12);
  --red: #ff5a5a;
  --red-dim: rgba(255, 90, 90, 0.12);
  --green: #8b5cf6;
  --green-dim: rgba(139, 92, 246, 0.15);
  --purple: #c4b5fd;
  --purple-dim: rgba(196, 181, 253, 0.14);
}

html {
  background: var(--bg);
  min-height: 100%;
}

body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-height: 100%;
}

.font-syne {
  font-family: Syne, system-ui, sans-serif;
}

.portal-bg {
  min-height: 100vh;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Cards / panels — solid surfaces (reference), not purple glass */
.glass-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  /* border-radius comes from Tailwind rounded-* on the element */
}

#portal-sidebar.portal-sidebar.glass-panel {
  border-radius: 0;
  border-top: none;
  border-bottom: none;
  border-left: none;
  border-right: 1px solid var(--border);
  box-shadow: none;
  background: var(--bg2);
}

.portal-mobile-nav {
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
}

.portal-mobile-nav.glass-panel {
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  box-shadow: none;
  background: var(--bg);
}

.portal-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

/* Primary actions — violet accent, darker violet hover */
.portal-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: "DM Sans", system-ui, sans-serif;
  font-weight: 600;
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  text-decoration: none;
}

.portal-btn-primary:hover {
  background: var(--accent-hover);
  color: var(--accent-hover-text);
}

.portal-btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.portal-link-accent {
  color: var(--accent);
}
.portal-link-accent:hover {
  color: #c4b5fd;
}

/* Utility for JS-driven states (e.g. billing trial bar) */
.bg-portal-accent {
  background-color: var(--accent);
}

.portal-billing-toggle-on {
  background-color: var(--accent);
  border-color: var(--accent);
}

/* Sidebar navigation — reference .nav-item */
.nav-link {
  color: var(--text2);
  transition: background 0.15s ease, color 0.15s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-left: none;
}


.portal-tab {
  color: var(--text2);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  transition: background 0.15s ease, color 0.15s ease;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.portal-tab:hover,
.portal-tab.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.nav-label {
  font-size: inherit;
  white-space: nowrap;
}

.portal-sidebar {
  position: relative;
  width: 13.75rem; /* --sidebar-w: 220px */
  transition: width 0.2s ease;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 12px 10px 6px;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

body:not(.portal-nav-collapsed) .sidebar-logo {
  padding-right: 3.25rem;
}

/* Collapse control: in flow under Settings when collapsed; pinned to header when expanded */
.portal-nav-collapse-slot {
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  padding: 6px 0 4px;
}

body:not(.portal-nav-collapsed) .portal-nav-collapse-slot {
  position: absolute;
  top: 20px;
  right: 12px;
  z-index: 5;
  padding: 0;
  display: block;
}

.sidebar-brand-logo {
  display: block;
  height: 28px;
  width: auto;
  max-width: min(150px, 48vw);
}

.sidebar-brand-mark {
  display: none;
  height: 28px;
  width: auto;
  max-width: 26px;
}

.sidebar-footer .user-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Syne, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.user-role {
  font-size: 11px;
  color: var(--text3);
}

.nav-link .nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-link.active .nav-icon {
  opacity: 1;
}

.portal-nav-collapse-btn {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.25rem;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.portal-nav-collapse-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--purple);
}

.portal-nav-collapse-btn svg {
  display: block;
}

.portal-nav-collapse-btn .collapse-icon-rail,
.portal-nav-collapse-btn .collapse-icon-panel,
.portal-nav-collapse-btn .collapse-icon-divider {
  transition: all 0.2s ease;
}

.portal-nav-collapse-btn .collapse-icon {
  transition: transform 0.2s ease;
  transform-origin: 50% 50%;
}

body.portal-nav-collapsed .portal-sidebar {
  width: 4.5rem;
}

body.portal-nav-collapsed .portal-sidebar .nav-label {
  display: none;
}

body.portal-nav-collapsed .portal-sidebar .nav-link {
  justify-content: center;
  gap: 0;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

body.portal-nav-collapsed .portal-sidebar .nav-link.active {
  border-left-width: 0;
}


body.portal-nav-collapsed .sidebar-brand-logo {
  display: none;
}

body.portal-nav-collapsed .sidebar-brand-mark {
  display: block;
}

body.portal-nav-collapsed .sidebar-brand-link {
  flex: 0 0 auto;
  justify-content: center;
  overflow: visible;
}

body.portal-nav-collapsed .sidebar-logo {
  justify-content: center;
  gap: 6px;
  padding-left: 10px;
  padding-right: 10px;
}

body.portal-nav-collapsed .sidebar-footer .user-block .min-w-0 {
  display: none;
}

body.portal-nav-collapsed .sidebar-footer .user-block {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

body.portal-nav-collapsed .nav-section-label {
  display: none;
}

body.portal-nav-collapsed .portal-nav-collapse-btn .collapse-icon-rail {
  fill: #ede9fe;
}

body.portal-nav-collapsed .portal-nav-collapse-btn .collapse-icon-panel {
  fill: #4338ca;
}

body.portal-nav-collapsed .portal-nav-collapse-btn .collapse-icon-divider {
  fill: #c4b5fd;
}

body.portal-nav-collapsed .portal-nav-collapse-btn .collapse-icon {
  transform: scaleX(-1);
}

@media (max-width: 767px) {
  .portal-mobile-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-height: 56px;
    padding: 0.5rem 0.25rem;
    color: var(--text2);
    text-decoration: none;
    font-size: 0.6875rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    -webkit-tap-highlight-color: transparent;
    text-align: center;
    transition: color 0.2s ease-out, border-color 0.2s ease-out, transform 0.15s ease-out;
  }

  .portal-mobile-nav-link:hover {
    color: var(--text);
  }

  .portal-mobile-nav-link:active {
    transform: scale(0.97);
  }

  .portal-mobile-nav-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
  }

  .portal-mobile-nav-link i {
    font-size: 1.125rem;
    color: inherit;
    transition: color 0.2s ease-out;
  }

  .portal-mobile-nav-link.active i {
    color: var(--accent);
  }
}

@media (min-width: 768px) {
  .portal-mobile-nav {
    display: none;
  }
}

.safe-area-pb {
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0));
}

/* Page shells that used purple ambient glow — neutral bg */
.portal-page-surface {
  background: var(--bg);
}

/* ── Dashboard / Calls ── */
.dashboard-noctua {
  position: relative;
  background: var(--bg);
}

.dashboard-noctua .dashboard-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.85fr);
  gap: 1.25rem;
}

@media (max-width: 1023px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.dashboard-subtle {
  color: var(--text2);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.dashboard-divider {
  border-top: 1px solid var(--border);
}

.dash-widget-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dash-widget-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  transition: background 0.15s ease, border-color 0.15s ease;
}

a.dash-widget-row:hover {
  background: var(--surface2);
  border-color: var(--accent-border);
}

.dash-pipeline-metric {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.dashboard-noctua .dashboard-input {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border2);
}

.dashboard-noctua .dashboard-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ── Leads ── */
.leads-noctua {
  position: relative;
  background: var(--bg);
}

.leads-noctua .leads-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

.leads-noctua .leads-input {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border2);
}

.leads-noctua .leads-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.leads-metric-card {
  position: relative;
  overflow: visible;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.leads-table-shell {
  position: relative;
  overflow: visible;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

/* ── Appointments ── */
.appointments-noctua {
  position: relative;
  background: var(--bg);
}

.appointments-noctua .appts-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

.appointments-noctua .appts-input {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border2);
}

.appointments-noctua .appts-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Scheduling / event-types: same inputs as appointments (page uses dashboard-noctua; modal is outside it) */
.dashboard-noctua .appts-input {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border2);
  color: var(--text);
}

.dashboard-noctua .appts-input::placeholder {
  color: var(--text3);
}

.dashboard-noctua .appts-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  outline: none;
}

/* Event type modal (#et-modal is a portal overlay, not under .dashboard-noctua) */
#et-modal {
  color-scheme: dark;
}

#et-modal .appts-input,
#et-modal input[type="text"],
#et-modal input[type="email"],
#et-modal input[type="number"],
#et-modal input[type="date"],
#et-modal input[type="time"],
#et-modal textarea,
#et-modal select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border2);
  color: var(--text);
}

#et-modal .appts-input::placeholder,
#et-modal input::placeholder,
#et-modal textarea::placeholder {
  color: var(--text3);
}

#et-modal .appts-input:focus,
#et-modal input:not([type="checkbox"]):not([type="color"]):focus,
#et-modal textarea:focus,
#et-modal select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  outline: none;
  /* Tailwind CDN adds a light ring; keep portal accent focus only */
  --tw-ring-width: 0px;
  --tw-ring-offset-width: 0px;
  --tw-ring-shadow: 0 0 #0000;
}

/* Event type modal: match onboarding wizard `.input-field` look on read-only BH preview */
#et-modal .input-field {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border2);
}
#et-modal .input-field:disabled {
  opacity: 1;
  cursor: default;
  color: var(--text);
}

.appts-metric-card {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.appts-table-shell {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

/* ── Assistant page: panels inside .dashboard-noctua ── */
.dashboard-noctua .glass-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  backdrop-filter: none;
}

.dashboard-noctua .input-field {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border2);
}

.dashboard-noctua .input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Auth pages (login / signup / password) */
.portal-auth-card.glass-panel {
  border-radius: 1rem;
}

.portal-auth-input {
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text);
}

.portal-auth-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.portal-auth-input::placeholder {
  color: var(--text3);
}

/* ── Conversations (matches automte.html #page-conversations) ── */
/* One-screen layout: shell does not scroll; list + thread + detail panels scroll inside */
html:has(.portal-conv-page),
body:has(.portal-conv-page) {
  overflow: hidden;
  height: 100dvh;
  max-height: 100dvh;
}

body:has(.portal-conv-page) > .flex.min-h-screen {
  height: 100dvh;
  max-height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  align-items: stretch;
}

body:has(.portal-conv-page) > .flex.min-h-screen > .flex.flex-col.min-w-0 {
  min-height: 0;
  flex: 1 1 0%;
  overflow: hidden;
  max-height: 100%;
}

main.portal-conv-main,
body:has(.portal-conv-page) main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  flex: 1 1 0%;
}

main.portal-conv-main > .portal-conv-page,
body:has(.portal-conv-page) main > .portal-conv-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.portal-conv-page {
  min-height: 0;
}

.portal-conv-root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.portal-conv-root .conv-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 0;
  overflow: hidden;
}

.portal-conv-root .conv-list {
  width: min(320px, 36vw);
  min-width: 260px;
  border-right: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0;
  background: var(--bg);
}

.portal-conv-root .conv-list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: transparent;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.portal-conv-root .conv-list-scroll::-webkit-scrollbar {
  width: 8px;
}

.portal-conv-root .conv-list-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.portal-conv-root .conv-list-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}

.portal-conv-root .conv-filter {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}

.portal-conv-root .conv-toolbar {
  padding: 12px 16px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.portal-conv-root .conv-thread {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.portal-conv-root .filter-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid var(--border2);
  color: var(--text3);
  cursor: pointer;
  transition: all 0.15s;
}

.portal-conv-root button.filter-pill {
  font: inherit;
  background: transparent;
  color: var(--text3);
}

.portal-conv-root .filter-pill.active,
.portal-conv-root .filter-pill:hover {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-dim);
}

.portal-conv-root button.filter-pill.active,
.portal-conv-root button.filter-pill:hover {
  color: var(--accent);
}

.portal-conv-root .conv-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.portal-conv-root .conv-item:hover {
  background: var(--surface);
}

.portal-conv-root .conv-item.active {
  background: var(--accent-dim);
  border-left: 2px solid var(--accent);
}

.portal-conv-root .conv-item.unread .conv-name {
  font-weight: 600;
  color: var(--text);
}

.portal-conv-root .conv-name {
  font-size: 13px;
  color: var(--text);
}

.portal-conv-root .conv-preview {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-conv-root .conv-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.portal-conv-root .conv-time {
  font-size: 11px;
  color: var(--text3);
}

.portal-conv-root .conv-unread-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
}

.portal-conv-root .chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.portal-conv-root .chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: transparent;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.portal-conv-root .chat-messages::-webkit-scrollbar {
  width: 8px;
}

.portal-conv-root .chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.portal-conv-root .chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}

.portal-conv-root .chat-input-row {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  align-items: flex-end;
}

.portal-conv-root .chat-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  outline: none;
  resize: none;
  line-height: 1.5;
  max-height: 100px;
}

.portal-conv-root .chat-input:focus {
  border-color: var(--accent-border);
}

.portal-conv-root .chat-input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.portal-conv-root .msg-row {
  display: flex;
  gap: 10px;
  max-width: 75%;
}

.portal-conv-root .msg-row.ai {
  align-self: flex-start;
}

.portal-conv-root .msg-row.human {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.portal-conv-root .msg-row.system {
  align-self: center;
  max-width: 90%;
}

.portal-conv-root .msg-row.conv-ai-notes {
  align-self: stretch;
  max-width: 100%;
}

.portal-conv-root .msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  margin-top: 2px;
}

.portal-conv-root .msg-avatar.ai-av {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.portal-conv-root .msg-avatar.lead-av {
  background: var(--blue-dim);
  color: var(--blue);
  border: 1px solid rgba(74, 158, 255, 0.25);
}

.portal-conv-root .msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
}

.portal-conv-root .msg-row.ai .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 4px 12px 12px 12px;
  color: var(--text);
}

.portal-conv-root .msg-row.human .msg-bubble {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px 4px 12px 12px;
  color: var(--text2);
}

.portal-conv-root .msg-row.system .msg-bubble {
  background: none;
  color: var(--text3);
  font-size: 11px;
  text-align: center;
  font-style: italic;
}

.portal-conv-root .msg-time {
  font-size: 10px;
  color: var(--text3);
  margin-top: 4px;
}

.portal-conv-root .msg-sender {
  font-size: 10px;
  color: var(--text3);
  margin-bottom: 3px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.portal-conv-root .ch-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
}

.portal-conv-root .ch-sms {
  background: var(--green-dim);
  color: var(--green);
}

.portal-conv-root .ch-phone,
.portal-conv-root .ch-calls {
  background: var(--blue-dim);
  color: var(--blue);
}

.portal-conv-root .ch-email {
  background: var(--amber-dim);
  color: var(--amber);
}

.portal-conv-root .handoff-bar {
  margin: 4px 20px;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(255, 170, 51, 0.08);
  border: 1px solid rgba(255, 170, 51, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--amber);
  flex-shrink: 0;
}

.portal-conv-root .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--blue-dim);
  border: 1px solid rgba(74, 158, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Syne, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--blue);
  flex-shrink: 0;
}

.portal-conv-root .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: "DM Sans", sans-serif;
  transition: all 0.15s;
}

.portal-conv-root .btn-ghost {
  background: var(--surface);
  color: var(--text2);
  border: 1px solid var(--border2);
}

.portal-conv-root .btn-ghost:hover {
  background: var(--surface2);
  color: var(--text);
}

.portal-conv-root .btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
}

.portal-conv-root .btn-primary:hover {
  filter: brightness(1.08);
}

.portal-conv-root .btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.portal-conv-root .text-dim {
  color: var(--text3);
}

.portal-conv-root .progress-bar {
  height: 4px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}

.portal-conv-root .progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1s ease;
}

.portal-conv-root .conv-mobile-back {
  display: none;
}

@media (max-width: 1024px) {
  .portal-conv-root .conv-layout {
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    align-items: stretch;
  }

  .portal-conv-root:not(.conv-mobile-thread-active) .conv-thread {
    display: none !important;
  }

  .portal-conv-root:not(.conv-mobile-thread-active) .conv-list {
    width: 100%;
    min-width: 0;
    max-height: none;
    flex: 1 1 0%;
    min-height: 0;
    border-right: none;
    border-bottom: none;
  }

  .portal-conv-root.conv-mobile-thread-active .conv-list {
    display: none !important;
  }

  .portal-conv-root.conv-mobile-thread-active .conv-thread {
    display: flex !important;
    flex: 1 1 0%;
    min-height: 0;
  }

  .portal-conv-root.conv-mobile-thread-active .conv-mobile-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    min-height: 2.25rem;
    padding: 0;
  }
}

@media (min-width: 1025px) {
  .portal-conv-root .conv-mobile-back {
    display: none !important;
  }

  .portal-conv-root .conv-list {
    display: flex !important;
    width: min(320px, 36vw);
    min-width: 260px;
    max-height: none;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    border-bottom: none;
  }

  .portal-conv-root .conv-thread {
    display: flex !important;
  }
}

/* ── Assistant page (matches automte.html #page-ai AI Persona) ── */
.portal-assistant-page .persona-dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .portal-assistant-page .persona-dash-grid {
    grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
    gap: clamp(16px, 2.5vw, 28px);
    align-items: stretch;
  }
  /* Allow columns to shrink so nested overflow/scroll works */
  .portal-assistant-page .persona-dash-grid > * {
    min-width: 0;
    min-height: 0;
  }
}

.portal-assistant-page .persona-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

.portal-assistant-page .persona-card-sticky {
  position: sticky;
  top: 1rem;
}

.portal-assistant-page .persona-aside-link {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text2);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.portal-assistant-page .persona-aside-link:hover {
  background: var(--surface);
  color: var(--text);
}

.portal-assistant-page .persona-section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}

.portal-assistant-page .persona-section-hdr h3 {
  font-family: Syne, system-ui, sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.portal-assistant-page .assistant-page-section {
  scroll-margin-top: 5rem;
  min-width: 0;
}

/* Tools panel: column layout; list scrolls on small screens */
.portal-assistant-page #assistant-tools .assistant-tools-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.portal-assistant-page #assistant-tools .assistant-tools-panel > :first-child {
  flex-shrink: 0;
}
.portal-assistant-page #assistant-tools .assistant-tool-list {
  max-height: min(52vh, 380px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Tools column: fill grid row height; scroll inside list only */
@media (min-width: 768px) {
  .portal-assistant-page #assistant-tools {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
  }
  .portal-assistant-page #assistant-tools .assistant-tools-panel {
    flex: 1 1 auto;
    min-height: 0;
  }
  .portal-assistant-page #assistant-tools .assistant-tool-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }
}

.portal-assistant-page .assistant-section-head {
  margin-bottom: 4px;
}

.portal-assistant-page .assistant-section-eyebrow {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
  font-weight: 600;
  margin: 0 0 6px;
}

.portal-assistant-page .assistant-section-title {
  font-family: Syne, system-ui, sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px;
  line-height: 1.3;
}

.portal-assistant-page .assistant-aside-sub {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3);
  font-weight: 600;
  margin: 12px 0 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.portal-assistant-page .assistant-aside-sub:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* ── AI Settings: Persona & Voice identity card ── */
.identity-persona-voice-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(
    155deg,
    rgba(24, 24, 28, 0.98) 0%,
    rgba(18, 18, 22, 0.99) 42%,
    rgba(22, 20, 32, 0.72) 100%
  );
  border: 1px solid var(--border2);
  box-shadow:
    0 4px 32px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(167, 139, 250, 0.07) inset,
    0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.identity-persona-voice-card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(129, 140, 248, 0.55) 22%,
    rgba(167, 139, 250, 0.65) 50%,
    rgba(34, 211, 238, 0.45) 78%,
    transparent 100%
  );
  pointer-events: none;
  opacity: 0.95;
}

.identity-persona-voice-card__head {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: stretch;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

@media (min-width: 640px) {
  .identity-persona-voice-card__head {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }
}

.identity-persona-voice-card__chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.identity-pv-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.identity-pv-chip i {
  font-size: 0.75rem;
  opacity: 0.9;
}

.identity-pv-chip--persona {
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(129, 140, 248, 0.28);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

.identity-pv-chip--voice {
  color: #a5f3fc;
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.22);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.identity-persona-voice-card__edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  flex-shrink: 0;
  align-self: flex-start;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-on-accent);
  background: linear-gradient(165deg, var(--accent) 0%, #8b5cf6 100%);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(139, 92, 246, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.identity-persona-voice-card__edit i {
  font-size: 0.7rem;
  opacity: 0.95;
}

.identity-persona-voice-card__edit:hover {
  filter: brightness(1.06);
  box-shadow: 0 4px 18px rgba(139, 92, 246, 0.42);
}

.identity-persona-voice-card__edit:active {
  transform: scale(0.98);
}

.identity-persona-voice-card__edit:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-dim), 0 2px 12px rgba(139, 92, 246, 0.35);
}

@media (min-width: 640px) {
  .identity-persona-voice-card__edit {
    align-self: center;
  }
}

.identity-pv-preview-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

@media (min-width: 640px) {
  .identity-pv-preview-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1rem;
  }
}

.identity-pv-stat {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-left: 3px solid rgba(129, 140, 248, 0.5);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.035) inset;
}

.identity-pv-stat--voice {
  border-left-color: rgba(45, 212, 191, 0.55);
}

.identity-pv-stat__icon {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(129, 140, 248, 0.18);
  color: #a5b4fc;
  font-size: 0.8rem;
}

.identity-pv-stat--voice .identity-pv-stat__icon {
  background: rgba(45, 212, 191, 0.12);
  border-color: rgba(45, 212, 191, 0.22);
  color: #5eead4;
}

.identity-pv-stat__body {
  min-width: 0;
  flex: 1;
}

.identity-pv-stat__label-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.3rem;
}

.identity-pv-stat__label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
}

.identity-pv-missing,
.identity-field-missing.identity-pv-missing {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fbbf24;
}

.identity-pv-missing i {
  font-size: 0.55rem;
}

.identity-pv-missing.hidden {
  display: none;
}

.identity-pv-stat__value {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text);
  word-break: break-word;
}

.identity-pv-stat__value--voice {
  font-weight: 500;
}

.identity-pv-stat__value--error {
  color: #fca5a5;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.4;
}

.identity-pv-edit-section {
  padding: 1rem 1.1rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.identity-pv-edit-section + .identity-pv-edit-section {
  margin-top: 0.25rem;
}

.identity-pv-edit-section__title {
  margin: 0 0 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
}

@media (prefers-reduced-motion: reduce) {
  .identity-persona-voice-card__edit {
    transition: none;
  }
  .identity-persona-voice-card__edit:active {
    transform: none;
  }
}

/* Identity tab: chat preview “off” until Persona/Voice edit; height matches card when off */
.identity-chat-preview-surface {
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  transition:
    height 0.28s ease,
    min-height 0.28s ease,
    max-height 0.28s ease,
    border-color 0.22s ease,
    box-shadow 0.22s ease;
}

.identity-chat-preview-body {
  position: relative;
  z-index: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.identity-chat-off-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  border-radius: inherit;
  background: rgba(6, 8, 14, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.24s ease, visibility 0.24s;
}

.identity-chat-preview-surface--on .identity-chat-off-overlay {
  opacity: 0;
  visibility: hidden;
}

.identity-chat-off-overlay__card {
  text-align: center;
  max-width: 15rem;
}

.identity-chat-off-overlay__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 0.65rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(148, 163, 184, 0.95);
  font-size: 0.85rem;
}

.identity-chat-off-overlay__title {
  margin: 0 0 0.35rem;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.95);
}

.identity-chat-off-overlay__hint {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text3);
}

.identity-chat-off-overlay__hint strong {
  color: rgba(203, 213, 225, 0.88);
  font-weight: 600;
}

.identity-chat-preview-surface--off .identity-chat-preview-surface__intro,
.identity-chat-preview-surface--off .identity-chat-preview-thread {
  opacity: 0.32;
  filter: grayscale(0.45);
  transition: opacity 0.24s ease, filter 0.24s ease;
}

.identity-chat-preview-surface--on .identity-chat-preview-surface__intro,
.identity-chat-preview-surface--on .identity-chat-preview-thread {
  opacity: 1;
  filter: none;
}

.identity-chat-preview-aside--editing .identity-chat-preview-surface {
  border-color: rgba(34, 211, 238, 0.14);
  box-shadow:
    0 4px 28px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(34, 211, 238, 0.07) inset;
}

@media (prefers-reduced-motion: reduce) {
  .identity-chat-preview-surface {
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    transition-property: border-color, box-shadow;
  }
  .identity-chat-off-overlay,
  .identity-chat-preview-surface--off .identity-chat-preview-surface__intro,
  .identity-chat-preview-surface--off .identity-chat-preview-thread {
    transition-duration: 0.12s;
  }
}
