/* V3 changes information hierarchy, inheriting V2's approved visual language. */
.layout-choices { display:grid; grid-template-columns:repeat(4, minmax(0,1fr)); gap:12px; margin:18px 0; }
.layout-choice { display:flex; flex-direction:column; align-items:stretch; gap:6px; text-align:left; padding:14px; border:1px solid var(--border-strong); border-radius:var(--radius-lg); background:var(--surface); color:var(--ink); cursor:pointer; font:inherit; }
.layout-choice > span:last-child { color:var(--muted); font-size:13px; }
.layout-choice:hover { background:var(--surface-muted); }
.layout-choice[aria-pressed="true"] { border-color:var(--accent-ink); outline:1px solid var(--accent-ink); background:var(--accent-soft); }
.layout-preview { height:64px; display:grid; grid-template-columns:2fr 1fr; grid-template-rows:12px 1fr 14px; gap:4px; padding:6px; margin-bottom:6px; background:var(--surface); border:1px solid var(--border); border-radius:5px; }
.layout-preview i { background:#c7dbd1; border-radius:2px; }
.layout-preview i:first-child { grid-column:1/-1; background:#70958a; }
.preview-v1 i:nth-child(2), .preview-v1 i:nth-child(3), .preview-v1 i:nth-child(4) { grid-column:1/-1; }
.preview-v2 i:nth-child(3) { grid-row:2/4; grid-column:2; }
.preview-v3 i:last-child { grid-column:1/-1; }
.preview-custom { grid-template-columns:repeat(3,1fr); grid-template-rows:1fr 1fr; }
.preview-custom i:first-child { grid-column:span 2; }
.preview-custom i:last-child { grid-column:span 2; }

/* Compact heading, metrics, and rows are limited to the new dashboard modes. */
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) #panel-overview .page-head { margin-bottom:20px; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .content:has(#panel-overview:not([hidden])) { padding-top:24px; }
html[data-portal-layout="v3"] .overview-layout { display:grid; grid-template-columns:minmax(0,2fr) minmax(250px,1fr); gap:24px; }
html[data-portal-layout="v3"] .overview-layout:not(:has(.overview-insights > *)) { grid-template-columns:minmax(0,1fr); }
html[data-portal-layout="v3"] .overview-layout > .stat-grid,
html[data-portal-layout="v3"] .overview-layout > .recent-calls-card { grid-column:1/-1; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) #overview-body .stat-grid { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:0; margin:0; padding:12px 0; border:1px solid var(--border); border-radius:var(--radius-lg); background:var(--surface); }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) #overview-body .stat { display:block; min-width:0; border:0; border-right:1px solid var(--border); border-radius:0; padding:2px 16px; margin:0; background:transparent; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) #overview-body .stat:last-child { border-right:0; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) #overview-body .stat-value { font-size:26px; margin:6px 0 0; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) #overview-body .stat-note { font-size:11px; line-height:1.4; margin-top:4px; }
html[data-portal-layout="v3"] .overview-insights { padding:18px; }
html[data-portal-layout="v3"] .overview-insights .card { padding:18px 0; }
html[data-portal-layout="v3"] .overview-insights .card:first-child { padding-top:0; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) #overview-body .card-sub { margin:5px 0 12px; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .leads-toolbar { margin-top:12px; gap:8px; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .leads-toolbar .field { flex:1 1 130px; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .leads-message { margin:10px 0; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .lead-row > summary { display:grid; grid-template-columns:32px minmax(0,1fr) auto 8px; align-items:center; gap:10px; padding:12px 0; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .lead-avatar { width:32px; height:32px; font-size:11px; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .lead-overview { min-width:0; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .lead-reason { display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:3px; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .lead-excerpt { display:none; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .lead-meta { padding:0; gap:4px; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .lead-row > summary::after { margin-top:0; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .appointments-empty > .card-sub { display:none; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .appointments-empty .empty { padding:8px 0 0; font-size:12px; }
html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .appointments-empty .empty-title { font:600 14px var(--font); margin-bottom:4px; }

.dashboard-status.sr-only, #dashboard-move-help { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; border:0; }
/* Editing stays on the canvas. Floating controls do not shift panel positions. */
.custom-dashboard-body { padding-bottom:84px; }
.dashboard-tools { position:fixed; right:24px; bottom:max(20px,env(safe-area-inset-bottom)); z-index:80; max-width:calc(100vw - 40px); padding:6px; border-radius:12px; background:var(--surface); box-shadow:0 6px 28px #173c3926; }
.dashboard-tool-buttons { display:flex; align-items:center; gap:4px; }
.dashboard-tools .btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; border:0; white-space:nowrap; padding:10px 12px; }
.dashboard-tools .btn svg, .dashboard-menu-action svg, .dashboard-catalog-item svg { width:18px; height:18px; flex-shrink:0; }
.dashboard-tools .is-done { background:var(--accent); color:var(--on-accent); }
.dashboard-tools .is-done:hover { background:var(--accent-hover); }
.dashboard-popover { position:absolute; bottom:calc(100% + 12px); right:0; width:320px; max-width:calc(100vw - 40px); max-height:min(60vh,520px); overflow:auto; overscroll-behavior:contain; padding:20px; border-radius:12px; background:var(--surface); box-shadow:0 10px 36px #173c3926; }
.dashboard-popover .card-title { font-size:18px; margin:0 0 16px; }
.dashboard-popover .hint { margin:14px 0 0; }
.dashboard-grid-options > label { display:block; font-size:13px; margin-bottom:6px; }
.dashboard-grid-options > .btn { margin-top:16px; border:1px solid var(--border); width:100%; }
.dashboard-catalog { display:flex; flex-direction:column; gap:4px; }
.dashboard-catalog-item { display:flex; align-items:center; gap:10px; min-height:44px; padding:8px; width:100%; border:0; border-radius:7px; background:transparent; color:var(--ink); font:inherit; font-size:13px; cursor:pointer; text-align:left; }
.dashboard-catalog-item:hover:not(:disabled) { background:var(--surface-muted); }
.dashboard-catalog-item:disabled { color:var(--muted); cursor:default; }
.dashboard-catalog-item small { margin-left:auto; font-size:11px; color:var(--muted); }
.dashboard-status.is-warning { position:fixed; bottom:92px; right:24px; z-index:81; max-width:min(360px,calc(100vw - 40px)); padding:12px 16px; border:1px solid var(--border-strong); border-radius:8px; background:var(--surface); color:var(--ink); font-size:13px; }
.dashboard-grid { --grid-columns:var(--chosen-columns,3); --edit-blue:#2563c4; display:grid; grid-template-columns:repeat(var(--grid-columns),minmax(0,1fr)); gap:20px; align-items:start; }
.dashboard-tile { position:relative; grid-column:span min(var(--tile-span,1),var(--grid-columns)); min-width:0; border:1px solid var(--border); border-radius:var(--radius-lg); padding:18px; background:var(--surface); container-type:inline-size; }
.dashboard-tile.tile-full, .dashboard-drop-slot.tile-full { grid-column:1/-1; }
html[data-portal-layout="custom"] .dashboard-tile > .card { padding:0; border:0; }
html[data-portal-layout="custom"] #overview-body .dashboard-tile > .stat-grid { border:0; padding:0; }
.dashboard-tile-controls { position:absolute; top:8px; right:8px; z-index:3; }
.dashboard-icon-button { display:inline-flex; align-items:center; justify-content:center; flex-shrink:0; width:44px; height:44px; padding:10px; border:0; border-radius:var(--radius-sm); background:transparent; color:var(--ink); cursor:pointer; }
.dashboard-icon-button svg { width:20px; height:20px; }
.dashboard-icon-button:hover:not(:disabled) { background:var(--surface-muted); }
.dashboard-icon-button:disabled { opacity:.4; cursor:default; }
.dashboard-options { background:var(--surface); }
.dashboard-grip { position:absolute; top:0; left:50%; transform:translate(-50%,-50%); z-index:1; display:grid; place-items:center; width:30px; height:20px; border:1px solid var(--border-strong); border-radius:6px; background:var(--surface); color:var(--muted); pointer-events:auto; touch-action:pinch-zoom; cursor:grab; }
.dashboard-grip svg { width:16px; height:16px; transform:rotate(90deg); }
.dashboard-tile-menu { position:absolute; top:48px; right:0; width:220px; max-width:calc(100vw - 64px); padding:16px; border-radius:12px; background:var(--surface); box-shadow:0 10px 32px #173c3926; color:var(--ink); font-size:13px; }
.dashboard-tile-menu > strong { display:block; margin-bottom:14px; }
.dashboard-tile-menu > label { display:block; font-size:12px; margin-bottom:5px; }
.dashboard-tile-menu > select { margin-bottom:8px; }
.dashboard-menu-action { display:flex; align-items:center; gap:8px; width:100%; min-height:44px; border:0; border-radius:6px; padding:8px; background:transparent; color:var(--ink); font:inherit; text-align:left; cursor:pointer; }
.dashboard-menu-action:hover:not(:disabled) { background:var(--surface-muted); }
.dashboard-menu-action:disabled { opacity:.45; cursor:default; }
.dashboard-tile.has-menu { z-index:10; }
.dashboard-grid.is-editing > .dashboard-tile { cursor:grab; touch-action:pinch-zoom; user-select:none; -webkit-user-select:none; outline:1px dashed var(--border-strong); outline-offset:3px; }
.dashboard-grid.is-editing > .dashboard-tile:hover, .dashboard-grid.is-editing > .dashboard-tile:focus-visible { outline:2px solid var(--edit-blue); outline-offset:3px; }
.dashboard-grid.is-editing > .dashboard-tile > [inert] { pointer-events:none; }
.dashboard-grid.is-dragging > .dashboard-tile:not(.is-dragging) { outline:1px dashed #729adc; background:#f4f6f8; }
.dashboard-grid.is-dragging > .dashboard-tile:not(.is-dragging) > :not(.dashboard-tile-controls):not(.dashboard-grip) { opacity:.38; filter:grayscale(1); }
.dashboard-grid.is-dragging .dashboard-tile-controls, .dashboard-grid.is-dragging .dashboard-grip { visibility:hidden; }
.dashboard-grid.is-editing > .dashboard-tile.is-dragging { position:fixed; top:0; left:0; z-index:100; margin:0; box-sizing:border-box; opacity:.94; outline:2px solid var(--edit-blue); outline-offset:0; box-shadow:0 16px 44px #173c3933; cursor:grabbing; pointer-events:none; will-change:transform; }
.dashboard-drop-slot { display:grid; place-items:center; grid-column:span min(var(--tile-span,1),var(--grid-columns)); min-width:0; box-sizing:border-box; border:2px dashed var(--edit-blue); border-radius:var(--radius-lg); background:#edf4ff; color:#1f519c; font-size:13px; font-weight:600; }
.dashboard-drop-slot.is-invalid { opacity:.35; }
.dashboard-dragging, .dashboard-dragging * { cursor:grabbing !important; }
.dashboard-dragging #panel-overview > .page-head { opacity:.45; }
.dashboard-empty { padding:32px 0; }
.dashboard-app-link { display:flex; flex-direction:column; align-items:flex-start; gap:8px; min-height:132px; color:var(--ink); text-decoration:none; }
.dashboard-app-link:hover strong { text-decoration:underline; text-underline-offset:3px; }
.dashboard-app-link > span:last-child { color:var(--muted); font-size:13px; }
.dashboard-app-icon { display:grid; place-items:center; width:44px; height:44px; border-radius:var(--radius-md); background:#eaf2ed; color:#366450; }
.dashboard-app-icon[data-product="followthrough"] { color:#935733; background:#fbecdf; }
.dashboard-app-icon[data-product="orderdesk"] { color:#3f577b; background:#edf0f8; }
.dashboard-app-icon[data-product="closeready"] { color:#69537b; background:#f1ebf6; }
.dashboard-app-icon svg { width:24px; height:24px; }
@container (max-width:520px) {
  html[data-portal-layout="custom"] #overview-body .stat-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px 0; }
  html[data-portal-layout="custom"] .lead-row > summary { grid-template-columns:32px minmax(0,1fr) 8px; }
  html[data-portal-layout="custom"] .lead-meta { grid-column:2; flex-direction:row; justify-content:space-between; max-width:none; }
  html[data-portal-layout="custom"] .lead-row > summary::after { grid-column:3; grid-row:1; }
}
@media (max-width:1100px) {
  .dashboard-grid { --grid-columns:2; }
  .layout-choices { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width:900px) {
  html[data-portal-layout="v3"] .overview-layout { grid-template-columns:minmax(0,1fr); gap:20px; }
  html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .content:has(#panel-overview:not([hidden])) { padding-top:24px; }
  html[data-portal-ui="new"] .dashboard-tile-menu select { font-size:16px; }
}
@media (max-width:680px) {
  .dashboard-grid { --grid-columns:1; gap:16px; }
  .dashboard-tile { padding:16px; }
  .dashboard-tools { right:20px; }
  .dashboard-tools .btn { padding:10px 8px; gap:6px; }
  .dashboard-tools .btn svg { display:none; }
  .dashboard-tool-buttons { gap:2px; }
  html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) #overview-body .stat-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px 0; padding:14px 0; }
  html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) #overview-body .stat:nth-child(even) { border-right:0; }
  html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .lead-row > summary { grid-template-columns:32px minmax(0,1fr) 8px; }
  html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .lead-meta { grid-column:2; flex-direction:row; justify-content:space-between; max-width:none; }
  html:is([data-portal-layout="v3"], [data-portal-layout="custom"]) .lead-row > summary::after { grid-column:3; grid-row:1; }
}

/* Layout lives beside the account navigation; its drawer preserves the current page. */
.portal-navigation { display:flex; align-items:stretch; gap:8px; max-width:var(--container); margin:0 auto; padding:0 var(--pad-x); }
.portal-navigation .tabs-inner { flex:1; min-width:0; margin:0; padding:0; }
.layout-nav-trigger { display:flex; align-items:center; gap:10px; flex-shrink:0; min-height:44px; padding:10px 14px; border:0; border-radius:7px; background:transparent; color:var(--muted); font:550 14px var(--font); cursor:pointer; white-space:nowrap; }
.layout-nav-trigger .nav-icon { display:inline-flex; width:19px; height:19px; flex-shrink:0; }
.layout-nav-trigger:hover { background:var(--surface-muted); color:var(--ink); }
.layout-nav-trigger[aria-expanded="true"] { background:var(--accent-soft); color:var(--ink); }
html[data-portal-ui="new"] .portal-navigation { flex-direction:column; align-items:stretch; gap:7px; width:100%; padding:0; margin:0; min-height:0; }
html[data-portal-ui="new"] .portal-navigation .tabs-inner { flex:0 1 auto; }
html[data-portal-ui="new"] .layout-nav-trigger { padding:13px 15px; gap:12px; min-height:46px; text-align:left; color:#4b655e; }
.layout-panel { position:fixed; inset:16px 16px 16px auto; margin:0; width:420px; max-width:calc(100vw - 32px); max-height:calc(100dvh - 32px); padding:24px; box-sizing:border-box; overflow:auto; overscroll-behavior:contain; touch-action:pan-y pinch-zoom; border:1px solid var(--border); border-radius:14px; background:var(--surface); color:var(--ink); box-shadow:0 16px 60px #173c3926; }
.layout-panel-head { display:flex; align-items:center; justify-content:space-between; gap:16px; }
.layout-panel-head .card-title { margin:0; font-size:24px; }
.layout-panel-head .dashboard-icon-button { margin:-8px -8px -8px 0; }
.layout-panel .layout-choices { grid-template-columns:repeat(2,minmax(0,1fr)); margin:24px 0; }
.layout-panel .layout-choice { padding:14px; }
.layout-panel .card-sub { margin-top:12px; }
.layout-panel .hint { font-size:13px; line-height:1.6; }
@media (max-width:900px) {
  html[data-portal-ui] .portal-navigation { flex-direction:row; align-items:stretch; gap:4px; padding:0 8px; min-width:0; width:100%; }
  html[data-portal-ui] .portal-navigation .tabs-inner { flex:1; }
  html[data-portal-ui] .layout-nav-trigger { padding:10px; gap:6px; min-width:86px; border-radius:0; border-left:1px solid var(--border); font-size:13px; }
  .layout-nav-trigger .nav-icon { width:17px; height:17px; }
}
@media (max-width:680px) {
  html[data-portal-ui="new"] { --masthead:72px; }
  html[data-portal-ui="new"] .topbar-inner { flex-wrap:nowrap; }
  html[data-portal-ui="new"] .topbar-brand { flex:1; width:auto; min-width:0; }
  html[data-portal-ui="new"] .topbar-user { width:auto; flex-shrink:0; }
  html[data-portal-ui="new"] .location-switch { max-width:90px; }
  html[data-portal-ui="new"] .content { margin-top:132px; }
  html[data-portal-ui="new"] .viewas-banner { margin-top:132px; }
  .layout-panel { inset:12px 12px 12px auto; width:calc(100vw - 24px); max-width:none; max-height:calc(100dvh - 24px); padding:20px; }
}
