/* Layout stability: nothing on any screen moves or scrolls sideways. Loaded last on every page. */

/* 1. The page scrollbar keeps its space, so going from a long screen to a short one, or opening a dialog, does not shift the layout. */
html{scrollbar-gutter:stable}
/* 2. The page itself never scrolls sideways. Wide content (boards, tab strips, tables) scrolls inside its own box. */
body{overflow-x:clip;min-width:320px}
.main,#view,.page,.cl,.eq,.q-wrap{min-width:0}
#view>*{min-width:0;max-width:100%}
img,svg,video,canvas,iframe{max-width:100%}
pre{white-space:pre-wrap;overflow-wrap:anywhere}
.kan,.brdw,.tabs,.bars{max-width:100%;overscroll-behavior-x:contain}
/* 3. Boxes may shrink below their content, and long words wrap instead of pushing the box wider. */
.card,.kpi,.item,.evcard,.note,.alert,.sheet,.sheet-b,.kcard,.field,.fgrid>*,.cols2>*,.cols2e>*,.cols3>*,.stackv,.stackv>*,.grid-k>*,.calwrap>*{min-width:0}
.card,.note,.alert,.kcard,.sheet-b,.item .t,.item .d{overflow-wrap:anywhere}
.item>span:not([class]),.item>div:not([class]){min-width:0}
.field input,.field select,.field textarea,.toolbar select,.toolbar input{max-width:100%}
.kpi .v,.kpi .s,.kpi .k{overflow:hidden;text-overflow:ellipsis}
.row-f.wrap>*{max-width:100%}
/* 4. A selected tab or segment keeps the same text width as an unselected one. */
.tabs .on,.tabs a,.tabs button,.seg .on,.seg button,.mbar .on,.mbar a,.mbar button{font-weight:500}
/* 5. Figures keep their width when the value changes. */
.kpi .v,.badge,.side nav .n,.mbar .cnt,.datebox b,.prow,.hb,.ring span{font-variant-numeric:tabular-nums}
/* 6. Scroll areas inside the shell keep a steady width too. */
.side{scrollbar-width:thin;scrollbar-gutter:stable}
.sheet-b{scrollbar-gutter:stable}

/* the enquiry form inside an iframe on the studio website (?embed=1) */
html.embed .eq-top{display:none}

/* profile pictures sit over the initials */
.avatar{position:relative;overflow:hidden}
.avatar>img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;border-radius:inherit}

/* leads: Pipeline / Archive / Trash tabs, bulk selection */
.seg{display:flex;flex-wrap:wrap;gap:6px}
.seg .btn .c{opacity:.75;margin-left:4px}
.kcard.pick{position:relative}
.kcard.pick.on{outline:2px solid var(--primary);outline-offset:-2px;background:var(--tint)}
.lbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:8px 0;padding:10px 12px;border:1px solid var(--primary);border-radius:var(--r-md);background:var(--tint)}
.lbar .grow{flex:1;min-width:120px}
.lrow{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-height:48px;padding:8px 12px}
.lrow input[type=checkbox]{width:20px;height:20px;accent-color:var(--primary);flex:none}
.lrow .main{flex:1;min-width:150px;text-align:left;background:none;border:0;color:inherit;padding:0;cursor:pointer;font:inherit}
.lrow .main .t{font-weight:600}

/* keyboard focus is always visible, on every screen (a fallback: nothing here overrides a stronger rule) */
:where(a,button,input,select,textarea,summary,[tabindex]):focus-visible{outline:2px solid var(--primary,#0B6E99);outline-offset:2px}

/* Leads: view tabs beside "New lead", and Archive / Trash as compact cards */
.ltabs{display:inline-flex;gap:2px;padding:3px;border:1px solid var(--border);border-radius:99px;background:var(--soft);max-width:100%}
.ltabs button{display:inline-flex;align-items:center;gap:6px;min-height:40px;padding:0 14px;border:0;border-radius:99px;background:transparent;color:var(--muted);font:inherit;font-size:14px;font-weight:500;cursor:pointer;white-space:nowrap}
.ltabs button:hover:not([aria-selected=true]){background:rgba(127,127,127,.14);color:inherit}
.ltabs button[aria-selected=true]{background:var(--primary);color:var(--on-primary,#fff)}
.ltabs .c{min-width:20px;padding:2px 6px;border-radius:99px;background:rgba(127,127,127,.2);font-size:12px;line-height:1.2;text-align:center}
.ltabs [aria-selected=true] .c{background:rgba(255,255,255,.25)}
.lgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,270px),1fr));gap:12px}
.lcard{display:flex;flex-direction:column;gap:8px;min-width:0;padding:12px 14px;border:1px solid var(--border);border-radius:var(--r-lg);background:var(--card)}
.lcard.on{border-color:var(--primary);box-shadow:0 0 0 1px var(--primary)}
.lcard-h{display:flex;align-items:center;gap:10px;min-width:0}
.lcard-h input[type=checkbox]{width:20px;height:20px;accent-color:var(--primary);flex:none}
.lname{flex:1;min-width:0;min-height:28px;padding:0;border:0;background:none;color:inherit;font:inherit;font-size:15px;font-weight:600;text-align:left;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.lname:hover{color:var(--primary)}
.lmeta{display:flex;flex-wrap:wrap;align-items:center;gap:4px 10px;font-size:12.5px;color:var(--muted)}
.lmeta span:not(.badge){display:inline-flex;align-items:center;gap:4px}
.lwhen .badge{max-width:100%}
.lact{display:flex;flex-wrap:wrap;gap:8px;margin-top:2px;padding-top:10px;border-top:1px solid var(--border)}
.lact .btn{flex:1 1 auto;min-width:0;justify-content:center}
@media (max-width:640px){
  .ph .acts .ltabs{width:100%}
  .ltabs button{flex:1 1 0;justify-content:center;min-width:0;padding:0 6px}
}

/* Lead sheet footer: Archive / Trash / Restore are icon-only buttons at the left; the main actions stay at the right */
.lmg{display:flex;gap:8px;margin-right:auto}
.lmg .btn,.sheet-f .lmg .btn{flex:none;width:44px;min-width:44px;height:44px;min-height:44px;padding:0!important;justify-content:center}   /* a sheet's footer buttons carry side padding that squeezed the icon to a dot on a phone */
.lmg .btn svg.i{width:20px;height:20px;max-width:none}
.lmg .btn.danger{color:var(--error,#B3261E)}
/* a phone: Archive, Trash, Mark lost and the next-stage button stay on ONE row (icons 40 px, Mark lost smaller, the main action a little wider; a long stage name wraps inside its button) */
@media (max-width:640px){
  .sheet-f .lmg{flex:none;margin:0;gap:6px}.sheet-f .lmg .btn{flex:none;width:40px;min-width:40px;height:40px;min-height:40px}
  .sheet-f .lmg~.btn{flex:1 1 0;min-width:0;min-height:40px;padding:0 8px;font-size:13px;line-height:1.15;gap:6px;text-align:center;white-space:normal;text-wrap:balance}
  .sheet-f .lmg~.btn:last-child{flex-grow:1.7}
  .sheet-f .lmg~.btn svg{width:16px;height:16px;flex:none}
}
@media (max-width:440px){.sheet-f .lmg~.btn{padding:0 6px;font-size:13px}.sheet-f .lmg~.btn svg{display:none}}
@media (max-width:360px){.sheet-f .lmg~.btn{font-size:12.5px}}
/* the Quote button's price is repeated in the Budget row above it: on a phone the button is just "Quote" */
@media (max-width:860px){.qcost{display:none}}

/* In-app confirm / notice / prompt (T.ask in core.js): one dialog for every "are you sure", closes on its X, Esc and a click outside */
.cm-wrap{position:fixed;inset:0;z-index:9000;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(10,10,10,.5)}
.cm{position:relative;width:min(440px,100%);max-height:calc(100vh - 32px);overflow:auto;padding:22px 22px 18px;border:1px solid var(--border);border-radius:var(--r-lg,16px);background:var(--card);color:var(--ink,inherit);box-shadow:0 24px 60px rgba(0,0,0,.35)}
.cm h3{margin:0 44px 8px 0;font-size:18px;line-height:1.3;overflow-wrap:anywhere}
.cm-b p{margin:0 0 10px;font-size:14px;line-height:1.5;color:var(--muted);overflow-wrap:anywhere}
.cm-l{display:block;margin:6px 0 4px;font-size:12px;color:var(--muted)}
.cm-i{width:100%;min-height:44px;padding:0 12px;border:1px solid var(--border);border-radius:var(--r-md,10px);background:var(--card);color:inherit;font:inherit}
.cm-x{position:absolute;top:6px;right:6px;width:44px;height:44px;border:0;border-radius:10px;background:transparent;color:inherit;font-size:26px;line-height:1;cursor:pointer}
.cm-x:hover{background:rgba(127,127,127,.15)}
.cm-f{display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end;margin-top:14px}
.cm-f .btn{min-height:44px}
@media (max-width:480px){.cm-wrap{align-items:flex-end;padding:8px}.cm{padding:20px 18px 14px}.cm-f .btn{flex:1 1 0;justify-content:center}}

/* the quote total stays in view above the buttons while the service list scrolls (phone) */
.qtotal{position:sticky;bottom:0;z-index:1;margin-top:10px;background:var(--soft);box-shadow:0 -8px 10px -8px rgba(0,0,0,.28)}

/* Custom scrollbars: slim, rounded, in the CRM's own colours (they follow light and dark mode through --muted and --bg), for the page and for every scrolling box
   (dialogs, boards, tables). Chrome, Edge and Safari use the ::-webkit-scrollbar rules; Firefox the standard scrollbar-width and scrollbar-color. A box that hides its
   own scrollbar (tab strips: scrollbar-width:none, ::-webkit-scrollbar{display:none}) still wins, because a class is more specific than the * used here. Touch phones
   draw their own thin overlay bar, so nothing changes there. */
@supports not selector(::-webkit-scrollbar){
  *{scrollbar-width:thin;scrollbar-color:color-mix(in srgb,var(--muted,#888) 50%,transparent) transparent}
}
*::-webkit-scrollbar{width:11px;height:11px}
*::-webkit-scrollbar-track{background:transparent}
*::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--muted,#888) 42%,transparent);border:3px solid transparent;background-clip:content-box;border-radius:99px;min-height:36px;min-width:36px}
*::-webkit-scrollbar-thumb:hover{background:color-mix(in srgb,var(--muted,#888) 70%,transparent);background-clip:content-box}
*::-webkit-scrollbar-thumb:active{background:var(--primary,#0b6e99);background-clip:content-box}
*::-webkit-scrollbar-button{display:none;width:0;height:0}
*::-webkit-scrollbar-corner{background:transparent}

/* ---- Forms and sheets, one refined look for the CRM and the client page ---- */
.field{margin-bottom:14px}
.field label,.field .lbl{font-size:12.5px;font-weight:600;letter-spacing:.01em;color:var(--ink);opacity:.78}
.field input,.field select,.field textarea,.toolbar select,.search input{min-height:46px;padding:10px 14px;border:1.5px solid var(--border);border-radius:12px;background:var(--card);transition:border-color .15s,box-shadow .15s,background .15s}
.field input:hover,.field select:hover,.field textarea:hover{border-color:color-mix(in srgb,var(--muted) 55%,var(--border))}
.field input:focus,.field select:focus,.field textarea:focus,.toolbar select:focus,.search input:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 4px color-mix(in srgb,var(--primary) 16%,transparent)}
.field input::placeholder,.field textarea::placeholder{color:var(--muted);opacity:.7}
.field select{appearance:none;-webkit-appearance:none;padding-right:38px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 14px center}
.field textarea{min-height:92px;line-height:1.5}
.field input:disabled,.field select:disabled,.field textarea:disabled{opacity:.6;background:var(--soft)}
.field input:required:invalid:not(:placeholder-shown){border-color:var(--error,#dc2626)}
.fgrid{gap:0 14px}
.fsec{margin:22px 0 10px}
.fsec small{font-size:12px;color:var(--muted)}
.checks label{min-height:40px;padding:0 12px;border:1.5px solid var(--border);border-radius:99px;transition:border-color .15s,background .15s}
.checks label:has(input:checked){border-color:var(--primary);background:color-mix(in srgb,var(--primary) 9%,var(--card))}
.sheet{border:1px solid var(--border);box-shadow:0 24px 60px rgba(0,0,0,.28)}
.sheet-h{padding:14px 12px 14px 22px;background:linear-gradient(180deg,color-mix(in srgb,var(--soft) 70%,var(--card)),var(--card))}
.sheet-h h3{font-size:18px;letter-spacing:-.005em}
.sheet-b{padding:20px 22px}
.sheet-f{padding:14px 22px;background:color-mix(in srgb,var(--soft) 55%,var(--card));gap:10px}
.sheet-f .btn{min-height:44px;padding:0 20px;border-radius:12px}
@media (max-width:640px){.sheet-b{padding:16px 18px}.sheet-f{padding:12px 16px}.fgrid{grid-template-columns:1fr 1fr}}
@media (max-width:380px){.fgrid{grid-template-columns:minmax(0,1fr)}}
