:root {
  --shell-sidebar: 264px;
  --shell-bottom: 68px;
  --shell-border: var(--ds-color-border);
  --shell-text: var(--ds-color-text);
  --shell-muted: var(--ds-color-text-secondary);
  --shell-brand: var(--ds-color-action);
  --shell-brand-soft: var(--ds-color-action-soft);
}

.product-shell { min-height: 100dvh; display: grid; grid-template-columns: var(--shell-sidebar) minmax(0,1fr); background: #f6f7f9; }
.shell-sidebar { position: sticky; top: 0; z-index: 40; height: 100dvh; display: flex; flex-direction: column; padding: 18px 14px 14px; border-right: 1px solid var(--shell-border); background: #fff; overflow: hidden; }
.shell-brand { min-height: 42px; display: flex; align-items: center; gap: 11px; padding: 0 8px; color: var(--shell-text); text-decoration: none; font-weight: 780; letter-spacing: -.025em; }
.shell-brand-mark { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: linear-gradient(145deg,var(--ds-color-action),#6f83e8); box-shadow: 0 7px 18px rgba(48,86,211,.22); }
.shell-context { display: grid; gap: 8px; margin: 18px 0; }
.shell-sidebar-header { flex: 0 0 auto; padding-bottom: 12px; border-bottom: 1px solid var(--shell-border); }
.shell-clock { display: block; margin: 6px 8px 0; color: var(--shell-muted); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.shell-clock-zone { display: block; margin-top: 2px; white-space: normal; }
.shell-sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; display: flex; flex-direction: column; }
.shell-sidebar-scroll > * { flex-shrink: 0; }
.shell-organization { min-width: 0; display: grid; gap: 4px; padding: 2px 11px 6px; color: var(--shell-text); }
.shell-organization strong { font-size: 13px; overflow-wrap: anywhere; }
.shell-location { min-width: 0; display: grid; gap: 2px; padding: 10px 11px; border: 1px solid var(--shell-border); border-radius: 12px; color: var(--shell-text); background: #fff; text-align: left; }
.shell-context-kicker { color: var(--shell-muted); font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.shell-location select { width: 100%; min-height: 24px; padding: 0 20px 0 0; border: 0; color: var(--shell-text); background: transparent; font: 650 13px inherit; }
.shell-navigation { display: grid; gap: 16px; }
.shell-nav-group { display: grid; gap: 3px; }
.shell-nav-heading { margin: 0 10px 4px; color:var(--ds-color-text-secondary); font-size: 10px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.shell-nav-link { min-height: 40px; display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px; color: #4f5b70; background: transparent; text-decoration: none; font: 580 13px inherit; text-align: left; }
.shell-nav-link:hover { color: var(--shell-text); background: #f6f7f9; }
.shell-nav-link[aria-current="page"] { color: var(--ds-color-action-hover); background: var(--shell-brand-soft); font-weight: 720; }
.shell-nav-link:disabled { cursor: default; opacity: .62; }
.shell-nav-icon { width: 20px; color: currentColor; font-size: 16px; text-align: center; }
.shell-nav-label { flex: 1; }
.shell-soon { padding: 2px 5px; border-radius: 5px; color:var(--ds-color-text-secondary); background: #f1f3f6; font-size: 9px; font-weight: 720; }
.shell-account { display: grid; grid-template-columns: 34px minmax(0,1fr) 28px; align-items: center; gap: 9px; margin-top: auto; padding: 14px 6px 2px; border-top: 1px solid var(--shell-border); }
.shell-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--ds-color-action-hover); background: #e9eeff; font-size: 13px; font-weight: 800; }
.shell-account-copy { min-width: 0; display: grid; }
.shell-account-copy strong,.shell-account-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-account-copy strong { color: var(--shell-text); font-size: 12px; }
.shell-account-copy span { color: var(--shell-muted); font-size: 10px; }
.shell-account-action { border: 0; color: var(--shell-muted); background: transparent; }
.shell-stage { min-width: 0; min-height: 100dvh; }
.shell-stage > main { min-width: 0; }
.shell-mobile-header,.shell-bottom-nav { display: none; }
.product-shell .chats-shell { height: 100dvh; }
.product-shell .templates-shell { min-height: 100dvh; }

@media (max-width: 1023px) {
  .product-shell { grid-template-columns: 224px minmax(0,1fr); }
  .shell-brand-name { font-size: 14px; }
  .shell-sidebar { padding-inline: 10px; }
}

@media (max-width: 820px) {
  .app-body { overflow-x: hidden; overflow-y: auto; padding-bottom: calc(var(--shell-bottom) + env(safe-area-inset-bottom)); }
  .product-shell { display: block; min-height: 100dvh; }
  .shell-sidebar { position: fixed; inset: 0 0 calc(var(--shell-bottom) + env(safe-area-inset-bottom)) auto; width: min(86vw,320px); height: auto; transform: translateX(105%); transition: transform .2s ease; box-shadow: -20px 0 50px rgba(20,30,55,.15); }
  .shell-drawer-open .shell-sidebar { transform: translateX(0); }
  .shell-stage { min-height: calc(100dvh - var(--shell-bottom)); }
  .shell-mobile-header { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--shell-border); background: #fff; }
  .shell-mobile-brand { color: var(--shell-text); font-size: 15px; font-weight: 780; }
  .shell-mobile-context { max-width: 50vw; overflow: hidden; color: var(--shell-muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
  .shell-bottom-nav { position: fixed; inset: auto 0 0; z-index: 60; min-height: calc(var(--shell-bottom) + env(safe-area-inset-bottom)); display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0,1fr); padding: 5px 4px env(safe-area-inset-bottom); border-top: 1px solid var(--shell-border); background: rgba(255,255,255,.96); backdrop-filter: blur(16px); }
  .shell-bottom-link { min-width: 0; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 3px 1px; border: 0; color:var(--ds-color-text-secondary); background: transparent; text-decoration: none; font: inherit; }
  .shell-bottom-link[aria-current="page"] { color: var(--shell-brand); }
  .shell-bottom-icon { min-height: 18px; font-size: 17px; line-height: 1; }
  .shell-bottom-label { max-width: 100%; overflow: hidden; font-size: 9px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
  .product-shell .chats-shell { height: calc(100dvh - 54px - var(--shell-bottom) - env(safe-area-inset-bottom)); }
  .product-shell .templates-shell { min-height: calc(100dvh - 54px - var(--shell-bottom)); }
}

@media (prefers-reduced-motion: reduce) { .shell-sidebar { transition: none; } }

/* Global inbox entry stays next to the brand, including the mobile header. */
.shell-brand-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.shell-brand-row .shell-brand { min-width: 0; padding-left: 8px; }
.shell-inbox-link { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 48px; min-height: 36px; padding: 6px 9px; border: 1px solid var(--shell-border); border-radius: 10px; color: var(--shell-muted); background: #f8f9fb; font-size: 12px; font-weight: 750; text-decoration: none; }
.shell-inbox-link.has-unread { color: var(--ds-color-action-hover); border-color: #d4defb; background: var(--ds-color-action-soft); }
.shell-inbox-link:hover { border-color: var(--shell-brand); }
.shell-inbox-link:focus-visible { outline: 2px solid var(--shell-brand); outline-offset: 3px; }
.shell-inbox-icon { position: relative; width: 15px; height: 12px; border: 1.5px solid currentColor; border-radius: 4px; }
.shell-inbox-icon::after { content: ""; position: absolute; left: 2px; bottom: -4px; width: 4px; height: 4px; border-left: 1.5px solid currentColor; transform: skewY(-35deg); background: inherit; }
.shell-inbox-count { font-variant-numeric: tabular-nums; }
@media (max-width: 820px) {
  .shell-mobile-header .shell-brand-row { gap: 10px; }
  .shell-mobile-context { max-width: 40vw; }
}

.chat-alert-settings-button{border:1px solid var(--border,#dce2ef);background:#fff;color:var(--ds-color-action);border-radius:9px;min-width:32px;min-height:32px;cursor:pointer;font-size:20px;flex-shrink:0}
.chat-alert-settings{position:fixed;z-index:110;top:74px;left:16px;width:min(340px,calc(100vw - 32px));padding:18px;background:white;color:var(--ds-color-text);border:1px solid #dce2ef;border-radius:14px;box-shadow:0 12px 40px #17244126;display:grid;gap:16px}
.chat-alert-settings[hidden]{display:none}.chat-alert-settings label{display:flex;gap:10px;align-items:center}.chat-alert-settings button{padding:9px;border:1px solid #dce2ef;border-radius:8px;background:#f5f7ff;color:var(--ds-color-action-hover);cursor:pointer}.chat-alert-settings p{margin:0;color:var(--ds-color-text-secondary);font-size:13px;line-height:1.5}
.chat-alert-toast{position:fixed;z-index:105;right:20px;bottom:24px;width:min(360px,calc(100vw - 40px));display:flex;align-items:center;gap:12px;padding:16px;background:white;border:1px solid #cbd6fb;border-left:4px solid var(--ds-color-action);border-radius:12px;box-shadow:0 10px 35px #17244126}.chat-alert-toast a{color:#243e94;text-decoration:none;flex:1;font-weight:600}.chat-alert-toast button{border:0;background:transparent;font-size:24px;cursor:pointer;color:var(--ds-color-text-secondary)}

.shell-nav-group[hidden], .shell-nav-link[hidden], .shell-bottom-link[hidden] { display: none !important; }



/* Prevent flex/grid stretching and horizontal overflow from detaching the sidebar. */
@media(min-width:821px){.shell-sidebar{align-self:start;box-sizing:border-box}.app-body{overflow-x:clip}}
.shell-sidebar-header{position:relative;z-index:1;background:inherit}
.shell-mobile-header{position:sticky;top:0;z-index:35}

@media(max-width:820px){
 .shell-calendar-stage .shell-work-context{min-height:44px;padding:0 16px;border-bottom:0}
 .shell-calendar-stage .shell-page-branch{font-size:0;gap:0;width:100%}
 .shell-calendar-stage .shell-page-branch select{font-size:14px;width:100%;min-height:44px;padding:4px 8px}
}

@media(max-width:820px){
 .shell-calendar-stage .shell-mobile-header{min-height:44px}
 .shell-calendar-stage .shell-work-context:has(.calendar-single-branch){min-height:28px}
 .shell-calendar-stage .calendar-single-branch{min-height:28px}
 .shell-calendar-stage .calendar-branch-name{font-size:14px;line-height:20px;overflow-wrap:anywhere}
 .shell-calendar-stage .calendar-single-branch select[hidden]{display:none}
}

@media(max-width:820px){.shell-calendar-stage:has(.calendar-single-branch) .shell-mobile-context{display:none}}
@media(max-width:820px){
 .shell-calendar-stage{display:grid;grid-template-columns:auto minmax(0,1fr);grid-template-rows:44px auto;align-content:start}
 .shell-calendar-stage>.shell-mobile-header{grid-column:1;grid-row:1;padding-right:8px;min-height:44px}
 .shell-calendar-stage>.shell-mobile-header .shell-mobile-context{display:none}
 .shell-calendar-stage>.shell-work-context{grid-column:2;grid-row:1;min-height:44px;padding:0 16px 0 0;position:sticky;top:0;z-index:35;background:var(--ds-color-surface)}
 .shell-calendar-stage>main{grid-column:1/-1}
 .shell-calendar-stage .calendar-branch-name{font-size:14px;line-height:20px}
}
