/* IntegrationOS — App shell (sidebar + topbar) */

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar{ width: 6px; height: 6px; }
::-webkit-scrollbar-thumb{ background: rgba(148,163,184,.35); border-radius: 6px; }
html:not(.light)::-webkit-scrollbar-thumb{ background: rgba(255,255,255,.14); }

.ambient{ display:none; } /* disable “orbs” for Stripe-like calm */

.shell{
  display:flex;
  height: 100vh;       /* exact — never grows beyond viewport */
  overflow: hidden;    /* clip children, only .main scrolls */
  background: var(--bg);
}

.sidebar{
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elev-1) 92%, var(--bg) 8%);
  /* static — no sticky needed when html/body are overflow:hidden */
  height: 100vh;
  display:flex;
  flex-direction: column;
  overflow: hidden;    /* nav sections clip; footer pinned via margin-top:auto */
}

.sidebar::before{ display:none; } /* remove dot texture */

.sidebar-head{
  height: var(--topbar-h);
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
}

.logo-link{
  display:flex;
  align-items:center;
  gap: 10px;
  text-decoration:none;
  color: inherit;
  min-width: 0;
  flex: 1;
}
.logo-icon{
  width: 30px; height: 30px;
  border-radius: 10px;
  background: var(--accent);
  display:flex; align-items:center; justify-content:center;
  color: var(--accent-ink);
  flex-shrink:0;
  box-shadow: var(--shadow-sm);
}
.logo-icon svg{ width: 15px; height: 15px; fill: currentColor; }
.logo-text{ font-size: 13px; font-weight: 750; letter-spacing: -.02em; white-space: nowrap; overflow:hidden; text-overflow:ellipsis; }
.logo-sub{ font-size: 10px; color: var(--text-3); margin-top: 1px; font-family: var(--font-mono); letter-spacing: .10em; text-transform: uppercase; }

.sidebar-toggle{
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-3);
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition: background .15s, border-color .15s, color .15s;
}
.sidebar-toggle:hover{ background: var(--bg-elev-2); border-color: var(--border-2); color: var(--text-2); }
.sidebar-toggle svg{ width: 15px; height: 15px; stroke: currentColor; fill:none; stroke-width: 2; stroke-linecap: round; }

.nav-section{ padding: 10px 10px 0; }
.nav-label{
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-4);
  padding: 10px 8px 6px;
}
.nav-item{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 550;
  text-decoration:none;
  transition: background .15s, border-color .15s, color .15s;
}
.nav-item:hover{
  background: var(--bg-elev-2);
  color: var(--text-2);
  border-color: color-mix(in srgb, var(--border) 60%, transparent);
}
.nav-item.active{
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent-border);
}
.nav-icon{ width: 18px; display:flex; align-items:center; justify-content:center; opacity: .9; }
.nav-icon svg{ width: 16px; height: 16px; stroke: currentColor; fill:none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-badge{
  margin-left:auto;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
}
.nav-badge.muted{
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.sidebar-footer{
  padding: 12px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.tenant-pill{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-elev-1);
}
.tenant-avatar{
  width: 28px; height: 28px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  display:flex; align-items:center; justify-content:center;
  font-weight: 750;
  font-size: 11px;
}
.tenant-name{ font-size: 12px; font-weight: 650; color: var(--text); }
.tenant-plan{ font-size: 10px; color: var(--text-3); font-family: var(--font-mono); margin-top: 2px; }

.main{
  flex: 1;
  min-width: 0;
  min-height: 0;       /* allow flex child to shrink below content size */
  display:flex;
  flex-direction: column;
  overflow-y: auto;    /* THIS is the only scroll context */
  height: 100vh;
}
.topbar{
  height: var(--topbar-h);
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
html:not(.light) .topbar{
  background: rgba(15,23,42,.72);
}
.page-title{ font-size: 14px; font-weight: 650; letter-spacing: -.01em; color: var(--text); }
.page-breadcrumb{ font-size: 12px; color: var(--text-3); display:flex; align-items:center; gap: 8px; }
.topbar-right{ display:flex; align-items:center; gap: 8px; }
.topbar-icon-btn{
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev-1);
  color: var(--text-2);
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition: background .15s, border-color .15s;
}
.topbar-icon-btn:hover{ background: var(--bg-elev-2); border-color: var(--border-2); }
.topbar-icon-btn svg{ width: 16px; height: 16px; stroke: currentColor; fill:none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.content{
  padding: 22px;
  flex: 1;
  /* overflow handled by .main — no double scroll */
}

/* Collapsed sidebar (keep your existing toggle behaviour) */
.shell.nav-mini .sidebar{ width: 60px; flex-basis: 60px; }
.shell.nav-mini .logo-labels,
.shell.nav-mini .nav-label,
.shell.nav-mini .nav-badge,
.shell.nav-mini .tenant-name,
.shell.nav-mini .tenant-plan{ display:none; }
.shell.nav-mini .sidebar-head{ padding: 0; justify-content: center; }
.shell.nav-mini .logo-link{ flex: 0; }
.shell.nav-mini .nav-item{ justify-content:center; padding: 10px 0; gap: 0; font-size: 0; color: transparent; }
.shell.nav-mini .nav-icon{ width: 100%; justify-content:center; opacity: 1; font-size: initial; color: var(--text-3); }
.shell.nav-mini .nav-item.active .nav-icon{ color: var(--accent); }
.shell.nav-mini .tenant-pill{ justify-content:center; padding: 10px 0; gap: 0; }

