/* Approved portal direction, September 2026. Every visual override is scoped;
   the original stylesheet remains the source of the Old UI appearance. */
.appearance-switch { display:flex; flex-shrink:0; gap:3px; padding:3px; border:1px solid #c7d2d9; border-radius:8px; background:#f2f5f7; }
.appearance-switch button { border:0; background:transparent; color:#496272; border-radius:5px; min-height:36px; padding:6px 11px; font:600 12px var(--font); cursor:pointer; white-space:nowrap; }
.appearance-switch button[aria-pressed="true"] { background:#fff; color:#173449; box-shadow:0 2px 5px #08243a12; }
.portal-skip { position:fixed; left:16px; top:-80px; z-index:100; background:white; color:#173449; padding:12px 20px; }
.portal-skip:focus { top:12px; }
.nav-icon, .rail-support, .lead-avatar, .customer-avatar, .lead-excerpt { display:none; }
.overview-layout, .overview-main, .overview-insights { display:contents; }

html[data-portal-ui="new"] {
  --bg:#fff; --surface:#fff; --surface-muted:#eef5f2;
  --ink:#173c39; --ink-2:#244844; --ink-3:#49655f; --muted:#536a65; --subtle:#60766e;
  --border:#dde5df; --border-strong:#b9ccc3;
  --accent:#da6d54; --accent-hover:#e47f68; --accent-ink:#98442c; --on-accent:#08243a;
  --accent-soft:#fae8dc; --petrol-dark:#063b39; --success:#246452;
  --radius-sm:7px; --radius-md:8px; --radius-lg:12px;
  --rail:212px; --masthead:76px;
}
:where(html[data-portal-ui="new"]) body { background:#fff; font-size:15px; }
:where(html[data-portal-ui="new"]) button, :where(html[data-portal-ui="new"]) a, :where(html[data-portal-ui="new"]) input, :where(html[data-portal-ui="new"]) select { -webkit-tap-highlight-color:transparent; }
:where(html[data-portal-ui="new"]) :focus-visible { outline:2px solid #97422c; outline-offset:3px; }
:where(html[data-portal-ui="new"]) .topbar { display:contents; }
:where(html[data-portal-ui="new"]) .topbar-inner { position:fixed; z-index:30; inset:0 0 auto; height:var(--masthead); max-width:none; padding:0 28px; background:var(--petrol-dark); border-bottom:2px solid transparent; gap:24px; }
:where(html[data-portal-ui="new"]) .topbar-mark { display:block; width:38px; height:38px; }
:where(html[data-portal-ui="new"]) .topbar .wordmark { display:none; }
:where(html[data-portal-ui="new"]) .topbar-divider { height:27px; margin:0 8px 0 16px; background:#ffffff30; }
:where(html[data-portal-ui="new"]) .topbar .topbar-business { color:#fff; font-size:14px; font-weight:550; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
:where(html[data-portal-ui="new"]) .topbar-user { gap:18px; min-width:0; }
:where(html[data-portal-ui="new"]) .topbar .topbar-email { color:#c6ded6; font-size:12px; max-width:220px; overflow:hidden; text-overflow:ellipsis; }
:where(html[data-portal-ui="new"]) .topbar .btn-ghost { color:#e0f0e9; font-size:13px; padding:8px; }
:where(html[data-portal-ui="new"]) .topbar .appearance-switch { border-color:#ffffff26; background:#ffffff09; }
:where(html[data-portal-ui="new"]) .topbar .appearance-switch button { color:#cee4db; }
:where(html[data-portal-ui="new"]) .topbar .appearance-switch button[aria-pressed="true"] { color:#143d37; background:#fff; }
:where(html[data-portal-ui="new"]) .topbar :focus-visible { outline-color:#f1b19c; }
:where(html[data-portal-ui="new"]) .tabs { position:fixed; z-index:20; top:var(--masthead); bottom:0; left:0; width:var(--rail); background:#faf9f6; border:0; border-right:1px solid var(--border); display:flex; flex-direction:column; padding:28px 14px 22px; }
:where(html[data-portal-ui="new"]) .tabs-inner { margin:0; padding:0; display:flex; flex-direction:column; align-items:stretch; gap:7px; overflow-y:auto; overflow-x:hidden; }
:where(html[data-portal-ui="new"]) .tab { display:flex; align-items:center; gap:12px; padding:13px 15px; min-height:46px; text-align:left; border:0; border-radius:7px; color:#4b655e; background:transparent; font-size:14px; white-space:normal; }
:where(html[data-portal-ui="new"]) .tab:hover { background:#efeee8; color:var(--ink); }
:where(html[data-portal-ui="new"]) .tab[aria-selected="true"] { background:#fae3d2; color:var(--ink); font-weight:650; box-shadow:none; }
:where(html[data-portal-ui="new"]) .tab::after { display:none; }
:where(html[data-portal-ui="new"]) .nav-icon { display:inline-flex; width:19px; height:19px; flex-shrink:0; }
:where(html[data-portal-ui="new"]) #tab-workspaces { margin-top:22px; }
:where(html[data-portal-ui="new"]) .rail-support { display:block; margin: auto 10px 0; padding:24px 4px 4px; border-top:1px solid var(--border); font-size:13px; color:#536a65; }
:where(html[data-portal-ui="new"]) .content { max-width:1440px; min-height:calc(100dvh - 174px); margin:var(--masthead) 0 0 var(--rail); padding:38px clamp(24px, 3.6vw, 64px) 32px; }
:where(html[data-portal-ui="new"]) .content:focus { outline:none; }
:where(html[data-portal-ui="new"]) .page-head { margin-bottom:32px; align-items:center; }
:where(html[data-portal-ui="new"]) .page-title { font-size:36px; font-weight:650; letter-spacing:-.035em; line-height:1.15; }
:where(html[data-portal-ui="new"]) .page-sub { margin-top:9px; font-size:14px; max-width:65ch; }
:where(html[data-portal-ui="new"]) .range-toggle { padding:4px; background:#f2f3ef; border:0; border-radius:7px; }
:where(html[data-portal-ui="new"]) .range-btn { min-height:36px; border:0; font-size:12px; padding:8px 13px; }
:where(html[data-portal-ui="new"]) .range-btn.is-active { background:white; color:var(--ink); box-shadow:0 2px 5px #1430440a; }
:where(html[data-portal-ui="new"]) .foot { margin-left:var(--rail); padding:22px clamp(24px, 3.6vw, 64px); font-size:12px; border-top:1px solid var(--border); color:var(--muted); text-align:left; }
:where(html[data-portal-ui="new"]) .viewas-banner { position:relative; z-index:19; margin:var(--masthead) 0 0 var(--rail); padding:15px clamp(24px, 3.6vw, 64px); max-width:none; background:#fff1cc; color:#63471c; font-size:13px; }
/* The light caution strip needs its own button contrast; the legacy banner is dark. */
:where(html[data-portal-ui="new"]) .viewas-banner .btn { color:var(--danger); background:#fff; border-color:var(--danger); }
:where(html[data-portal-ui="new"]) .viewas-banner .btn:hover:not(:disabled) { color:#fff; background:var(--danger); border-color:var(--danger); }
:where(html[data-portal-ui="new"]) .viewas-banner .btn:focus-visible { outline:2px solid var(--danger); outline-offset:3px; }
:where(html[data-portal-ui="new"]) #app-view:has(.viewas-banner:not([hidden])) .content { margin-top:0; }
:where(html[data-portal-ui="new"]) .btn { min-height:44px; padding:10px 16px; font-size:13px; border-radius:7px; box-shadow:none; }
:where(html[data-portal-ui="new"]) .btn-primary { background:var(--accent); color:var(--on-accent); }
:where(html[data-portal-ui="new"]) .btn-primary:hover:not(:disabled) { background:var(--accent-hover); }
:where(html[data-portal-ui="new"]) .btn-secondary { background:#fff; border-color:#d5dfe5; }
:where(html[data-portal-ui="new"]) .btn-secondary:hover:not(:disabled) { background:#f4f7f8; border-color:#aebfc9; }
:where(html[data-portal-ui="new"]) .btn:active:not(:disabled) { transform:translateY(1px); }
:where(html[data-portal-ui="new"]) .card { border:0; border-radius:0; padding:26px 0; margin:0; border-bottom:1px solid var(--border); background:transparent; }
:where(html[data-portal-ui="new"]) .card:first-child { padding-top:0; }
:where(html[data-portal-ui="new"]) .card-title { font-family:var(--font-display); font-size:21px; letter-spacing:-.025em; font-weight:650; }
:where(html[data-portal-ui="new"]) .card-sub { margin-top:7px; font-size:13px; line-height:1.6; max-width:72ch; }
:where(html[data-portal-ui="new"]) .overview-layout { display:grid; grid-template-columns:minmax(0, 1fr) 286px; align-items:start; gap:32px; }
:where(html[data-portal-ui="new"]) .overview-main, :where(html[data-portal-ui="new"]) .overview-insights { display:block; min-width:0; }
:where(html[data-portal-ui="new"]) .overview-insights:empty { display:none; }
:where(html[data-portal-ui="new"]) .overview-layout:not(:has(.overview-insights > *)) { grid-template-columns:minmax(0, 1fr); }
:where(html[data-portal-ui="new"]) .overview-insights { background:#f0f6f3; border:1px solid #dbe7e2; border-radius:12px; padding:22px; }
:where(html[data-portal-ui="new"]) .overview-insights .card { padding:22px 0; border-color:#d5e2dc; }
:where(html[data-portal-ui="new"]) .overview-insights .card:last-child { border-bottom:0; padding-bottom:0; }
:where(html[data-portal-ui="new"]) .overview-insights .card-title { font-size:18px; }
:where(html[data-portal-ui="new"]) .overview-insights .card-sub { font-size:12px; color:#476759; }
:where(html[data-portal-ui="new"]) .overview-insights .stat-grid { display:block; margin:0; background:transparent; border:0; border-radius:0; overflow:visible; }
:where(html[data-portal-ui="new"]) .overview-insights .stat { display:grid; grid-template-columns:1fr auto; border:0; border-radius:0; background:transparent; padding:8px 0; gap:2px 10px; align-items:center; }
:where(html[data-portal-ui="new"]) .overview-insights .stat:first-child { display:flex; flex-direction:column; align-items:flex-start; padding:0 0 22px; margin-bottom:8px; border-bottom:1px solid #d5e2dc; }
:where(html[data-portal-ui="new"]) .stat-label { font-size:12px; letter-spacing:0; text-transform:none; color:var(--ink-3); font-weight:500; }
:where(html[data-portal-ui="new"]) .stat-value { font-family:var(--font-display); font-size:23px; font-weight:650; line-height:1.15; letter-spacing:-.025em; }
:where(html[data-portal-ui="new"]) .overview-insights .stat:first-child .stat-label { font-size:16px; font-weight:600; }
:where(html[data-portal-ui="new"]) .overview-insights .stat:first-child .stat-value { font-size:56px; margin-top:14px; }
:where(html[data-portal-ui="new"]) .overview-insights .stat:not(:first-child) .stat-value { margin-top:0; font-size:19px; }
:where(html[data-portal-ui="new"]) .overview-insights .stat-note { grid-column:1 / -1; text-align:left; font-size:11px; color:#476759; margin:2px 0 0; }
:where(html[data-portal-ui="new"]) .chart-bar { fill:#a8c5b8; }
:where(html[data-portal-ui="new"]) .chart-bar-today { fill:#296b56; }
:where(html[data-portal-ui="new"]) .chart-svg .chart-axis-text { fill:#476759; font-size:11px; }
:where(html[data-portal-ui="new"]) .leads-toolbar { gap:10px; margin-top:22px; }
:where(html[data-portal-ui="new"]) .leads-toolbar .field { flex:1 1 150px; }
:where(html[data-portal-ui="new"]) .leads-toolbar .field + .field { flex:1 1 155px; }
:where(html[data-portal-ui="new"]) .leads-toolbar label { font-size:12px; }
:where(html[data-portal-ui="new"]) .leads-toolbar input, :where(html[data-portal-ui="new"]) .leads-toolbar select { font-size:13px; }
:where(html[data-portal-ui="new"]) .leads-message { font-size:12px; }
:where(html[data-portal-ui="new"]) .lead-row > summary { padding:22px 0; gap:12px; flex-wrap:wrap; }
:where(html[data-portal-ui="new"]) .lead-avatar, :where(html[data-portal-ui="new"]) .customer-avatar { display:flex; align-items:center; justify-content:center; flex-shrink:0; width:40px; height:40px; border-radius:50%; background:#eaf2ed; color:#366450; font-size:12px; font-weight:600; }
:where(html[data-portal-ui="new"]) .lead-row:nth-child(3n+2) .lead-avatar { color:#935733; background:#fbecdf; }
:where(html[data-portal-ui="new"]) .lead-row:nth-child(3n+3) .lead-avatar { color:#4f5b8a; background:#edf0f8; }
:where(html[data-portal-ui="new"]) .lead-overview { min-width:100px; }
:where(html[data-portal-ui="new"]) .lead-overview strong { font-size:14px; font-weight:650; }
:where(html[data-portal-ui="new"]) .lead-reason { font-size:13px; margin-top:5px; white-space:normal; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
:where(html[data-portal-ui="new"]) .lead-status { font-size:11px; background:#f3f5f6; padding:3px 7px; border-radius:4px; }
:where(html[data-portal-ui="new"]) .lead-status-needs_follow_up { color:#895717; background:#fff2d8; }
:where(html[data-portal-ui="new"]) .lead-status-done { color:#246452; background:#e7f3ec; }
:where(html[data-portal-ui="new"]) .lead-detail { padding:20px; margin-bottom:20px; background:#f7f9fa; border-radius:10px; }
:where(html[data-portal-ui="new"]) .lead-meta time { font-size:11px; }
:where(html[data-portal-ui="new"]) .table-wrap { border:0; border-radius:0; }
:where(html[data-portal-ui="new"]) table { font-size:13px; }
:where(html[data-portal-ui="new"]) table.calls th { background:#f6f8f9; text-transform:none; letter-spacing:0; color:#52697a; font-size:11px; font-weight:500; }
:where(html[data-portal-ui="new"]) table td { padding:16px 10px; }
:where(html[data-portal-ui="new"]) .call-caller, :where(html[data-portal-ui="new"]) .call-duration { font-family:var(--font); font-size:12px; font-variant-numeric:tabular-nums; }
:where(html[data-portal-ui="new"]) .summary-toggle { display:block; margin:4px 0 0; min-height:32px; padding:4px; color:#536a65; font-size:11px; }
:where(html[data-portal-ui="new"]) .setting-row { padding:22px 0; gap:24px; }
:where(html[data-portal-ui="new"]) .setting-label { font-size:14px; font-weight:600; }
:where(html[data-portal-ui="new"]) .setting-desc { font-size:13px; max-width:65ch; }
:where(html[data-portal-ui="new"]) input, :where(html[data-portal-ui="new"]) textarea, :where(html[data-portal-ui="new"]) select { border-radius:7px; }
:where(html[data-portal-ui="new"]) .routing-number { font-family:var(--font-display); letter-spacing:-.02em; }
:where(html[data-portal-ui="new"]) .tile-grid { grid-template-columns:repeat(auto-fill,minmax(min(100%, 290px),1fr)); gap:22px; }
:where(html[data-portal-ui="new"]) .tile { position:relative; padding:26px; gap:12px; border:1px solid var(--border); border-radius:12px; background:#fff; transition:background 160ms ease, border-color 160ms ease; }
:where(html[data-portal-ui="new"]) .tile:hover { background:#f7faf8; border-color:#9cb8ad; }
:where(html[data-portal-ui="new"]) .customer-avatar { width:46px; height:46px; font-size:14px; margin-bottom:10px; }
:where(html[data-portal-ui="new"]) .tile:nth-child(3n+2) .customer-avatar { background:#f9e9e0; color:#985b3b; }
:where(html[data-portal-ui="new"]) .tile:nth-child(3n+3) .customer-avatar { background:#e8edf7; color:#57688c; }
:where(html[data-portal-ui="new"]) .tile-name { font:650 22px/1.2 var(--font-display); letter-spacing:-.025em; }
:where(html[data-portal-ui="new"]) .tile-stats { margin-top:12px; font-family:var(--font); font-size:14px; }
:where(html[data-portal-ui="new"]) .tile-sub { font-size:12px; }
:where(html[data-portal-ui="new"]) .detail-head { padding:24px; background:#f0f6f3; border:1px solid #dbe7e2; border-radius:12px; margin:18px 0; }
:where(html[data-portal-ui="new"]) .detail-title { font-family:var(--font-display); font-size:28px; }
:where(html[data-portal-ui="new"]) .chip { letter-spacing:0; font-size:11px; }
:where(html[data-portal-ui="new"]) .workspace-card { border-radius:12px; padding:30px; background:#f0f6f3; border-color:#dbe7e2; }
:where(html[data-portal-ui="new"]) .workspace-card[data-product="followthrough"] { background:#fcf3e9; border-color:#ecdfd2; }
:where(html[data-portal-ui="new"]) .workspace-card[data-product="orderdesk"] { background:#eef3fa; border-color:#dce4ee; }
:where(html[data-portal-ui="new"]) .workspace-card[data-product="closeready"] { background:#f4f1f8; border-color:#e3dcec; }
:where(html[data-portal-ui="new"]) .workspace-card h2 { font-family:var(--font-display); font-size:30px; }
:where(html[data-portal-ui="new"]) .ws-product { border-bottom:1px solid var(--border); padding:24px 0; }
:where(html[data-portal-ui="new"]) .modal { border:0; border-radius:14px; box-shadow:0 24px 70px #142f4033; padding:30px; }
:where(html[data-portal-ui="new"]) .login-wrap { min-height:100dvh; background:#f2f6f4; padding:100px 24px 50px; }
:where(html[data-portal-ui="new"]) .login-card { padding:40px; background:white; border:1px solid #dbe5df; border-radius:14px; box-shadow:none; max-width:460px; }
:where(html[data-portal-ui="new"]) .login-brand span, :where(html[data-portal-ui="new"]) .login-card .kicker { display:none; }
:where(html[data-portal-ui="new"]) .login-brand { margin-bottom:28px; }
:where(html[data-portal-ui="new"]) .login-brand img { width:44px; height:44px; }
:where(html[data-portal-ui="new"]) .login-title { font:650 34px/1.1 var(--font-display); letter-spacing:-.035em; margin-bottom:28px; }
:where(html[data-portal-ui="new"]) .login-card .btn { min-height:46px; }
:where(html[data-portal-ui="new"]) .empty { padding:24px 0; text-align:left; }
:where(html[data-portal-ui="new"]) .empty-title { font-family:var(--font-display); font-size:20px; }
:where(html[data-portal-ui="new"]) .toast { border-radius:9px; box-shadow:0 8px 24px #14304420; }
@media (min-width:901px) and (max-width:1180px) {
  html[data-portal-ui="new"] { --rail:178px; }
  :where(html[data-portal-ui="new"]) .content { padding:32px 26px; }
  :where(html[data-portal-ui="new"]) .overview-layout { grid-template-columns:minmax(0,1fr) 240px; gap:24px; }
  :where(html[data-portal-ui="new"]) .overview-insights { padding:18px; }
  :where(html[data-portal-ui="new"]) .topbar-email { display:none; }
}
@media (max-width:900px) {
  html[data-portal-ui="new"] { --rail:0px; --masthead:72px; }
  :where(html[data-portal-ui="new"]) .topbar-inner { padding:0 20px; gap:16px; }
  :where(html[data-portal-ui="new"]) .topbar-email { display:none; }
  :where(html[data-portal-ui="new"]) .topbar-user { gap:10px; }
  :where(html[data-portal-ui="new"]) .tabs { top:var(--masthead); bottom:auto; width:100%; padding:8px 16px; border-right:0; border-bottom:1px solid var(--border); }
  :where(html[data-portal-ui="new"]) .tabs-inner { flex-direction:row; gap:6px; overflow-x:auto; padding:0; }
  :where(html[data-portal-ui="new"]) .tab { flex-shrink:0; white-space:nowrap; padding:10px 12px; min-height:44px; font-size:13px; }
  :where(html[data-portal-ui="new"]) #tab-workspaces { margin-top:0; }
  :where(html[data-portal-ui="new"]) .rail-support { display:none; }
  :where(html[data-portal-ui="new"]) .content { margin:132px 0 0; padding:30px 24px; min-height:calc(100dvh - 225px); }
  :where(html[data-portal-ui="new"]) .overview-layout { grid-template-columns:minmax(0,1fr) 240px; gap:24px; }
  :where(html[data-portal-ui="new"]) .overview-insights { padding:18px; }
  :where(html[data-portal-ui="new"]) .viewas-banner { margin-top:132px; padding:16px 24px; }
  :where(html[data-portal-ui="new"]) .foot { margin:0; padding:22px 24px; }
}
@media (max-width:680px) {
  html[data-portal-ui="new"] { --masthead:108px; }
  :where(html[data-portal-ui="new"]) .topbar-inner { padding:14px 16px; flex-wrap:wrap; align-content:center; gap:8px; }
  :where(html[data-portal-ui="new"]) .topbar-brand { width:100%; gap:10px; flex-direction:row; align-items:center; }
  :where(html[data-portal-ui="new"]) .topbar-mark { width:28px; height:28px; }
  :where(html[data-portal-ui="new"]) .topbar-divider { display:block; margin:0 3px; height:22px; }
  :where(html[data-portal-ui="new"]) .topbar .topbar-business { font-size:13px; }
  :where(html[data-portal-ui="new"]) .topbar-user { width:100%; justify-content:space-between; gap:8px; }
  :where(html[data-portal-ui="new"]) .topbar .appearance-switch { padding:2px; }
  :where(html[data-portal-ui="new"]) .appearance-switch button { min-height:32px; }
  :where(html[data-portal-ui="new"]) .topbar .btn-ghost { min-height:36px; padding:4px 8px; }
  :where(html[data-portal-ui="new"]) .location-switch { flex:1; min-width:0; max-width:120px; font-size:12px; }
  :where(html[data-portal-ui="new"]) .nav-icon { width:16px; height:16px; }
  :where(html[data-portal-ui="new"]) .tab { gap:8px; }
  :where(html[data-portal-ui="new"]) .content { margin-top:168px; padding:26px 20px; }
  :where(html[data-portal-ui="new"]) .page-head { gap:18px; margin-bottom:28px; }
  :where(html[data-portal-ui="new"]) .page-title { font-size:32px; }
  :where(html[data-portal-ui="new"]) .page-sub { font-size:13px; }
  :where(html[data-portal-ui="new"]) .overview-layout { display:flex; flex-direction:column; gap:28px; }
  :where(html[data-portal-ui="new"]) .overview-main, :where(html[data-portal-ui="new"]) .overview-insights { width:100%; }
  :where(html[data-portal-ui="new"]) .lead-row > summary { display:grid; grid-template-columns:36px minmax(0,1fr) 10px; gap:12px; }
  :where(html[data-portal-ui="new"]) .lead-avatar { width:36px; height:36px; }
  :where(html[data-portal-ui="new"]) .lead-meta { grid-column:2; flex-direction:row; align-items:center; max-width:none; justify-content:space-between; }
  :where(html[data-portal-ui="new"]) .lead-row > summary::after { grid-column:3; grid-row:1; }
  :where(html[data-portal-ui="new"]) .lead-detail { padding:16px; }
  :where(html[data-portal-ui="new"]) .leads-toolbar .field { flex-basis:100%; }
  :where(html[data-portal-ui="new"]) .leads-toolbar .field + .field { flex:1 1 150px; }
  :where(html[data-portal-ui="new"]) .setting-row { gap:16px; }
  :where(html[data-portal-ui="new"]) .workspace-grid { grid-template-columns:1fr; }
  :where(html[data-portal-ui="new"]) .workspace-card { padding:24px; }
  :where(html[data-portal-ui="new"]) .viewas-banner { margin-top:168px; padding:16px 20px; }
  :where(html[data-portal-ui="new"]) .foot { padding:22px 20px; font-size:11px; }
  :where(html[data-portal-ui="new"]) .login-card { padding:28px 24px; }
  :where(html[data-portal-ui="new"]) .login-title { font-size:30px; }
  :where(html[data-portal-ui="new"]) .modal { padding:24px 20px; }
}
@media (prefers-reduced-motion:reduce) {
  :where(html[data-portal-ui="new"]) *, :where(html[data-portal-ui="new"]) *::before, :where(html[data-portal-ui="new"]) *::after { animation:none !important; transition:none !important; scroll-behavior:auto !important; }
}

:where(html[data-portal-ui="new"]) .lead-excerpt { display:block; background:#f5f8f6; color:#314e42; border-radius:8px; padding:12px 14px; margin-top:12px; font-size:13px; line-height:1.65; overflow-wrap:anywhere; }
:where(html[data-portal-ui="new"]) .lead-row > summary { align-items:start; }
:where(html[data-portal-ui="new"]) .lead-meta { padding-top:3px; }
:where(html[data-portal-ui="new"]) .lead-row > summary::after { margin-top:9px; }

:where(html[data-portal-ui="new"]) .page-title { scroll-margin-top:calc(var(--masthead) + 90px); }
:where(html[data-portal-ui="new"]) .overview-insights .stat:first-child .stat-label { align-self:flex-start; }
:where(html[data-portal-ui="new"]) .overview-insights .stat:first-child .stat-value { text-align:left; }
:where(html[data-portal-ui="new"]) .lead-excerpt { display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }

/* Preserve the legacy overview's visual sequence without replacing any forms. */
html[data-portal-ui="old"] .overview-layout { display:flex; flex-direction:column; }
html[data-portal-ui="old"] .overview-layout .stat-grid { order:0; }
html[data-portal-ui="old"] .overview-layout .chart-card { order:1; }
html[data-portal-ui="old"] .overview-layout .reasons-card { order:2; }
html[data-portal-ui="old"] .overview-layout .recent-calls-card { order:3; }
html[data-portal-ui="old"] .overview-layout .appointments-card { order:4; }
html[data-portal-ui="old"] .overview-layout .leads-card { order:5; }

/* Mobile viewport stability applies to both appearances. Keep the document
   still at its edges while tabs and tables retain their own horizontal scroll. */
@media (max-width:900px) {
  html:has(#app-view:not([hidden])),
  body:has(#app-view:not([hidden])) {
    overflow-x:clip;
    overscroll-behavior:none;
  }
  .table-wrap { overscroll-behavior-x:contain; }
  /* The desktop rail scrolls vertically. On phones only its tab contents may
     pan sideways; a swipe on the fixed chrome must not drag/bounce the page. */
  .topbar-inner { touch-action:pinch-zoom; }
  .tabs { touch-action:pan-x pinch-zoom; }
  html[data-portal-ui] .tabs-inner {
    min-width:0;
    max-width:100%;
    overflow-x:auto;
    overflow-y:hidden;
    overscroll-behavior:none;
    touch-action:pan-x pinch-zoom;
  }
  html[data-portal-ui] .tab { margin-bottom:0; }

  /* Safari zooms small fields on focus and can retain that zoom after login.
     Fix the trigger instead of restricting the user's pinch-to-zoom. */
  html[data-portal-ui] :is(input, select, textarea) {
    font-size:max(16px, 1rem);
  }
}

/* Keep every single-choice field on the portal's type and control scale. */
html[data-portal-ui="new"] select:where(:not([multiple]):not([size])) {
  min-height:44px;
  padding:10px 12px;
  border:1px solid var(--border-strong);
  border-radius:7px;
  background-color:var(--surface);
  color:var(--ink);
  font-family:var(--font);
  font-size:13px;
  line-height:1.5;
  cursor:pointer;
}
html[data-portal-ui="new"] select:disabled { opacity:.55; cursor:default; }
html[data-portal-ui="new"] .topbar select { background-color:var(--petrol-dark); color:#e0f0e9; border-color:#ffffff50; }

/* Native semantics/keyboard behavior, with a styled picker in supporting browsers.
   Other browsers retain the operating system menu and the matched closed field. */
@supports (appearance: base-select) {
  html[data-portal-ui="new"] select:where(:not([multiple]):not([size])),
  html[data-portal-ui="new"] select:where(:not([multiple]):not([size]))::picker(select) { appearance:base-select; }
  html[data-portal-ui="new"] select:where(:not([multiple]):not([size])) {
    position:relative;
    align-items:center;
    padding-inline-end:42px;
  }
  html[data-portal-ui="new"] select::picker(select) {
    margin-block:6px;
    padding:5px;
    max-height:min(320px, 60dvh);
    overflow-y:auto;
    overscroll-behavior:contain;
    border:1px solid var(--border-strong);
    border-radius:8px;
    background:var(--surface);
    color:var(--ink);
    font:400 13px/1.5 var(--font);
  }
  html[data-portal-ui="new"] select::picker-icon {
    content:'';
    /* Safari supplies padding and a text baseline for this pseudo-element.
       Anchor the zero-padding SVG box to the field, independent of text. */
    position:absolute;
    inset-block-start:50%;
    inset-inline-end:12px;
    box-sizing:border-box;
    width:18px;
    height:18px;
    padding:0;
    margin:0;
    border:0;
    background-color:currentColor;
    mask:url('./icons/chevron-down.svg') center / contain no-repeat;
    rotate:none;
    translate:0 -50%;
  }
  html[data-portal-ui="new"] select:open::picker-icon { rotate:180deg; }
  html[data-portal-ui="new"] select option { min-height:40px; display:flex; align-items:center; gap:10px; padding:9px 11px; border-radius:4px; font:inherit; color:var(--ink); background:var(--surface); }
  html[data-portal-ui="new"] select option:checked { background:var(--surface-muted); font-weight:600; }
  html[data-portal-ui="new"] select option:hover:not(:disabled),
  html[data-portal-ui="new"] select option:focus { background:var(--accent-soft); outline:none; }
  html[data-portal-ui="new"] select option:disabled { color:var(--subtle); opacity:.6; }
  html[data-portal-ui="new"] select option::checkmark { content:''; order:1; flex:0 0 18px; width:18px; height:18px; margin-inline-start:auto; background-color:var(--accent-ink); mask:url('./icons/check.svg') center / contain no-repeat; }
}
@media (max-width:900px) {
  html[data-portal-ui="new"] select:where(:not([multiple]):not([size])) { font-size:max(16px, 1rem); }
  @supports (appearance: base-select) {
    html[data-portal-ui="new"] select::picker(select) { font-size:max(16px, 1rem); }
  }
}
