* {
  box-sizing: border-box;
}

:root {
  --portal-ink: #0b1736;
  --portal-muted: #5d6984;
  --portal-line: #dfe7f2;
  --portal-blue: #0f6bff;
  --portal-blue-2: #2485ff;
  --portal-teal: #0f766e;
  --portal-green: #16a34a;
  --portal-red: #dc2626;
  --portal-orange: #ea7a00;
  --portal-bg: #f8fbff;
  --portal-card: #ffffff;
  --portal-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
  --portal-brand-gradient: linear-gradient(135deg, #0a1b2e 0%, #3b82f6 100%);
  --fud-portal-background:
    radial-gradient(circle at 15% 8%, rgba(37, 99, 235, 0.11), transparent 28%),
    radial-gradient(circle at 88% 42%, rgba(22, 163, 74, 0.06), transparent 32%),
    linear-gradient(180deg, #ffffff 0%, #f7fbff 55%, #faf7f2 100%);
}

html,
body {
  width: 100%;
  max-width: 100%;
  margin: 0;
  overflow-x: hidden;
}

.topbar[hidden] {
  display: none !important;
}

.portal-root {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

.portal-app {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  margin: 0;
  padding-bottom: 92px;
  background: var(--fud-portal-background);
  color: var(--portal-ink);
  overflow-x: clip;
}

.portal-titlebar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 12px clamp(18px, 5vw, 40px);
  border-bottom: 1px solid rgba(10, 27, 46, 0.1);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
}

.portal-brand,
.portal-titlebar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.portal-brand {
  overflow: hidden;
}

.portal-titlebar__actions {
  justify-content: end;
}

.portal-brand strong {
  color: var(--portal-ink);
  font-size: clamp(1.25rem, 4vw, 1.9rem);
  line-height: 1;
  letter-spacing: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-logo-icon {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.portal-context {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(10, 27, 46, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  font-weight: 750;
  white-space: nowrap;
  min-width: 0;
  max-width: 176px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-menu summary {
  border: 0 !important;
  background: transparent !important;
  font-size: 1.6rem !important;
}

.portal-main {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: clamp(24px, 5vw, 42px) clamp(16px, 5vw, 42px);
  overflow-x: hidden;
}

.portal-page-head {
  display: grid;
  gap: 12px;
  margin-bottom: 22px;
}

.portal-lead-options {
  margin-top: 20px;
}

.portal-page-head h1 {
  margin: 0;
  color: var(--portal-ink);
  font-size: clamp(2.25rem, 8vw, 3.75rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.portal-page-head p {
  margin: 0;
  color: var(--portal-muted);
  font-size: clamp(1rem, 3vw, 1.35rem);
}

.portal-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
  margin-top: 12px;
  width: 100%;
}

.portal-tabs a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--portal-line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--portal-ink);
  text-decoration: none;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.03);
}

.portal-tabs a.selected {
  border-color: var(--portal-blue);
  background: linear-gradient(135deg, var(--portal-blue), var(--portal-blue-2));
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(15, 107, 255, 0.22);
}

.group-heading {
  margin: 24px 0 10px;
  font-size: 1.08rem;
}

.lead-list,
.draft-group ul,
.calendar-day ul {
  display: grid;
  gap: 14px;
}

.portal-card {
  display: grid;
  gap: 0;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--portal-line);
  border-radius: 16px;
  background: var(--portal-card);
  box-shadow: var(--portal-shadow);
  backdrop-filter: blur(10px);
}

.admin-account-list {
  display: grid;
  gap: 14px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.admin-account-link {
  display: grid;
  gap: 14px;
  padding: 18px 20px;
  color: inherit;
  text-decoration: none;
}

.admin-account-link:hover strong {
  color: var(--portal-blue);
}

.admin-ops-details {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.admin-ops-details summary {
  width: max-content;
  max-width: 100%;
  cursor: pointer;
  padding: 9px 12px;
  border: 1px solid var(--portal-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--portal-muted);
  font-weight: 850;
}

.admin-ops-details[open] summary {
  color: var(--portal-blue);
  border-color: rgba(15, 107, 255, 0.28);
}

.admin-ops-details--mirror {
  margin: 16px auto 108px;
  width: min(960px, calc(100% - 24px));
}

.portal-admin .portal-main {
  width: min(1120px, 100%);
}

.admin-mirror-head {
  padding: 16px;
  border: 1px solid var(--portal-line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
}

.admin-mirror-toolbar {
  position: sticky;
  top: 0;
  z-index: 32;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--portal-line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

.admin-mirror-toolbar__copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.admin-mirror-toolbar__copy strong,
.admin-mirror-toolbar__copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-mirror-toolbar__actions {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.admin-back-to-clients {
  width: max-content;
}

.admin-client-switcher {
  position: relative;
  min-width: 210px;
}

.admin-client-switcher summary {
  display: grid;
  gap: 2px;
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid var(--portal-line);
  border-radius: 12px;
  background: #ffffff;
  cursor: pointer;
  list-style: none;
}

.admin-client-switcher summary::-webkit-details-marker {
  display: none;
}

.admin-client-switcher summary span {
  color: var(--portal-muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.admin-client-switcher summary strong {
  overflow: hidden;
  color: var(--portal-ink);
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-client-switcher__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  display: grid;
  gap: 6px;
  width: min(320px, calc(100vw - 24px));
  max-height: min(430px, calc(100vh - 96px));
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--portal-line);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
}

.admin-client-switcher__label {
  padding: 4px 8px 6px;
  color: var(--portal-muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.admin-client-switcher__menu a {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 12px;
  color: var(--portal-ink);
  text-decoration: none;
}

.admin-client-switcher__menu a:hover,
.admin-client-switcher__menu a.selected {
  background: #edf4ff;
  color: var(--portal-blue);
}

.admin-client-switcher__menu small {
  overflow: hidden;
  color: var(--portal-muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-mirror-frame {
  min-width: 0;
  max-width: 100%;
  overflow: visible;
  background: #f8fbff;
}

.admin-mirror-frame .portal-app {
  min-height: auto;
}

.admin-mirror-frame textarea[readonly] {
  background: #f8fafc;
  cursor: default;
}

.portal-admin-mirror .portal-bottom-nav {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.portal-admin-mirror .portal-bottom-nav .admin-clients-tab {
  color: var(--portal-blue);
  background: rgba(237, 244, 255, 0.9);
}

.portal-admin-mirror .portal-bottom-nav .admin-clients-tab::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: min(42px, 54%);
  height: 3px;
  border-radius: 999px;
  background: var(--portal-blue);
  transform: translateX(-50%);
}

.portal-card > details,
.portal-card summary {
  display: grid;
  min-width: 0;
}

.portal-card summary {
  list-style: none;
  cursor: pointer;
  gap: 14px;
  padding: 18px 20px;
}

.portal-card summary::-webkit-details-marker {
  display: none;
}

.lead-card__top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
}

.avatar {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #eaf2ff;
  color: var(--portal-blue);
  font-weight: 950;
  font-size: 1.15rem;
}

.lead-card__identity {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.lead-card__identity strong {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--portal-ink);
  font-size: 1.15rem;
}

.lead-card__identity small {
  color: var(--portal-muted);
  font-size: 0.94rem;
  line-height: 1.35;
}

.chevron {
  color: var(--portal-ink);
  font-size: 2rem;
  line-height: 1;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.status-overdue {
  background: #fee2e2;
  color: var(--portal-red);
}

.status-today {
  background: #fff0d6;
  color: var(--portal-orange);
}

.status-upcoming,
.status-unscheduled,
.status-neutral {
  background: #edf4ff;
  color: var(--portal-blue);
}

.status-warning {
  background: #fff7ed;
  color: var(--portal-orange);
}

.portal-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--portal-line);
  border-bottom: 1px solid var(--portal-line);
}

.portal-meta--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.portal-meta__item {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 13px 12px;
  border-right: 1px solid var(--portal-line);
}

.portal-meta__item:last-child {
  border-right: 0;
}

.portal-meta__item span {
  color: var(--portal-muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.portal-meta__item strong {
  color: var(--portal-ink);
  font-size: 0.92rem;
  line-height: 1.25;
}

.portal-meta__item--overdue strong {
  color: var(--portal-red);
}

.portal-meta__item--today strong,
.portal-meta__item--warning strong {
  color: var(--portal-orange);
}

.portal-meta__item--upcoming strong,
.portal-meta__item--unscheduled strong {
  color: var(--portal-blue);
}

.lead-card__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.lead-card__actions:has(.portal-button:only-child),
.lead-card__actions:has(.summary-action:only-child) {
  grid-template-columns: 1fr;
}

.portal-button,
.summary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  width: 100%;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--portal-blue);
  font: inherit;
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
}

.portal-button--primary,
.summary-action {
  background: linear-gradient(135deg, var(--portal-blue), var(--portal-blue-2));
  color: #ffffff;
}

.portal-button--ghost {
  background: #ffffff;
  color: var(--portal-blue);
}

.portal-button.sent,
.followup-sent-button.sent {
  border-color: #86efac;
  background: #dcfce7;
  color: #166534;
}

.lead-detail-body {
  display: grid;
  gap: 12px;
  padding: 0 20px 20px;
}

.detail-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--portal-line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.84);
}

.detail-panel h2 {
  margin: 0;
  font-size: 1rem;
}

.draft-copy {
  width: 100%;
  min-height: 116px;
  margin: 0;
  padding: 14px;
  border: 1px solid #cfe0ff;
  border-radius: 12px;
  background: #fbfdff;
  color: var(--portal-ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  line-height: 1.55;
}

textarea.draft-copy {
  resize: vertical;
}

.copy-row,
.sent-action-row,
.contact-grid {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.copy-row span,
.rationale-grid span,
.followup-plan span {
  color: var(--portal-muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.rationale-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.rationale-grid div {
  padding: 12px;
  border: 1px solid var(--portal-line);
  border-radius: 12px;
  background: rgba(248, 251, 255, 0.82);
}

.rationale-grid p {
  margin: 6px 0 0;
}

.draft-group {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.draft-group__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 9px 14px;
  border-radius: 12px;
  font-weight: 900;
}

.calendar-day {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
}

.calendar-day__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.calendar-day__head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.calendar-day__head span {
  color: var(--portal-muted);
}

.calendar-card {
  position: relative;
  padding: 18px 20px;
  gap: 14px;
}

.draft-card {
  padding: 18px 20px;
  gap: 14px;
}

.draft-review-panel {
  display: grid;
  gap: 12px;
  padding-top: 2px;
}

.draft-review-panel[hidden] {
  display: none;
}

.calendar-card__time {
  position: absolute;
  top: 18px;
  right: 20px;
  font-weight: 800;
}

.settings-card {
  padding: 18px;
}

.analytics-head {
  margin-bottom: 16px;
}

.analytics-signal {
  gap: 8px;
  padding: 20px;
  margin-bottom: 14px;
  border-color: rgba(15, 107, 255, 0.2);
  background:
    radial-gradient(circle at 90% 10%, rgba(22, 163, 74, 0.1), transparent 36%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(237, 244, 255, 0.92));
}

.analytics-signal span,
.analytics-metric span {
  color: var(--portal-blue);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.analytics-signal h2 {
  max-width: 680px;
  margin: 0;
  font-size: clamp(1.28rem, 5vw, 1.8rem);
  line-height: 1.1;
}

.analytics-signal p {
  max-width: 680px;
  margin: 0;
  color: var(--portal-muted);
  line-height: 1.45;
}

.analytics-signal small {
  display: block;
  width: fit-content;
  max-width: 100%;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(15, 107, 255, 0.08);
  color: #31527d;
  font-weight: 800;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
}

.analytics-metrics,
.analytics-grid {
  display: grid;
  gap: 14px;
}

.analytics-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.analytics-metric {
  gap: 7px;
  padding: 16px;
}

.analytics-metric strong {
  color: var(--portal-ink);
  font-size: clamp(1.55rem, 6vw, 2.25rem);
  line-height: 1;
}

.analytics-metric small {
  color: var(--portal-muted);
  line-height: 1.35;
}

.analytics-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.analytics-panel {
  gap: 12px;
  padding: 18px;
}

.analytics-panel--priority {
  border-color: rgba(15, 107, 255, 0.26);
  background:
    radial-gradient(circle at 100% 0%, rgba(15, 107, 255, 0.08), transparent 34%),
    rgba(255, 255, 255, 0.94);
}

.analytics-panel h2,
.analytics-panel p {
  margin: 0;
}

.analytics-panel ul {
  display: grid;
  gap: 10px;
}

.analytics-bar {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.analytics-bar div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.analytics-bar strong {
  color: var(--portal-ink);
}

.analytics-bar span {
  color: var(--portal-muted);
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
}

.analytics-bar small {
  color: var(--portal-muted);
  line-height: 1.35;
}

.analytics-bar i {
  display: block;
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(223, 231, 242, 0.75);
}

.analytics-bar i::before {
  content: "";
  display: block;
  width: var(--bar-width);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--portal-blue), var(--portal-blue-2));
}

.analytics-bar--warning i::before {
  background: linear-gradient(135deg, #f59e0b, #f97316);
}

.analytics-bar--green i::before {
  background: linear-gradient(135deg, #16a34a, #22c55e);
}

.analytics-bar--red i::before {
  background: linear-gradient(135deg, #dc2626, #fb7185);
}

.analytics-next li {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--portal-line);
  border-radius: 12px;
  background: rgba(248, 251, 255, 0.82);
}

.analytics-next li span {
  color: var(--portal-muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.analytics-empty {
  border-style: dashed;
}

.analytics-empty strong {
  color: var(--portal-ink);
}

.analytics-empty span {
  color: var(--portal-muted);
  line-height: 1.4;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.portal-button.danger {
  border-color: #fecaca;
  color: var(--portal-red);
}

.timeline-panel ul {
  display: grid;
  gap: 0;
}

.timeline-panel li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--portal-line);
}

.timeline-panel li:last-child {
  border-bottom: 0;
}

.timeline-panel span {
  color: var(--portal-muted);
}

.portal-sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  align-items: end;
}

.portal-sheet__scrim {
  position: absolute;
  inset: 0;
  background: rgba(11, 23, 54, 0.34);
}

.portal-sheet__panel {
  position: relative;
  display: grid;
  gap: 12px;
  width: min(640px, calc(100% - 24px));
  margin: 0 auto 12px;
  padding: 20px;
  border: 1px solid var(--portal-line);
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.25);
}

.portal-sheet__panel h2 {
  margin: 0;
  font-size: 1.2rem;
}

.portal-sheet__panel label {
  color: var(--portal-muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.portal-sheet__panel input,
.portal-sheet__panel select,
.portal-sheet__panel textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--portal-line);
  border-radius: 12px;
  background: #fbfdff;
  color: var(--portal-ink);
  font: inherit;
}

.portal-sheet__panel textarea {
  min-height: 92px;
  resize: vertical;
}

.sheet-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.sheet-options button {
  min-height: 40px;
  border: 1px solid var(--portal-line);
  border-radius: 999px;
  background: #f8fbff;
  color: var(--portal-ink);
  font: inherit;
  font-weight: 800;
}

.sheet-options button:focus,
.sheet-options button:hover {
  border-color: var(--portal-blue);
  color: var(--portal-blue);
}

.sheet-options button.selected {
  border-color: var(--portal-blue);
  background: rgba(37, 99, 235, 0.1);
  color: var(--portal-blue);
}

.sheet-warning,
.sheet-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 750;
}

.sheet-warning {
  border: 1px solid rgba(217, 119, 6, 0.24);
  background: rgba(255, 247, 237, 0.92);
  color: #92400e;
}

.sheet-error {
  border: 1px solid rgba(220, 38, 38, 0.24);
  background: rgba(254, 242, 242, 0.95);
  color: #b91c1c;
}

.portal-sheet__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.portal-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  min-height: 74px;
  padding: 8px max(10px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-right));
  border-top: 1px solid var(--portal-line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
}

.portal-bottom-nav a {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  color: var(--portal-muted);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 800;
}

.portal-bottom-nav a:first-child:not(.selected) {
  background: transparent;
  color: var(--portal-muted);
}

.portal-bottom-nav a.selected {
  color: var(--portal-blue);
}

.portal-bottom-nav a.selected::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: min(42px, 54%);
  height: 3px;
  border-radius: 999px;
  background: var(--portal-blue);
  transform: translateX(-50%);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
}

.nav-icon svg {
  display: block;
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty {
  display: grid;
  gap: 8px;
  padding: 22px;
  border: 1px dashed rgba(15, 107, 255, 0.22);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--portal-muted);
  line-height: 1.45;
}

.empty::before {
  content: "✓";
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(15, 107, 255, 0.1);
  color: var(--portal-blue);
  font-weight: 900;
}

@media (max-width: 720px) {
  .portal-titlebar {
    gap: 6px;
    padding: 10px 12px;
  }

  .admin-mirror-toolbar {
    grid-template-columns: 1fr;
  }

  .admin-mirror-toolbar__actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
  }

  .admin-client-switcher {
    min-width: 0;
  }

  .portal-brand {
    gap: 6px;
  }

  .portal-brand strong {
    font-size: clamp(0.78rem, 3.7vw, 0.94rem);
    max-width: 132px;
  }

  .portal-logo-icon {
    width: 32px;
    height: 32px;
  }

  .portal-context {
    display: none;
  }

  .portal-menu summary {
    width: 26px !important;
    font-size: 1.25rem !important;
  }

  .portal-main {
    width: 100%;
    max-width: 100%;
    padding: 22px 12px 104px;
  }

  .portal-page-head h1 {
    font-size: clamp(1.85rem, 9vw, 2.55rem);
  }

  .portal-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .portal-tabs a {
    min-height: 38px;
    padding: 0 6px;
    border-radius: 11px;
    font-size: clamp(0.72rem, 3.4vw, 0.84rem);
    line-height: 1;
    white-space: nowrap;
  }

  .lead-card__top {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .lead-card__badge {
    grid-column: 2 / 3;
    justify-self: start;
  }

  .chevron {
    grid-column: 3;
    grid-row: 1;
  }

  .portal-meta,
  .portal-meta--two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analytics-metrics,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .analytics-signal,
  .analytics-panel,
  .analytics-metric {
    padding: 15px;
  }

  .portal-bottom-nav {
    padding-left: max(6px, env(safe-area-inset-left));
    padding-right: max(6px, env(safe-area-inset-right));
  }

  .portal-bottom-nav a {
    font-size: clamp(0.62rem, 2.9vw, 0.72rem);
  }

  .portal-meta__item:nth-child(2n) {
    border-right: 0;
  }

  .portal-meta__item:nth-child(n + 3) {
    border-top: 1px solid var(--portal-line);
  }

  .lead-card__actions,
  .rationale-grid,
  .quick-actions,
  .portal-sheet__actions {
    grid-template-columns: 1fr;
  }

  .sheet-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-card__time {
    position: static;
    justify-self: start;
  }
}


.portal-app.portal-admin {
  width: 100%;
  max-width: 100%;
  margin: 0;
  overflow-x: hidden;
}

.admin-titlebar {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.admin-brand-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.admin-brand-copy small {
  color: var(--portal-muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-backend-warning {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid #fed7aa;
  border-radius: 18px;
  background: #fff7ed;
  color: #7c2d12;
  box-shadow: 0 12px 32px rgba(124, 45, 18, 0.08);
}

.admin-backend-warning strong {
  font-size: 1rem;
  color: #7c2d12;
}

.admin-backend-warning p,
.admin-backend-warning small {
  margin: 0;
  color: #9a3412;
  line-height: 1.35;
}

.admin-backend-warning .badge {
  justify-self: start;
}

.admin-mirror-toolbar + .admin-backend-warning {
  margin: 12px max(12px, env(safe-area-inset-left)) 0;
}

.admin-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(18px, 5vw, 26px);
  border: 1px solid rgba(15, 107, 255, 0.14);
  border-radius: 24px;
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 255, 255, 0.42), transparent 26%),
    linear-gradient(135deg, #0a1b2e 0%, #2563eb 100%);
  box-shadow: var(--portal-shadow);
}

.admin-hero::after {
  content: "";
  position: absolute;
  inset: auto -32px -48px auto;
  width: 142px;
  height: 142px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.admin-hero > * {
  position: relative;
  z-index: 1;
}

.admin-hero h1 {
  color: #fff;
}

.admin-hero p {
  max-width: 42rem;
  color: rgba(232, 241, 255, 0.88);
  line-height: 1.45;
}

.admin-hero .badge {
  justify-self: start;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.14);
  color: #eaf3ff;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-action-queue {
  display: grid;
  gap: 14px;
}

.admin-action-queue h2 {
  margin: 8px 0 4px;
  color: var(--portal-ink);
  font-size: clamp(1.3rem, 4vw, 1.8rem);
}

.admin-action-queue p {
  margin: 0;
  color: var(--portal-muted);
  line-height: 1.4;
}

.admin-action-queue__meta {
  border-radius: 16px;
  overflow: hidden;
}

.admin-action-queue__last {
  font-size: 0.9rem;
}

.admin-action-queue__healthy {
  padding: 10px 12px;
  border-radius: 14px;
  background: #ecfdf5;
  color: #047857 !important;
  font-weight: 800;
}

.admin-action-queue__failures {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-action-queue__failures li {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 14px;
  background: #fef2f2;
  color: #7f1d1d;
}

.admin-action-queue__failures span,
.admin-action-queue__failures small {
  color: #991b1b;
  overflow-wrap: anywhere;
}

.admin-imports {
  display: grid;
  gap: 14px;
}

.admin-connectors {
  display: grid;
  gap: 14px;
}

.admin-connector-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-connector-list li {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(15, 107, 255, 0.12);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.admin-connector-list li > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.admin-connector-list span,
.admin-connector-list small,
.admin-connector-list code {
  color: var(--portal-muted);
  overflow-wrap: anywhere;
}

.admin-connector-list code {
  display: block;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(15, 107, 255, 0.08);
  color: var(--portal-blue);
  font-size: 0.78rem;
  line-height: 1.35;
}

.admin-connector-error {
  color: #991b1b !important;
  font-weight: 800;
}

.admin-import-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-import-list li {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 107, 255, 0.12);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.admin-import-list span,
.admin-import-list small {
  color: var(--portal-muted);
  overflow-wrap: anywhere;
}

.admin-account-card {
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.admin-account-card:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 107, 255, 0.28);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.1);
}

.admin-account-card__top {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}

.admin-account-meta .portal-meta__item:last-child strong {
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-admin .portal-titlebar__actions {
  min-width: 0;
  max-width: 100%;
  overflow: visible;
}

.portal-admin .portal-context {
  max-width: min(34vw, 176px);
}

.portal-admin .portal-titlebar .portal-button {
  flex: 0 0 auto;
  width: auto;
  min-height: 38px;
  padding: 0 12px;
  white-space: nowrap;
}

.admin-empty-card {
  box-shadow: var(--portal-shadow);
}

@media (max-width: 720px) {
  .portal-admin .portal-titlebar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    min-height: 58px;
    padding: 8px 8px;
  }

  .portal-admin .portal-brand {
    min-width: 0;
  }

  .portal-admin .portal-brand strong {
    max-width: 46vw;
    font-size: clamp(0.82rem, 3.45vw, 0.96rem);
    line-height: 1.05;
    white-space: nowrap;
  }

  .admin-brand-copy small {
    display: none;
  }

  .portal-admin .portal-titlebar .portal-button {
    min-height: 34px;
    padding: 0 8px;
    border-radius: 10px;
    font-size: 0.76rem;
  }

  .portal-admin-main {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 18px 12px 28px;
  }

  .portal-admin .portal-context {
    display: none;
  }

  .admin-hero {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    gap: 10px;
    margin-bottom: 16px;
    padding: 16px;
    border-radius: 20px;
  }

  .admin-hero h1 {
    font-size: clamp(1.85rem, 9.6vw, 2.45rem);
    line-height: 1;
  }

  .admin-hero p {
    font-size: 0.98rem;
    line-height: 1.42;
  }

  .admin-account-link {
    padding: 16px;
  }

  .admin-account-card__top {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .admin-account-card__top .badge {
    grid-column: 2 / 3;
    justify-self: start;
  }

  .admin-account-card .portal-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
