/* Automte platform UI — aligned with automte.html design tokens */
:root {
  --bg: #0b0c0e;
  --bg2: #111214;
  --bg3: #161719;
  --surface: #1c1d20;
  --surface2: #222325;
  --border: rgba(255, 255, 255, 0.07);
  --border2: rgba(255, 255, 255, 0.12);
  --text: #f0eee8;
  --text2: #9b9994;
  --text3: #5c5b57;
  --accent: #a78bfa;
  --accent-hover: #7c3aed;
  --accent-hover-text: #f5f3ff;
  --accent-dim: rgba(167, 139, 250, 0.12);
  --accent-border: rgba(167, 139, 250, 0.25);
  --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: #0b0c0e;
  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 {
  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);
}

.logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Syne, system-ui, sans-serif;
  font-weight: 800;
  font-size: 14px;
  color: #0b0c0e;
}

.logo-name {
  font-family: Syne, system-ui, sans-serif;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.3px;
  color: var(--text);
}

.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 .logo-name {
  display: none;
}

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 .conv-detail {
  width: min(280px, 30vw);
  min-width: 220px;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  min-height: 0;
  padding: 20px;
  background: var(--bg2);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

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

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

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

.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-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: #0b0c0e;
}

.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 .badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 100px;
}

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

.portal-conv-root .badge-blue {
  background: var(--blue-dim);
  color: var(--blue);
}

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

.portal-conv-root .badge-purple {
  background: var(--purple-dim);
  color: var(--purple);
}

.portal-conv-root .badge-gray {
  background: var(--surface2);
  color: var(--text3);
}

@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 .conv-list {
    width: 100%;
    min-width: 0;
    max-height: min(260px, 34vh);
    flex-shrink: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .portal-conv-root .conv-thread {
    flex: 1 1 0%;
    min-height: 0;
  }

  .portal-conv-root .conv-detail {
    width: 100%;
    min-width: 0;
    max-height: min(240px, 32vh);
    flex-shrink: 0;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

/* ── 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;
}
